Emergency 20 Dokumentation  4.2.0
DefaultCommandMode.h
Go to the documentation of this file.
1 // Copyright (C) 2012-2018 Promotion Software GmbH
2 
3 
4 //[-------------------------------------------------------]
5 //[ Header guard ]
6 //[-------------------------------------------------------]
7 #pragma once
8 
9 
10 //[-------------------------------------------------------]
11 //[ Includes ]
12 //[-------------------------------------------------------]
13 #include "em5/Export.h"
14 
15 #include <qsf_game/command/evaluation/CommandEvaluationHelper.h> // For qsf::game::CommandEvaluationHelper::CommandInfo. Forward declaration for nested classes is not possible
17 
19 #include <qsf/time/Time.h>
20 
21 
22 //[-------------------------------------------------------]
23 //[ Forward declarations ]
24 //[-------------------------------------------------------]
25 namespace em5
26 {
27  class CommandableComponent;
28  struct RayMapQueryResponse;
29 }
30 
31 
32 //[-------------------------------------------------------]
33 //[ Namespace ]
34 //[-------------------------------------------------------]
35 namespace em5
36 {
37 
38 
39  //[-------------------------------------------------------]
40  //[ Classes ]
41  //[-------------------------------------------------------]
47  {
48 
49 
50  //[-------------------------------------------------------]
51  //[ Public definitions ]
52  //[-------------------------------------------------------]
53  public:
54  static const uint32 PLUGINABLE_ID;
55 
56 
57  //[-------------------------------------------------------]
58  //[ Public static methods ]
59  //[-------------------------------------------------------]
60  public:
65  static void showVisualCommandFeedback(const qsf::game::CommandContext& context);
66 
77  static bool isUnitAllowedForSelection(const CommandableComponent& commandableComponent);
78 
89  static bool isUnitAllowedForSelection(const qsf::Entity& entity);
90 
91 
92  //[-------------------------------------------------------]
93  //[ Public methods ]
94  //[-------------------------------------------------------]
95  public:
101 
106  virtual ~DefaultCommandMode();
107 
108  qsf::Time getWaitTimeBetweenChecks() const;
109  void setWaitTimeBetweenChecks(const qsf::Time& waitTimeBetweenChecks);
110  void onRayMapQueryResponse(const RayMapQueryResponse& rayMapQueryResponse);
111 
116  uint64 getMouseoverHighlightedEntityId() const;
117 
125  void setOnlyCommandHighlightingEntity(qsf::Entity* commandHighlightOnlyThisEntity);
126 
127 
128  //[-------------------------------------------------------]
129  //[ Public virtual qsf::game::CommandMode methods ]
130  //[-------------------------------------------------------]
131  public:
132  virtual void startup() override;
133  virtual void shutdown() override;
134  virtual bool executeCommandContext(qsf::game::CommandContext& commandContext, const EntityIdSet& callerIds) override;
135  virtual void updateCommandMode(const qsf::Clock& clock) override;
136 
137 
138  //[-------------------------------------------------------]
139  //[ Private definitions ]
140  //[-------------------------------------------------------]
141  private:
142  enum MouseCursorIcon
143  {
144  MOUSECURSORICON_DEFAULT,
145  MOUSECURSORICON_BLOCKED,
146  MOUSECURSORICON_FROM_COMMAND
147  };
148 
149 
150  //[-------------------------------------------------------]
151  //[ Private methods ]
152  //[-------------------------------------------------------]
153  private:
154  void highlightEntityUnderMouse(qsf::Entity* entityUnderMouse);
155 
161  void showCommandWhichCanBeExecuted(qsf::Entity* entityUnderMouse, const glm::vec3& hitPosition);
162  void updateDisplayOfExecutableCommand();
163 
168  void resetToDefault();
169 
174  void setBlockedMouseCursor();
175 
176  void resetCommandTargetHighlighting();
177  void resetSelectableHighlighting();
178 
179 
180  //[-------------------------------------------------------]
181  //[ Private data ]
182  //[-------------------------------------------------------]
183  private:
184  qsf::Time mWaitTimeBetweenChecks;
185  uint64 mMouseoverHighlightedEntityId;
186  uint64 mCommandTargetHighlightedEntityId;
187  qsf::Time mElapsedWaitTime;
188  boost::optional<qsf::game::CommandEvaluationHelper::CommandInfo> mLastCommandInfo;
189  qsf::Entity* mLastEntityUnderMouse;
190  qsf::Entity* mEntityForCommandHighlighting;
191  MouseCursorIcon mCurrentMouseCursorIcon;
192 
193  // Debug
194  qsf::DebugDrawProxy mDebugDrawProxy;
195 
196 
197  };
198 
199 
200 //[-------------------------------------------------------]
201 //[ Namespace ]
202 //[-------------------------------------------------------]
203 } // em5
Definition: ActionPriority.h:13
static const uint32 PLUGINABLE_ID
"em5::DefaultCommandMode" unique command mode pluginable ID
Definition: DefaultCommandMode.h:54
Entity class.
Definition: Entity.h:46
unsigned int uint32
Definition: PlatformTypes.h:181
Clock class.
Definition: Clock.h:33
#define EM5_API_EXPORT
Definition: Export.h:28
Definition: RayMapQuery.h:44
uint64_t uint64
Definition: PlatformTypes.h:184
Debug draw proxy class.
Definition: DebugDrawProxy.h:46
Command mode base class.
Definition: CommandMode.h:51
Default command mode for EMERGENCY 5.
Definition: DefaultCommandMode.h:46
boost::container::flat_set< uint64 > EntityIdSet
Definition: CommandMode.h:59
Commandable component class.
Definition: CommandableComponent.h:46
Command context base class.
Definition: CommandContext.h:48
Data type for encapsulating time information. It might represents points in time and time spans...
Definition: Time.h:32