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/array.h"
25 #include "common/scummsys.h"
26 #include "graphics/surface.h"
27 
28 namespace Dragons {
29 class Actor;
30 class ActorResourceLoader;
31 class ActorResource;
32 struct ActorFrame;
33 
34 #define DRAGONS_ENGINE_NUM_ACTORS 64
35 
36 enum ActorFlags {
37  ACTOR_FLAG_1 = 1,
38  ACTOR_FLAG_2 = 2,
39  ACTOR_FLAG_4 = 4,
40  ACTOR_FLAG_8 = 8,
41  ACTOR_FLAG_10 = 0x10, //actor is walking a path
42  ACTOR_FLAG_20 = 0x20,
43  ACTOR_FLAG_40 = 0x40,
44  ACTOR_FLAG_80 = 0x80,
45  ACTOR_FLAG_100 = 0x100,
46  ACTOR_FLAG_200 = 0x200, // Use screen coordinates not map coordinates.
47  ACTOR_FLAG_400 = 0x400, // Actor is hidden
48  ACTOR_FLAG_800 = 0x800,
49  ACTOR_FLAG_1000 = 0x1000,
50  ACTOR_FLAG_2000 = 0x2000,
51  ACTOR_FLAG_4000 = 0x4000,
52  ACTOR_FLAG_8000 = 0x8000 //Seems turn off semi trans mode when selected.
53 };
54 
55 enum ActorFrameFlags {
56  ACTOR_FRAME_FLAG_2 = 0x2,
57  ACTOR_FRAME_FLAG_10 = 0x10,
58  ACTOR_FRAME_FLAG_20 = 0x20
59 };
60 
61 class ActorManager {
62 public:
64 
65 private:
66  ActorResourceLoader *_actorResourceLoader;
67  Actors _actors;
68  uint16 _displayOrder[DRAGONS_ENGINE_NUM_ACTORS];
69 public:
70  ActorManager(ActorResourceLoader *actorResourceLoader);
71 
72 public:
73  Actor *loadActor(uint32 resourceId, uint32 sequenceId, int16 x, int16 y);
74  Actor *loadActor(uint32 resourceId, uint32 sequenceId, int16 x, int16 y, uint16 priorityLayer);
75  Actor *loadActor(uint32 resourceId, uint16 actorId);
76  Actor *getActor(uint16 actorId);
77  Actor *getActorByDisplayOrder(uint16 position);
78  void clearActorFlags(uint16 startingActorId);
79  ActorResource *getActorResource(uint32 resourceId);
80  void updateActorDisplayOrder();
81 private:
82  Actor *findFreeActor(int16 resourceID);
83  void resetDisplayOrder();
84 };
85 
86 class Actor {
87 public:
88  uint16 _actorID;
89  ActorResource* _actorResource;
90  uint16 _actorFileDictionaryIndex;
91  int16 _resourceID;
92  byte *_seqCodeIp;
93  ActorFrame *_frame;
94  Graphics::Surface *_surface;
95  uint16 _sequenceTimerMaxValue;
96  int16 _scale; // scale factor 0x100 is 100%
97  uint16 _sequenceTimer;
98  uint16 _sequenceID;
99  int16 _direction;
100  int16 _priorityLayer;
101  uint16 _flags;
102  int16 _x_pos;
103  int16 _y_pos;
104  int16 _walkDestX;
105  int16 _walkDestY;
106  int32 _xShl16;
107  int32 _yShl16;
108  int32 _walkSlopeX;
109  int32 _walkSlopeY;
110  uint16 _walkPointsTbl[32];
111  int16 _walkPointsIndex;
112  int16 _finalWalkDestX;
113  int16 _finalWalkDestY;
114  uint16 _field_7a;
115  int32 _walkSpeed;
116  uint16 _frame_flags;
117 public:
118 
119  Actor(uint16 id);
120  void init(ActorResource *resource, int16 x, int16 y, uint32 sequenceID);
121  void updateSequence(uint16 newSequenceID);
122  void resetSequenceIP();
123  byte *getSeqIpAtOffset(uint32 offset);
124  void loadFrame(uint16 frameOffset);
125  void freeFrame();
126  void reset_maybe();
127  bool startWalk(int16 destX, int16 destY, uint16 flags);
128  void walkPath();
129  void waitUntilFlag4IsSet();
130  void waitUntilFlag8IsSet();
131  void waitUntilFlag8And4AreSet();
132  void waitUntilFlag8SetThenSet1000();
133  void waitUntilFlag8SetThenSet1000AndWaitFor4();
134  void waitForWalkToFinish();
135 
136  bool waitUntilFlag4IsSetAllowSkip();
137  bool actorSetSequenceAndWaitAllowSkip(uint16 newSequenceID);
138 
139  void clearFlag(uint32 flag);
140  void setFlag(uint32 flag);
141  bool isFlagSet(uint32 flag);
142  bool isFlagClear(uint32 flag) { return !isFlagSet(flag); }
143 
144  byte *getPalette();
145  int16 getFrameYOffset();
146 private:
147  void stopWalk();
148  uint16 canWalkLine(int16 actor_x, int16 actor_y, int16 target_x, int16 target_y, uint16 walkFlags);
149  int16 pathfindingFindClosestPoint(int16 actor_x, int16 actor_y, int16 target_x, int16 target_y, int16 unkType,
150  bool *pointsInUseTbl);
151  int startMoveToPoint(int destX, int destY);
152 };
153 
154 } // End of namespace Dragons
155 
156 #endif //DRAGONS_ACTOR_H
Definition: surface.h:67
Definition: actorresource.h:49
Definition: actor.h:86
Definition: actorresource.h:58
Definition: actorresource.h:33
Definition: actor.h:28
Definition: actor.h:61