Emergency 20 Dokumentation  4.2.0
SpawnUnitAction.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 //[-------------------------------------------------------]
14 
16 
17 #include <glm/gtc/quaternion.hpp>
18 
19 #include <boost/optional.hpp>
20 
21 
22 //[-------------------------------------------------------]
23 //[ Forward declarations ]
24 //[-------------------------------------------------------]
25 namespace em5
26 {
27  class Player;
28 }
29 namespace qsf
30 {
31  class Transform;
32 }
33 
34 
35 //[-------------------------------------------------------]
36 //[ Namespace ]
37 //[-------------------------------------------------------]
38 namespace em5
39 {
40 
41 
42  //[-------------------------------------------------------]
43  //[ Classes ]
44  //[-------------------------------------------------------]
53  {
54 
55 
56  //[-------------------------------------------------------]
57  //[ Public definitions ]
58  //[-------------------------------------------------------]
59  public:
61 
62 
63  //[-------------------------------------------------------]
64  //[ Public static methods ]
65  //[-------------------------------------------------------]
66  public:
80  static void setupCreatedEntityAsUnitVehicle(qsf::Entity& newOrderedUnit, qsf::Entity& spawnPointEntity, const OrderInfo& orderInfo, const Player& player);
81  static void setupCreatedEntityAsUnitVehicle(qsf::Entity& newOrderedUnit, const qsf::Transform& transform, const OrderInfo& orderInfo, const Player& player);
82  static void setupCreatedEntityAsUnitVehicle(qsf::Entity& newOrderedUnit, const OrderInfo& orderInfo, const Player& player);
83 
84  static void registerPersonnelInSpawn(const OrderInfo& orderInfo, const OrderInfo::OrderPair& orderPair, const Player& player);
85  static void fillVehicleWithStartPersonnel(qsf::Entity& vehicleEntity, const OrderInfo& orderInfo, const Player& player, OrderInfo::OrderPairList* orderPairList = nullptr, uint64 spawnpointEntityId = qsf::getUninitialized<uint64>(), uint64 userData = qsf::getUninitialized<uint64>());
86 
102  static void setupCreatedEntityAsUnitPerson(qsf::Entity& newOrderedUnit, qsf::Entity* vehicleEntity, const OrderInfo& orderInfo, const Player& player, bool hidden = true);
103 
115  static void setupCreatedEntityAsUnit(qsf::Entity& newOrderedUnit, const OrderInfo& orderInfo, const Player& player);
116 
117  static void sendUnitSpawnedMessage(const qsf::Entity& newOrderedUnit, uint64 spawnpointEntityId, uint64 userData);
118 
119  static void sendUnitSpawnedPlayerUpdateSelectionMessage(uint32 playerId, uint64 spawnedUnitEntityId);
120 
121 
122  //[-------------------------------------------------------]
123  //[ Public methods ]
124  //[-------------------------------------------------------]
125  public:
130  SpawnUnitAction();
131 
136  virtual ~SpawnUnitAction();
137 
142  void init(const OrderInfo& orderInfo, const glm::vec3& targetPosition, Player* player, const OrderInfo::OrderPairList& orderPairList = OrderInfo::OrderPairList(), int index = 1, int maxIndex = 1, const glm::quat* targetRotation = nullptr, uint64 userData = qsf::getUninitialized<uint64>());
143 
144 
145  //[-------------------------------------------------------]
146  //[ Public virtual qsf::Actions methods ]
147  //[-------------------------------------------------------]
148  public:
149  virtual void serialize(qsf::BinarySerializer& serializer) override;
150 
151 
152  //[-------------------------------------------------------]
153  //[ Protected virtual qsf::Action methods ]
154  //[-------------------------------------------------------]
155  protected:
156  virtual qsf::action::Result updateAction(const qsf::Clock& clock) override;
157 
158 
159  //[-------------------------------------------------------]
160  //[ Private methods ]
161  //[-------------------------------------------------------]
162  private:
163  void registerUnitWithPersonnelInSpawn();
164 
165 
166  //[-------------------------------------------------------]
167  //[ Private definitions ]
168  //[-------------------------------------------------------]
169  private:
170  enum State
171  {
172  STATE_INIT,
173  STATE_WAIT_FORSPACE,
174  STATE_WAIT_FORORDERTIME,
175  STATE_SPAWNUNIT,
176  STATE_SPAWNUNIT_2_PART,
177  STATE_CLOSEDOORS
178  };
179 
180 
181  //[-------------------------------------------------------]
182  //[ Private data ]
183  //[-------------------------------------------------------]
184  private:
185  State mCurrentState;
186  const OrderInfo* mOrderInfo;
187  glm::vec3 mTargetPosition;
188  boost::optional<glm::quat> mTargetRotation;
189  uint64 mUserData;
190  Player* mPlayer;
191  qsf::Time mOrderedTimeStamp;
192  OrderInfo::OrderPairList mOrderPairList;
193  int mIndex;
194  int mMaxIndex;
195  qsf::WeakPtr<qsf::Entity> mNewSpawnedVehicle;
196 
197 
198  //[-------------------------------------------------------]
199  //[ CAMP reflection system ]
200  //[-------------------------------------------------------]
201  QSF_CAMP_RTTI() // Only adds the virtual method "campClassId()", nothing more
202 
203 
204  };
205 
206 
207 //[-------------------------------------------------------]
208 //[ Namespace ]
209 //[-------------------------------------------------------]
210 } // em5
211 
212 
213 //[-------------------------------------------------------]
214 //[ CAMP reflection system ]
215 //[-------------------------------------------------------]
Definition: ActionPriority.h:13
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
static const qsf::NamedIdentifier ACTION_ID
"em5::SpawnUnitAction" unique action identifier
Definition: SpawnUnitAction.h:60
uint64_t uint64
Definition: PlatformTypes.h:184
EMERGENCY 5 player class.
Definition: Player.h:57
void serialize(BinarySerializer &serializer, BitFlagSet< STORAGE, ENUM > &bitFlagSet)
Definition: BitFlagSet.h:359
3D transform class
Definition: Transform.h:45
Definition: PickupPersonByParamedicAction.h:21
State
Definition: ProcessState.h:20
std::pair< std::string, uint32 > OrderPair
Definition: OrderInfo.h:62
#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
Abstract action base class.
Definition: Action.h:59
boost::container::flat_map< std::string, uint32 > OrderPairList
Definition: OrderInfo.h:63
Class combining strings with their hashes.
Definition: NamedIdentifier.h:34
Binary serializer class.
Definition: BinarySerializer.h:35
Result
Definition: ActionResult.h:20
Data type for encapsulating time information. It might represents points in time and time spans...
Definition: Time.h:32