/TGame/TCommon/Gene/Status/GEStatus.h

http://awoe.googlecode.com/ · C Header · 73 lines · 24 code · 11 blank · 38 comment · 0 complexity · 706e5a0358679b10e733c963ef2aa292 MD5 · raw file

  1. ///////////////////////////////////////////////////////////////////////////////////////////////////
  2. // GEStatus.h
  3. // 2010?1?20?
  4. // Copyright ?2007, 2010, 8DWorld, Inc. All rights reserved.
  5. //
  6. //
  7. ///////////////////////////////////////////////////////////////////////////////////////////////////
  8. #ifndef GE_STATUS_H
  9. #define GE_STATUS_H
  10. #include "Gene/GeneE.h"
  11. #include "Combat/CombatDefinition.h"
  12. #include "Entity/EntityDefinition.h"
  13. #include "Move/MoveDefinition.h"
  14. #include "Combat/CombatSysIf.h"
  15. /**
  16. *
  17. *
  18. * GEStatus
  19. * Derived from IGene , which can be treat as a complex state. enter state when attach to its host, leave state when detach to it.
  20. * Yes, an GEStatus is a complex state model for unit in combat, a unit in combat can have one or more GEStatus at the same time, which
  21. * mean that the unit is in these parallel state, and the unit is the state host.
  22. *
  23. * Complex State is a combination of simple, mutable state, like the move state in Entity will have 3 simple , mutable state:
  24. * state Moving: unit is moving
  25. * state Idle: unit is stand by and ready to move
  26. * state Freeze: unit is frozen and can't be moved
  27. * And a unit in combat will have the following simple, mutable state:
  28. * state Peace: no combat
  29. * state Ready: in combat, ready for casting a spell to its target
  30. * state Casting: in combat, casting a spell on its target
  31. * state CoolDown: in combat, cool down time interval just after a previous spell is casted
  32. * state Forbidden: in combat, forbidden to cast a spell
  33. * state Charging: in combat, approaching to its target for casting a spell
  34. * And so on...
  35. *
  36. */
  37. class TCOM_API GEStatus : public GeneE
  38. {
  39. public:
  40. enum
  41. {
  42. ArgIdx_StateID = 1,
  43. };
  44. GEStatus();
  45. virtual ~GEStatus();
  46. //
  47. // Fire when the gene is attached on a unit. just like unit enter the state.
  48. //
  49. virtual bool onAttach();
  50. //
  51. // Fire when the gene is attached on a unit. just like unit enter the state.
  52. //
  53. virtual bool onDetach();
  54. //
  55. // Periodically update gene logic, normally a gene will be detach when run out of its time to live.
  56. //
  57. virtual bool onUpdate(int nElapse);
  58. protected:
  59. ICombatSys* m_wpCombat;
  60. int m_nStateID;
  61. };
  62. #endif // GESTATEAES_H