Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

93 рядки
1.7 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. #if defined HAVE_CONFIG_H
  11. # include "config.h"
  12. #endif
  13. #include <cstdlib>
  14. #include <lol/main.h>
  15. namespace lol
  16. {
  17. /*
  18. * Public Entity class
  19. */
  20. Entity::Entity() :
  21. m_initstate(InitState::Ready),
  22. m_ref(0),
  23. m_destroy(0)
  24. {
  25. #if !LOL_BUILD_RELEASE
  26. m_tickstate = STATE_IDLE;
  27. #endif
  28. m_gamegroup = GAMEGROUP_DEFAULT;
  29. m_drawgroup = DRAWGROUP_DEFAULT;
  30. Ticker::Register(this);
  31. }
  32. Entity::~Entity()
  33. {
  34. #if !LOL_BUILD_RELEASE
  35. if (!m_destroy)
  36. Log::Error("entity destructor called directly\n");
  37. #endif
  38. }
  39. char const *Entity::GetName()
  40. {
  41. return "<entity>";
  42. }
  43. void Entity::InitGame()
  44. {
  45. }
  46. void Entity::InitDraw()
  47. {
  48. }
  49. void Entity::TickGame(float seconds)
  50. {
  51. UNUSED(seconds);
  52. #if !LOL_BUILD_RELEASE
  53. if (m_tickstate != STATE_PRETICK_GAME)
  54. Log::Error("invalid entity game tick\n");
  55. m_tickstate = STATE_POSTTICK_GAME;
  56. #endif
  57. }
  58. void Entity::TickDraw(float seconds, Scene &scene)
  59. {
  60. (void)seconds;
  61. #if !LOL_BUILD_RELEASE
  62. if (m_tickstate != STATE_PRETICK_DRAW)
  63. Log::Error("invalid entity draw tick\n");
  64. m_tickstate = STATE_POSTTICK_DRAW;
  65. #endif
  66. }
  67. void Entity::SetState(uint32_t state)
  68. {
  69. Ticker::SetState(this, state);
  70. }
  71. void Entity::SetStateWhenMatch(uint32_t state,
  72. Entity *other_entity, uint32_t other_state)
  73. {
  74. Ticker::SetStateWhenMatch(this, state, other_entity, other_state);
  75. }
  76. } /* namespace lol */