25 #include "common/hashmap.h" 26 #include "common/ptr.h" 27 #include "common/rect.h" 28 #include "common/scummsys.h" 31 class SeekableReadStream;
67 int _movementDirections;
68 int _fogMinZ, _fogMaxZ;
70 struct AnimationDescription {
74 uint canvasW, canvasH;
83 const AnimationDescription *_description;
89 static const int kAnimsPerDirection = 5;
92 return _movementDirections != 0 &&
93 _animations.size() >= (uint)(_movementDirections * kAnimsPerDirection);
96 int animIndexFor(
int dir,
int phase)
const {
97 return phased() ? dir * kAnimsPerDirection + phase : dir;
101 const AnimationDescription *desc = animationDescription(animIndexFor(dir, phase));
102 if (!desc || desc->frames.empty())
106 if (frame >= (
int)desc->frames.size())
107 frame = desc->frames.size() - 1;
108 return &desc->frames[frame];
111 bool animate(
int animIndex,
int speed,
bool jokes);
112 float perspectiveScale()
const;
121 kWalkRemovePending = 5,
122 kWalkLeavePending = 6,
134 int _cyclesA, _cyclesB;
138 int _errX, _errY, _errStepX, _errStepY;
139 int _errPeriodX, _errPeriodY, _errPhaseX, _errPhaseY;
141 int _cycleErrX, _cycleErrY, _corrX, _corrY;
144 void walkUpdateTick();
146 void startNextSegment();
147 void setCycleScale(uint idx,
int scale);
148 void setupSegmentPhased(
int dx,
int dy);
149 int advanceWalkPhase(
bool cont);
150 void advanceWalkFrame();
151 bool walkTickAdvance();
152 void stepErrorCorrection();
154 void arrive(
int prevState);
155 void stopMoving(
bool force);
158 int perspectiveScalePermyriad(
int y)
const;
159 int scaleForSegmentY(
int simY,
int targetY)
const;
160 static double scalePermyriad(
int v,
int scale);
161 void checkTrapRegions();
169 const AnimationDescription *animationDescription(uint index)
const {
170 auto it = _animations.find(index);
171 return it != _animations.end() ? &it->_value :
nullptr;
186 void enable(
bool enabled =
true) {
190 void visible(
bool visible);
191 bool visible()
const {
192 return _visible && _shown;
195 bool active()
const {
196 return _enabled && _visible;
205 return _jokes ? _phase : -1;
207 void phase(
int phase) {
218 _walkState = kWalkIdle;
221 _targetDir = _direction;
232 bool userMove =
false,
bool leave =
false);
236 void requestStop(
int dir);
238 bool walking()
const {
239 return _walkState != kWalkIdle;
242 bool direction(
int dir);
244 int direction()
const {
245 return _jokes ? _jokesDirection : _direction;
249 int baseDirection()
const {
253 void tick(
bool reactivate);
Definition: managed_surface.h:51
void clear()
Definition: array.h:321
Definition: character.h:48
Definition: algorithm.h:29
Definition: formatinfo.h:28
Definition: character.h:71