No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 

109 líneas
2.3 KiB

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