Emergency 20 Dokumentation  4.2.0
HeatWaveEvent.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 
17 #include <qsf/time/Time.h>
18 
19 
20 //[-------------------------------------------------------]
21 //[ Namespace ]
22 //[-------------------------------------------------------]
23 namespace em5
24 {
25 
26 
27  //[-------------------------------------------------------]
28  //[ Classes ]
29  //[-------------------------------------------------------]
35  {
36 
37 
38  //[-------------------------------------------------------]
39  //[ Public definitions ]
40  //[-------------------------------------------------------]
41  public:
42  static const uint32 FREEPLAY_EVENT_ID;
43 
45  {
47  numberOfPersonsToInjure(3),
48  numberOfVehiclesToInflame(4),
49  numberOfVegetationToInflame(7),
50  heatwaveFadeInTime(qsf::Time::fromSeconds(5.0f)),
51  heatwaveFadeOutTime(qsf::Time::fromSeconds(5.0f)),
52  heatwavePersistInjurePersonWaitTime(qsf::Time::fromSeconds(5.0f)),
53  heatwavePersistInflameObjectWaitTime(qsf::Time::fromSeconds(5.0f)),
54  heatwavePersistInflameVehicleWaitTime(qsf::Time::fromSeconds(5.0f)),
55  deadPersonsToFail(2)
56  {}
57 
58  void serialize(qsf::BinarySerializer& serializer)
59  {
60  serializer.serialize(numberOfPersonsToInjure);
61  serializer.serialize(numberOfVehiclesToInflame);
62  serializer.serialize(numberOfVegetationToInflame);
63  serializer.serialize(heatwaveFadeInTime);
64  serializer.serialize(heatwaveFadeOutTime);
65  serializer.serialize(heatwavePersistInjurePersonWaitTime);
66  serializer.serialize(heatwavePersistInflameObjectWaitTime);
67  serializer.serialize(heatwavePersistInflameVehicleWaitTime);
68  serializer.serialize(deadPersonsToFail);
69  }
70 
74 
77 
81 
83  };
84 
85 
86  //[-------------------------------------------------------]
87  //[ Public methods ]
88  //[-------------------------------------------------------]
89  public:
94  HeatWaveEvent();
95 
100  virtual ~HeatWaveEvent();
101 
106  Configuration& getConfiguration() { return mConfiguration; }
107 
108 
109  //[-------------------------------------------------------]
110  //[ Public virtual em5::FreeplayEvent methods ]
111  //[-------------------------------------------------------]
112  public:
113  virtual bool onStartup() override;
114  virtual void onShutdown() override;
115  virtual void onRun() override;
116  virtual bool onFailure(EventResult& eventResult) override;
117  virtual void updateFreeplayEvent(const qsf::Time& timePassed) override;
118  virtual bool addEntityToEvent(qsf::Entity& targetEntity, eventspreadreason::Reason eventSpreadReason, bool newReason) override;
119  virtual void hintCallback(Observer& hintObserver) override;
120  virtual const qsf::Entity* getFocusEntity() override;
121  virtual bool checkEventConfiguration() override;
122  virtual void serialize(qsf::BinarySerializer& serializer) override;
123 
124 
125  //[-------------------------------------------------------]
126  //[ Private methods ]
127  //[-------------------------------------------------------]
128  private:
129  void startObjectives();
130  void startHintObservers();
131 
132  bool injureARandomPerson();
133 
134  bool inflameARandomVehicle();
135  qsf::Entity* findVehicleCandidate() const;
136  bool checkVehicleCandidate(qsf::Entity& entity) const;
137 
138  void chooseNextPersistingState(bool fastRetry);
139 
140  bool inflameARandomObject();
141  qsf::Entity* findTreeOrHedgeCandidate() const;
142  void toggleCustomGlobalAmbientAIBehavior(bool enable);
143 
144 
145  //[-------------------------------------------------------]
146  //[ Private definitions ]
147  //[-------------------------------------------------------]
148  private:
149  enum HeatwaveState
150  {
151  HEATWAVE_TURN_UP,
152  HEATWAVE_PERSISTING_INJURE_PERSON,
153  HEATWAVE_PERSISTING_INFLAME_OBJECT,
154  HEATWAVE_PERSISTING_INFLAME_VEHICLE,
155  HEATWAVE_TURN_DOWN,
156  HEATWAVE_AFTERMATH
157  };
158 
159 
160  //[-------------------------------------------------------]
161  //[ Private data ]
162  //[-------------------------------------------------------]
163  private:
164  Configuration mConfiguration;
165  HeatwaveState mState;
166  qsf::Time mCurrentStateTime;
167  uint32 mNumberOfPersonsInjured;
168  uint32 mNumberOfVehiclesInflamed;
169  uint32 mNumberOfObjectsInflamed;
170  bool mTriggerForrestFire;
171 
172 
173  //[-------------------------------------------------------]
174  //[ CAMP reflection system ]
175  //[-------------------------------------------------------]
176  QSF_CAMP_RTTI() // Only adds the virtual method "campClassId()", nothing more
177 
178 
179  };
180 
181 
182 //[-------------------------------------------------------]
183 //[ Namespace ]
184 //[-------------------------------------------------------]
185 } // em5
186 
187 
188 //[-------------------------------------------------------]
189 //[ CAMP reflection system ]
190 //[-------------------------------------------------------]
Definition: ActionPriority.h:13
EMERGENCY 5 observer base class.
Definition: Observer.h:41
Entity class.
Definition: Entity.h:46
qsf::Time heatwavePersistInflameObjectWaitTime
Definition: HeatWaveEvent.h:79
unsigned int uint32
Definition: PlatformTypes.h:181
void serialize(T &value, const char *name=nullptr)
Serialize or deserialize a value with optional name (for usage as additional security token) ...
Definition: BinarySerializer-inl.h:52
#define EM5_API_EXPORT
Definition: Export.h:28
Configuration & getConfiguration()
Get number persons that have to die so that the event fails.
Definition: HeatWaveEvent.h:106
uint32 numberOfVegetationToInflame
Definition: HeatWaveEvent.h:73
Reason
Definition: EventSpreadReason.h:20
uint32 numberOfPersonsToInjure
Definition: HeatWaveEvent.h:71
void serialize(BinarySerializer &serializer, BitFlagSet< STORAGE, ENUM > &bitFlagSet)
Definition: BitFlagSet.h:359
Definition: PickupPersonByParamedicAction.h:21
static const uint32 FREEPLAY_EVENT_ID
"em5::HeatWaveEvent" unique freeplay event ID
Definition: HeatWaveEvent.h:42
#define QSF_CAMP_RTTI()
Only adds the virtual method "campClassId()", nothing more.
Definition: CampClass.h:75
Emergency 5 freeplay event "heat wave" 11.9.
Definition: HeatWaveEvent.h:34
#define QSF_CAMP_TYPE_NONCOPYABLE(type)
See "CAMP_TYPE_NONCOPYABLE" for details.
Definition: CampClass.h:112
qsf::Time heatwaveFadeOutTime
Definition: HeatWaveEvent.h:76
qsf::Time heatwavePersistInflameVehicleWaitTime
Definition: HeatWaveEvent.h:80
qsf::Time heatwaveFadeInTime
Definition: HeatWaveEvent.h:75
qsf::Time heatwavePersistInjurePersonWaitTime
Definition: HeatWaveEvent.h:78
void serialize(qsf::BinarySerializer &serializer)
Definition: HeatWaveEvent.h:58
Configuration()
Definition: HeatWaveEvent.h:46
Abstract EMERGENCY 5 freeplay event base class.
Definition: FreeplayEvent.h:66
uint32 numberOfVehiclesToInflame
Definition: HeatWaveEvent.h:72
Binary serializer class.
Definition: BinarySerializer.h:35
uint32 deadPersonsToFail
Definition: HeatWaveEvent.h:82
Definition: HeatWaveEvent.h:44
Data type for encapsulating time information. It might represents points in time and time spans...
Definition: Time.h:32