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.

пре 14 година
пре 12 година
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. //
  2. // Lol Engine
  3. //
  4. // Copyright © 2010—2015 Sam Hocevar <sam@hocevar.net>
  5. //
  6. // This library is free software. It comes without any warranty, to
  7. // the extent permitted by applicable law. You can redistribute it
  8. // and/or modify it under the terms of the Do What the Fuck You Want
  9. // to Public License, Version 2, as published by the WTFPL Task Force.
  10. // See http://www.wtfpl.net/ for more details.
  11. //
  12. #include <lol/engine-internal.h>
  13. #include <cstdlib>
  14. namespace lol
  15. {
  16. /*
  17. * Public Entity class
  18. */
  19. Entity::Entity() :
  20. m_initstate(InitState::Ready),
  21. m_ref(0),
  22. m_destroy(0)
  23. {
  24. #if !LOL_BUILD_RELEASE
  25. m_tickstate = STATE_IDLE;
  26. #endif
  27. m_gamegroup = GAMEGROUP_ENTITY;
  28. m_drawgroup = DRAWGROUP_ENTITY;
  29. Ticker::Register(this);
  30. }
  31. Entity::~Entity()
  32. {
  33. #if !LOL_BUILD_RELEASE
  34. if (!m_destroy)
  35. msg::error("entity destructor called directly\n");
  36. #endif
  37. }
  38. char const *Entity::GetName()
  39. {
  40. return "<entity>";
  41. }
  42. void Entity::InitGame()
  43. {
  44. }
  45. void Entity::InitDraw()
  46. {
  47. }
  48. void Entity::TickGame(float seconds)
  49. {
  50. UNUSED(seconds);
  51. #if !LOL_BUILD_RELEASE
  52. if (m_tickstate != STATE_PRETICK_GAME)
  53. msg::error("invalid entity game tick\n");
  54. m_tickstate = STATE_POSTTICK_GAME;
  55. #endif
  56. }
  57. void Entity::TickDraw(float seconds, Scene &scene)
  58. {
  59. (void)seconds;
  60. #if !LOL_BUILD_RELEASE
  61. if (m_tickstate != STATE_PRETICK_DRAW)
  62. msg::error("invalid entity draw tick\n");
  63. m_tickstate = STATE_POSTTICK_DRAW;
  64. #endif
  65. }
  66. void Entity::SetState(uint32_t state)
  67. {
  68. Ticker::SetState(this, state);
  69. }
  70. void Entity::SetStateWhenMatch(uint32_t state,
  71. Entity *other_entity, uint32_t other_state)
  72. {
  73. Ticker::SetStateWhenMatch(this, state, other_entity, other_state);
  74. }
  75. } /* namespace lol */