action_vfx.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #include "action_vfx.h"
  2. #include "../../game/core/component.h"
  3. #include "../../game/core/entity.h"
  4. #include "../../game/core/world.h"
  5. #include "../../game/game_config.h"
  6. #include "../../game/systems/arrow_system.h"
  7. namespace App::Controllers {
  8. void ActionVFX::spawnAttackArrow(Engine::Core::World *world,
  9. Engine::Core::EntityID targetId) {
  10. if (!world)
  11. return;
  12. auto *arrowSystem = world->getSystem<Game::Systems::ArrowSystem>();
  13. if (!arrowSystem)
  14. return;
  15. auto *targetEntity = world->getEntity(targetId);
  16. if (!targetEntity)
  17. return;
  18. auto *targetTrans =
  19. targetEntity->getComponent<Engine::Core::TransformComponent>();
  20. if (!targetTrans)
  21. return;
  22. QVector3D targetPos(targetTrans->position.x, targetTrans->position.y + 1.0f,
  23. targetTrans->position.z);
  24. QVector3D aboveTarget = targetPos + QVector3D(0, 2.0f, 0);
  25. arrowSystem->spawnArrow(aboveTarget, targetPos, QVector3D(1.0f, 0.2f, 0.2f),
  26. Game::GameConfig::instance().arrow().speedAttack);
  27. }
  28. } // namespace App::Controllers