Emergency 20 Dokumentation  4.2.0
TrafficAccident01Event.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 
16 //[-------------------------------------------------------]
17 //[ Forward declarations ]
18 //[-------------------------------------------------------]
19 namespace em5
20 {
21  class VehicleComponent;
22 }
23 namespace qsf
24 {
25  class Layer;
26  class Map;
27 }
28 
29 
30 //[-------------------------------------------------------]
31 //[ Namespace ]
32 //[-------------------------------------------------------]
33 namespace em5
34 {
35 
36 
37  //[-------------------------------------------------------]
38  //[ Classes ]
39  //[-------------------------------------------------------]
45  {
46 
47 
48  //[-------------------------------------------------------]
49  //[ Public definitions ]
50  //[-------------------------------------------------------]
51  public:
52  static const uint32 FREEPLAY_EVENT_ID;
53 
54 
55  //[-------------------------------------------------------]
56  //[ Public static methods ]
57  //[-------------------------------------------------------]
58  public:
59  static bool canSpawnEntitiesCollisionFree(const qsf::Layer& layer, qsf::Map& map);
60 
61 
62  //[-------------------------------------------------------]
63  //[ Public methods ]
64  //[-------------------------------------------------------]
65  public:
71 
76  virtual ~TrafficAccident01Event();
77 
78  void init(qsf::Layer* accidentLayer);
79 
80  // Range is 0 (no fire) to 1 (always fire)
81  float getChanceFire() const;
82  void setChanceFire(float chance);
83 
84  float getChanceHardInjury() const;
85  void setChanceHardInjury(float chance);
86 
87  float getHint01WaitTime() const;
88  void setHint01WaitTime(float seconds);
89 
90  float getHint03LifeEnergy() const;
91  void setHint03LifeEnergy(float energy);
92 
93 
94  //[-------------------------------------------------------]
95  //[ Public virtual em5::FreeplayEvent methods ]
96  //[-------------------------------------------------------]
97  public:
98  virtual bool onStartup() override;
99  virtual void onRun() override;
100  virtual void onShutdown() override;
101  virtual void updateFreeplayEvent(const qsf::Time& timePassed) override;
102  virtual bool addEntityToEvent(qsf::Entity& targetEntity, eventspreadreason::Reason eventSpreadReason, bool newReason) override;
103  virtual void hintCallback(Observer& hintObserver) override;
104  virtual const qsf::Entity* getFocusEntity() override;
105  virtual bool checkEventConfiguration() override;
106  virtual void serialize(qsf::BinarySerializer& serializer) override;
107 
108 
109  //[-------------------------------------------------------]
110  //[ Private static methods ]
111  //[-------------------------------------------------------]
112  private:
113  static bool isInjuredOutsideCars(const qsf::Entity& personEntity);
114  static bool isBrawler(const qsf::Entity& personEntity);
115  static bool isContaminationVehicle(const qsf::Entity& vehicleEntity);
116 
117 
118  //[-------------------------------------------------------]
119  //[ Private methods ]
120  //[-------------------------------------------------------]
121  private:
122  void startHintObservers();
123  void setupScene(qsf::Layer& accidentLayer);
124  void attackTarget(qsf::Entity& attackerEntity, qsf::Entity& targetEntity);
125 
126 
127  //[-------------------------------------------------------]
128  //[ Private data ]
129  //[-------------------------------------------------------]
130  private:
131  uint32 mAccidentLayerId;
132  bool mHasFire;
133  bool mIsBrawling;
134  std::vector<uint64> mLayerVehicles; // All vehicles
135  std::vector<uint64> mLayerBrawler; // All persons that are standing outside and brawl
136  std::vector<uint64> mLayerTrappedPersons; // All persons that are trapped inside vehicles
137  std::vector<uint64> mLayerContaminationVehicles; // All vehicles that causes contamination (chemical transporter)
138 
139  // Settings
140  float mChanceFire;
141  float mChanceHardInjury; // Chance that injured persons have hard injuries, Only used for chemical contamination
142  float mHint01TimeSeconds;
143  float mHint03LifeEnergy;
144  qsf::Time mChemicalTransportHint01WaitTime;
145 
146 
147  //[-------------------------------------------------------]
148  //[ CAMP reflection system ]
149  //[-------------------------------------------------------]
150  QSF_CAMP_RTTI() // Only adds the virtual method "campClassId()", nothing more
151 
152 
153  };
154 
155 
156 //[-------------------------------------------------------]
157 //[ Namespace ]
158 //[-------------------------------------------------------]
159 } // em5
160 
161 
162 //[-------------------------------------------------------]
163 //[ CAMP reflection system ]
164 //[-------------------------------------------------------]
Definition: ActionPriority.h:13
EMERGENCY 5 observer base class.
Definition: Observer.h:41
Entity class.
Definition: Entity.h:46
Map class.
Definition: Map.h:93
Layer class.
Definition: Layer.h:56
unsigned int uint32
Definition: PlatformTypes.h:181
#define EM5_API_EXPORT
Definition: Export.h:28
Reason
Definition: EventSpreadReason.h:20
void serialize(BinarySerializer &serializer, BitFlagSet< STORAGE, ENUM > &bitFlagSet)
Definition: BitFlagSet.h:359
Definition: PickupPersonByParamedicAction.h:21
EMERGENCY 5 freeplay event "traffic accident 01".
Definition: TrafficAccident01Event.h:44
#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
Abstract EMERGENCY 5 freeplay event base class.
Definition: FreeplayEvent.h:66
Binary serializer class.
Definition: BinarySerializer.h:35
static const uint32 FREEPLAY_EVENT_ID
"em5::TrafficAccident01Event" unique freeplay event ID
Definition: TrafficAccident01Event.h:52
Data type for encapsulating time information. It might represents points in time and time spans...
Definition: Time.h:32