healer_aura_renderer.cpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #include "healer_aura_renderer.h"
  2. #include "../../game/core/component.h"
  3. #include "../../game/core/world.h"
  4. #include "../../game/systems/nation_id.h"
  5. #include "../scene_renderer.h"
  6. namespace Render::GL {
  7. void render_healer_auras(Renderer *renderer, ResourceManager *,
  8. Engine::Core::World *world) {
  9. if (renderer == nullptr || world == nullptr) {
  10. return;
  11. }
  12. float animation_time = renderer->get_animation_time();
  13. auto healers = world->get_entities_with<Engine::Core::HealerComponent>();
  14. for (auto *healer : healers) {
  15. if (healer->has_component<Engine::Core::PendingRemovalComponent>()) {
  16. continue;
  17. }
  18. auto *transform = healer->get_component<Engine::Core::TransformComponent>();
  19. auto *healer_comp = healer->get_component<Engine::Core::HealerComponent>();
  20. auto *unit_comp = healer->get_component<Engine::Core::UnitComponent>();
  21. if (transform == nullptr || healer_comp == nullptr) {
  22. continue;
  23. }
  24. if (unit_comp != nullptr && unit_comp->health <= 0) {
  25. continue;
  26. }
  27. if (!healer_comp->is_healing_active) {
  28. continue;
  29. }
  30. if (unit_comp != nullptr &&
  31. unit_comp->nation_id == Game::Systems::NationID::RomanRepublic) {
  32. continue;
  33. }
  34. QVector3D position(transform->position.x, transform->position.y + 0.1F,
  35. transform->position.z);
  36. float radius = healer_comp->healing_range;
  37. float intensity = 1.0F;
  38. QVector3D color(0.4F, 1.0F, 0.5F);
  39. renderer->healer_aura(position, color, radius, intensity, animation_time);
  40. }
  41. }
  42. } // namespace Render::GL