Emergency 20 Dokumentation  4.2.0
MoveAction.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 
16 
17 
18 //[-------------------------------------------------------]
19 //[ Forward declarations ]
20 //[-------------------------------------------------------]
21 namespace em5
22 {
23  class GameComponent;
24 }
25 
26 
27 //[-------------------------------------------------------]
28 //[ Namespace ]
29 //[-------------------------------------------------------]
30 namespace em5
31 {
32 
33 
34  //[-------------------------------------------------------]
35  //[ Classes ]
36  //[-------------------------------------------------------]
42  {
43 
44 
45  //[-------------------------------------------------------]
46  //[ Public definitions ]
47  //[-------------------------------------------------------]
48  public:
50  static const float MIN_DISTANCE_FOR_RETRY;
51 
52 
53  //[-------------------------------------------------------]
54  //[ Public methods ]
55  //[-------------------------------------------------------]
56  public:
61  MoveAction();
62 
67  virtual ~MoveAction();
68 
82  void init(qsf::ai::NavigationGoal* goal, uint32 movementModeId = qsf::getUninitialized(static_cast<uint32>(0)), qsf::ai::Path* path = nullptr, qsf::Time maxMoveTime = qsf::Time::ZERO);
83 
89  float getPathLength() const;
90 
95  uint64 getFollowedEntity() const;
96 
106  void forceFollowedEntityToWait(float distance, qsf::Time waitTime);
107 
108 
109  //[-------------------------------------------------------]
110  //[ Public virtual qsf::Action methods ]
111  //[-------------------------------------------------------]
112  public:
113  virtual void serialize(qsf::BinarySerializer& serializer) override;
114  virtual bool onStartup() override;
115  virtual void onShutdown() override;
116 
117 
118  //[-------------------------------------------------------]
119  //[ Protected virtual qsf::Action methods ]
120  //[-------------------------------------------------------]
121  protected:
122  virtual qsf::action::Result updateAction(const qsf::Clock& clock) override;
123 
124 
125  //[-------------------------------------------------------]
126  //[ Private definitions ]
127  //[-------------------------------------------------------]
128  private:
129  enum TraceNodeAddMode
130  {
131  ADD_NEW_NODE,
132  UPDATE_EXISTING_NODE,
133  FINISH_OFF_TRACE
134  };
135 
136  enum class StuckCheckMode
137  {
138  NONE = 0,
139  CIVIL_VEHICLES,
140  SQUADS // Also gangsters
141  };
142 
143 
144  //[-------------------------------------------------------]
145  //[ Private methods ]
146  //[-------------------------------------------------------]
147  private:
148  /*
149  * Returns whether the entity is currently on emergency operations that is used to trigger blue lights and sirens.
150  * This is currently decided based on the AI movement mode ID.
151  */
152  bool isOnEmergencyOperations() const;
153 
154  uint32 getMovementMode(uint32 movementModeId) const;
155  bool checkAllowUpdate() const;
156  bool checkPositionStuck();
157  bool checkIfStuck(const qsf::Time& timePassed);
158  void checkForSirenActivationOnStartMoving();
159  void addTraceNode(const glm::vec3& position, TraceNodeAddMode addMode = ADD_NEW_NODE);
160 
161 
162  //[-------------------------------------------------------]
163  //[ Private data ]
164  //[-------------------------------------------------------]
165  private:
166  // Internal
167  bool mIsPerson;
168  bool mIsCivilPerson;
169  bool mIsCivilRoadVehicle;
170  bool mIsSquadVehicle;
171  bool mDidStartMoveCheckForBluelightAndSiren;
172  qsf::WeakPtr<GameComponent> mGameComponent;
173 
174  // Stuck check
175  StuckCheckMode mStuckCheckMode;
176  qsf::Time mStuckTime;
177  glm::vec3 mOldPosition;
178 
179  // Trace ground
180  glm::vec3 mPreviousTracePosition;
181  float mPreviousTracePointPosition;
182  bool mIsOnTraceGround;
183  qsf::WeakPtr<qsf::Entity> mCurrentTraceEntity;
184 
185  qsf::Time mMaxMoveTime;
186  qsf::Time mTimePassed;
187 
188  float mForcedWaitSquaredDistance;
189  qsf::Time mForcedWaitTime;
190  uint32 mNumberOfRetries;
191 
192 
193  //[-------------------------------------------------------]
194  //[ CAMP reflection system ]
195  //[-------------------------------------------------------]
196  QSF_CAMP_RTTI() // Only adds the virtual method "campClassId()", nothing more
197 
198 
199  };
200 
201 
202 //[-------------------------------------------------------]
203 //[ Namespace ]
204 //[-------------------------------------------------------]
205 } // em5
206 
207 
208 //[-------------------------------------------------------]
209 //[ CAMP reflection system ]
210 //[-------------------------------------------------------]
Definition: ActionPriority.h:13
Definition: Path.h:38
Definition: MoveAction.h:33
unsigned int uint32
Definition: PlatformTypes.h:181
Clock class.
Definition: Clock.h:33
#define EM5_API_EXPORT
Definition: Export.h:28
static const Time ZERO
A zero value for time.
Definition: Time.h:40
uint64_t uint64
Definition: PlatformTypes.h:184
Lightweight weak pointer implementation.
Definition: WeakPtr.h:133
void serialize(BinarySerializer &serializer, BitFlagSet< STORAGE, ENUM > &bitFlagSet)
Definition: BitFlagSet.h:359
#define QSF_CAMP_RTTI()
Only adds the virtual method "campClassId()", nothing more.
Definition: CampClass.h:75
T getUninitialized()
Definition: GetUninitialized.h:38
#define QSF_CAMP_TYPE_NONCOPYABLE(type)
See "CAMP_TYPE_NONCOPYABLE" for details.
Definition: CampClass.h:112
Definition: NavigationGoal.h:43
EMERGENCY 5 move action.
Definition: MoveAction.h:41
Class combining strings with their hashes.
Definition: NamedIdentifier.h:34
Binary serializer class.
Definition: BinarySerializer.h:35
Result
Definition: ActionResult.h:20
static const float MIN_DISTANCE_FOR_RETRY
Minimal distance for retrying the pathfinding.
Definition: MoveAction.h:50
static const qsf::NamedIdentifier ACTION_ID
"em5::MoveAction" unique action identifier
Definition: MoveAction.h:49
Data type for encapsulating time information. It might represents points in time and time spans...
Definition: Time.h:32