You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

преди 12 години
преди 14 години
преди 14 години
преди 14 години
преди 14 години
преди 14 години
преди 14 години
преди 14 години
преди 14 години
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. //
  2. // Lol Engine
  3. //
  4. // Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net>
  5. // This program is free software; you can redistribute it and/or
  6. // modify it under the terms of the Do What The Fuck You Want To
  7. // Public License, Version 2, as published by Sam Hocevar. See
  8. // http://www.wtfpl.net/ for more details.
  9. //
  10. //
  11. // The Entity class
  12. // ---------------
  13. // Entities are objects that can be ticked by the game loop and/or the render
  14. // loop. Entities are implemented as one or several linked lists. See the
  15. // Ticker class for the ticking logic and the linked list implementation.
  16. //
  17. #if !defined __LOL_ENTITY_H__
  18. #define __LOL_ENTITY_H__
  19. #include <stdint.h>
  20. namespace lol
  21. {
  22. struct InitState
  23. {
  24. enum Value
  25. {
  26. Unknown,
  27. Error,
  28. NeedInitDraw,
  29. NeedInitGame,
  30. Ready,
  31. }
  32. m_value;
  33. inline InitState(Value v) : m_value(v) {}
  34. inline operator Value() { return m_value; }
  35. };
  36. class Entity
  37. {
  38. friend class Ticker;
  39. friend class TickerData;
  40. friend class Dict;
  41. friend class Emcee;
  42. public:
  43. virtual char const *GetName();
  44. protected:
  45. Entity();
  46. virtual ~Entity();
  47. inline int IsDestroying() { return m_destroy; }
  48. virtual void InitGame();
  49. virtual void InitDraw();
  50. virtual void TickGame(float seconds);
  51. virtual void TickDraw(float seconds);
  52. enum
  53. {
  54. GAMEGROUP_BEFORE = 0,
  55. GAMEGROUP_DEFAULT,
  56. GAMEGROUP_AFTER,
  57. GAMEGROUP_AFTER_0,
  58. GAMEGROUP_AFTER_1,
  59. // Must be the last element
  60. GAMEGROUP_END
  61. }
  62. m_gamegroup;
  63. enum
  64. {
  65. DRAWGROUP_BEFORE = GAMEGROUP_END,
  66. DRAWGROUP_LIGHT,
  67. DRAWGROUP_CAMERA,
  68. DRAWGROUP_DEFAULT,
  69. DRAWGROUP_AFTER,
  70. DRAWGROUP_AFTER_0,
  71. DRAWGROUP_AFTER_1,
  72. DRAWGROUP_HUD,
  73. DRAWGROUP_CAPTURE,
  74. // Must be the last element
  75. DRAWGROUP_END
  76. }
  77. m_drawgroup;
  78. static int const GAMEGROUP_BEGIN = 0;
  79. static int const DRAWGROUP_BEGIN = GAMEGROUP_END;
  80. static int const ALLGROUP_END = DRAWGROUP_END;
  81. /* The initialisation state */
  82. InitState m_initstate;
  83. #if !LOL_BUILD_RELEASE
  84. enum
  85. {
  86. STATE_IDLE = 0,
  87. STATE_PRETICK_GAME,
  88. STATE_POSTTICK_GAME,
  89. STATE_PRETICK_DRAW,
  90. STATE_POSTTICK_DRAW,
  91. }
  92. m_tickstate;
  93. #endif
  94. // Emcee begin
  95. private:
  96. void SetState(uint32_t newstate);
  97. void SetStateWhenMatch(uint32_t newstate,
  98. Entity *other_entity, uint32_t other_state);
  99. virtual uint32_t OnStateChanged(uint32_t newstate)
  100. {
  101. return LOLm_state = newstate;
  102. }
  103. uint32_t LOLm_state;
  104. // Emcee end
  105. private:
  106. int m_ref, m_autorelease, m_destroy;
  107. };
  108. } /* namespace lol */
  109. #endif // __LOL_ENTITY_H__