4
#include "../Ext/SWType/Body.h"
8
// New SW Type framework. See SWTypes/*.h for examples of implemented ones. Don't touch yet, still WIP.
16
{ Array.AddItem(this); this->TypeIndex = Array.Count; }
20
{ Registered = 0; Register(); };
27
virtual bool CanFireAt(CellStruct* pCoords)
29
virtual bool Launch(SuperClass* pSW, CellStruct* pCoords, byte IsPlayer) = 0;
31
virtual void LoadFromINI(
32
SWTypeExt::ExtData *pData,
33
SuperWeaponTypeClass *pSW, CCINIClass *pINI) = 0;
35
virtual const char * GetTypeString()
37
virtual const int GetTypeIndex()
40
static DynamicVectorClass<NewSWType *> Array;
42
static NewSWType * GetNthItem(int i)
43
{ return Array.GetItem(i - FIRST_SW_TYPE); }
45
static int FindIndex(const char *Type) {
46
for(int i = 0; i < Array.Count; ++i) {
47
if(!strcmp(Array.GetItem(i)->GetTypeString(), Type)) {
48
return FIRST_SW_TYPE + i;
55
// state machines - create one to use delayed effects [create a child class per NewSWType, obviously]
56
// i.e. start anim/sound 1 frame after clicking, fire a damage wave 25 frames later, and play second sound 50 frames after that...
57
class SWStateMachine {
59
static DynamicVectorClass<SWStateMachine *> Array;
66
bool Finished() { return Clock.IsDone(); }
68
int TimePassed() { return Unsorted::CurrentFrame - Clock.StartTime; }
70
SWStateMachine(int Duration, CellStruct XY, SuperClass *pSuper, NewSWType * pSWType)
71
: Type(pSWType), Super(pSuper), Coords(XY) {
72
Clock.Start(Duration);
76
virtual ~SWStateMachine() {
78
Array.RemoveItem(Array.FindItemIndex(&t));
81
virtual void Update() {};
83
static void UpdateAll();
85
SWTypeExt::ExtData * FindExtData () {
86
return SWTypeExt::ExtMap.Find(this->Super->Type);
90
class UnitDeliveryStateMachine : public SWStateMachine {
92
UnitDeliveryStateMachine(int Duration, CellStruct XY, SuperClass *pSuper, NewSWType * pSWType)
93
: SWStateMachine(Duration, XY, pSuper, pSWType) {};
94
virtual void Update();