00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef __ANIMATIONS_H__
00031 #define __ANIMATIONS_H__
00032
00034
00035 #include <string>
00036 #include <map>
00037
00038 #include "upgrade_structs.h"
00039 #define ANIMATIONS_DEATHTYPES 40
00040
00041 class CFile;
00042 class CUnit;
00043 struct lua_State;
00044
00045
00046
00047
00048
00052 extern std::string ExtraDeathTypes[ANIMATIONS_DEATHTYPES];
00053
00054 enum AnimationType {
00055 AnimationNone,
00056 AnimationFrame,
00057 AnimationExactFrame,
00058 AnimationWait,
00059 AnimationRandomWait,
00060 AnimationSound,
00061 AnimationRandomSound,
00062 AnimationAttack,
00063 AnimationRotate,
00064 AnimationRandomRotate,
00065 AnimationMove,
00066 AnimationUnbreakable,
00067 AnimationLabel,
00068 AnimationGoto,
00069 AnimationRandomGoto,
00070 AnimationSpawnMissile,
00071 AnimationSpawnUnit,
00072 AnimationIfVar,
00073 AnimationSetVar,
00074 AnimationSetPlayerVar,
00075 AnimationDie
00076 };
00077
00078 class CAnimation
00079 {
00080 public:
00081 CAnimation(AnimationType type) : Type(type), Next(NULL) {}
00082
00083 virtual ~CAnimation() {}
00084
00085 virtual void Action(CUnit &unit, int &move, int scale) const = 0;
00086 virtual void Init(const char *s) {}
00087
00088 const AnimationType Type;
00089 CAnimation *Next;
00090 };
00091
00092 class CAnimations
00093 {
00094 public:
00095 CAnimations() : Attack(NULL), Build(NULL), Move(NULL), Repair(NULL),
00096 Research(NULL), SpellCast(NULL), Start(NULL), Still(NULL),
00097 Train(NULL), Upgrade(NULL) {
00098 memset(Death, 0, sizeof(Death));
00099 memset(Harvest, 0, sizeof(Harvest));
00100 }
00101
00102 ~CAnimations() {
00103 delete Attack;
00104 delete Build;
00105 for (int i = 0; i < ANIMATIONS_DEATHTYPES + 1; ++i) {
00106 delete Death[i];
00107 }
00108 for (int i = 0; i < MaxCosts; ++i) {
00109 delete Harvest[i];
00110 }
00111 delete Move;
00112 delete Repair;
00113 delete Research;
00114 delete SpellCast;
00115 delete Start;
00116 delete Still;
00117 delete Train;
00118 delete Upgrade;
00119 }
00120
00121 static void SaveUnitAnim(CFile &file, const CUnit &unit);
00122 static void LoadUnitAnim(lua_State *l, CUnit &unit, int luaIndex);
00123
00124 public:
00125 CAnimation *Attack;
00126 CAnimation *Build;
00127 CAnimation *Death[ANIMATIONS_DEATHTYPES + 1];
00128 CAnimation *Harvest[MaxCosts];
00129 CAnimation *Move;
00130 CAnimation *Repair;
00131 CAnimation *Research;
00132 CAnimation *SpellCast;
00133 CAnimation *Start;
00134 CAnimation *Still;
00135 CAnimation *Train;
00136 CAnimation *Upgrade;
00137 };
00138
00139
00140
00141
00142
00143
00145 extern CAnimations *AnimationsByIdent(const std::string &ident);
00146
00147 extern void AnimationCclRegister();
00148
00150 extern int UnitShowAnimationScaled(CUnit &unit, const CAnimation *anim, int scale);
00152 extern int UnitShowAnimation(CUnit &unit, const CAnimation *anim);
00153
00154
00155 extern int ParseAnimInt(const CUnit *unit, const char *parseint);
00156
00157 extern void FindLabelLater(CAnimation **anim, const std::string &name);
00159
00160 #endif // !__ANIMATIONS_H__