Emergency 20 Dokumentation  4.2.0
Tutorial.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>
19 
20 #include <vector>
21 
22 
23 //[-------------------------------------------------------]
24 //[ Forward declarations ]
25 //[-------------------------------------------------------]
26 namespace em5
27 {
28  class GameComponent;
29  class TutorialStep;
30 }
31 namespace qsf
32 {
33  class Entity;
34  namespace game
35  {
36  class EventTagManagerComponent;
37  }
38 }
39 
40 
41 //[-------------------------------------------------------]
42 //[ Namespace ]
43 //[-------------------------------------------------------]
44 namespace em5
45 {
46 
47 
48  //[-------------------------------------------------------]
49  //[ Classes ]
50  //[-------------------------------------------------------]
55  class Tutorial : public FreeplayEvent
56  {
57 
58 
59  //[-------------------------------------------------------]
60  //[ Friends ]
61  //[-------------------------------------------------------]
62  friend class FreeplayEventMetaclasses2; // CAMP export of editable values for Game Design
63  friend class TutorialStepIntro; // To access the protected methods
64  friend class TutorialStep; // To access the protected methods
65  friend class TutorialStepStation1; // To access the protected methods
66  friend class TutorialStepStation2; // To access the protected methods
67  friend class TutorialStepStation3; // To access the protected methods
68  friend class TutorialStepOutro; // To access the protected methods
69 
70 
71  //[-------------------------------------------------------]
72  //[ Public definitions ]
73  //[-------------------------------------------------------]
74  public:
75  static const uint32 FREEPLAY_EVENT_ID;
76 
77 
78  //[-------------------------------------------------------]
79  //[ Public methods ]
80  //[-------------------------------------------------------]
81  public:
86  Tutorial();
87 
92  virtual ~Tutorial();
93 
94 
95  //[-------------------------------------------------------]
96  //[ Public virtual em5::FreeplayEvent methods ]
97  //[-------------------------------------------------------]
98  public:
99  //[-------------------------------------------------------]
100  //[ Lifecycle ]
101  //[-------------------------------------------------------]
102  virtual bool onStartup() override;
103  virtual void onShutdown() override;
104  virtual void onRun() override;
105  virtual bool checkEventConfiguration() override;
106 
107  //[-------------------------------------------------------]
108  //[ Points evaluation ]
109  //[-------------------------------------------------------]
110  virtual uint32 calculatePointGain(EventResult& eventResult) override;
111 
112  //[-------------------------------------------------------]
113  //[ Regular update ]
114  //[-------------------------------------------------------]
115  virtual void updateFreeplayEvent(const qsf::Time& timePassed) override;
116 
117  //[-------------------------------------------------------]
118  //[ Callbacks from observers ]
119  //[-------------------------------------------------------]
120  virtual bool addEntityToEvent(qsf::Entity& targetEntity, eventspreadreason::Reason eventSpreadReason, bool newReason) override;
121 
122  //[-------------------------------------------------------]
123  //[ Miscellaneous ]
124  //[-------------------------------------------------------]
125  virtual const qsf::Entity* getFocusEntity() override;
126 
127  //[-------------------------------------------------------]
128  //[ Serialize ]
129  //[-------------------------------------------------------]
130  virtual void serialize(qsf::BinarySerializer& serializer) override;
131 
132 
133  //[-------------------------------------------------------]
134  //[ Protected methods ]
135  //[-------------------------------------------------------]
136  protected:
137  //[-------------------------------------------------------]
138  //[ Game simulation ]
139  //[-------------------------------------------------------]
144  void setPlayerControl(bool playerControl) const;
145 
150  void setGameSimulation(bool gameSimulation) const;
151 
156  void setAiSimulation(bool aiSimulation) const;
157 
162  void setCivilianSpawn(bool civilianSpawn) const;
163 
164  //[-------------------------------------------------------]
165  //[ Layers ]
166  //[-------------------------------------------------------]
171  void activateLayer(const std::string& activate) const;
172 
177  void deactivateLayer(const std::string& deactivate, bool saveEntities = false) const;
178 
179 
180  //[-------------------------------------------------------]
181  //[ Private definitions ]
182  //[-------------------------------------------------------]
183  private:
184  typedef std::vector<std::unique_ptr<TutorialStep>> TutorialStepContainer;
185 
186  enum class HUD_BUTTON_ID
187  {
191  UNITTYPE_TEC,
196  UNIT_TEC_ASF,
206  };
207 
208 
209  //[-------------------------------------------------------]
210  //[ Private methods ]
211  //[-------------------------------------------------------]
212  private:
213  // Handler for the EM5_PRE_COMMAND_EXECUTE to deny for specific entities the move command
214  void onPreCommandExecuted(const qsf::MessageParameters& parameters);
215 
216  void setStartDayTimeAndWeather();
217  void enableCommandsInput(bool enable) const;
218  void enableGlobalInput(bool enable) const;
219  void enableZoomInput(bool enable) const;
220  void enableRotateInput(bool enable) const;
221  void enableSelectionInput(bool enable) const;
222  void enableMultiSelectionInput(bool enable) const;
223  void enableHighlightInteractionObjects(bool enable) const;
224  void enableMinimapInput(bool enable) const;
225  void enableLeftClickInput(bool enable) const;
226 
227  void enableUnitAutomatism(bool enable);
228 
229  void showMouseCursor(bool show) const;
230 
231  void showAllHudElements(bool show) const;
232  void showUnitTypeButtons(bool show) const;
233  void showMinimap(bool show) const;
234  void enableAllHudButtons(bool enable) const;
235  void disableAllBlinkingButtons() const;
236  bool isVehicleListHudWindowOpen(const qsf::Time& timePassed) const;
237  bool isVehicleOrderHudWindowOpen(const qsf::Time& timePassed) const;
238  void enableButton(const HUD_BUTTON_ID buttonId, bool enable) const;
239  void letHudButtonBlink(const HUD_BUTTON_ID buttonId, const bool blink) const;
240  void letObjectiveFlash(const qsf::StringHash& objectiveId) const;
241 
242  void letObjectiveFlashWhenNotCompleted(uint32 objectiveId) const;
243 
244  qsf::Entity* acquireTaggedEntity(const std::string& tag);
259  bool tryAcquireTaggedEntities(std::vector<qsf::Entity*>& outEntities, const std::string& tag, uint32 minimumNumberNeeded);
260 
261  void changeToNextStep();
262 
263  void addEntityToDeniedMoveList(const qsf::Entity& entity);
264  void removeEntityFromDeniedMoveList(const qsf::Entity& entity);
265 
266 
267  //[-------------------------------------------------------]
268  //[ Private data ]
269  //[-------------------------------------------------------]
270  private:
271  // Connected to CAMP
272  glm::vec2 mStartDayTime;
273  std::string mStartWeather;
274 
275  // Internal
276  qsf::game::EventTagManagerComponent* mEventTagManager;
277  GameComponent* mGameComponent;
278 
279  TutorialStepContainer mTutorialSteps;
280  TutorialStepContainer::iterator mCurrentTutorialStep;
281  glm::vec3 mOriginalMapBoundaryTopLeft;
282  glm::vec3 mOriginalMapBoundaryBottomRight;
283  std::vector<uint64> mEntitiesToDenyMoveCommand;
284  qsf::MessageProxy mDenyMoveCommandMessageProxy;
285 
286  // Spec settings for GD connected to CAMP
287  // General
288  // Intro
289  qsf::Time mIntroWaitTimeForSupervisor;
290  qsf::Time mIntroWaitTimeForIntroEnd;
291  // Station one
292  qsf::Time mHint01WaitTime;
293  qsf::Time mHint02WaitTime;
294  qsf::Time mHint03WaitTime;
295  qsf::Time mHint04WaitTime;
296  qsf::Time mHint05WaitTime;
297  qsf::Time mHint08WaitTime;
298  qsf::Time mSupervisor15WaitTime;
299  // Station two
300  qsf::Time mScrollSlowTime;
301  qsf::Time mScrollFastTime;
302  qsf::Time mHint12WaitTime;
303  qsf::Time mHint14WaitTime;
304  qsf::Time mHint15WaitTime;
305  qsf::Time mHint16WaitTime;
306  qsf::Time mHint17WaitTime;
307  qsf::Time mHint18WaitTime;
308  qsf::Time mHint20WaitTime;
309  qsf::Time mHint21WaitTime;
310  // Station three
311  qsf::Time mHint22WaitTime;
312  qsf::Time mHint23WaitTime;
313  qsf::Time mHint25WaitTime;
314  qsf::Time mHint27WaitTime;
315 
316  // Settings backup
317  GameSettingsGroup::AutomatismValue mAutomatismBackup;
318  float mOriginalPolicemanAutomatismWaitTime;
319  float mOriginalParamedicAutomatismWaitTime;
320 
321 
322  //[-------------------------------------------------------]
323  //[ CAMP reflection system ]
324  //[-------------------------------------------------------]
325  QSF_CAMP_RTTI() // Only adds the virtual method "campClassId()", nothing more
326 
327 
328  };
329 
330 
331 //[-------------------------------------------------------]
332 //[ Namespace ]
333 //[-------------------------------------------------------]
334 } // em5
335 
336 
337 //[-------------------------------------------------------]
338 //[ CAMP reflection system ]
339 //[-------------------------------------------------------]
Definition: ActionPriority.h:13
Definition: FreeplayEvent.h:110
EMERGENCY 5 tutorial step station 3.
Definition: TutorialStepStation3.h:35
Entity class.
Definition: Entity.h:46
Message parameters class.
Definition: MessageParameters.h:34
EMERGENCY 5 tutorial step intro.
Definition: TutorialStepIntro.h:35
EMERGENCY 5 tutorial step outro.
Definition: TutorialStepOutro.h:35
virtual ~Tutorial()
Destructor.
unsigned int uint32
Definition: PlatformTypes.h:181
virtual void updateFreeplayEvent(const qsf::Time &timePassed) override
Regular update call, gets called once a game tick.
virtual void onShutdown() override
React to shutdown of the freeplay event.
void setPlayerControl(bool playerControl) const
Set player control active / inactive.
EMERGENCY 5 tutorial step base class.
Definition: TutorialStep.h:48
Message listener proxy class.
Definition: MessageProxy.h:47
Reason
Definition: EventSpreadReason.h:20
Static CAMP freeplay event plugin metaclass collection class.
Definition: FreeplayEventMetaclasses2.h:30
QSF game event tag manager component class.
Definition: EventTagManagerComponent.h:46
void activateLayer(const std::string &activate) const
Activate the scenery layer.
void setAiSimulation(bool aiSimulation) const
Set AI simulation.
Definition: PickupPersonByParamedicAction.h:21
void deactivateLayer(const std::string &deactivate, bool saveEntities=false) const
Deactivate the scenery layer.
#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
virtual bool checkEventConfiguration() override
Returns "true" if the event has the right configuration and can trigger right now.
virtual void onRun() override
React to state change from (initial) hidden state to running state.
#define QSF_CAMP_TYPE_NONCOPYABLE(type)
See "CAMP_TYPE_NONCOPYABLE" for details.
Definition: CampClass.h:112
void setCivilianSpawn(bool civilianSpawn) const
Set civilian spawn active / inactive.
AutomatismValue
The amount of used unit automatism. Eg. the doctor logic has an automatically treatment of injured pe...
Definition: GameSettingsGroup.h:143
void setGameSimulation(bool gameSimulation) const
Set damage, fire and health simulation active / inactive.
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.
EMERGENCY 5 tutorial step station 1.
Definition: TutorialStepStation1.h:42
virtual bool onStartup() override
React to startup of the freeplay event.
virtual void serialize(qsf::BinarySerializer &serializer) override
Serialization using a binary serializer.
virtual uint32 calculatePointGain(EventResult &eventResult) override
Calculate the point gain for this event.
EMERGENCY 5 tutorial event.
Definition: Tutorial.h:55
Abstract EMERGENCY 5 freeplay event base class.
Definition: FreeplayEvent.h:66
Compile time string hash class.
Definition: StringHash.h:59
Binary serializer class.
Definition: BinarySerializer.h:35
static const uint32 FREEPLAY_EVENT_ID
"em5::Tutorial" unique freeplay event ID
Definition: Tutorial.h:75
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 ...
EMERGENCY 5 tutorial step station 2.
Definition: TutorialStepStation2.h:36
Tutorial()
Default constructor.
Data type for encapsulating time information. It might represents points in time and time spans...
Definition: Time.h:32