25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 

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