ScummVM API documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
actor.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11 
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16 
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 #ifndef DRAGONS_ACTOR_H
22 #define DRAGONS_ACTOR_H
23 
24 #include "common/system.h"
25 
26 namespace Dragons {
27 class Actor;
28 class ActorResourceLoader;
29 class ActorResource;
30 struct ActorFrame;
31 
32 #define DRAGONS_ENGINE_NUM_ACTORS 64
33 
34 enum ActorFlags {
35  ACTOR_FLAG_1 = 1,
36  ACTOR_FLAG_2 = 2,
37  ACTOR_FLAG_4 = 4,
38  ACTOR_FLAG_8 = 8,
39  ACTOR_FLAG_10 = 0x10, //actor is walking a path
40  ACTOR_FLAG_20 = 0x20,
41  ACTOR_FLAG_40 = 0x40,
42  ACTOR_FLAG_80 = 0x80,
43  ACTOR_FLAG_100 = 0x100,
44  ACTOR_FLAG_200 = 0x200, // Use screen coordinates not map coordinates.
45  ACTOR_FLAG_400 = 0x400, // Actor is hidden
46  ACTOR_FLAG_800 = 0x800,
47  ACTOR_FLAG_1000 = 0x1000,
48  ACTOR_FLAG_2000 = 0x2000,
49  ACTOR_FLAG_4000 = 0x4000,
50  ACTOR_FLAG_8000 = 0x8000 //Seems turn off semi trans mode when selected.
51 };
52 
53 enum ActorFrameFlags {
54  ACTOR_FRAME_FLAG_2 = 0x2,
55  ACTOR_FRAME_FLAG_10 = 0x10,
56  ACTOR_FRAME_FLAG_20 = 0x20
57 };
58 
59 class ActorManager {
60 public:
62 
63 private:
64  ActorResourceLoader *_actorResourceLoader;
65  Actors _actors;
66  uint16 _displayOrder[DRAGONS_ENGINE_NUM_ACTORS];
67 public:
68  ActorManager(ActorResourceLoader *actorResourceLoader);
69 
70 public:
71  Actor *loadActor(uint32 resourceId, uint32 sequenceId, int16 x, int16 y);
72  Actor *loadActor(uint32 resourceId, uint32 sequenceId, int16 x, int16 y, uint16 priorityLayer);
73  Actor *loadActor(uint32 resourceId, uint16 actorId);
74  Actor *getActor(uint16 actorId);
75  Actor *getActorByDisplayOrder(uint16 position);
76  void clearActorFlags(uint16 startingActorId);
77  ActorResource *getActorResource(uint32 resourceId);
78  void updateActorDisplayOrder();
79 private:
80  Actor *findFreeActor(int16 resourceID);
81  void resetDisplayOrder();
82 };
83 
84 class Actor {
85 public:
86  uint16 _actorID;
87  ActorResource* _actorResource;
88  uint16 _actorFileDictionaryIndex;
89  int16 _resourceID;
90  byte *_seqCodeIp;
91  ActorFrame *_frame;
92  Graphics::Surface *_surface;
93  uint16 _sequenceTimerMaxValue;
94  int16 _scale; // scale factor 0x100 is 100%
95  uint16 _sequenceTimer;
96  uint16 _sequenceID;
97  int16 _direction;
98  int16 _priorityLayer;
99  uint16 _flags;
100  int16 _x_pos;
101  int16 _y_pos;
102  int16 _walkDestX;
103  int16 _walkDestY;
104  int32 _xShl16;
105  int32 _yShl16;
106  int32 _walkSlopeX;
107  int32 _walkSlopeY;
108  uint16 _walkPointsTbl[32];
109  int16 _walkPointsIndex;
110  int16 _finalWalkDestX;
111  int16 _finalWalkDestY;
112  uint16 _field_7a;
113  int32 _walkSpeed;
114  uint16 _frame_flags;
115 public:
116 
117  Actor(uint16 id);
118  void init(ActorResource *resource, int16 x, int16 y, uint32 sequenceID);
119  void updateSequence(uint16 newSequenceID);
120  void resetSequenceIP();
121  byte *getSeqIpAtOffset(uint32 offset);
122  void loadFrame(uint16 frameOffset);
123  void freeFrame();
124  void reset_maybe();
125  bool startWalk(int16 destX, int16 destY, uint16 flags);
126  void walkPath();
127  void waitUntilFlag4IsSet();
128  void waitUntilFlag8IsSet();
129  void waitUntilFlag8And4AreSet();
130  void waitUntilFlag8SetThenSet1000();
131  void waitUntilFlag8SetThenSet1000AndWaitFor4();
132  void waitForWalkToFinish();
133 
134  bool waitUntilFlag4IsSetAllowSkip();
135  bool actorSetSequenceAndWaitAllowSkip(uint16 newSequenceID);
136 
137  void clearFlag(uint32 flag);
138  void setFlag(uint32 flag);
139  bool isFlagSet(uint32 flag);
140  bool isFlagClear(uint32 flag) { return !isFlagSet(flag); }
141 
142  byte *getPalette();
143  int16 getFrameYOffset();
144 private:
145  void stopWalk();
146  uint16 canWalkLine(int16 actor_x, int16 actor_y, int16 target_x, int16 target_y, uint16 walkFlags);
147  int16 pathfindingFindClosestPoint(int16 actor_x, int16 actor_y, int16 target_x, int16 target_y, int16 unkType,
148  bool *pointsInUseTbl);
149  int startMoveToPoint(int destX, int destY);
150 };
151 
152 } // End of namespace Dragons
153 
154 #endif //DRAGONS_ACTOR_H
Definition: surface.h:67
Definition: actorresource.h:47
Definition: actor.h:84
Definition: actorresource.h:56
Definition: actorresource.h:31
Definition: actor.h:26
Definition: actor.h:59