00001
#ifndef DEF_EVENTS_H
00002
#define DEF_EVENTS_H 1
00003
00004
#define EV_DELAY 0x00000001
00005
#define EV_START 0x00000002
00006
#define EV_RUN 0x00000004
00007
#define EV_END 0x00000008
00008
#define EV_CANCEL 0x00000010
00009
00016 class Event {
00017
public:
00022
Event(
Object* obj, Uint16 length, Uint16 edelay=0, Uint32 switchstate=NOTHING);
00024
virtual ~Event();
00025
virtual Uint16 update(Uint16 dt);
00026
virtual void cancel();
00027
virtual void start();
00028
virtual void end();
00029
virtual void reset() { }
00030
protected:
00031
Object* owner;
00032 Uint16 duration;
00033 Uint16 delay;
00034 Sint16 tleft;
00035
bool started;
00036 Uint32 state;
00037 };
00038
00043 class CEvent :
public Event {
00044
public:
00045
CEvent(
Character* chr, Uint16 length, Uint16 edelay=0, Uint32 switchstate=NOTHING);
00046
protected:
00047
Character* charowner;
00048 };
00049
00054 class AnimEvent :
public Event {
00055
public:
00063
AnimEvent(
Object* obj, Uint16 length, Uint16 edelay=0, Uint32 switchstate=NOTHING,
00064 Mix_Chunk* asound=NULL, EmptyAnimationPtr runanim=EmptyAnimationPtr());
00068
virtual Uint16
update(Uint16 dt);
00069
virtual void start();
00070
virtual void end();
00071
virtual void cancel();
00072
protected:
00073 EmptyAnimationPtr anim;
00074 Mix_Chunk* sound;
00075 };
00076
00081 class CAnimEvent :
public CEvent {
00082
public:
00083
CAnimEvent(
Character* chr, Uint16 length, Uint16 edelay=0, Uint32 switchstate=NOTHING,
00084 Mix_Chunk* asound=NULL, EmptyAnimationPtr runanim=EmptyAnimationPtr());
00085
virtual Uint16 update(Uint16 dt);
00086
virtual void start();
00087
virtual void end();
00088
virtual void cancel();
00089
protected:
00090 EmptyAnimationPtr anim;
00091 Mix_Chunk* sound;
00092 };
00093
00099 class EAttack :
public CAnimEvent {
00100
public:
00112
EAttack(
Character* chr, Uint16 length,
Weapon* atweapon, Uint16 dir, Uint16 weapon_range=0,
00113 Uint16 target_mask=NOTHING, Uint16 edelay=0, Uint32 switchstate=0, Mix_Chunk* esound=NULL,
00114 EmptyAnimationPtr runanim=EmptyAnimationPtr());
00115
virtual void end();
00116
protected:
00117
Weapon* weapon;
00118 Uint16 direction;
00119 Uint16 range;
00120 Uint16 mask;
00121 };
00122
00128 class ERun :
public CAnimEvent {
00129
public:
00131
ERun(
Character* chr, Uint16 length, Sint16 edmax, Uint16 edelay=0,
00132 Uint32 switchstate=0, Mix_Chunk* esound=NULL, EmptyAnimationPtr runanim=EmptyAnimationPtr());
00133
virtual ~
ERun();
00135
virtual void start();
00136
virtual void end();
00137
virtual void cancel();
00138
virtual void reset();
00140
virtual Uint16
update(Uint16 dt);
00141
protected:
00142 Sint16 dmax;
00143 Sint16 t_reset;
00144 };
00145
00146
#endif