command_controller.h 2.0 KB

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