Emergency 20 Dokumentation  4.2.0
MainEvent.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/base/WeakPtr.h>
19 
20 
21 //[-------------------------------------------------------]
22 //[ Forward declarations ]
23 //[-------------------------------------------------------]
24 namespace em5
25 {
26  class GameComponent;
27  class CutscenePlayer;
28 }
29 
30 
31 //[-------------------------------------------------------]
32 //[ Namespace ]
33 //[-------------------------------------------------------]
34 namespace em5
35 {
36 
37 
38  //[-------------------------------------------------------]
39  //[ Classes ]
40  //[-------------------------------------------------------]
49  {
50 
51 
52  //[-------------------------------------------------------]
53  //[ Friends ]
54  //[-------------------------------------------------------]
55  friend class MainEventMetaclasses; // CAMP export of editable values for Game Design
56 
57 
58  //[-------------------------------------------------------]
59  //[ Public definitions ]
60  //[-------------------------------------------------------]
61  public:
62  static const std::string SEQUENCE_FADEOUT; // "sequence_fadeout"
63 
64 
65  //[-------------------------------------------------------]
66  //[ Public methods ]
67  //[-------------------------------------------------------]
68  public:
73  MainEvent(const std::string& eraseLayerName, const std::string& settingLayerName, const std::string& eventLayerName, const std::string& introCutsceneLayerName, const std::string& sceneTag,
74  const std::string& introSequence, const std::string& prologueSequence);
75 
80  virtual ~MainEvent();
81 
86  void onFinishScreenClosed();
87 
88 
89  //[-------------------------------------------------------]
90  //[ Public virtual em5::FreeplayEvent methods ]
91  //[-------------------------------------------------------]
92  public:
93  virtual bool onStartup() override;
94  virtual void onShutdown() override;
95  virtual bool onSuccess(EventResult& eventResult) override;
96  virtual bool onFailure(EventResult& eventResult) override;
97  virtual uint32 calculatePointGain(EventResult& eventResult) override;
98  virtual void updateFreeplayEvent(const qsf::Time& timePassed) override;
99  virtual bool checkEventConfiguration() override;
100  virtual void serialize(qsf::BinarySerializer& serializer) override;
101 
102 
103  //[-------------------------------------------------------]
104  //[ Protected virtual em5::MainEvent methods ]
105  //[-------------------------------------------------------]
106  protected:
111  virtual void onStartIntroRequest();
112 
117  virtual inline void onIntroStart(const qsf::MessageParameters& parameters);
118 
123  virtual inline void onIntroFinished(const qsf::MessageParameters& parameters);
124 
129  virtual inline void onPrologueFinished(const qsf::MessageParameters& parameters);
130 
137  virtual void onUpdateMainEvent(const qsf::Time& timePassed);
138 
144  virtual void onUpdateMusic(const qsf::Time& timePassed);
145 
150  virtual uint32 getEventNumber() = 0;
151 
156  virtual std::string getCamStartEventTag();
157 
162  virtual void showBriefingSupervisorMessage();
163 
168  virtual void showSupervisorMessageForFinalEvaluation(uint32 pointGain);
169 
170 
171  //[-------------------------------------------------------]
172  //[ Protected methods ]
173  //[-------------------------------------------------------]
174  protected:
175  //[-------------------------------------------------------]
176  //[ Layers ]
177  //[-------------------------------------------------------]
182  void activateLayer(const std::string& activate, bool showError = true);
183 
188  void deactivateLayer(const std::string& deactivate, bool showError = true, bool saveEntities = false);
189 
194  inline const std::string& getEventLayerName() const;
195 
200  inline const std::string& getEraseLayerName() const;
201 
206  inline const std::string& getCutsceneLayerName() const;
207 
208  //[-------------------------------------------------------]
209  //[ Game simulation ]
210  //[-------------------------------------------------------]
215  void setPlayerControl(bool playerControl) const;
216 
221  void setGameSimulation(bool gameSimulation) const;
222 
227  void setCivilistSpawn(bool spawnEnabled) const;
228 
233  void setAiSimulation(bool aiSimulation) const;
234 
235  //[-------------------------------------------------------]
236  //[ Scene ]
237  //[-------------------------------------------------------]
242  inline qsf::Entity& getScene() const;
243 
248  void setStartDayTimeAndWeather();
249 
250  //[-------------------------------------------------------]
251  //[ Point gain ]
252  //[-------------------------------------------------------]
260  uint32 addObjectiveValue(const qsf::StringHash& objectiveId, EventResult& eventResult, uint32 pointValue) const;
261 
269  uint32 addObjectiveValue(const Objective* objective, EventResult& eventResult, uint32 pointValue) const;
270 
275  uint32 getEfficiencyPointValue() const;
276 
277  //[-------------------------------------------------------]
278  //[ Cutscene ]
279  //[-------------------------------------------------------]
284  void startIntro(bool forceNoFadeOut = false);
285 
290  CutscenePlayer& getCutscenePlayer() const;
291 
296  void flyCameraTo(qsf::Entity& targetCameraEntity, float maximumAcceleration = 100.0f, float maximumSpeed = 25.0f);
297 
298  //[-------------------------------------------------------]
299  //[ Lifecycle ]
300  //[-------------------------------------------------------]
310  void setMainEventFinished(bool successful, bool showFailedReason = true);
311 
312  //[-------------------------------------------------------]
313  //[ Music ]
314  //[-------------------------------------------------------]
315  bool isNumberOfBurningObjectsBelowX(uint32 number);
316  bool personsWithHealthBelowXPercent(float health);
317  bool isEntityGettingHeatDamage(const qsf::Entity& entity) const;
318  bool isObjectiveAccomplished(uint32 typeId);
319  void setCurrentTime(const glm::vec2& currentTime);
320 
321  //[-------------------------------------------------------]
322  //[ Achievement ]
323  //[-------------------------------------------------------]
324  void triggerCampaignHeroAchievement() const;
325 
326 
327  //[-------------------------------------------------------]
328  //[ Private methods ]
329  //[-------------------------------------------------------]
330  private:
331  //[-------------------------------------------------------]
332  //[ Life cycle ]
333  //[-------------------------------------------------------]
338  void introStarted(const qsf::MessageParameters& parameters);
339 
344  void introFinished(const qsf::MessageParameters& parameters);
345 
350  void prologueFinished(const qsf::MessageParameters& parameters);
351 
356  void cleanup();
357 
358 
359  //[-------------------------------------------------------]
360  //[ Protected data ]
361  //[-------------------------------------------------------]
362  protected:
363  // Connected to CAMP
370 
371  // Internal
373 
374 
375  //[-------------------------------------------------------]
376  //[ Private data ]
377  //[-------------------------------------------------------]
378  private:
379  // Connected to CAMP
380  glm::vec2 mStartDayTime;
381  std::string mStartWeather;
382  float mTimeOfDaySpeed;
383 
384  // Internal
385  const std::string mEventLayerName;
386  const std::string mEraseLayerName;
387  const std::string mSceneryLayerName;
388  const std::string mIntroCutsceneLayerName;
389  const std::string mIntroSequence;
390  const std::string mPrologueSequence;
391 
392  qsf::Entity* mScene;
393  GameComponent* mGameComponent;
394  bool mShowFailedReason;
395  qsf::Time mShowFailedWindowWaitTime;
396 
397  float mTimeOfDayOriginalDaySpeedFactor;
398  float mTimeOfDayOriginalNightSpeedFactor;
399 
400 
401  //[-------------------------------------------------------]
402  //[ CAMP reflection system ]
403  //[-------------------------------------------------------]
404  QSF_CAMP_RTTI() // Only adds the virtual method "campClassId()", nothing more
405 
406 
407  };
408 
409 
410 //[-------------------------------------------------------]
411 //[ Namespace ]
412 //[-------------------------------------------------------]
413 } // em5
414 
415 
416 //[-------------------------------------------------------]
417 //[ Implementation ]
418 //[-------------------------------------------------------]
420 
421 
422 //[-------------------------------------------------------]
423 //[ CAMP reflection system ]
424 //[-------------------------------------------------------]
Definition: ActionPriority.h:13
Definition: FreeplayEvent.h:110
Entity class.
Definition: Entity.h:46
Message parameters class.
Definition: MessageParameters.h:34
EMERGENCY 5 main event base class.
Definition: MainEvent.h:48
unsigned int uint32
Definition: PlatformTypes.h:181
#define EM5_API_EXPORT
Definition: Export.h:28
uint32 mMinEfficiencyPoints
Definition: MainEvent.h:364
Message listener proxy class.
Definition: MessageProxy.h:47
EMERGENCY 5 cutscene player.
Definition: CutscenePlayer.h:47
qsf::MessageProxy mLifeCycleMessageProxy
Listens to messages that affect the lifecycle.
Definition: MainEvent.h:372
void serialize(BinarySerializer &serializer, BitFlagSet< STORAGE, ENUM > &bitFlagSet)
Definition: BitFlagSet.h:359
EMERGENCY 5 objective class.
Definition: Objective.h:51
uint32 mNeededPointsForGold
Definition: MainEvent.h:368
static const std::string SEQUENCE_FADEOUT
Definition: MainEvent.h:62
#define QSF_CAMP_RTTI()
Only adds the virtual method "campClassId()", nothing more.
Definition: CampClass.h:75
EMERGENCY 5 game component class. Holds information for the map properties.
Definition: GameComponent.h:32
qsf::Time mMaxEfficiencyTime
Definition: MainEvent.h:367
#define QSF_CAMP_TYPE_NONCOPYABLE(type)
See "CAMP_TYPE_NONCOPYABLE" for details.
Definition: CampClass.h:112
uint32 mMaxEfficiencyPoints
Definition: MainEvent.h:365
uint32 mNeededPointsForSilver
Definition: MainEvent.h:369
Abstract EMERGENCY 5 freeplay event base class.
Definition: FreeplayEvent.h:66
Compile time string hash class.
Definition: StringHash.h:59
Static CAMP main event plugin metaclass collection class.
Definition: MainEventMetaclasses.h:30
Binary serializer class.
Definition: BinarySerializer.h:35
qsf::Time mMinEfficiencyTime
Definition: MainEvent.h:366
Data type for encapsulating time information. It might represents points in time and time spans...
Definition: Time.h:32