Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 

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