Emergency 20 Dokumentation  4.2.0
FireSystem.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/System.h>
17 #include <qsf/job/JobProxy.h>
19 
20 
21 //[-------------------------------------------------------]
22 //[ Forward declarations ]
23 //[-------------------------------------------------------]
24 namespace em5
25 {
26  class FireMaterialManager;
27  class FireMaterial;
28  class FireReceiverComponent;
29  class FireSpreadCalculation;
30  namespace firesimulation
31  {
32  struct ComponentData;
33  }
34 }
35 namespace qsf
36 {
37  class Map;
38 }
39 
40 
41 //[-------------------------------------------------------]
42 //[ Namespace ]
43 //[-------------------------------------------------------]
44 namespace em5
45 {
46 
47 
48  //[-------------------------------------------------------]
49  //[ Classes ]
50  //[-------------------------------------------------------]
64  {
65 
66 
67  //[-------------------------------------------------------]
68  //[ Public definitions ]
69  //[-------------------------------------------------------]
70  public:
72  {
73  SHOW_NONE,
74  SHOW_GLOBAL,
75  SHOW_ONLY_SELECTED
76  };
77 
79  {
80  SHOW_BOTH,
81  SHOW_RECEIVING,
82  SHOW_SENDING
83  };
84 
85  typedef boost::container::flat_set<uint64> EntityIdSet;
86 
87 
88  //[-------------------------------------------------------]
89  //[ Public methods ]
90  //[-------------------------------------------------------]
91  public:
96  FireSystem();
97 
105  ~FireSystem();
106 
108  const FireMaterial* getFireMaterialByName(const std::string& id) const;
109 
114  inline FireMaterialManager& getFireMaterialManager() const;
115 
116  inline bool getFireSimulationActive() const;
117  void setFireSimulationActive(bool fireSimulationEnabled);
118 
123  void onGameStartup();
124 
129  void onGameShutdown();
130 
135  inline void resetFireSystem();
136 
137  float getFireEnergyMultiplier() const;
138  void setFireEnergyMultiplier(float multiplier);
139 
140  inline SimulationVisualisationMode getFireRadiansSimulationVisualisationMode() const;
141  inline void setFireRadiansSimulationVisualisationMode(SimulationVisualisationMode visualisationMode);
142 
143  inline SimulationVisualisationMode getFireSpreadSimulationVisualisationMode() const;
144  inline void setFireSpreadSimulationVisualisationMode(SimulationVisualisationMode visualisationMode);
145 
146  inline FireSpreadLinesVisualisationMode getFireSpreadLinesVisualisationMode() const;
147  inline void setFireSpreadLinesVisualisationMode(FireSpreadLinesVisualisationMode visualisationMode);
148 
149  void registerFireReceiver(FireReceiverComponent& fireReceiver);
150  void unregisterFireReceiver(FireReceiverComponent& fireReceiver);
151 
152 
153  //[-------------------------------------------------------]
154  //[ Public virtual qsf::System methods ]
155  //[-------------------------------------------------------]
156  public:
157  inline virtual const char* getName() const override;
158 
159  //[-------------------------------------------------------]
160  //[ Lifecycle ]
161  //[-------------------------------------------------------]
162  virtual bool onStartup(bool serverMode) override;
163  virtual void onShutdown() override;
164 
165 
166  //[-------------------------------------------------------]
167  //[ Private methods ]
168  //[-------------------------------------------------------]
169  private:
170  // Methods for the fire spread calculation
171  void updateSimulation(const qsf::JobArguments& jobArguments);
172  void resetDebugDrawRequests(const qsf::Map& map);
173  void writeCalculationResultsToEntities(const std::vector<firesimulation::ComponentData>& calculationResult);
174  void updateDebugDrawRequests(const qsf::Map& map, const std::vector<firesimulation::ComponentData>& calculationResult);
175  void prepareDataForNextCalculation(const qsf::Map& map, float secondsPassed);
176 
177  void drawFireChainLinesForAllFireReceiver(const qsf::Map& map);
178  void drawFireRadianForAllFireComponents(const std::vector<firesimulation::ComponentData>& calculationResult, bool showFireRadians);
179  void drawPositionCircleAllFireComponents(const std::vector<firesimulation::ComponentData>& calculationResult);
180 
181  void drawFireRadianForSelectedFireComponents(const std::vector<firesimulation::ComponentData>& calculationResult, const EntityIdSet& callerIds);
182  void drawFireChainTextAndChainLinesForSelectedFireComponents(const EntityIdSet& callerIds);
183 
184 
185  //[-------------------------------------------------------]
186  //[ Private data ]
187  //[-------------------------------------------------------]
188  private:
189  FireMaterialManager* mFireMaterialManager;
190  bool mFireSimulationEnabled;
191  float mFireEnergyMultiplier;
192 
193  // Job update
194  qsf::JobProxy mSimulationJobProxy;
195 
196  // Debug
197  qsf::DebugDrawProxy mDebugDrawProxy;
198 
199  // Fire spread simulation
200  FireSpreadCalculation& mFireSpreadCalculation;
201  qsf::Time mPassedUpdateSimulationTime;
202  qsf::Time mUpdateFireSpreadInterval;
203 
204  SimulationVisualisationMode mFireRadiansVisualisationMode;
205  SimulationVisualisationMode mFireSpreadVisualisationMode;
206  FireSpreadLinesVisualisationMode mFireSpreadLinesVisualisationMode;
207  bool mIsFireSpreadPreview;
208  bool mSavedShowFireReceiverDebugFlag;
209  bool mDrawFireReceiverLinesActive;
210  bool mResetFireSystem;
211 
213  std::vector<FireReceiverData> mActiveFireReceivers;
214 
215 
216  //[-------------------------------------------------------]
217  //[ CAMP reflection system ]
218  //[-------------------------------------------------------]
219  QSF_CAMP_RTTI() // Only adds the virtual method "campClassId()", nothing more
220 
221 
222  };
223 
224 
225 //[-------------------------------------------------------]
226 //[ Namespace ]
227 //[-------------------------------------------------------]
228 } // em5
229 
230 
231 //[-------------------------------------------------------]
232 //[ Implementation ]
233 //[-------------------------------------------------------]
234 #include "em5/fire/FireSystem-inl.h"
235 
236 
237 //[-------------------------------------------------------]
238 //[ CAMP reflection system ]
239 //[-------------------------------------------------------]
Definition: ActionPriority.h:13
Job proxy class.
Definition: JobProxy.h:51
SimulationVisualisationMode
Definition: FireSystem.h:71
Fire system.
Definition: FireSystem.h:63
Map class.
Definition: Map.h:93
Definition: FireReceiverComponent.h:50
EMERGENCY 5 fire receiver component class.
Definition: FireReceiverComponent.h:69
#define EM5_API_EXPORT
Definition: Export.h:28
Manager contains all fire materials.
Definition: FireMaterialManager.h:47
Fire material class.
Definition: FireMaterial.h:40
boost::container::flat_set< uint64 > EntityIdSet
Definition: FireSystem.h:85
Job arguments class: holds data to be passed to the called job method by the job manager.
Definition: JobArguments.h:40
Definition: PickupPersonByParamedicAction.h:21
Debug draw proxy class.
Definition: DebugDrawProxy.h:46
Abstract system class.
Definition: System.h:48
#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
FireSpreadLinesVisualisationMode
Definition: FireSystem.h:78
Fire spread calculation helper.
Definition: FireSpreadCalculation.h:74
unsigned char uint8
Definition: PlatformTypes.h:175
Data type for encapsulating time information. It might represents points in time and time spans...
Definition: Time.h:32