action_vfx.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. }
  13. auto *arrowSystem = world->getSystem<Game::Systems::ArrowSystem>();
  14. if (!arrowSystem) {
  15. return;
  16. }
  17. auto *targetEntity = world->getEntity(targetId);
  18. if (!targetEntity) {
  19. return;
  20. }
  21. auto *targetTrans =
  22. targetEntity->getComponent<Engine::Core::TransformComponent>();
  23. if (!targetTrans) {
  24. return;
  25. }
  26. QVector3D targetPos(targetTrans->position.x, targetTrans->position.y + 1.0f,
  27. targetTrans->position.z);
  28. QVector3D aboveTarget = targetPos + QVector3D(0, 2.0f, 0);
  29. arrowSystem->spawnArrow(aboveTarget, targetPos, QVector3D(1.0f, 0.2f, 0.2f),
  30. Game::GameConfig::instance().arrow().speedAttack);
  31. }
  32. } // namespace App::Controllers