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.
 
 
 

110 lines
2.3 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_HUD,
  54. DRAWGROUP_CAPTURE,
  55. // Must be the last element
  56. DRAWGROUP_END
  57. }
  58. m_drawgroup;
  59. static int const GAMEGROUP_BEGIN = 0;
  60. static int const DRAWGROUP_BEGIN = GAMEGROUP_END;
  61. static int const ALLGROUP_END = DRAWGROUP_END;
  62. #if !LOL_RELEASE
  63. enum
  64. {
  65. STATE_IDLE = 0,
  66. STATE_PRETICK_GAME,
  67. STATE_POSTTICK_GAME,
  68. STATE_PRETICK_DRAW,
  69. STATE_POSTTICK_DRAW,
  70. }
  71. m_tickstate;
  72. #endif
  73. // Emcee begin
  74. private:
  75. void SetState(uint32_t newstate);
  76. void SetStateWhenMatch(uint32_t newstate,
  77. Entity *other_entity, uint32_t other_state);
  78. virtual uint32_t OnStateChanged(uint32_t newstate)
  79. {
  80. return LOLm_state = newstate;
  81. }
  82. uint32_t LOLm_state;
  83. // Emcee end
  84. private:
  85. Entity *m_gamenext, *m_drawnext, *m_autonext;
  86. int m_ref, m_autorelease, m_destroy;
  87. };
  88. } /* namespace lol */
  89. #endif // __LOL_ENTITY_H__