Emergency 20 Dokumentation  4.2.0
MainEvent100.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 #include <qsf/math/Transform.h>
18 
19 
20 //[-------------------------------------------------------]
21 //[ Forward declarations ]
22 //[-------------------------------------------------------]
23 namespace em5
24 {
25  class MedievalPreludeScreen;
26  class OrderInfo;
27  class Player;
28 }
29 
30 
31 //[-------------------------------------------------------]
32 //[ Namespace ]
33 //[-------------------------------------------------------]
34 namespace em5
35 {
36 
37 
38  //[-------------------------------------------------------]
39  //[ Classes ]
40  //[-------------------------------------------------------]
45  class MainEvent100 : public MainEvent
46  {
47 
48 
49  //[-------------------------------------------------------]
50  //[ Friends ]
51  //[-------------------------------------------------------]
52  friend class MainEventMetaclasses; // CAMP export of editable values for Game Design
53 
54 
55  //[-------------------------------------------------------]
56  //[ Public definitions ]
57  //[-------------------------------------------------------]
58  public:
59  static const uint32 FREEPLAY_EVENT_ID;
60 
61 
62  //[-------------------------------------------------------]
63  //[ Public static methods ]
64  //[-------------------------------------------------------]
65  public:
66  static void setMedievalGraphics(bool medievalMode, int gameSessionConfiguration = 1);
67 
68 
69  //[-------------------------------------------------------]
70  //[ Public methods ]
71  //[-------------------------------------------------------]
72  public:
77  MainEvent100();
78 
83  virtual ~MainEvent100();
84 
85 
86  //[-------------------------------------------------------]
87  //[ Public virtual em5::FreeplayEvent methods ]
88  //[-------------------------------------------------------]
89  public:
90  //[-------------------------------------------------------]
91  //[ Life cycle ]
92  //[-------------------------------------------------------]
93  virtual bool onStartup() override;
94  virtual void onShutdown() override;
95  virtual void onRun() override;
96  virtual bool onSuccess(EventResult& eventResult) override;
97  virtual bool onFailure(EventResult& eventResult) override;
98 
99  //[-------------------------------------------------------]
100  //[ Points evaluation ]
101  //[-------------------------------------------------------]
102  virtual uint32 calculatePointGain(EventResult& eventResult) override;
103 
104  //[-------------------------------------------------------]
105  //[ Callbacks from observers ]
106  //[-------------------------------------------------------]
107  virtual bool addEntityToEvent(qsf::Entity& targetEntity, eventspreadreason::Reason eventSpreadReason, bool newReason) override;
108  virtual void hintCallback(Observer& hintObserver) override;
109 
110  //[-------------------------------------------------------]
111  //[ Miscellaneous ]
112  //[-------------------------------------------------------]
113  virtual const qsf::Entity* getFocusEntity() override;
114 
115  //[-------------------------------------------------------]
116  //[ Serialize ]
117  //[-------------------------------------------------------]
118  virtual void serialize(qsf::BinarySerializer& serializer) override;
119 
120 
121  //[-------------------------------------------------------]
122  //[ Protected virtual em5::MainEvent methods ]
123  //[-------------------------------------------------------]
124  protected:
125  virtual void onStartIntroRequest() override;
126  virtual void onIntroStart(const qsf::MessageParameters& parameters) override;
127  virtual void onIntroFinished(const qsf::MessageParameters& parameters) override;
128  virtual void onUpdateMainEvent(const qsf::Time& timePassed) override;
129  virtual void onPrologueFinished(const qsf::MessageParameters& parameters) override;
130  virtual void onUpdateMusic(const qsf::Time& timePassed) override;
131  virtual uint32 getEventNumber() override;
132  virtual std::string getCamStartEventTag() override;
133  virtual void showBriefingSupervisorMessage() override;
134 
135 
136  //[-------------------------------------------------------]
137  //[ Private methods ]
138  //[-------------------------------------------------------]
139  private:
140  void blockInput(bool block);
141  void onMedievalPreludeScreenPlaybackFinished();
142 
147  void introFinished(const qsf::MessageParameters& parameters);
148 
149  void gatherEventEntities();
150 
151  void registerPlagueDoctorForPlayer();
152  void registerSpawnMechanic();
153  void deregisterSpawnMechanic();
154 
155  void addPlaguePersonToEvent(qsf::Entity& plaguePerson);
156  void addPlagueBuildingToEvent(qsf::Entity& plagueBuilding);
157 
158  void despawnPlagueDoctor();
159  void setupPlagueDoctor(qsf::Entity& entity, OrderInfo& plagueDoctorOrderInfo, Player& localPlayer);
160  void updatePlagueDoctorEvasion();
161 
162  void startPhase1();
163  void startBoatCutscene();
164  void startPhase2();
165  void winall(); // Debug
166 
167  void onUpdateInfoScreen(const qsf::JobArguments& jobArguments);
168  void fadeoutComplete(const qsf::MessageParameters& parameters);
169 
170 
171  //[-------------------------------------------------------]
172  //[ Private data ]
173  //[-------------------------------------------------------]
174  private:
175  // Hint values
176  qsf::Time mHint08WaitTime;
177  qsf::Time mHint09WaitTime;
178  qsf::Time mHintTabWaitTime;
179  bool mCanStartHint08;
180  bool mCanStartHint09;
181  bool mCanStartHintTab;
182 
183  qsf::Time mTimeGroupStarts1;
184  qsf::Time mTimeGroupStarts2;
185  // Internal data
186  MedievalPreludeScreen* mMedievalPreludeScreen;
187  qsf::WeakPtr<qsf::Entity> mDespawnHarbour;
188  qsf::WeakPtr<qsf::Entity> mDespawnTriggerHarbour;
189  qsf::WeakPtr<qsf::Entity> mHarbourMark;
190  qsf::Time mTimeWaitTillStart;
191  qsf::Time mPhase1TimeOut;
192 
193  struct UnitPosition
194  {
196  qsf::Transform mStartTransform;
197  bool mKeepInPhase2;
198  };
199  std::vector<UnitPosition> mUnitPositions;
200 
201  // Trigger the groupstart in phase2 only once
202  qsf::Time mPhase1Active;
203  qsf::Time mPhase2Active;
204  bool mCanGroupStart1;
205  bool mCanGroupStart2;
206 
207  enum State
208  {
209  State_Intro,
210  State_SelectDoctor,
211  State_OpenInfoScreen,
212  State_CloseInfoScreen,
213  State_WaitTillStart,
214  State_Phase1,
215  State_BoatCutscene,
216  State_Phase2,
217  State_Wait_for_fadeout
218  };
219 
220  State mCurrentState;
221  qsf::JobProxy mRegisterOpenHelpWindowJobProxy; // Only active in specific gamestate
222 
223 
224  //[-------------------------------------------------------]
225  //[ CAMP reflection system ]
226  //[-------------------------------------------------------]
227  QSF_CAMP_RTTI() // Only adds the virtual method "campClassId()", nothing more
228 
229 
230  };
231 
232 
233 //[-------------------------------------------------------]
234 //[ Namespace ]
235 //[-------------------------------------------------------]
236 } // em5
237 
238 
239 //[-------------------------------------------------------]
240 //[ CAMP reflection system ]
241 //[-------------------------------------------------------]
virtual ~MainEvent100()
Destructor.
Definition: ActionPriority.h:13
EMERGENCY 5 observer base class.
Definition: Observer.h:41
Definition: FreeplayEvent.h:110
virtual void onStartIntroRequest() override
React to the intro start request; do only overwrite the default implementation if you really have to...
Job proxy class.
Definition: JobProxy.h:51
virtual void onShutdown() override
React to shutdown of the freeplay event.
Entity class.
Definition: Entity.h:46
Message parameters class.
Definition: MessageParameters.h:34
EMERGENCY 5 main event base class.
Definition: MainEvent.h:48
Order information.
Definition: OrderInfo.h:54
unsigned int uint32
Definition: PlatformTypes.h:181
Medieval prelude screen.
Definition: MedievalPreludeScreen.h:50
virtual void showBriefingSupervisorMessage() override
Shows the briefing supervisor message for the event.
virtual void onIntroFinished(const qsf::MessageParameters &parameters) override
React to the end of the intro; note that the prologue cutscene is played next.
virtual void onRun() override
React to state change from (initial) hidden state to running state.
EMERGENCY 2016 main event 100 "Medieval Cologne".
Definition: MainEvent100.h:45
static const uint32 FREEPLAY_EVENT_ID
"em5::MainEvent100" unique freeplay event ID
Definition: MainEvent100.h:59
Reason
Definition: EventSpreadReason.h:20
virtual bool onFailure(EventResult &eventResult) override
React to state change from running state to failed state.
EMERGENCY 5 player class.
Definition: Player.h:57
Job arguments class: holds data to be passed to the called job method by the job manager.
Definition: JobArguments.h:40
virtual bool onSuccess(EventResult &eventResult) override
React to state change from running state to success state.
3D transform class
Definition: Transform.h:45
MainEvent100()
Default constructor.
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...
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.
virtual void hintCallback(Observer &hintObserver) override
Handle the activation of a hint observer.
#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...
#define QSF_CAMP_TYPE_NONCOPYABLE(type)
See "CAMP_TYPE_NONCOPYABLE" for details.
Definition: CampClass.h:112
virtual std::string getCamStartEventTag() override
Return event tag of a start camera for the event; only necessary for main events without prologue cut...
static void setMedievalGraphics(bool medievalMode, int gameSessionConfiguration=1)
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 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 serialize(qsf::BinarySerializer &serializer) override
Serialization using a binary serializer.
virtual void onIntroStart(const qsf::MessageParameters &parameters) override
React to the activation of the black screen, which is the start of the intro cutscene.
Static CAMP main event plugin metaclass collection class.
Definition: MainEventMetaclasses.h:30
Binary serializer class.
Definition: BinarySerializer.h:35
virtual uint32 getEventNumber() override
Gets number of the main event (Is needed for the highscore management)
virtual uint32 calculatePointGain(EventResult &eventResult) override
Calculate the point gain for this event.
Data type for encapsulating time information. It might represents points in time and time spans...
Definition: Time.h:32