Emergency 20 Dokumentation  4.2.0
EvacuateTrainStationEvent.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"
16 #include "qsf/math/Transform.h"
18 
19 
20 //[-------------------------------------------------------]
21 //[ Forward declarations ]
22 //[-------------------------------------------------------]
23 namespace qsf
24 {
25  class Layer;
26 }
27 
28 
29 //[-------------------------------------------------------]
30 //[ Namespace ]
31 //[-------------------------------------------------------]
32 namespace em5
33 {
34 
35 
36  //[-------------------------------------------------------]
37  //[ Classes ]
38  //[-------------------------------------------------------]
44  {
45 
46 
47  //[-------------------------------------------------------]
48  //[ Public definitions ]
49  //[-------------------------------------------------------]
50  public:
51  static const uint32 FREEPLAY_EVENT_ID;
52 
53 
54  //[-------------------------------------------------------]
55  //[ Public methods ]
56  //[-------------------------------------------------------]
57  public:
63 
68  virtual ~EvacuateTrainStationEvent();
69 
70  void init(qsf::Layer& eventLayer);
71 
72  QSF_DEFINE_SIMPLE_GETTER_AND_SETTER(TimeTillBombExplode, qsf::Time, mTimeTillBombExplode);
73  QSF_DEFINE_SIMPLE_GETTER_AND_SETTER(TimeToBombDefuse, qsf::Time, mTimeToBombDefuse);
74  QSF_DEFINE_SIMPLE_GETTER_AND_SETTER(PersonsLeaveTillTweet, int, mPersonsLeaveTillTweet);
75 
76 
77  //[-------------------------------------------------------]
78  //[ Public virtual em5::FreeplayEvent methods ]
79  //[-------------------------------------------------------]
80  public:
81  virtual bool onStartup() override;
82  virtual void onShutdown() override;
83  virtual void onRun() override;
84  virtual bool onFailure(EventResult& eventResult) override;
85  virtual bool onSuccess(EventResult& eventResult) override;
86  virtual void updateFreeplayEvent(const qsf::Time& timePassed) override;
87  virtual bool addEntityToEvent(qsf::Entity& targetEntity, eventspreadreason::Reason eventSpreadReason, bool newReason) override;
88  virtual const qsf::Entity* getFocusEntity() override;
89  virtual bool checkEventConfiguration() override;
90  virtual void serialize(qsf::BinarySerializer& serializer) override;
91  virtual void hintCallback(Observer& hintObserver) override;
92 
93 
94  //[-------------------------------------------------------]
95  //[ Private definitions ]
96  //[-------------------------------------------------------]
97  private:
98  struct PersonsPosition
99  {
100  uint64 entityId;
101  qsf::Transform finalTransform;
102  };
103 
104 
105  //[-------------------------------------------------------]
106  //[ Private methods ]
107  //[-------------------------------------------------------]
108  private:
109  void startObjectives();
110  bool getSubLayerFromMainLayer();
111  void setupScene();
112  void setupFleeingPerson(qsf::Entity& fleeingPerson);
113 
114  void onEvacuatePerson(const qsf::MessageParameters& parameters);
115  void onBombDefused(const qsf::MessageParameters& parameters);
116  void onFoundBomb(const qsf::MessageParameters& parameters);
117  void activateBombCases();
118  void activateRealBomb();
119 
120  void onReleasedFromMegaphone(const qsf::MessageParameters& parameters);
121 
122 
123  //[-------------------------------------------------------]
124  //[ Private data ]
125  //[-------------------------------------------------------]
126  private:
127  // Settings
128  qsf::Time mTimeTillBombExplode;
129  qsf::Time mTimeToBombDefuse;
130  qsf::Time mTimeDelayLeavingStation;
131  int mPersonsLeaveTillTweet;
132 
133  // Setup
134  qsf::Layer* mMainLayer;
135  qsf::Layer* mEventLayer;
136  qsf::Layer* mEraseLayer;
137 
138  // Internal
139  qsf::WeakPtr<qsf::Entity> mStationEntity; // This is the main entity for the event
140  qsf::WeakPtr<qsf::Entity> mStationEntity2; // This is the second train station exit for the evacuated persons
141  qsf::WeakPtr<qsf::Entity> mEvacuationEntity;
142  std::vector<qsf::WeakPtr<qsf::Entity>> mFleeingCivil;
143  std::vector<qsf::WeakPtr<qsf::Entity>> mGapingCivil;
144  std::vector<qsf::WeakPtr<qsf::Entity>> mPotentialPersonsInArea;
145  std::vector<qsf::WeakPtr<qsf::Entity>> mFakeBombEntities;
146  qsf::WeakPtr<qsf::Entity> mBombEntity;
147  qsf::WeakPtr<qsf::Entity> mEvacuateArea;
148  qsf::WeakPtr<qsf::Entity> mTweetCameraEntity;
149  boost::container::flat_set<uint64> mCivilistsToChaseAway;
150 
151  bool mTrainStationIsEvacuated;
152  qsf::MessageProxy mEvacuatePersonsMessageProxy;
153  bool mPersonsShocked;
154  bool mBombDefused;
155  qsf::MessageProxy mBombExplodeMessageProxy;
156  qsf::MessageProxy mSearchBombMessageProxy;
157  bool mCanTweet;
158  std::vector<PersonsPosition> mPersonsPositions;
159  int mNumberPersonsEvacuated;
160 
161  qsf::MessageProxy mReleasedFromMegaphoneMessageProxy;
162 
163 
164 
165  //[-------------------------------------------------------]
166  //[ CAMP reflection system ]
167  //[-------------------------------------------------------]
168  QSF_CAMP_RTTI() // Only adds the virtual method "campClassId()", nothing more
169 
170 
171  };
172 
173 
174 //[-------------------------------------------------------]
175 //[ Namespace ]
176 //[-------------------------------------------------------]
177 } // em5
178 
179 
180 //[-------------------------------------------------------]
181 //[ CAMP reflection system ]
182 //[-------------------------------------------------------]
Definition: ActionPriority.h:13
EMERGENCY 5 observer base class.
Definition: Observer.h:41
Definition: FreeplayEvent.h:110
Entity class.
Definition: Entity.h:46
Message parameters class.
Definition: MessageParameters.h:34
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
uint64_t uint64
Definition: PlatformTypes.h:184
3D transform class
Definition: Transform.h:45
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
static const uint32 FREEPLAY_EVENT_ID
"em5::EvacuateTrainStationEvent" unique freeplay event ID
Definition: EvacuateTrainStationEvent.h:51
#define QSF_CAMP_TYPE_NONCOPYABLE(type)
See "CAMP_TYPE_NONCOPYABLE" for details.
Definition: CampClass.h:112
EMERGENCY 5 freeplay event "Evacuate TrainStation".
Definition: EvacuateTrainStationEvent.h:43
#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