ScummVM API documentation
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  typedef Actors::iterator ActorsIterator;
63 
64 private:
65  ActorResourceLoader *_actorResourceLoader;
66  Actors _actors;
67  uint16 _displayOrder[DRAGONS_ENGINE_NUM_ACTORS];
68 public:
69  ActorManager(ActorResourceLoader *actorResourceLoader);
70 
71 public:
72  Actor *loadActor(uint32 resourceId, uint32 sequenceId, int16 x, int16 y);
73  Actor *loadActor(uint32 resourceId, uint32 sequenceId, int16 x, int16 y, uint16 priorityLayer);
74  Actor *loadActor(uint32 resourceId, uint16 actorId);
75  Actor *getActor(uint16 actorId);
76  Actor *getActorByDisplayOrder(uint16 position);
77  void clearActorFlags(uint16 startingActorId);
78  ActorResource *getActorResource(uint32 resourceId);
79  void updateActorDisplayOrder();
80 private:
81  Actor *findFreeActor(int16 resourceID);
82  void resetDisplayOrder();
83 };
84 
85 class Actor {
86 public:
87  uint16 _actorID;
88  ActorResource* _actorResource;
89  uint16 _actorFileDictionaryIndex;
90  int16 _resourceID;
91  byte *_seqCodeIp;
92  ActorFrame *_frame;
93  Graphics::Surface *_surface;
94  uint16 _sequenceTimerMaxValue;
95  int16 _scale; // scale factor 0x100 is 100%
96  uint16 _sequenceTimer;
97  uint16 _sequenceID;
98  int16 _direction;
99  int16 _priorityLayer;
100  uint16 _flags;
101  int16 _x_pos;
102  int16 _y_pos;
103  int16 _walkDestX;
104  int16 _walkDestY;
105  int32 _xShl16;
106  int32 _yShl16;
107  int32 _walkSlopeX;
108  int32 _walkSlopeY;
109  uint16 _walkPointsTbl[32];
110  int16 _walkPointsIndex;
111  int16 _finalWalkDestX;
112  int16 _finalWalkDestY;
113  uint16 _field_7a;
114  int32 _walkSpeed;
115  uint16 _frame_flags;
116 public:
117 
118  Actor(uint16 id);
119  void init(ActorResource *resource, int16 x, int16 y, uint32 sequenceID);
120  void updateSequence(uint16 newSequenceID);
121  void resetSequenceIP();
122  byte *getSeqIpAtOffset(uint32 offset);
123  void loadFrame(uint16 frameOffset);
124  void freeFrame();
125  void reset_maybe();
126  bool startWalk(int16 destX, int16 destY, uint16 flags);
127  void walkPath();
128  void waitUntilFlag4IsSet();
129  void waitUntilFlag8IsSet();
130  void waitUntilFlag8And4AreSet();
131  void waitUntilFlag8SetThenSet1000();
132  void waitUntilFlag8SetThenSet1000AndWaitFor4();
133  void waitForWalkToFinish();
134 
135  bool waitUntilFlag4IsSetAllowSkip();
136  bool actorSetSequenceAndWaitAllowSkip(uint16 newSequenceID);
137 
138  void clearFlag(uint32 flag);
139  void setFlag(uint32 flag);
140  bool isFlagSet(uint32 flag);
141  bool isFlagClear(uint32 flag) { return !isFlagSet(flag); }
142 
143  byte *getPalette();
144  int16 getFrameYOffset();
145 private:
146  void stopWalk();
147  uint16 canWalkLine(int16 actor_x, int16 actor_y, int16 target_x, int16 target_y, uint16 walkFlags);
148  int16 pathfindingFindClosestPoint(int16 actor_x, int16 actor_y, int16 target_x, int16 target_y, int16 unkType,
149  bool *pointsInUseTbl);
150  int startMoveToPoint(int destX, int destY);
151 };
152 
153 } // End of namespace Dragons
154 
155 #endif //DRAGONS_ACTOR_H
Definition: surface.h:67
Actor * iterator
Definition: array.h:54
Definition: actorresource.h:47
Definition: actor.h:85
Definition: actorresource.h:56
Definition: actorresource.h:31
Definition: actor.h:26
Definition: actor.h:59