Emergency 20 Dokumentation  4.2.0
MainEvent104.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 
15 #include <qsf/job/JobProxy.h>
16 #include <qsf/base/WeakPtr.h>
17 
18 
19 //[-------------------------------------------------------]
20 //[ Forward declarations ]
21 //[-------------------------------------------------------]
22 namespace em5
23 {
24  class DoorComponent;
25 }
26 
27 
28 //[-------------------------------------------------------]
29 //[ Namespace ]
30 //[-------------------------------------------------------]
31 namespace em5
32 {
33 
34 
35  //[-------------------------------------------------------]
36  //[ Classes ]
37  //[-------------------------------------------------------]
42  class MainEvent104 : public MainEvent
43  {
44 
45 
46  //[-------------------------------------------------------]
47  //[ Friends ]
48  //[-------------------------------------------------------]
49  friend class MainEventMetaclasses; // CAMP export of editable values for Game Design
50 
51 
52  //[-------------------------------------------------------]
53  //[ Private definitions ]
54  //[-------------------------------------------------------]
55  private:
57  typedef std::vector<WeakEntityPtr> WeakPtrEntityList;
58 
59  struct TrapBomb
60  {
61  // Is the bomb active?
62  bool mIsHot;
63 
64  // Was the bomb discovered?
65  bool mIsDiscovered;
66 
67  // Bomb entity ref
68  WeakEntityPtr mBomb;
69 
70  // Trap trigger entity ref
71  WeakEntityPtr mTrigger;
72 
73  // Visual representation of the trigger zone entity ref
74  WeakEntityPtr mMarker;
75 
76  TrapBomb() :
77  mIsHot(false),
78  mIsDiscovered(false)
79  {}
80  };
81 
82  struct ConvoyTruck
83  {
84  // Did the truck enter the quarantine zone?
85  bool mReachedTrigger;
86 
87  // Did the truck parked on the target spot in the quarantine zone?
88  bool mReachedTarget;
89 
90  // Truck entity ref
91  WeakEntityPtr mTruck;
92 
93  // Truck parking spot entity ref
94  WeakEntityPtr mParkingTarget;
95  };
96 
97  typedef std::vector<ConvoyTruck> ConvoyTruckList;
98 
99  enum TerroristZoneState
100  {
101  TerroristZoneState_Blocked,
102  TerroristZoneState_SemiBlocked,
103  TerroristZoneState_Open
104  };
105 
106 
107  //[-------------------------------------------------------]
108  //[ Public definitions ]
109  //[-------------------------------------------------------]
110  public:
111  static const uint32 FREEPLAY_EVENT_ID;
112 
113 
114  //[-------------------------------------------------------]
115  //[ Public methods ]
116  //[-------------------------------------------------------]
117  public:
122  MainEvent104();
123 
128  virtual ~MainEvent104();
129 
130 
131  //[-------------------------------------------------------]
132  //[ Public virtual em5::FreeplayEvent methods ]
133  //[-------------------------------------------------------]
134  public:
135  //[-------------------------------------------------------]
136  //[ Life cycle ]
137  //[-------------------------------------------------------]
138  virtual bool onStartup() override;
139  virtual void onShutdown() override;
140  virtual void onRun() override;
141  virtual bool onSuccess(EventResult& eventResult) override;
142  virtual bool onFailure(EventResult& eventResult) override;
143 
144  //[-------------------------------------------------------]
145  //[ Points evaluation ]
146  //[-------------------------------------------------------]
147  virtual uint32 calculatePointGain(EventResult& eventResult) override;
148 
149  //[-------------------------------------------------------]
150  //[ Callbacks from observers ]
151  //[-------------------------------------------------------]
152  virtual bool addEntityToEvent(qsf::Entity& targetEntity, eventspreadreason::Reason eventSpreadReason, bool newReason) override;
153  virtual void hintCallback(Observer& hintObserver) override;
154  virtual void hintCallbackWithMessage(Observer& hintObserver, const qsf::MessageParameters& parameters) override;
155 
156  //[-------------------------------------------------------]
157  //[ Miscellaneous ]
158  //[-------------------------------------------------------]
159  virtual const qsf::Entity* getFocusEntity() override;
160 
161  //[-------------------------------------------------------]
162  //[ Serialize ]
163  //[-------------------------------------------------------]
164  virtual void serialize(qsf::BinarySerializer& serializer) override;
165 
166 
167  //[-------------------------------------------------------]
168  //[ Protected virtual em5::MainEvent methods ]
169  //[-------------------------------------------------------]
170  protected:
171  virtual void onIntroStart(const qsf::MessageParameters& parameters) override;
172  virtual void onIntroFinished(const qsf::MessageParameters& parameters) override;
173  virtual void onPrologueFinished(const qsf::MessageParameters& parameters) override;
174 
175  //[-------------------------------------------------------]
176  //[ Regular update ]
177  //[-------------------------------------------------------]
178  virtual void onUpdateMainEvent(const qsf::Time& timePassed) override;
179 
180  virtual uint32 getEventNumber() override;
181  virtual std::string getCamStartEventTag() override;
182 
183 
184  //[-------------------------------------------------------]
185  //[ Private static methods ]
186  //[-------------------------------------------------------]
187  private:
188  static bool isInsideBox(const qsf::TransformComponent& boxTransform, const glm::vec3& position);
189 
190 
191  //[-------------------------------------------------------]
192  //[ Private methods ]
193  //[-------------------------------------------------------]
194  private:
195  void gatherEventEntities();
196 
197  void startObjectives();
198  void startHintObservers();
199 
200  void onTerrorbaseFound(const qsf::MessageParameters& messageParameters);
201 
202  void handleTerrorbaseFound();
203 
204  void openGate(DoorComponent& door);
205  void closeGate(DoorComponent& door);
206 
207  void onUnitMovementBlockedRequest(const qsf::MessageParameters& messageParameters);
208  void onSEKDroneInvalidTargetRequest(const qsf::MessageParameters& messageParameters);
209 
210  bool isEntityTerroristBaseTerrorist(const uint64 potentialTargetEntityId);
211 
212  bool isEntityInList(const WeakPtrEntityList& entities, const uint64 entityId) const;
213 
214  void onBombDefused(const qsf::MessageParameters& messageParameters);
215 
216  void handleBombDefused(const uint64 bombEntityId);
217 
218  void onDoorEboxRepaired(const qsf::MessageParameters& messageParameters);
219  void onAnythingRepaired(const qsf::MessageParameters& messageParameters);
220 
221  void onTruckRepaired(WeakEntityPtr &truck);
222 
223  void truckEntersCheeringZone();
224  void truckLeavesCheeringZone();
225  void checkCivilsCheeringCondition();
226 
227  void onObjectiveCompleted(const qsf::MessageParameters& messageParameters);
228 
229  void onObjectiveNeedTransportInjuredCompleted();
230 
231  void onAllInjuredPersonsAtBrandenburgerTorTransported();
232 
233  void onTerrorBaseRaidCompleted();
234 
235  void unlockYardGate();
236 
237  void setupTerrorist(const WeakEntityPtr& terrorist);
238 
239  void discoverSecondTrap();
240 
241  void setTrapVisibility(TrapBomb& trap, bool visible);
242  bool isTrapTriggerActivated(TrapBomb& trap);
243 
244  bool isAnySquadUnitInsideBox(const qsf::TransformComponent &triggerBoxTransform, bool excludeDefuseRobot = false, bool excludeVehicles = false) const;
245 
246  void activateTrapBomb(TrapBomb& trap);
247 
248  void onTrapBombDiscovered(TrapBomb &trap);
249 
250  void initializeTrap(TrapBomb& trap);
251  void defuseTrap(TrapBomb& trap);
252 
253  void setupGangstersHiddenInTerrorBaseBuilding();
254 
255  void debugDefuseTrap01();
256  void debugDefuseTrap02();
257  void debugRepairAllTrucks();
258 
259  void onGunShot(const qsf::MessageParameters& messageParameters);
260  void startTerroristBackup();
261 
262 
263  //[-------------------------------------------------------]
264  //[ Private data ]
265  //[-------------------------------------------------------]
266  private:
267  // Connected to CAMP
268  qsf::Time mME103Hint02WaitTime;
269  qsf::Time mGE01Hint02WaitTime;
270  qsf::Time mME104Hint02WaitTime;
271  qsf::Time mME103Hint02CooldownTime;
272  uint32 mME104Hint02TerroristCount;
273  float mTerroristAggroRange;
274  float mTerroristDeAggroRange;
275  float mTerroristChainPullRange;
276  float mTerroristFirearmAttackRange;
277  int mMaximumInjuredSquadMembers;
278  int mMaximumDeadPersons;
279 
280  // Internal
281  WeakPtrEntityList mInjured;
282  WeakPtrEntityList mCars;
283  WeakPtrEntityList mCarTrappedPersons;
284  WeakPtrEntityList mTerrorists;
285  WeakPtrEntityList mTerroristsOutside;
286  WeakPtrEntityList mTerroristBackup;
287  WeakPtrEntityList mCivilsCheering;
288  WeakPtrEntityList mGateDoors;
289 
290  WeakEntityPtr mTerrorDronetarget;
291  WeakEntityPtr mBlocking;
292  WeakEntityPtr mTerroristZone;
293  WeakEntityPtr mTerroristTrigger;
294  WeakEntityPtr mEbox;
295  WeakEntityPtr mTrap02TerrorbaseTrigger;
296  WeakEntityPtr mQuarantineMarker;
297  WeakEntityPtr mQuarantineTrigger;
298  WeakEntityPtr mQuarantineBlocking;
299  WeakEntityPtr mTerrorbase;
300 
301  TrapBomb mTrap01;
302  TrapBomb mTrap02;
303 
304  ConvoyTruckList mTrucks;
305 
306  int mNumTrucksRepaired;
307  bool mSecondTrapDiscovered;
308  bool mTerroristBackupArrived;
309  bool mTransportedAllInitiallyInjuredPersons;
310 
311  qsf::Time mME103Hint02Cooldown;
312 
313  // How many trucks are currently in the cheering zone, i.e. the civils should play the cheering animation while this is >0
314  int mNumberOfConvoyTrucksInCheeringZone;
315  TerroristZoneState mTerroristZoneState;
316 
317  qsf::MessageProxy mTerrorbaseFoundProxy;
318  qsf::MessageProxy mUnitMovementBlockedRequestProxy;
319  qsf::MessageProxy mSEKDroneInvalidTargetRequestProxy;
320  qsf::MessageProxy mBombDefusedProxy;
321  qsf::MessageProxy mDoorEboxRepairedProxy;
322  qsf::MessageProxy mObjectiveCompletedProxy;
323  qsf::MessageProxy mAnythingRepairedProxy;
324  qsf::MessageProxy mGunShotProxy;
325 
326  bool mTriggeredGE01_Hint02;
327  bool mTriggeredME103_Hint04;
328  bool mTriggeredME104_Hint02;
329  bool mTriggeredME104_Hint06;
330 
331 
332  //[-------------------------------------------------------]
333  //[ CAMP reflection system ]
334  //[-------------------------------------------------------]
335  QSF_CAMP_RTTI() // Only adds the virtual method "campClassId()", nothing more
336 
337 
338  };
339 
340 
341 //[-------------------------------------------------------]
342 //[ Namespace ]
343 //[-------------------------------------------------------]
344 } // em5
345 
346 
347 //[-------------------------------------------------------]
348 //[ CAMP reflection system ]
349 //[-------------------------------------------------------]
virtual bool addEntityToEvent(qsf::Entity &targetEntity, eventspreadreason::Reason eventSpreadReason, bool newReason) override
React to adding to an entity to this event, i.e. setting the event ID for the entity.
Definition: ActionPriority.h:13
EMERGENCY 5 observer base class.
Definition: Observer.h:41
Definition: FreeplayEvent.h:110
Entity class.
Definition: Entity.h:46
Message parameters class.
Definition: MessageParameters.h:34
virtual void onUpdateMainEvent(const qsf::Time &timePassed) override
Gets called when the main event gets an update call We use here a separate update method...
EMERGENCY 5 main event base class.
Definition: MainEvent.h:48
virtual bool onSuccess(EventResult &eventResult) override
React to state change from running state to success state.
virtual uint32 getEventNumber() override
Gets number of the main event (Is needed for the highscore management)
unsigned int uint32
Definition: PlatformTypes.h:181
Transform component class.
Definition: TransformComponent.h:33
virtual bool onStartup() override
React to startup of the freeplay event.
virtual const qsf::Entity * getFocusEntity() override
Get an event entity that is currently crucial for this event This is the entity which gets the focus ...
virtual void hintCallback(Observer &hintObserver) override
Handle the activation of a hint observer.
Message listener proxy class.
Definition: MessageProxy.h:47
Reason
Definition: EventSpreadReason.h:20
virtual bool onFailure(EventResult &eventResult) override
React to state change from running state to failed state.
uint64_t uint64
Definition: PlatformTypes.h:184
virtual uint32 calculatePointGain(EventResult &eventResult) override
Calculate the point gain for this event.
MainEvent104()
Default constructor.
virtual void onIntroFinished(const qsf::MessageParameters &parameters) override
React to the end of the intro; note that the prologue cutscene is played next.
#define QSF_CAMP_RTTI()
Only adds the virtual method "campClassId()", nothing more.
Definition: CampClass.h:75
virtual void onShutdown() override
React to shutdown of the freeplay event.
virtual void hintCallbackWithMessage(Observer &hintObserver, const qsf::MessageParameters &parameters) override
#define QSF_CAMP_TYPE_NONCOPYABLE(type)
See "CAMP_TYPE_NONCOPYABLE" for details.
Definition: CampClass.h:112
virtual void onIntroStart(const qsf::MessageParameters &parameters) override
React to the activation of the black screen, which is the start of the intro cutscene.
virtual ~MainEvent104()
Destructor.
static const uint32 FREEPLAY_EVENT_ID
"em5::MainEvent104" unique freeplay event ID
Definition: MainEvent104.h:111
virtual std::string getCamStartEventTag() override
Return event tag of a start camera for the event; only necessary for main events without prologue cut...
EMERGENCY 5 door component class.
Definition: DoorComponent.h:41
Static CAMP main event plugin metaclass collection class.
Definition: MainEventMetaclasses.h:30
virtual void onRun() override
React to state change from (initial) hidden state to running state.
Binary serializer class.
Definition: BinarySerializer.h:35
EMERGENCY 5 main event 15 "Assassination".
Definition: MainEvent104.h:42
virtual void onPrologueFinished(const qsf::MessageParameters &parameters) override
React to the end of the prologue.
virtual void serialize(qsf::BinarySerializer &serializer) override
Serialization using a binary serializer.
Data type for encapsulating time information. It might represents points in time and time spans...
Definition: Time.h:32