Emergency 20 Dokumentation  4.2.0
MainEvent201.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 //[-------------------------------------------------------]
15 
16 #include <qsf/job/JobProxy.h>
17 #include <qsf/base/WeakPtr.h>
18 
19 
20 //[-------------------------------------------------------]
21 //[ Namespace ]
22 //[-------------------------------------------------------]
23 namespace em5
24 {
25 
26 
27  //[-------------------------------------------------------]
28  //[ Classes ]
29  //[-------------------------------------------------------]
34  class MainEvent201 : public MainEvent
35  {
36 
37 
38  //[-------------------------------------------------------]
39  //[ Friends ]
40  //[-------------------------------------------------------]
41  friend class MainEventMetaclasses; // CAMP export of editable values for Game Design
42 
43 
44  //[-------------------------------------------------------]
45  //[ Public definitions ]
46  //[-------------------------------------------------------]
47  public:
48  static const uint32 FREEPLAY_EVENT_ID;
49 
51  {
56  };
57 
58 
59  //[-------------------------------------------------------]
60  //[ Public methods ]
61  //[-------------------------------------------------------]
62  public:
67  MainEvent201();
68 
73  virtual ~MainEvent201();
74 
75 
76  //[-------------------------------------------------------]
77  //[ Public virtual em5::FreeplayEvent methods ]
78  //[-------------------------------------------------------]
79  public:
80  //[-------------------------------------------------------]
81  //[ Life cycle ]
82  //[-------------------------------------------------------]
83  virtual bool onStartup() override;
84  virtual void onShutdown() override;
85  virtual void onRun() override;
86  virtual bool onSuccess(EventResult& eventResult) override;
87  virtual bool onFailure(EventResult& eventResult) override;
88 
89  //[-------------------------------------------------------]
90  //[ Points evaluation ]
91  //[-------------------------------------------------------]
92  virtual uint32 calculatePointGain(EventResult& eventResult) override;
93 
94  //[-------------------------------------------------------]
95  //[ Callbacks from observers ]
96  //[-------------------------------------------------------]
97  virtual bool addEntityToEvent(qsf::Entity& targetEntity, eventspreadreason::Reason eventSpreadReason, bool newReason) override;
98  virtual void hintCallback(Observer& hintObserver) override;
99  virtual void hintCallbackWithMessage(Observer& hintObserver, const qsf::MessageParameters& parameters) override;
100 
101  //[-------------------------------------------------------]
102  //[ Miscellaneous ]
103  //[-------------------------------------------------------]
104  virtual const qsf::Entity* getFocusEntity() override;
105 
106  //[-------------------------------------------------------]
107  //[ Serialize ]
108  //[-------------------------------------------------------]
109  virtual void serialize(qsf::BinarySerializer& serializer) override;
110 
111 
112  //[-------------------------------------------------------]
113  //[ Protected virtual em5::MainEvent methods ]
114  //[-------------------------------------------------------]
115  protected:
116  virtual void onIntroStart(const qsf::MessageParameters& parameters) override;
117  virtual void onIntroFinished(const qsf::MessageParameters& parameters) override;
118  virtual void onPrologueFinished(const qsf::MessageParameters& parameters) override;
119 
120  //[-------------------------------------------------------]
121  //[ Regular update ]
122  //[-------------------------------------------------------]
123  virtual void onUpdateMainEvent(const qsf::Time& timePassed) override;
124 
125  virtual uint32 getEventNumber() override;
126  virtual std::string getCamStartEventTag() override;
127 
128 
129  //[-------------------------------------------------------]
130  //[ Private methods ]
131  //[-------------------------------------------------------]
132  private:
133  EventPhase getEventPhase() const;
134  void setEventPhase(EventPhase phase);
135 
136  void initializePhase1();
137  void deinitializePhase1();
138 
139  void playPhase2IntroSequence();
140  void initializePhase2();
141  void deinitializePhase2();
142 
143  void updatePhase1();
144  void updatePhase2();
145  void updateDebugMenu();
146 
147  void gatherPhase1EventEntities();
148  void gatherPhase2EventEntities();
149  void startObjectives();
150  void startHintObservers();
151 
152  void createObjectiveFinishedObserver();
153 
154  void onPersonDied(const qsf::MessageParameters& parameters);
155 
156  //TODO(ca) Remove this once eventspreadreason::DAMAGE_VEHICLE works as intended
157  void onVehicleDamaged(const qsf::MessageParameters& parameters);
158 
159  void onPersonMagnetStopFollow(const qsf::MessageParameters& parameters);
160 
161  void onPhase2IntroSequenceFinished(const qsf::MessageParameters& parameters);
162 
163  void onTweet1TruckTrigger(const qsf::MessageParameters& parameters);
164  void onTweet1Trigger(const qsf::MessageParameters& parameters);
165 
166 
167  //[-------------------------------------------------------]
168  //[ Private data ]
169  //[-------------------------------------------------------]
170  private:
171  // Settings, connected to camp
172  std::string mGangsterLogic;
173  uint32 mMaxDeadCivilians;
174  uint32 mMaxDrownedCivilians;
175  uint32 mMaxInjuredUnits;
176  uint32 mMaxDamagedVehicles;
177  uint32 mMaxBurningObjects;
178  qsf::Time mNewsFeed1WaitTime;
179  qsf::Time mNewsFeed2WaitTime;
180  qsf::Time mGaperHintWaitTime;
181 
182  // Internal data
183  EventPhase mEventPhase;
184 
185  // - Units
186  std::vector<qsf::WeakPtr<qsf::Entity>> mUnitGaper;
187  std::vector<qsf::WeakPtr<qsf::Entity>> mUnitTruck;
188  std::vector<qsf::WeakPtr<qsf::Entity>> mUnitBurn;
189  std::vector<qsf::WeakPtr<qsf::Entity>> mUnitDrowning;
190  std::vector<qsf::WeakPtr<qsf::Entity>> mUnitInjured;
191  std::vector<qsf::WeakPtr<qsf::Entity>> mUnitInjuredShip;
192  std::vector<qsf::WeakPtr<qsf::Entity>> mUnitTerrorist;
193 
194  // - Areas
195  qsf::WeakPtr<qsf::Entity> mAreaGaperTargetArea;
196 
197  // - Marker
198  qsf::WeakPtr<qsf::Entity> mMarkerGaperTargetArea;
199 
200  // - Tweets
201  qsf::WeakPtr<qsf::Entity> mTweet1UnitGaper;
202  qsf::WeakPtr<qsf::Entity> mTweet1UnitTruck;
203 
204  // Message proxies
205  qsf::MessageProxy mPersonDiedMessageProxy;
206  qsf::MessageProxy mPersonMagnetPreStartFollowMessageProxy;
207  qsf::MessageProxy mPersonMagnetStopFollowMessageProxy;
208  qsf::MessageProxy mSequenceFinishedMessageProxy;
209  qsf::MessageProxy mTweetTriggerMessageProxy;
210  //TODO(ca) Remove this once eventspreadreason::DAMAGE_VEHICLE works as intended
211  qsf::MessageProxy mVehicleDamagedMessageProxy;
212 
213  // Tweet helpers
214  WarblerTweetHelper mTweet1;
215  WarblerTweetHelper mTweet2;
216 
217 
218  //[-------------------------------------------------------]
219  //[ CAMP reflection system ]
220  //[-------------------------------------------------------]
221  QSF_CAMP_RTTI() // Only adds the virtual method "campClassId()", nothing more
222 
223 
224  };
225 
226 
227 //[-------------------------------------------------------]
228 //[ Namespace ]
229 //[-------------------------------------------------------]
230 } // em5
231 
232 
233 //[-------------------------------------------------------]
234 //[ CAMP reflection system ]
235 //[-------------------------------------------------------]
Definition: ActionPriority.h:13
EMERGENCY 5 observer base class.
Definition: Observer.h:41
virtual void hintCallbackWithMessage(Observer &hintObserver, const qsf::MessageParameters &parameters) override
Entity class.
Definition: Entity.h:46
Message parameters class.
Definition: MessageParameters.h:34
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 bool onSuccess(EventResult &eventResult) override
React to state change from running state to success state.
virtual void serialize(qsf::BinarySerializer &serializer) override
Serialization using a binary serializer.
EMERGENCY 5 main event base class.
Definition: MainEvent.h:48
unsigned int uint32
Definition: PlatformTypes.h:181
EventPhase
Definition: MainEvent201.h:50
MainEvent201()
Default constructor.
virtual bool onFailure(EventResult &eventResult) override
React to state change from running state to failed state.
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.
virtual void onShutdown() override
React to shutdown of the freeplay event.
Message listener proxy class.
Definition: MessageProxy.h:47
Reason
Definition: EventSpreadReason.h:20
virtual void hintCallback(Observer &hintObserver) override
Handle the activation of a hint observer.
Definition: MainEvent201.h:55
static const uint32 FREEPLAY_EVENT_ID
"em5::MainEvent201" unique freeplay event ID
Definition: MainEvent201.h:48
virtual std::string getCamStartEventTag() override
Return event tag of a start camera for the event; only necessary for main events without prologue cut...
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 ...
Helper class for warbler tweets.
Definition: WarblerTweetHelper.h:41
#define QSF_CAMP_RTTI()
Only adds the virtual method "campClassId()", nothing more.
Definition: CampClass.h:75
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...
Definition: MainEvent201.h:53
#define QSF_CAMP_TYPE_NONCOPYABLE(type)
See "CAMP_TYPE_NONCOPYABLE" for details.
Definition: CampClass.h:112
Definition: MainEvent201.h:52
Definition: MainEvent201.h:54
virtual void onRun() override
React to state change from (initial) hidden state to running state.
virtual ~MainEvent201()
Destructor.
virtual void onPrologueFinished(const qsf::MessageParameters &parameters) override
React to the end of the prologue.
virtual void onIntroFinished(const qsf::MessageParameters &parameters) override
React to the end of the intro; note that the prologue cutscene is played next.
Static CAMP main event plugin metaclass collection class.
Definition: MainEventMetaclasses.h:30
virtual bool onStartup() override
React to startup of the freeplay event.
virtual uint32 getEventNumber() override
Gets number of the main event (Is needed for the highscore management)
Binary serializer class.
Definition: BinarySerializer.h:35
virtual uint32 calculatePointGain(EventResult &eventResult) override
Calculate the point gain for this event.
EMERGENCY 2017 main event 201 "Kreuzfahrschiff wird gekapert".
Definition: MainEvent201.h:34
Data type for encapsulating time information. It might represents points in time and time spans...
Definition: Time.h:32