| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- #pragma once
- #include <QObject>
- #include <QString>
- #include <QVector3D>
- #include <vector>
- namespace Engine::Core {
- class World;
- class Entity;
- using EntityID = unsigned int;
- } // namespace Engine::Core
- namespace Game::Systems {
- class SelectionSystem;
- class PickingService;
- } // namespace Game::Systems
- namespace App::Controllers {
- struct CommandResult {
- bool inputConsumed = false;
- bool resetCursorToNormal = false;
- };
- class CommandController : public QObject {
- Q_OBJECT
- public:
- CommandController(Engine::Core::World *world,
- Game::Systems::SelectionSystem *selection_system,
- Game::Systems::PickingService *pickingService,
- QObject *parent = nullptr);
- auto onAttackClick(qreal sx, qreal sy, int viewportWidth, int viewportHeight,
- void *camera) -> CommandResult;
- auto onStopCommand() -> CommandResult;
- auto onHoldCommand() -> CommandResult;
- auto onPatrolClick(qreal sx, qreal sy, int viewportWidth, int viewportHeight,
- void *camera) -> CommandResult;
- auto setRallyAtScreen(qreal sx, qreal sy, int viewportWidth,
- int viewportHeight, void *camera,
- int localOwnerId) -> CommandResult;
- void recruitNearSelected(const QString &unit_type, int localOwnerId);
- [[nodiscard]] bool hasPatrolFirstWaypoint() const {
- return m_hasPatrolFirstWaypoint;
- }
- [[nodiscard]] QVector3D getPatrolFirstWaypoint() const {
- return m_patrolFirstWaypoint;
- }
- void clearPatrolFirstWaypoint() { m_hasPatrolFirstWaypoint = false; }
- Q_INVOKABLE [[nodiscard]] bool anySelectedInHoldMode() const;
- signals:
- void attack_targetSelected();
- void troopLimitReached();
- void hold_modeChanged(bool active);
- private:
- Engine::Core::World *m_world;
- Game::Systems::SelectionSystem *m_selection_system;
- Game::Systems::PickingService *m_pickingService;
- bool m_hasPatrolFirstWaypoint = false;
- QVector3D m_patrolFirstWaypoint;
- static void resetMovement(Engine::Core::Entity *entity);
- };
- } // namespace App::Controllers
|