00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef ANIMATIONTRACKER_H
00020 #define ANIMATIONTRACKER_H
00021
00022 #include "Animation.h"
00023 #include "Pathfinder.h"
00024
00025 class Actor;
00026 class IDataSource;
00027 class ODataSource;
00028 struct AnimAction;
00029 struct AnimFrame;
00030
00031 class AnimationTracker
00032 {
00033 public:
00034 AnimationTracker();
00035 ~AnimationTracker();
00036
00040 bool init(Actor* actor, Animation::Sequence action, uint32 dir,
00041 PathfindingState* state=0);
00042
00045 void evaluateMaxAnimTravel(sint32& max_endx, sint32& max_endy, uint32 dir);
00046
00050 bool step();
00051
00055 bool stepFrom(sint32 x, sint32 y, sint32 z);
00056
00058 void updateState(PathfindingState& state);
00059
00061 void updateActorFlags();
00062
00064 void getPosition(sint32& x_, sint32& y_, sint32& z_)
00065 { x_ = x; y_ = y; z_ = z; }
00066
00067 void getInterpolatedPosition(sint32& x_, sint32& y_, sint32& z_, int fc);
00068
00070 void getSpeed(sint32& dx, sint32& dy, sint32& dz);
00071
00073 uint32 getFrame() { return shapeframe; }
00074
00076 AnimAction* getAnimAction() { return animaction; }
00077
00079 AnimFrame* getAnimFrame();
00080
00081 void setTargetedMode(sint32 x_, sint32 y_, sint32 z_);
00082
00083 bool isDone() const { return done; }
00084 bool isBlocked() const { return blocked; }
00085 bool isUnsupported() const { return unsupported; }
00086 ObjId hitSomething() const { return hitobject; }
00087
00088 bool load(IDataSource* ids, uint32 version);
00089 void save(ODataSource* ods);
00090
00091 private:
00092 enum Mode
00093 {
00094 NormalMode = 0,
00095 TargetMode
00096 };
00097
00098 unsigned int getNextFrame(unsigned int frame);
00099 void checkWeaponHit();
00100
00101 unsigned int startframe, endframe;
00102 bool firstframe;
00103 unsigned int currentframe;
00104
00105 ObjId actor;
00106 unsigned int dir;
00107
00108 AnimAction* animaction;
00109
00110
00111 sint32 prevx,prevy,prevz;
00112 sint32 x,y,z;
00113 sint32 startx,starty,startz;
00114 sint32 target_dx,target_dy;
00115 bool firststep, flipped;
00116 uint32 shapeframe;
00117
00118
00119 bool done;
00120 bool blocked;
00121 bool unsupported;
00122 ObjId hitobject;
00123
00124 Mode mode;
00125 };
00126
00127
00128 #endif