76 行
1.1 KiB

  1. //
  2. // Deus Hax (working title)
  3. // Copyright (c) 2010 Sam Hocevar <sam@hocevar.net>
  4. //
  5. #if defined HAVE_CONFIG_H
  6. # include "config.h"
  7. #endif
  8. #include <cstdlib>
  9. #include <cstdio>
  10. #include "core.h"
  11. /*
  12. * Public Entity class
  13. */
  14. Entity::Entity() :
  15. next(0),
  16. ref(0),
  17. destroy(0)
  18. {
  19. #if !FINAL_RELEASE
  20. state = STATE_IDLE;
  21. #endif
  22. Ticker::Register(this);
  23. }
  24. Entity::~Entity()
  25. {
  26. #if !FINAL_RELEASE
  27. if (!destroy)
  28. fprintf(stderr, "ERROR: entity destructor called directly\n");
  29. #endif
  30. }
  31. char const *Entity::GetName()
  32. {
  33. return "Generic entity";
  34. }
  35. Entity::Group Entity::GetGroup()
  36. {
  37. return GROUP_DEFAULT;
  38. }
  39. void Entity::TickGame(float deltams)
  40. {
  41. #if !FINAL_RELEASE
  42. if (state != STATE_PRETICK_GAME)
  43. fprintf(stderr, "ERROR: invalid entity game tick\n");
  44. state = STATE_POSTTICK_GAME;
  45. #endif
  46. }
  47. void Entity::TickRender(float deltams)
  48. {
  49. #if !FINAL_RELEASE
  50. if (state != STATE_PRETICK_RENDER)
  51. fprintf(stderr, "ERROR: invalid entity render tick\n");
  52. state = STATE_POSTTICK_RENDER;
  53. #endif
  54. }
  55. void Entity::Ref()
  56. {
  57. ref++;
  58. }
  59. int Entity::Unref()
  60. {
  61. return --ref;
  62. }