/TGame/TCommon/Combat/States/CombatState.h

http://awoe.googlecode.com/ · C Header · 72 lines · 33 code · 13 blank · 26 comment · 0 complexity · 36ced661dbbb2c528cc1444b96954f8a MD5 · raw file

  1. #ifndef CombatSysStateIf_H
  2. #define CombatSysStateIf_H
  3. #include "Entry/LibExportCom.h"
  4. #include "Move/MoveDefinition.h"
  5. #include "Combat/CombatDefinition.h"
  6. #include "Entity/EntityDefinition.h"
  7. class IEvt;
  8. class CombatSysImp;
  9. class IEntity;
  10. /*
  11. *
  12. * CombatState Interface
  13. * Combat State:
  14. * state Peace: no combat
  15. * state Ready: in combat, ready for casting a spell to its target
  16. * state Casting: in combat, casting a spell on its target
  17. * state CoolDown: in combat, cool down time interval just after a previous spell is casted
  18. * state Forbidden: in combat, forbidden to cast a spell
  19. * state Charging: in combat, approaching to its target for casting a spell
  20. */
  21. class TCOM_API ICombatState
  22. {
  23. public:
  24. ICombatState()
  25. :m_nTTL(0),
  26. m_wpEntity(NULL),
  27. m_wpCombat(NULL)
  28. {}
  29. virtual ~ICombatState(){;}
  30. //
  31. //
  32. void init(CombatSysImp* pCombat, IEntity* pEntity)
  33. {
  34. m_wpCombat = pCombat;
  35. m_wpEntity = pEntity;
  36. }
  37. //
  38. // Fire when enter a new state
  39. //
  40. virtual void enter() = 0;
  41. //
  42. // Fire just before leaving a state
  43. //
  44. virtual void leave() = 0;
  45. //
  46. // update in current state
  47. //
  48. virtual bool update(int nElapse) = 0;
  49. //
  50. // onEvent callback in current state
  51. //
  52. virtual void onEvent(IEvt& evt) = 0;
  53. protected:
  54. int m_nTTL; // Time To Live
  55. CombatSysImp* m_wpCombat;
  56. IEntity* m_wpEntity;
  57. };
  58. #endif // CombatSys_H