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.
 
 
 

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