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.
 
 
 

103 lines
2.2 KiB

  1. //
  2. // Lol Engine
  3. //
  4. // Copyright: (c) 2010-2011 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://sam.zoy.org/projects/COPYING.WTFPL 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. protected:
  29. Entity();
  30. virtual ~Entity();
  31. virtual char const *GetName();
  32. inline int IsDestroying() { return destroy; }
  33. virtual void TickGame(float deltams);
  34. virtual void TickDraw(float deltams);
  35. enum
  36. {
  37. GAMEGROUP_BEFORE = 0,
  38. GAMEGROUP_DEFAULT,
  39. GAMEGROUP_AFTER,
  40. // Must be the last element
  41. GAMEGROUP_END
  42. }
  43. gamegroup;
  44. enum
  45. {
  46. DRAWGROUP_BEFORE = GAMEGROUP_END,
  47. DRAWGROUP_DEFAULT,
  48. DRAWGROUP_HUD,
  49. DRAWGROUP_CAPTURE,
  50. // Must be the last element
  51. DRAWGROUP_END
  52. }
  53. drawgroup;
  54. static int const GAMEGROUP_BEGIN = 0;
  55. static int const DRAWGROUP_BEGIN = GAMEGROUP_END;
  56. static int const ALLGROUP_END = DRAWGROUP_END;
  57. #if !LOL_RELEASE
  58. enum
  59. {
  60. STATE_IDLE = 0,
  61. STATE_PRETICK_GAME,
  62. STATE_POSTTICK_GAME,
  63. STATE_PRETICK_DRAW,
  64. STATE_POSTTICK_DRAW,
  65. }
  66. state;
  67. #endif
  68. // Emcee begin
  69. private:
  70. void SetState(uint32_t newstate);
  71. void SetStateWhenMatch(uint32_t newstate,
  72. Entity *other_entity, uint32_t other_state);
  73. virtual uint32_t OnStateChanged(uint32_t newstate)
  74. {
  75. return m_state = newstate;
  76. }
  77. uint32_t m_state;
  78. // Emcee end
  79. private:
  80. Entity *gamenext, *drawnext, *autonext;
  81. int ref, autorelease, destroy;
  82. };
  83. } /* namespace lol */
  84. #endif // __LOL_ENTITY_H__