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