Emergency 20 Dokumentation  4.2.0
OrderUnitCommandMode.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 //[-------------------------------------------------------]
15 
17 
19 #include <qsf/time/Time.h>
20 
21 
22 //[-------------------------------------------------------]
23 //[ Forward declarations ]
24 //[-------------------------------------------------------]
25 namespace em5
26 {
27  class Player;
28  class CommandContext;
29  class SpawnUnitAction;
30 }
31 
32 
33 //[-------------------------------------------------------]
34 //[ Namespace ]
35 //[-------------------------------------------------------]
36 namespace em5
37 {
38 
39 
40  //[-------------------------------------------------------]
41  //[ Classes ]
42  //[-------------------------------------------------------]
51  {
52 
53 
54  //[-------------------------------------------------------]
55  //[ Public definitions ]
56  //[-------------------------------------------------------]
57  public:
58  static const uint32 PLUGINABLE_ID;
59 
60 
61  //[-------------------------------------------------------]
62  //[ Public static methods ]
63  //[-------------------------------------------------------]
64  public:
65  static SpawnUnitAction* orderUnit(const OrderInfo& orderInfo, Player& player, const OrderInfo::OrderPairList& orderPairList, const glm::vec3& targetPosition, const glm::quat* targetRotation = nullptr);
66 
67 
68  //[-------------------------------------------------------]
69  //[ Public methods ]
70  //[-------------------------------------------------------]
71  public:
77 
82  virtual ~OrderUnitCommandMode();
83 
93  void initialize(const OrderInfo& orderInfo, uint32 numberToOrder = 1, OrderInfo::OrderPairList orderPairList = OrderInfo::OrderPairList());
94 
102  void setOrderOnlyInThisAreaEntity(qsf::Entity* orderOnlyInThisAreaEntity);
103 
104  const OrderInfo* getOrderInfo() const;
105  uint32 getNumberToOrder() const;
106  void setNumberToOrder(uint32 numberToOrder);
107 
108 
109  //[-------------------------------------------------------]
110  //[ Public virtual qsf::game::CommandMode methods ]
111  //[-------------------------------------------------------]
112  public:
113  virtual void startup() override;
114  virtual void shutdown() override;
115  virtual bool executeCommandContext(qsf::game::CommandContext& commandContext, const EntityIdSet& callerIds) override;
116  virtual void updateCommandMode(const qsf::Clock& clock) override;
117 
118 
119  //[-------------------------------------------------------]
120  //[ Private static methods ]
121  //[-------------------------------------------------------]
122  private:
123  static UnitSpawnPointComponent* findUnitSpawnPoint(const OrderInfo& orderInfo, UnitSpawnPointComponent::UnitSpawnPointType type, const glm::vec3& targetPosition);
124 
125 
126  //[-------------------------------------------------------]
127  //[ Private methods ]
128  //[-------------------------------------------------------]
129  private:
130  bool allowOrderingUnderMousePosition();
131  bool getTargetUnderMouse(glm::vec3& targetPosition, qsf::Entity*& targetEntity);
132  bool allowOrderingAtTarget(const glm::vec3& targetPosition, const qsf::Entity* targetEntity);
133  void triggerUnitSpawn(const UnitSpawnPointComponent& unitSpawnPointComponent, uint32 index, CommandContext& commandContext);
134  void showAllHarborIcons(bool show);
135 
136 
137  //[-------------------------------------------------------]
138  //[ Private definitions ]
139  //[-------------------------------------------------------]
140  private:
141  static const uint32 ACTION_PRIORITY;
142 
143 
144  //[-------------------------------------------------------]
145  //[ Private data ]
146  //[-------------------------------------------------------]
147  private:
148  const OrderInfo* mOrderInfo;
149  qsf::Entity* mOrderOnlyInThisAreaEntity;
150  uint32 mNumberToOrder;
151  OrderInfo::OrderPairList mOrderPairList;
152  bool mPlayAudioForOrderUnit;
153  qsf::Time mElapsedWaitTime;
154 
155  // Debug
156  qsf::DebugDrawProxy mDebugDrawProxy;
157 
158 
159  //[-------------------------------------------------------]
160  //[ CAMP reflection system ]
161  //[-------------------------------------------------------]
162  QSF_CAMP_RTTI() // Only adds the virtual method "campClassId()", nothing more
163 
164 
165  };
166 
167 
168 //[-------------------------------------------------------]
169 //[ Namespace ]
170 //[-------------------------------------------------------]
171 } // em5
172 
173 
174 //[-------------------------------------------------------]
175 //[ CAMP reflection system ]
176 //[-------------------------------------------------------]
Definition: ActionPriority.h:13
UnitSpawnPointType
Definition: UnitSpawnPointComponent.h:43
Entity class.
Definition: Entity.h:46
Order information.
Definition: OrderInfo.h:54
unsigned int uint32
Definition: PlatformTypes.h:181
Clock class.
Definition: Clock.h:33
#define EM5_API_EXPORT
Definition: Export.h:28
EMERGENCY 5 player class.
Definition: Player.h:57
Debug draw proxy class.
Definition: DebugDrawProxy.h:46
#define QSF_CAMP_RTTI()
Only adds the virtual method "campClassId()", nothing more.
Definition: CampClass.h:75
EMERGENCY 5 spawn unit action.
Definition: SpawnUnitAction.h:52
#define QSF_CAMP_TYPE_NONCOPYABLE(type)
See "CAMP_TYPE_NONCOPYABLE" for details.
Definition: CampClass.h:112
EMERGENCY 5 command context class.
Definition: CommandContext.h:41
Order unit command mode.
Definition: OrderUnitCommandMode.h:50
EMERGENCY 5 spawn point component.
Definition: UnitSpawnPointComponent.h:33
boost::container::flat_map< std::string, uint32 > OrderPairList
Definition: OrderInfo.h:63
Command mode base class.
Definition: CommandMode.h:51
boost::container::flat_set< uint64 > EntityIdSet
Definition: CommandMode.h:59
static const uint32 PLUGINABLE_ID
"em5::OrderUnitCommandMode" unique command pluginable ID
Definition: OrderUnitCommandMode.h:58
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