Emergency 20 Dokumentation  4.2.0
FireReceiverComponent.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 //[-------------------------------------------------------]
13 #include "em5/Export.h"
14 
16 
17 #include <boost/container/flat_map.hpp>
18 
19 
20 //[-------------------------------------------------------]
21 //[ Forward declarations ]
22 //[-------------------------------------------------------]
23 namespace em5
24 {
25  class FireReceiverComponent;
26  class HealthComponent;
27  class DamageComponent;
28 }
29 namespace qsf
30 {
31  class Time;
32  class TransformComponent;
33 }
34 
35 
36 //[-------------------------------------------------------]
37 //[ Namespace ]
38 //[-------------------------------------------------------]
39 namespace em5
40 {
41 
42 
43  //[-------------------------------------------------------]
44  //[ Structs ]
45  //[-------------------------------------------------------]
46  namespace firesimulation
47  {
48  // This structure is used just as performance optimization, to cache certain values so they don't have to be gathered in each fire system update again
49  // TODO(fw): There is quite some more potential in caching, add more data here that is expensive to gather
51  {
53  glm::vec3 mPosition;
54  bool mHasPosition;
55  };
56  }
57 
58 
59  //[-------------------------------------------------------]
60  //[ Classes ]
61  //[-------------------------------------------------------]
70  {
71 
72 
73  //[-------------------------------------------------------]
74  //[ Friends ]
75  //[-------------------------------------------------------]
76  friend class FireSystem; // Needed to be able to call the both protected virtual methods within the FireSystem (write back calculated fire simulation values)
77 
78 
79  //[-------------------------------------------------------]
80  //[ Public definitions ]
81  //[-------------------------------------------------------]
82  public:
83  static const uint32 COMPONENT_ID;
84 
85 
86  //[-------------------------------------------------------]
87  //[ Public methods ]
88  //[-------------------------------------------------------]
89  public:
97  explicit FireReceiverComponent(qsf::Prototype* prototype);
98 
103  virtual ~FireReceiverComponent();
104 
116  virtual void addCoolingEnergySource(uint64 entityId, float extinguishEnergy, float coolingEnergy);
117 
125  virtual void removeCoolingEnergySource(uint64 entityId);
126 
131  inline virtual bool isBurning() const;
132 
137  inline virtual bool isBurned() const;
138 
146  float getCoolingEnergy() const;
147 
152  uint32 getCoolingEnergySourceCount() const;
153 
154  /*
155  * @brief
156  * Returns the IDs of the current cooling source entities
157  *
158  * @remarks
159  * Call by reference to outsource the memory operations
160  */
161  void getCoolingSources(std::vector<uint64>& coolingSourceIds) const;
162 
167  qsf::TransformComponent* getTransformComponent() const;
168 
169  //[-------------------------------------------------------]
170  //[ Achievement ]
171  //[-------------------------------------------------------]
176  virtual bool canCountedForExtinguishAchievement() const;
177 
182  virtual void setCountedForExtinguishAchievement(bool canCounted);
183 
184 
185  //[-------------------------------------------------------]
186  //[ Protected em5::FireReceiverComponent methods ]
187  //[-------------------------------------------------------]
188  protected:
193  void internalActive(bool simulating, bool active);
194 
195 
196  //[-------------------------------------------------------]
197  //[ Protected virtual em5::FireReceiverComponent methods ]
198  //[-------------------------------------------------------]
199  protected:
204  virtual bool checkFireReceiver(qsf::Component* sender);
205 
217  virtual void receiveFireEnergy(float fireEnergy, const qsf::Time& timePassed, qsf::Component* sender);
218 
226  virtual void updateSimulation(const qsf::Time& timePassed);
227 
228 
229  //[-------------------------------------------------------]
230  //[ Protected virtual qsf::Component methods ]
231  //[-------------------------------------------------------]
232  protected:
233  virtual void onSetSimulating(bool simulating) override;
234  virtual void onSetActive(bool active) override;
235  virtual void onComponentTransformChange(const qsf::Transform& transform, TransformChangeFlags flags) override;
236 
237 
238  //[-------------------------------------------------------]
239  //[ Protected data ]
240  //[-------------------------------------------------------]
241  protected:
245 
246 
247  //[-------------------------------------------------------]
248  //[ Private data ]
249  //[-------------------------------------------------------]
250  private:
251  boost::container::flat_map<uint64, float> mCoolingEnergySet;
252  firesimulation::FireReceiverData* mFireReceiverData;
253 
254 
255  //[-------------------------------------------------------]
256  //[ CAMP reflection system ]
257  //[-------------------------------------------------------]
258  QSF_CAMP_RTTI() // Only adds the virtual method "campClassId()", nothing more
259 
260 
261  };
262 
263 
264 //[-------------------------------------------------------]
265 //[ Namespace ]
266 //[-------------------------------------------------------]
267 } // em5
268 
269 
270 //[-------------------------------------------------------]
271 //[ Implementation ]
272 //[-------------------------------------------------------]
274 
275 
276 //[-------------------------------------------------------]
277 //[ CAMP reflection system ]
278 //[-------------------------------------------------------]
Definition: ActionPriority.h:13
glm::vec3 mPosition
World position of the fire receiver.
Definition: FireReceiverComponent.h:53
Abstract component class.
Definition: Component.h:105
Fire system.
Definition: FireSystem.h:63
Definition: FireReceiverComponent.h:50
unsigned int uint32
Definition: PlatformTypes.h:181
Transform component class.
Definition: TransformComponent.h:33
EMERGENCY 5 fire receiver component class.
Definition: FireReceiverComponent.h:69
qsf::WeakPtr< HealthComponent > mHealthComponent
Definition: FireReceiverComponent.h:243
#define EM5_API_EXPORT
Definition: Export.h:28
uint64_t uint64
Definition: PlatformTypes.h:184
3D transform class
Definition: Transform.h:45
Definition: PickupPersonByParamedicAction.h:21
qsf::WeakPtr< qsf::TransformComponent > mTransformComponent
Definition: FireReceiverComponent.h:242
#define QSF_CAMP_RTTI()
Only adds the virtual method "campClassId()", nothing more.
Definition: CampClass.h:75
Bit flag set class template.
Definition: BitFlagSet.h:41
#define QSF_CAMP_TYPE_NONCOPYABLE(type)
See "CAMP_TYPE_NONCOPYABLE" for details.
Definition: CampClass.h:112
static const uint32 COMPONENT_ID
"em5::FireReceiverComponent" unique component ID
Definition: FireReceiverComponent.h:83
FireReceiverComponent * mComponent
The fire receiver component associated with this data instance.
Definition: FireReceiverComponent.h:52
qsf::WeakPtr< DamageComponent > mDamageComponent
Definition: FireReceiverComponent.h:244
Prototype class.
Definition: Prototype.h:100
bool mHasPosition
"true" if the position is set at all
Definition: FireReceiverComponent.h:54
Data type for encapsulating time information. It might represents points in time and time spans...
Definition: Time.h:32