Emergency 20 Dokumentation  4.2.0
CityBlackoutEvent.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 em5
23 {
24  class SpawnPointComponent;
25  class WarblerTweetHelper;
26 }
27 namespace qsf
28 {
29  class Layer;
30 }
31 
32 
33 //[-------------------------------------------------------]
34 //[ Namespace ]
35 //[-------------------------------------------------------]
36 namespace em5
37 {
38 
39 
40  //[-------------------------------------------------------]
41  //[ Classes ]
42  //[-------------------------------------------------------]
48  {
49 
50 
51  //[-------------------------------------------------------]
52  //[ Public definitions ]
53  //[-------------------------------------------------------]
54  public:
55  static const uint32 FREEPLAY_EVENT_ID;
56 
57 
58  //[-------------------------------------------------------]
59  //[ Public methods ]
60  //[-------------------------------------------------------]
61  public:
67 
72  virtual ~CityBlackoutEvent();
73 
74  void init(qsf::Layer& eventLayer);
75 
76  QSF_DEFINE_SIMPLE_GETTER_AND_SETTER(DeadPersonsToFail, uint32, mDeadPersonsToFail);
77  QSF_DEFINE_SIMPLE_GETTER_AND_SETTER(BurningObjectsToFail, uint32, mBurningObjectsToFail);
78  QSF_DEFINE_SIMPLE_GETTER_AND_SETTER(MinTriggerTimeOfDay, qsf::Time, mMinTriggerTimeOfDay);
79  QSF_DEFINE_SIMPLE_GETTER_AND_SETTER(MaxTriggerTimeOfDay, qsf::Time, mMaxTriggerTimeOfDay);
80  QSF_DEFINE_SIMPLE_GETTER_AND_SETTER(CorrectionTimeOfDay, qsf::Time, mCorrectionTimeOfDay);
81  QSF_DEFINE_SIMPLE_GETTER_AND_SETTER(TimeToDefuseBomb, qsf::Time, mTimeToDefuseBomb)
82  QSF_DEFINE_SIMPLE_GETTER_AND_SETTER(TimeToWaitForExplosion, qsf::Time, mTimeToWaitForExplosion);
83  QSF_DEFINE_SIMPLE_GETTER_AND_SETTER(WaitTimeForArea02, qsf::Time, mWaitTimeForArea02);
84  QSF_DEFINE_SIMPLE_GETTER_AND_SETTER(TimeToRepairEbox, qsf::Time, mTimeToRepairEbox);
85  QSF_DEFINE_SIMPLE_GETTER_AND_SETTER(TimeToDamageEbox, qsf::Time, mTimeToDamageEbox);
86 
87 
88  //[-------------------------------------------------------]
89  //[ Public virtual em5::FreeplayEvent methods ]
90  //[-------------------------------------------------------]
91  public:
92  virtual bool onStartup() override;
93  virtual void onShutdown() override;
94  virtual void onRun() override;
95  virtual bool onFailure(EventResult& eventResult) override;
96  virtual bool onSuccess(EventResult& eventResult) override;
97  virtual void updateFreeplayEvent(const qsf::Time& timePassed) override;
98  virtual bool addEntityToEvent(qsf::Entity& targetEntity, eventspreadreason::Reason eventSpreadReason, bool newReason) override;
99  virtual const qsf::Entity* getFocusEntity() override;
100  virtual bool checkEventConfiguration() override;
101  virtual void serialize(qsf::BinarySerializer& serializer) override;
102  virtual void hintCallback(Observer& hintObserver) override;
103 
104 
105  //[-------------------------------------------------------]
106  //[ Private methods ]
107  //[-------------------------------------------------------]
108  private:
109  void startObjectives();
110  void setupScene();
111  void setupSceneMiniEvent();
112  void setupSceneFreeplay();
113 
114  void setBlackoutAreaActive(uint32 index, bool blackout);
115  void makeEboxDefective(uint32 index);
116  void spawnFreeplayGangster();
117  void startTrafficAccident(const std::string& accidentLayerName);
118  void injurePerson(const std::string& eventTag);
119 
120  void onGameTimerMessage(const qsf::MessageParameters& parameters);
121  void onBombExplosion(const qsf::MessageParameters& parameters);
122  void onEboxDamageByGangster(const qsf::MessageParameters& parameters);
123  void onEboxRepaired(const qsf::MessageParameters& parameters);
124 
125 
126  //[-------------------------------------------------------]
127  //[ Private data ]
128  //[-------------------------------------------------------]
129  private:
130  // Configuration
131  uint32 mDeadPersonsToFail;
132  uint32 mBurningObjectsToFail;
133  qsf::Time mMinTriggerTimeOfDay;
134  qsf::Time mMaxTriggerTimeOfDay;
135  qsf::Time mCorrectionTimeOfDay;
136  qsf::Time mTimeToDefuseBomb;
137  qsf::Time mTimeToWaitForExplosion;
138  qsf::Time mWaitTimeForArea02;
139  qsf::Time mTimeToRepairEbox;
140  qsf::Time mTimeToDamageEbox;
141 
142  // Layers
143  qsf::Layer* mEventLayer;
144  qsf::Layer* mAddLayer;
145  qsf::Layer* mEraseLayer;
146  qsf::Layer* mAddLayerP2;
147  qsf::Layer* mEraseLayerP2;
148 
149  std::vector<std::pair<qsf::Layer*, qsf::Layer*>> mLayersToCleanup; // First is the layer to cleanup, second is an optional "erase" layer to reactivate
150 
151  // Objects
152  enum EboxState
153  {
154  EBOX_INTACT,
155  EBOX_DEFECTIVE,
156  EBOX_REPAIRED
157  };
158  struct EboxInfo
159  {
161  std::vector<qsf::Entity*> mAreaBoxes;
162  EboxState mState;
163  };
164  std::vector<EboxInfo> mEboxInfos;
165  qsf::WeakPtr<SpawnPointComponent> mTerroristSpawnPoint;
166  qsf::WeakPtr<qsf::Entity> mBuildingToDestroy;
167  qsf::WeakPtr<qsf::Entity> mGangster;
169 
170  // Warbler tweet
171  WarblerTweetHelper& mTweet01;
172 
173  // Messages
174  qsf::MessageProxy mGameTimerMessageProxy;
175  qsf::MessageProxy mBombExplosionMessageProxy;
176  qsf::MessageProxy mDamageEboxMessageProxy;
177  qsf::MessageProxy mRepairEboxMessageProxy;
178 
179 
180  //[-------------------------------------------------------]
181  //[ CAMP reflection system ]
182  //[-------------------------------------------------------]
183  QSF_CAMP_RTTI() // Only adds the virtual method "campClassId()", nothing more
184 
185 
186  };
187 
188 
189 //[-------------------------------------------------------]
190 //[ Namespace ]
191 //[-------------------------------------------------------]
192 } // em5
193 
194 
195 //[-------------------------------------------------------]
196 //[ CAMP reflection system ]
197 //[-------------------------------------------------------]
Definition: ActionPriority.h:13
EMERGENCY 5 observer base class.
Definition: Observer.h:41
Definition: FreeplayEvent.h:110
Layer class.
Definition: Layer.h:56
unsigned int uint32
Definition: PlatformTypes.h:181
EMERGENCY 5 freeplay event "City blackout".
Definition: CityBlackoutEvent.h:47
#define EM5_API_EXPORT
Definition: Export.h:28
Definition: AreaConfiguration.h:58
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
#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
static const uint32 FREEPLAY_EVENT_ID
"em5::CityBlackoutEvent" unique freeplay event ID
Definition: CityBlackoutEvent.h:55
#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
Data type for encapsulating time information. It might represents points in time and time spans...
Definition: Time.h:32