ScummVM API documentation
player.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 
22 #ifndef MADS_PLAYER_H
23 #define MADS_PLAYER_H
24 
25 #include "common/scummsys.h"
26 #include "common/str.h"
27 #include "common/serializer.h"
28 
29 namespace MADS {
30 namespace Nebular {
31 
32 class RexNebularEngine;
33 class MADSAction;
34 
35 #define PLAYER_SPRITES_FILE_COUNT 8
36 #define MAX_ROUTE_NODES 22
37 
41 enum Facing {
42  FACING_NORTH = 8, FACING_SOUTH = 2, FACING_EAST = 6, FACING_WEST = 4,
43  FACING_NORTHEAST = 9, FACING_SOUTHEAST = 3,
44  FACING_SOUTHWEST = 1, FACING_NORTHWEST = 7,
45  FACING_NONE = 5, FACING_DUMMY = 0
46 };
47 
49  int _stack;
50  int _trigger;
51 
52  StopWalkerEntry() : _stack(0), _trigger(0) {
53  }
54  StopWalkerEntry(int stack, int trigger) : _stack(stack), _trigger(trigger) {
55  }
56 
57  void synchronize(Common::Serializer &s);
58 };
59 
60 class StopWalkers : public Common::FixedStack<StopWalkerEntry, 12> {
61 public:
63  }
64 
65  void synchronize(Common::Serializer &s);
66 };
67 
68 class Player {
69 private:
70  static const int _directionListIndexes[32];
71 private:
72  RexNebularEngine *_vm;
73  bool _highSprites;
74  bool _spriteSetsPresent[PLAYER_SPRITES_FILE_COUNT];
75  bool _mirror;
76  int _frameCount;
77  int _frameListIndex;
78  int _distAccum;
79  int _pixelAccum;
80  int _deltaDistance;
81  int _totalDistance;
82 
83  void clearStopList();
84 
88  void move();
89 
93  void setFrame();
94 
98  int getSpriteSlot();
99 
103  int getScale(int yp);
104 
108  void setBaseFrameRate();
109 
113  void startMovement();
114 
115  void changeFacing();
116 
117  void activateTrigger();
118 public:
119  MADSAction *_action;
120 
121  Facing _facing;
122  Facing _turnToFacing;
123  Facing _prepareWalkFacing;
124  int _xDirection, _yDirection;
125  Facing _targetFacing;
126  bool _spritesLoaded;
127  int _spritesStart;
128  int _spritesIdx;
129  int _numSprites;
130  bool _stepEnabled;
131  bool _spritesChanged;
132  bool _visible;
133  bool _priorVisible;
134  bool _beenVisible;
135  bool _walkAnywhere;
136  int _frameNumber;
137  bool _loadsFirst;
138  bool _loadedFirst;
139  Common::Point _playerPos;
140  Common::Point _targetPos;
141  Common::Point _posChange;
142  Common::Point _posDiff;
143  Common::Point _prepareWalkPos;
144  bool _moving;
145  int _walkOffScreen, _walkOffScreenSceneId;
146  int _special;
147  int _ticksAmount;
148  uint32 _priorTimer;
149  int _velocity;
150  int _upcomingTrigger;
151  int _trigger;
152  bool _scalingVelocity;
153  bool _forceRefresh;
154  bool _forcePrefix;
155  bool _needToWalk;
156  bool _readyToWalk;
157  bool _commandsAllowed;
158  bool _enableAtTarget;
159  int _centerOfGravity;
160  int _currentDepth;
161  int _currentScale;
162  Common::String _spritesPrefix;
163 
164  int _walkTrigger;
165  TriggerMode _walkTriggerDest;
166  ActionDetails _walkTriggerAction;
167  StopWalkers _stopWalkers;
168 public:
170 
174  bool loadSprites(const Common::String &prefix);
175 
180  void setFinalFacing();
181 
185  void cancelWalk();
186 
190  void cancelCommand();
191 
195  void selectSeries();
196 
197  /*
198  * Moves to the next frame for the currently active player sprite set
199  */
200  void updateFrame();
201 
202  void update();
203 
207  void idle();
208 
214  void startWalking(const Common::Point &pt, Facing facing);
215 
221  void walk(const Common::Point &pos, Facing facing);
222 
227  void newWalk();
228 
229  void nextFrame();
230 
234  void addWalker(int walker, int trigger);
235 
239  void releasePlayerSprites();
240 
244  void synchronize(Common::Serializer &s);
245 
246  static void preloadSequences(const Common::String &prefix, int level) {
247  // No implementation in ScummVM
248  }
249  static void himem_preload_series(const Common::String &prefix, int level) {
250  // No implementation in ScummVM
251  }
252 
253  void removePlayerSprites();
254 
255  void firstWalk(Common::Point fromPos, Facing fromFacing, Common::Point destPos, Facing destFacing, bool enableFl);
256 
257  void setWalkTrigger(int val);
258 
259  void resetFacing(Facing facing);
260 
261 };
262 
263 } // namespace Nebular
264 } // namespace MADS
265 
266 #endif
Definition: str.h:59
Definition: nebular.h:51
Definition: action.h:106
Definition: player.h:48
Definition: serializer.h:80
Definition: stack.h:43
Definition: rect.h:144
Definition: player.h:68
Out move(In first, In last, Out dst)
Definition: algorithm.h:109
Definition: mps_installer.h:31
Definition: player.h:60
Definition: action.h:78