ScummVM API documentation
animation_tracker.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 WORLD_ACTORS_ANIMATIONTRACKER_H
23#define WORLD_ACTORS_ANIMATIONTRACKER_H
24
25#include "ultima/ultima8/misc/common_types.h"
26#include "ultima/ultima8/misc/point3.h"
27#include "ultima/ultima8/world/actors/animation.h"
28#include "ultima/ultima8/world/actors/pathfinder.h"
29
30namespace Ultima {
31namespace Ultima8 {
32
33class Actor;
34class AnimAction;
35struct AnimFrame;
36
38public:
41
45 bool init(const Actor *actor, Animation::Sequence action, Direction dir,
46 const PathfindingState *state = 0);
47
50 void evaluateMaxAnimTravel(int32 &max_endx, int32 &max_endy, Direction dir);
51
55 bool step();
56
60 bool stepFrom(const Point3 &pt);
61
64
67
70 return _curr;
71 }
72
73 Point3 getInterpolatedPosition(int fc) const;
74
76 void getSpeed(int32 &dx, int32 &dy, int32 &dz) const;
77
79 uint32 getFrame() const {
80 return _shapeFrame;
81 }
82
84 const AnimAction *getAnimAction() const {
85 return _animAction;
86 }
87
89 const AnimFrame *getAnimFrame() const;
90
91 void setTargetedMode(const Point3 &pt);
92
93 bool isDone() const {
94 return _done;
95 }
96 bool isBlocked() const {
97 return _blocked;
98 }
99 bool isUnsupported() const {
100 return _unsupported;
101 }
102 ObjId hitSomething() const {
103 return _hitObject;
104 }
105
106 bool load(Common::ReadStream *rs, uint32 version);
107 void save(Common::WriteStream *ods);
108
109private:
110 enum Mode {
111 NormalMode = 0,
112 TargetMode
113 };
114
115 unsigned int getNextFrame(unsigned int frame) const;
116 void checkWeaponHit();
117
118 unsigned int _startFrame, _endFrame;
119 bool _firstFrame;
120 unsigned int _currentFrame;
121
122 ObjId _actor;
123 Direction _dir;
124
125 const AnimAction *_animAction;
126
127 // actor state
128 Point3 _prev;
129 Point3 _curr;
130 Point3 _start;
131 int32 _targetDx, _targetDy, _targetDz;
132 int32 _targetOffGroundLeft;
133 bool _firstStep, _flipped;
134 uint32 _shapeFrame;
135
136 // status flags
137 bool _done;
138 bool _blocked;
139 bool _unsupported;
140 ObjId _hitObject;
141
142 Mode _mode;
143};
144
145} // End of namespace Ultima8
146} // End of namespace Ultima
147
148#endif
Definition: stream.h:385
Definition: stream.h:77
Definition: actor.h:37
Definition: anim_action.h:94
Definition: animation_tracker.h:37
const AnimAction * getAnimAction() const
get the current AnimAction
Definition: animation_tracker.h:84
void updateActorFlags()
update the Actor with latest flags and animframe
void getSpeed(int32 &dx, int32 &dy, int32 &dz) const
get the difference between current position and previous position
bool stepFrom(const Point3 &pt)
Point3 getPosition() const
get the current position
Definition: animation_tracker.h:69
void evaluateMaxAnimTravel(int32 &max_endx, int32 &max_endy, Direction dir)
uint32 getFrame() const
get the current (shape)frame
Definition: animation_tracker.h:79
const AnimFrame * getAnimFrame() const
get the current AnimFrame
bool init(const Actor *actor, Animation::Sequence action, Direction dir, const PathfindingState *state=0)
void updateState(PathfindingState &state)
update the PathfindingState with latest coordinates and flags
Definition: anim_action.h:33
Definition: pathfinder.h:39
Definition: point3.h:30