Emergency 20 Dokumentation  4.2.0
ExtinguishFireAction.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/audio/AudioProxy.h"
14 
16 
17 
18 //[-------------------------------------------------------]
19 //[ Forward declarations ]
20 //[-------------------------------------------------------]
21 namespace em5
22 {
23  class FireReceiverComponent;
24  class FireComponent;
25  class WaterCannonComponent;
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:
52 
53  enum State
54  {
57  STATE_EXTINGUISH
58  };
59 
60 
61  //[-------------------------------------------------------]
62  //[ Public methods ]
63  //[-------------------------------------------------------]
64  public:
70 
75  virtual ~ExtinguishFireAction();
76 
81  void init(const qsf::Entity& targetEntity, float extinguishPower, float coolingPower);
82 
83  uint64 getTargetEntityId() const;
84 
85  void setAutoSearchNewTarget(bool enable) { mAutoSearchNewTarget = enable; }
86 
87 
88  //[-------------------------------------------------------]
89  //[ Public virtual qsf::Actions methods ]
90  //[-------------------------------------------------------]
91  public:
92  virtual void serialize(qsf::BinarySerializer& serializer) override;
93 
94 
95  //[-------------------------------------------------------]
96  //[ Protected virtual qsf::Action methods ]
97  //[-------------------------------------------------------]
98  protected:
99  virtual bool onStartup() override;
100  virtual void onShutdown() override;
101  virtual qsf::action::Result updateAction(const qsf::Clock& clock) override;
102 
103 
104  //[-------------------------------------------------------]
105  //[ Private methods ]
106  //[-------------------------------------------------------]
107  private:
108  void startExtinguishEffect();
109  void stopExtinguishEffect();
110  qsf::Entity* createExtinguisherEffectEntity() const;
111  qsf::Entity* createWaterJetEffectEntity();
112  void linkEffectEntity(qsf::Entity& effectEntity);
113  FireReceiverComponent* getFireComponentFromTarget();
114  FireComponent* searchNewTargetInRange();
115  uint64 getTargetIdForLinkingEffectEntity();
116  void pushExtinguishAction(FireComponent& fireTarget) const;
117  WaterCannonComponent* getWaterCannonComponent() const;
118  bool isTargetInExtinguishRange(qsf::Entity& targetEntity, const glm::vec3& callerPosition) const;
119 
120 
121  //[-------------------------------------------------------]
122  //[ Private data ]
123  //[-------------------------------------------------------]
124  private:
125  // Configuration
126  uint64 mTargetEntityId;
127  float mExtinguishPower;
128  float mCoolingPower;
129  bool mTargetIsBurning;
130  uint64 mEffectEntityId;
131  uint64 mOpticalTargetEntityId;
132  State mState;
133  float mMaxExtinguishRange;
134  bool mAutoSearchNewTarget;
135 
136  // Internal
137  AudioProxy mAudioProxy;
138 
139 
140  //[-------------------------------------------------------]
141  //[ CAMP reflection system ]
142  //[-------------------------------------------------------]
143  QSF_CAMP_RTTI() // Only adds the virtual method "campClassId()", nothing more
144 
145 
146  };
147 
148 
149 //[-------------------------------------------------------]
150 //[ Namespace ]
151 //[-------------------------------------------------------]
152 } // em5
153 
154 
155 //[-------------------------------------------------------]
156 //[ CAMP reflection system ]
157 //[-------------------------------------------------------]
Definition: ActionPriority.h:13
Definition: ExtinguishFireAction.h:56
Entity class.
Definition: Entity.h:46
State
Definition: ExtinguishFireAction.h:53
EMERGENCY 5 fire receiver component class.
Definition: FireReceiverComponent.h:69
Clock class.
Definition: Clock.h:33
#define EM5_API_EXPORT
Definition: Export.h:28
void setAutoSearchNewTarget(bool enable)
Definition: ExtinguishFireAction.h:85
Definition: ExtinguishFireAction.h:55
EMERGENCY 5 fire component class.
Definition: FireComponent.h:64
uint64_t uint64
Definition: PlatformTypes.h:184
void serialize(BinarySerializer &serializer, BitFlagSet< STORAGE, ENUM > &bitFlagSet)
Definition: BitFlagSet.h:359
EMERGENCY 5 extinguish fire action.
Definition: ExtinguishFireAction.h:43
State
Definition: ProcessState.h:20
#define QSF_CAMP_RTTI()
Only adds the virtual method "campClassId()", nothing more.
Definition: CampClass.h:75
Extended audio proxy for easier multiplay usage.
Definition: AudioProxy.h:47
#define QSF_CAMP_TYPE_NONCOPYABLE(type)
See "CAMP_TYPE_NONCOPYABLE" for details.
Definition: CampClass.h:112
Abstract action base class.
Definition: Action.h:59
Class combining strings with their hashes.
Definition: NamedIdentifier.h:34
static const qsf::NamedIdentifier ACTION_ID
"em5::ExtinguishFireAction" unique action identifier
Definition: ExtinguishFireAction.h:51
Binary serializer class.
Definition: BinarySerializer.h:35
Result
Definition: ActionResult.h:20
EMERGENCY 5 water cannon component. Consists in a cannon part with this component and an optional can...
Definition: WaterCannonComponent.h:43