AnimationTracker.h

Go to the documentation of this file.
00001 /*
00002 Copyright (C) 2004-2007 The Pentagram team
00003 
00004 This program is free software; you can redistribute it and/or
00005 modify it under the terms of the GNU General Public License
00006 as published by the Free Software Foundation; either version 2
00007 of the License, or (at your option) any later version.
00008 
00009 This program is distributed in the hope that it will be useful,
00010 but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 GNU General Public License for more details.
00013 
00014 You should have received a copy of the GNU General Public License
00015 along with this program; if not, write to the Free Software
00016 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
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         // actor state
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         // status flags
00119         bool done;
00120         bool blocked;
00121         bool unsupported;
00122         ObjId hitobject;
00123 
00124         Mode mode;
00125 };
00126 
00127 
00128 #endif

Generated on Fri Jul 27 22:27:09 2007 for pentagram by  doxygen 1.4.7