healing_beam_system.cpp 930 B

123456789101112131415161718192021222324252627282930
  1. #include "healing_beam_system.h"
  2. #include "../core/world.h"
  3. #include <QDebug>
  4. #include <algorithm>
  5. namespace Game::Systems {
  6. void HealingBeamSystem::update(Engine::Core::World *, float delta_time) {
  7. for (auto &beam : m_beams) {
  8. if (beam && beam->is_active()) {
  9. beam->update(delta_time);
  10. }
  11. }
  12. m_beams.erase(std::remove_if(m_beams.begin(), m_beams.end(),
  13. [](const std::unique_ptr<HealingBeam> &beam) {
  14. return !beam || !beam->is_active();
  15. }),
  16. m_beams.end());
  17. }
  18. void HealingBeamSystem::spawn_beam(const QVector3D &healer_pos,
  19. const QVector3D &target_pos,
  20. const QVector3D &color, float duration) {
  21. m_beams.push_back(
  22. std::make_unique<HealingBeam>(healer_pos, target_pos, color, duration));
  23. }
  24. } // namespace Game::Systems