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.
 
 
 

113 lines
2.4 KiB

  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. class Entity
  23. {
  24. friend class Ticker;
  25. friend class TickerData;
  26. friend class Dict;
  27. friend class Emcee;
  28. public:
  29. virtual char const *GetName();
  30. protected:
  31. Entity();
  32. virtual ~Entity();
  33. inline int IsDestroying() { return m_destroy; }
  34. virtual void TickGame(float seconds);
  35. virtual void TickDraw(float seconds);
  36. enum
  37. {
  38. GAMEGROUP_BEFORE = 0,
  39. GAMEGROUP_DEFAULT,
  40. GAMEGROUP_AFTER,
  41. GAMEGROUP_AFTER_0,
  42. GAMEGROUP_AFTER_1,
  43. // Must be the last element
  44. GAMEGROUP_END
  45. }
  46. m_gamegroup;
  47. enum
  48. {
  49. DRAWGROUP_BEFORE = GAMEGROUP_END,
  50. DRAWGROUP_LIGHT,
  51. DRAWGROUP_CAMERA,
  52. DRAWGROUP_DEFAULT,
  53. DRAWGROUP_AFTER,
  54. DRAWGROUP_AFTER_0,
  55. DRAWGROUP_AFTER_1,
  56. DRAWGROUP_HUD,
  57. DRAWGROUP_CAPTURE,
  58. // Must be the last element
  59. DRAWGROUP_END
  60. }
  61. m_drawgroup;
  62. static int const GAMEGROUP_BEGIN = 0;
  63. static int const DRAWGROUP_BEGIN = GAMEGROUP_END;
  64. static int const ALLGROUP_END = DRAWGROUP_END;
  65. #if !LOL_RELEASE
  66. enum
  67. {
  68. STATE_IDLE = 0,
  69. STATE_PRETICK_GAME,
  70. STATE_POSTTICK_GAME,
  71. STATE_PRETICK_DRAW,
  72. STATE_POSTTICK_DRAW,
  73. }
  74. m_tickstate;
  75. #endif
  76. // Emcee begin
  77. private:
  78. void SetState(uint32_t newstate);
  79. void SetStateWhenMatch(uint32_t newstate,
  80. Entity *other_entity, uint32_t other_state);
  81. virtual uint32_t OnStateChanged(uint32_t newstate)
  82. {
  83. return LOLm_state = newstate;
  84. }
  85. uint32_t LOLm_state;
  86. // Emcee end
  87. private:
  88. Entity *m_gamenext, *m_drawnext, *m_autonext;
  89. int m_ref, m_autorelease, m_destroy;
  90. };
  91. } /* namespace lol */
  92. #endif // __LOL_ENTITY_H__