command_controller.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #pragma once
  2. #include <QObject>
  3. #include <QString>
  4. #include <QVector3D>
  5. #include <vector>
  6. namespace Engine {
  7. namespace Core {
  8. class World;
  9. class Entity;
  10. using EntityID = unsigned int;
  11. } // namespace Core
  12. } // namespace Engine
  13. namespace Game::Systems {
  14. class SelectionSystem;
  15. class PickingService;
  16. } // namespace Game::Systems
  17. namespace App::Controllers {
  18. struct CommandResult {
  19. bool inputConsumed = false;
  20. bool resetCursorToNormal = false;
  21. };
  22. class CommandController : public QObject {
  23. Q_OBJECT
  24. public:
  25. CommandController(Engine::Core::World *world,
  26. Game::Systems::SelectionSystem *selectionSystem,
  27. Game::Systems::PickingService *pickingService,
  28. QObject *parent = nullptr);
  29. CommandResult onAttackClick(qreal sx, qreal sy, int viewportWidth,
  30. int viewportHeight, void *camera);
  31. CommandResult onStopCommand();
  32. CommandResult onPatrolClick(qreal sx, qreal sy, int viewportWidth,
  33. int viewportHeight, void *camera);
  34. CommandResult setRallyAtScreen(qreal sx, qreal sy, int viewportWidth,
  35. int viewportHeight, void *camera,
  36. int localOwnerId);
  37. void recruitNearSelected(const QString &unitType, int localOwnerId);
  38. bool hasPatrolFirstWaypoint() const { return m_hasPatrolFirstWaypoint; }
  39. QVector3D getPatrolFirstWaypoint() const { return m_patrolFirstWaypoint; }
  40. void clearPatrolFirstWaypoint() { m_hasPatrolFirstWaypoint = false; }
  41. signals:
  42. void attackTargetSelected();
  43. void troopLimitReached();
  44. private:
  45. Engine::Core::World *m_world;
  46. Game::Systems::SelectionSystem *m_selectionSystem;
  47. Game::Systems::PickingService *m_pickingService;
  48. bool m_hasPatrolFirstWaypoint = false;
  49. QVector3D m_patrolFirstWaypoint;
  50. void resetMovement(Engine::Core::Entity *entity);
  51. };
  52. } // namespace App::Controllers