| 1 |
|
| 2 |
|
| 3 |
#ifndef ACTIONS_H |
| 4 |
#define ACTIONS_H |
| 5 |
|
| 6 |
#include <SDL/SDL.h> |
| 7 |
#include <map> |
| 8 |
|
| 9 |
class ActionQueue; |
| 10 |
|
| 11 |
class Action { |
| 12 |
private: |
| 13 |
ActionQueue* actionQueue; |
| 14 |
protected: |
| 15 |
int actionID; |
| 16 |
public: |
| 17 |
Action(); |
| 18 |
virtual void execute( const Uint32& time ) = 0; |
| 19 |
virtual ~Action() {} |
| 20 |
void setActionQueue( ActionQueue* actionQueue ); |
| 21 |
ActionQueue* getActionQueue() const; |
| 22 |
int getActionID() { return actionID; } |
| 23 |
}; |
| 24 |
|
| 25 |
class ActionQueue : public std::multimap< Uint32, Action* > { |
| 26 |
private: |
| 27 |
Uint32 time; |
| 28 |
public: |
| 29 |
ActionQueue(); |
| 30 |
void scheduleAction( Uint32 time, Action* action ); |
| 31 |
|
| 32 |
Uint32 timeOfNextEvent(); |
| 33 |
|
| 34 |
void executeNextEvent(); |
| 35 |
void executeAllEvents(); |
| 36 |
void executeEventsBefore( Uint32 time ); |
| 37 |
}; |
| 38 |
|
| 39 |
#endif |