Emergency 20 Dokumentation  4.2.0
StormDamageEvent.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>
17 
18 
19 //[-------------------------------------------------------]
20 //[ Forward declarations ]
21 //[-------------------------------------------------------]
22 namespace qsf
23 {
24  class Layer;
25 }
26 
27 
28 //[-------------------------------------------------------]
29 //[ Namespace ]
30 //[-------------------------------------------------------]
31 namespace em5
32 {
33 
34 
35  //[-------------------------------------------------------]
36  //[ Classes ]
37  //[-------------------------------------------------------]
43  {
44 
45 
46  //[-------------------------------------------------------]
47  //[ Public definitions ]
48  //[-------------------------------------------------------]
49  public:
50  static const uint32 FREEPLAY_EVENT_ID;
51 
52 
53  //[-------------------------------------------------------]
54  //[ Public methods ]
55  //[-------------------------------------------------------]
56  public:
62 
67  virtual ~StormDamageEvent();
68 
69  QSF_DEFINE_SIMPLE_GETTER_AND_SETTER(TimeBeforeFirstTask, qsf::Time, mTimeBeforeFirstTask);
70  QSF_DEFINE_SIMPLE_GETTER_AND_SETTER(TimeBetweenTasks, qsf::Time, mTimeBetweenTasks);
71  QSF_DEFINE_SIMPLE_GETTER_AND_SETTER(EboxRepairTime, qsf::Time, mEboxRepairTime);
72  QSF_DEFINE_SIMPLE_GETTER_AND_SETTER(TrappedPersonsInBuildings, uint32, mTrappedPersonsInBuildings);
73  QSF_DEFINE_SIMPLE_GETTER_AND_SETTER(DeadPersonsToFail, uint32, mDeadPersonsToFail);
74  QSF_DEFINE_SIMPLE_GETTER_AND_SETTER(BurningObjectsToFail, uint32, mBurningObjectsToFail);
75 
76  inline uint32 getTasksDummy() const { return 0; } // Lazy solution, the CAMP getter is irrelevant anyway
77  void setNumberOfTreeOnRoadTasks(uint32 number);
78  void setNumberOfTreeOnCarTasks(uint32 number);
79  void setNumberOfCarAccidentTasks(uint32 number);
80  void setNumberOfLightningFireTasks(uint32 number);
81  void setNumberOfTornadoTasks(uint32 number);
82  void setNumberOfBrokenElectricPylonTasks(uint32 number);
83  void setNumberOfInjuriesTasks(uint32 number);
84 
85 
86  //[-------------------------------------------------------]
87  //[ Public virtual em5::FreeplayEvent methods ]
88  //[-------------------------------------------------------]
89  public:
90  virtual bool onStartup() override;
91  virtual void onShutdown() override;
92  virtual void onRun() override;
93  virtual bool onFailure(EventResult& eventResult) override;
94  virtual bool onSuccess(EventResult& eventResult) override;
95  virtual void updateFreeplayEvent(const qsf::Time& timePassed) override;
96  virtual bool addEntityToEvent(qsf::Entity& targetEntity, eventspreadreason::Reason eventSpreadReason, bool newReason) override;
97  virtual const qsf::Entity* getFocusEntity() override;
98  virtual bool checkEventConfiguration() override;
99  virtual void serialize(qsf::BinarySerializer& serializer) override;
100  virtual void hintCallback(Observer& hintObserver) override;
101 
102 
103  //[-------------------------------------------------------]
104  //[ Private definitions ]
105  //[-------------------------------------------------------]
106  private:
107  enum TaskType
108  {
109  TASK_TREE_ON_ROAD,
110  TASK_TREE_ON_CAR,
111  TASK_CAR_ACCIDENT,
112  TASK_LIGHTNING_FIRE,
113  TASK_TORNADO,
114  TASK_BROKEN_ELECTRIC_PYLON,
115  TASK_INJURIES,
116  _NUM_TASKS
117  };
118  struct Task
119  {
120  TaskType mType;
121  };
122 
123 
124  //[-------------------------------------------------------]
125  //[ Private methods ]
126  //[-------------------------------------------------------]
127  private:
128  void startObjectives();
129  void setupScene();
130 
131  bool tryTriggerNewTask();
132  bool startTask(TaskType type);
133 
134  qsf::Layer* chooseSubLayer(const std::string& layerNaming, bool usesAddEraseLayers);
135  void activateLayer(qsf::Layer& layer);
136  void toggleAddEraseSubLayers(qsf::Layer& layer);
137  void initBuryingObjectsInLayer(qsf::Layer& layer, const std::string& eventTag, bool makeCuttable);
138  void initAccidentCarsInLayer(qsf::Layer& layer);
139  void initEboxInLayer(qsf::Layer& layer);
140  bool initDamagedBuildingsAssociatedWithLayer(qsf::Layer& layer);
141  qsf::Entity* findLightningFireTarget();
142  void setParticleEffectEnabled(qsf::Entity& entity, bool enabled);
143 
144  void onEboxRepaired(const qsf::MessageParameters& parameters);
145 
146 
147  //[-------------------------------------------------------]
148  //[ Private data ]
149  //[-------------------------------------------------------]
150  private:
151  // Configuration
152  qsf::Time mTimeBeforeFirstTask;
153  qsf::Time mTimeBetweenTasks;
154  qsf::Time mEboxRepairTime;
155  uint32 mTrappedPersonsInBuildings;
156  uint32 mDeadPersonsToFail;
157  uint32 mBurningObjectsToFail;
158 
159  // Layers
160  qsf::Layer* mEventLayer;
161  std::vector<std::pair<qsf::Layer*, qsf::Layer*>> mLayersToCleanup; // First is the layer to cleanup, second is an optional "erase" layer to reactivate
162 
163  // Event
164  qsf::Time mTimeUntilNextTask;
165  bool mIsTriggeringNewTasks;
166 
167  // Tasks
168  std::vector<Task> mTasksStarted;
169  std::map<TaskType, uint32> mTaskPool;
170 
171  // Eboxes
172  struct EboxInfo
173  {
177  };
178  std::vector<EboxInfo> mEboxInfos;
179 
180  // Messages
181  qsf::MessageProxy mRepairEboxMessageProxy;
182 
183 
184  //[-------------------------------------------------------]
185  //[ CAMP reflection system ]
186  //[-------------------------------------------------------]
187  QSF_CAMP_RTTI() // Only adds the virtual method "campClassId()", nothing more
188 
189 
190  };
191 
192 
193 //[-------------------------------------------------------]
194 //[ Namespace ]
195 //[-------------------------------------------------------]
196 } // em5
197 
198 
199 //[-------------------------------------------------------]
200 //[ CAMP reflection system ]
201 //[-------------------------------------------------------]
Definition: ActionPriority.h:13
EMERGENCY 5 observer base class.
Definition: Observer.h:41
static const uint32 FREEPLAY_EVENT_ID
"em5::StormDamageEvent" unique freeplay event ID
Definition: StormDamageEvent.h:50
Entity class.
Definition: Entity.h:46
Message parameters class.
Definition: MessageParameters.h:34
EMERGENCY 5 freeplay event "Storm damage".
Definition: StormDamageEvent.h:42
Layer class.
Definition: Layer.h:56
unsigned int uint32
Definition: PlatformTypes.h:181
#define EM5_API_EXPORT
Definition: Export.h:28
Message listener proxy class.
Definition: MessageProxy.h:47
Reason
Definition: EventSpreadReason.h:20
void serialize(BinarySerializer &serializer, BitFlagSet< STORAGE, ENUM > &bitFlagSet)
Definition: BitFlagSet.h:359
Definition: PickupPersonByParamedicAction.h:21
uint32 getTasksDummy() const
Definition: StormDamageEvent.h:76
#define QSF_CAMP_RTTI()
Only adds the virtual method "campClassId()", nothing more.
Definition: CampClass.h:75
#define QSF_CAMP_TYPE_NONCOPYABLE(type)
See "CAMP_TYPE_NONCOPYABLE" for details.
Definition: CampClass.h:112
#define QSF_DEFINE_SIMPLE_GETTER_AND_SETTER(name, type, variable)
Definition: PropertyHelper.h:16
Abstract EMERGENCY 5 freeplay event base class.
Definition: FreeplayEvent.h:66
Binary serializer class.
Definition: BinarySerializer.h:35
Data type for encapsulating time information. It might represents points in time and time spans...
Definition: Time.h:32