endsequence.cpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. // SuperTux - End Sequence
  2. // Copyright (C) 2007 Christoph Sommer <christoph.sommer@2006.expires.deltadevelopment.de>
  3. //
  4. // This program is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // This program is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License
  15. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. #include "object/endsequence.hpp"
  17. #include "object/player.hpp"
  18. #include "supertux/sector.hpp"
  19. EndSequence::EndSequence() :
  20. m_is_running(false),
  21. m_is_done(false),
  22. m_tux_is_stopped(),
  23. m_end_sequence_controllers()
  24. {
  25. }
  26. EndSequence::~EndSequence()
  27. {
  28. }
  29. void
  30. EndSequence::update(float dt_sec)
  31. {
  32. if (!m_is_running) return;
  33. running(dt_sec);
  34. }
  35. void
  36. EndSequence::draw(DrawingContext& /*context*/)
  37. {
  38. }
  39. void
  40. EndSequence::start()
  41. {
  42. if (m_is_running) return;
  43. m_is_running = true;
  44. m_is_done = false;
  45. starting();
  46. }
  47. void
  48. EndSequence::stop_tux(int player)
  49. {
  50. m_tux_is_stopped[player] = true;
  51. }
  52. void
  53. EndSequence::stop()
  54. {
  55. if (!m_is_running) return;
  56. m_is_running = false;
  57. m_is_done = true;
  58. stopping();
  59. }
  60. bool
  61. EndSequence::is_running() const
  62. {
  63. return m_is_running;
  64. }
  65. bool
  66. EndSequence::is_tux_stopped(int player)
  67. {
  68. return m_tux_is_stopped[player];
  69. }
  70. bool
  71. EndSequence::is_done() const
  72. {
  73. return m_is_done;
  74. }
  75. void
  76. EndSequence::starting()
  77. {
  78. }
  79. void
  80. EndSequence::running(float /*dt_sec*/)
  81. {
  82. for (auto& ctrl : m_end_sequence_controllers)
  83. {
  84. ctrl.second->update();
  85. }
  86. }
  87. void
  88. EndSequence::stopping()
  89. {
  90. }
  91. const Controller*
  92. EndSequence::get_controller(int player)
  93. {
  94. return get_code_controller(player);
  95. }
  96. CodeController*
  97. EndSequence::get_code_controller(int player)
  98. {
  99. auto& ctrl = m_end_sequence_controllers[player];
  100. if (!ctrl)
  101. ctrl.reset(new CodeController());
  102. return ctrl.get();
  103. }
  104. /* EOF */