Emergency 20 Dokumentation  4.2.0
MainEvent01.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 
16 //[-------------------------------------------------------]
17 //[ Forward declarations ]
18 //[-------------------------------------------------------]
19 namespace em5
20 {
21  class MainEvent01KerosinePuddle;
22  class ObjectiveHelper;
23 }
24 namespace qsf
25 {
26  class ParticlesComponent;
27 }
28 
29 
30 //[-------------------------------------------------------]
31 //[ Namespace ]
32 //[-------------------------------------------------------]
33 namespace em5
34 {
35 
36 
37  //[-------------------------------------------------------]
38  //[ Classes ]
39  //[-------------------------------------------------------]
44  class MainEvent01 : public MainEvent
45  {
46 
47 
48  //[-------------------------------------------------------]
49  //[ Friends ]
50  //[-------------------------------------------------------]
51  friend class MainEventMetaclasses; // CAMP export of editable values for Game Design
52  friend class MainEvent01DebugGui;
53 
54 
55  //[-------------------------------------------------------]
56  //[ Public definitions ]
57  //[-------------------------------------------------------]
58  public:
59  static const uint32 FREEPLAY_EVENT_ID;
60 
61 
62  //[-------------------------------------------------------]
63  //[ Public methods ]
64  //[-------------------------------------------------------]
65  public:
70  MainEvent01();
71 
76  virtual ~MainEvent01();
77 
78 
79  //[-------------------------------------------------------]
80  //[ Public virtual em5::FreeplayEvent methods ]
81  //[-------------------------------------------------------]
82  public:
83  //[-------------------------------------------------------]
84  //[ Lifecycle ]
85  //[-------------------------------------------------------]
86  virtual bool onStartup() override;
87  virtual void onShutdown() override;
88  virtual void onRun() override;
89  virtual bool onSuccess(EventResult& eventResult) override;
90  virtual bool onFailure(EventResult& eventResult) override;
91 
92  //[-------------------------------------------------------]
93  //[ Points evaluation ]
94  //[-------------------------------------------------------]
95  virtual uint32 calculatePointGain(EventResult& eventResult) override;
96 
97  //[-------------------------------------------------------]
98  //[ Callbacks from observers ]
99  //[-------------------------------------------------------]
100  virtual bool addEntityToEvent(qsf::Entity& targetEntity, eventspreadreason::Reason eventSpreadReason, bool newReason) override;
101  virtual void hintCallback(Observer& hintObserver) override;
102 
103  //[-------------------------------------------------------]
104  //[ Miscellaneous ]
105  //[-------------------------------------------------------]
106  virtual const qsf::Entity* getFocusEntity() override;
107 
108  //[-------------------------------------------------------]
109  //[ Serialize ]
110  //[-------------------------------------------------------]
111  virtual void serialize(qsf::BinarySerializer& serializer) override;
112 
113 
114  //[-------------------------------------------------------]
115  //[ Protected virtual em5::MainEvent methods ]
116  //[-------------------------------------------------------]
117  protected:
118  virtual void onIntroStart(const qsf::MessageParameters& parameters) override;
119  virtual void onIntroFinished(const qsf::MessageParameters& parameters) override;
120  virtual void onPrologueFinished(const qsf::MessageParameters& parameters) override;
121 
122  //[-------------------------------------------------------]
123  //[ Regular update ]
124  //[-------------------------------------------------------]
125  virtual void onUpdateMainEvent(const qsf::Time& timePassed) override;
126  virtual void onUpdateMusic(const qsf::Time& timePassed) override;
127 
128  virtual uint32 getEventNumber() override;
129  virtual void showSupervisorMessageForFinalEvaluation(uint32 pointGain) override;
130 
131 
132  //[-------------------------------------------------------]
133  //[ Private definitions ]
134  //[-------------------------------------------------------]
135  private:
136  enum class WAIT_STATES
137  {
138  NONE,
141  };
142 
143 
144  //[-------------------------------------------------------]
145  //[ Private methods ]
146  //[-------------------------------------------------------]
147  private:
148  void gatherEventEntities();
149 
150  void startObjectives();
151  void startHintObservers();
152  void startAchievementObserver();
153 
158  void checkForShowSparks(const qsf::Time& timePassed);
159 
164  void setupSparksTimeout();
165 
170  void onDriverRescue(const qsf::MessageParameters& parameters);
171 
176  void startFire(const qsf::MessageParameters& parameters);
177 
182  void fireCutsceneFinished(const qsf::MessageParameters& parameters);
183 
191  void kerosineStopBurning(const qsf::MessageParameters& parameters);
192 
197  void startTruckExplosion();
198 
203  void onExplosionCutsceneEnded(const qsf::MessageParameters& parameters);
204 
209  void createSaveTruckerObjective(qsf::Entity& trucker);
210 
215  void createTreatTruckerObjective(qsf::Entity& trucker);
216 
221  void addPassengerToObjective(qsf::Entity& passenger);
222 
227  bool addOtherInjuredPersonsToObjective(qsf::Entity& person);
228 
233  void onAchievementMessage(const qsf::MessageParameters& parameters);
234 
239  void onMouseRightClickMessage(const qsf::MessageParameters& parameters);
240 
241  void checkObjectivesForSubervisorMessages(const qsf::MessageParameters& parameters);
242 
247  bool anyEmptyRTWsOnMap();
248 
249  bool hasCameraStoppedAutomaticMovement();
250 
255  void onShowHint18(const qsf::MessageParameters& parameters);
256 
261  void onShowHint28(const qsf::MessageParameters& parameters);
262 
267  void checkForFailedConditionOfInjuredSquad(qsf::Entity& injuredSquadEntity, const ObjectiveHelper& objectiveHelper);
268 
269  //[-------------------------------------------------------]
270  //[ Music ]
271  //[-------------------------------------------------------]
272  void musicStart();
273  void musicSuccess();
274  void musicFail();
275  void musicStartKerosinFire();
276  void musicStartLevel2();
277  void musicStartLevel3();
278  void musicStartActionShort();
279 
280 
281  //[-------------------------------------------------------]
282  //[ Private data ]
283  //[-------------------------------------------------------]
284  private:
285  // Connected to CAMP
286  qsf::Time mHint01WaitTime; // 30 sec.
287  qsf::Time mHint02WaitTime; // 60 sec.
288 
289  qsf::Time mHint04WaitTime; // 30 sec.
290  float mHint05LifeEnergy; // 35%
291  float mHint06LifeEnergy; // 10%
292  qsf::Time mHint07WaitTime; // 90 sec.
293  qsf::Time mHint08WaitTime; // 20 sec.
294  float mHint09LifeEnergy; // 25%
295  qsf::Time mHint10WaitTime; // 30 sec.
296 
297  qsf::Time mHint12WaitTime; // 20 sec.
298  qsf::Time mHint13WaitTime; // 35 sec.
299  qsf::Time mHint14WaitTime; // 60 sec.
300  qsf::Time mHint15WaitTime; // 90 sec.
301 
302  float mHint17DamageEnergy; // 25% Rest life (=> 75% damaged)
303 
304  qsf::Time mHint18WaitTime; // 180 sec.
305 
306  qsf::Time mHint26WaitTime; // 15 sec.
307  qsf::Time mHint27WaitTime; // 20 sec.
308 
309  qsf::Time mHint18DelayWaitTime; // 10 sec.
310  qsf::Time mHint28DelayWaitTime; // 25 sec.
311  glm::vec2 mDayTimeAfterEnd;
312 
313  // Internal
314  qsf::MessageProxy mKeroisePuddleStopBurningMessageProxy;
315  qsf::MessageProxy mAchievementMessageProxy;
316  qsf::MessageProxy mHint23MessageProxy;
317  qsf::MessageProxy mObjectiveChangedMessageProxy;
318  qsf::Entity* mTruck;
319  qsf::Entity* mTrucker;
320  std::vector<qsf::Entity*> mPassengers;
321  qsf::Entity* mKerosine;
322  MainEvent01KerosinePuddle* mKerosinePuddle;
323  qsf::Time mTimeForNextSparks;
324  std::vector<qsf::ParticlesComponent*> mSparkParticles;
325 
326  bool mObjective05Succeeded;
327 
328  qsf::Time mAchievementTimeout;
329  WAIT_STATES mCurrentWaitState;
330  bool mStartedTruckExplosionCutscene;
331  uint32 mObserverIdForHint18_CivilianGetsHeatEnergy;
332 
333  qsf::MessageProxy mDelayHint18ShowingTimerMessageProxy;
334  qsf::MessageProxy mDelayHint28ShowingTimerMessageProxy;
335 
336  // Music
337  bool mIsHealthLowForTheMusic;
338 
339  // Ending
340  bool mPlayingWinFadeOut;
341 
342  boost::container::flat_set<uint32> mAlreadyPlayedObjectiveSupervisorMessages;
343 
344 
345  //[-------------------------------------------------------]
346  //[ CAMP reflection system ]
347  //[-------------------------------------------------------]
348  QSF_CAMP_RTTI() // Only adds the virtual method "campClassId()", nothing more
349 
350 
351  };
352 
353 
354 //[-------------------------------------------------------]
355 //[ Namespace ]
356 //[-------------------------------------------------------]
357 } // em5
358 
359 
360 //[-------------------------------------------------------]
361 //[ CAMP reflection system ]
362 //[-------------------------------------------------------]
Definition: ActionPriority.h:13
EMERGENCY 5 observer base class.
Definition: Observer.h:41
Definition: FreeplayEvent.h:110
Entity class.
Definition: Entity.h:46
Wait mode until the camera reaches a position which shows the kerosene puddle, which starts burning...
virtual void showSupervisorMessageForFinalEvaluation(uint32 pointGain) override
Shows a supervisor message when the event ends.
Message parameters class.
Definition: MessageParameters.h:34
virtual void onUpdateMusic(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 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.
unsigned int uint32
Definition: PlatformTypes.h:181
MainEvent01()
Default constructor.
EMERGENCY 5 main event 01 growing kerosine puddle.
Definition: MainEvent01KerosinePuddle.h:40
Message listener proxy class.
Definition: MessageProxy.h:47
Reason
Definition: EventSpreadReason.h:20
virtual void onShutdown() override
React to shutdown of the freeplay event.
virtual void hintCallback(Observer &hintObserver) override
Handle the activation of a hint observer.
virtual bool onFailure(EventResult &eventResult) override
React to state change from running state to failed state.
virtual ~MainEvent01()
Destructor.
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 ...
Definition: PickupPersonByParamedicAction.h:21
EMERGENCY 5 main event 01 "Munich tram accident".
Definition: MainEvent01.h:44
EMERGENCY 5 objective helper class.
Definition: ObjectiveHelper.h:43
virtual void serialize(qsf::BinarySerializer &serializer) override
Serialization using a binary serializer.
#define QSF_CAMP_RTTI()
Only adds the virtual method "campClassId()", nothing more.
Definition: CampClass.h:75
virtual void onRun() override
React to state change from (initial) hidden state to running state.
static const uint32 FREEPLAY_EVENT_ID
"em5::MainEvent01" unique freeplay event ID
Definition: MainEvent01.h:59
#define QSF_CAMP_TYPE_NONCOPYABLE(type)
See "CAMP_TYPE_NONCOPYABLE" for details.
Definition: CampClass.h:112
friend class MainEvent01DebugGui
Definition: MainEvent01.h:52
virtual bool onSuccess(EventResult &eventResult) override
React to state change from running state to success state.
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...
virtual void onPrologueFinished(const qsf::MessageParameters &parameters) override
React to the end of the prologue.
virtual bool onStartup() override
React to startup of the freeplay event.
Static CAMP main event plugin metaclass collection class.
Definition: MainEventMetaclasses.h:30
Binary serializer class.
Definition: BinarySerializer.h:35
virtual uint32 calculatePointGain(EventResult &eventResult) override
Calculate the point gain for this event.
virtual void onIntroStart(const qsf::MessageParameters &parameters) override
React to the activation of the black screen, which is the start of the intro cutscene.
Wait mode until the camera reaches a position which shows the truck, which starts exploding...
virtual void onIntroFinished(const qsf::MessageParameters &parameters) override
React to the end of the intro; note that the prologue cutscene is played next.
virtual uint32 getEventNumber() override
Gets number of the main event (Is needed for the highscore management)
Data type for encapsulating time information. It might represents points in time and time spans...
Definition: Time.h:32