Emergency 20 Dokumentation  4.2.0
TreeComponent.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/asset/AssetProxy.h>
16 #include <qsf/math/EnumBitmask.h>
17 
18 #include <glm/gtc/quaternion.hpp> // For glm::quat
19 
20 
21 //[-------------------------------------------------------]
22 //[ Forward declarations ]
23 //[-------------------------------------------------------]
24 namespace em5
25 {
26  class TreeFallDownAnimation;
27 }
28 
29 
30 //[-------------------------------------------------------]
31 //[ Namespace ]
32 //[-------------------------------------------------------]
33 namespace em5
34 {
35 
36 
37  //[-------------------------------------------------------]
38  //[ Classes ]
39  //[-------------------------------------------------------]
45  {
46 
47 
48  //[-------------------------------------------------------]
49  //[ Friends ]
50  //[-------------------------------------------------------]
51  friend class TreeFallDownAnimation;
52 
53 
54  //[-------------------------------------------------------]
55  //[ Public definitions ]
56  //[-------------------------------------------------------]
57  public:
58  static const uint32 COMPONENT_ID;
59 
60 
61  //[-------------------------------------------------------]
62  //[ Public methods ]
63  //[-------------------------------------------------------]
64  public:
72  inline explicit TreeComponent(qsf::Prototype* prototype);
73 
78  inline virtual ~TreeComponent();
79 
84  void cutTree(qsf::Entity& firefighterEntity);
85 
90  bool isIntact() const;
91 
96  qsf::Entity* getTreeTop();
97 
102  bool getWasCut() const;
103 
111  void setWasCut(bool wasCut);
112 
113 
114  //[-------------------------------------------------------]
115  //[ Public virtual em5::DamageComponent methods ]
116  //[-------------------------------------------------------]
117  public:
125  inline virtual bool isReadyForCleanup() const override;
126 
131  virtual void cleanup() override;
132 
133 
134  //[-------------------------------------------------------]
135  //[ Public virtual qsf::Component methods ]
136  //[-------------------------------------------------------]
137  public:
138  virtual void serialize(qsf::BinarySerializer& serializer) override;
139 
140 
141  //[-------------------------------------------------------]
142  //[ Protected virtual qsf::Component methods ]
143  //[-------------------------------------------------------]
144  protected:
145  virtual void onSetSimulating(bool simulating) override;
146 
147 
148  //[-------------------------------------------------------]
149  //[ Protected virtual em5::DamageComponent methods ]
150  //[-------------------------------------------------------]
151  protected:
152  virtual void onSetIntact() override;
153  virtual void onSetDamagedLevel1() override;
154  virtual void onSetDamagedLevel2() override;
155  virtual void onSetDestroyed() override;
156  virtual void onSetFireLifePercentage(float fireLifePercentage) override;
157  virtual void onFireStarted(FreeplayEvent* freeplayEvent) override;
158 
159  virtual void setCustomParametersForFireGlowAndSmutOverlay(const qsf::MeshComponent& meshComponent) override;
160 
161 
162  //[-------------------------------------------------------]
163  //[ Private methods ]
164  //[-------------------------------------------------------]
165  private:
166  void updateMaterialAndLeafParticles(bool treeParticlesActive) const;
167  void setDamageOverlaysActive(bool smutActive, bool emissiveActive) const;
168  void destroyTreeFallDownAnimation();
169 
170 
171  //[-------------------------------------------------------]
172  //[ Private definition ]
173  //[-------------------------------------------------------]
174  private:
175  enum InternalFlags
176  {
177  TREE_IS_CUT
178  };
179  typedef qsf::EnumBitmask<uint8, InternalFlags> InternalFlagSet;
180 
181 
182  //[-------------------------------------------------------]
183  //[ Private data ]
184  //[-------------------------------------------------------]
185  private:
186  InternalFlagSet mInternalFlags;
187  qsf::JobProxy mFireFadeAnimationJobProxy;
188  bool mTreeParticlesEnabled;
189  glm::quat mInitialChildRotation;
190  TreeFallDownAnimation* mTreeFallDownAnimation;
191 
192 
193  //[-------------------------------------------------------]
194  //[ CAMP reflection system ]
195  //[-------------------------------------------------------]
196  QSF_CAMP_RTTI() // Only adds the virtual method "campClassId()", nothing more
197 
198 
199  };
200 
201 
202 //[-------------------------------------------------------]
203 //[ Namespace ]
204 //[-------------------------------------------------------]
205 } // em5
206 
207 
208 //[-------------------------------------------------------]
209 //[ Implementation ]
210 //[-------------------------------------------------------]
212 
213 
214 //[-------------------------------------------------------]
215 //[ CAMP reflection system ]
216 //[-------------------------------------------------------]
Definition: ActionPriority.h:13
Job proxy class.
Definition: JobProxy.h:51
Entity class.
Definition: Entity.h:46
unsigned int uint32
Definition: PlatformTypes.h:181
EMERGENCY 5 tree fall down animation.
Definition: TreeFallDownAnimation.h:47
#define EM5_API_EXPORT
Definition: Export.h:28
void serialize(BinarySerializer &serializer, BitFlagSet< STORAGE, ENUM > &bitFlagSet)
Definition: BitFlagSet.h:359
#define QSF_CAMP_RTTI()
Only adds the virtual method "campClassId()", nothing more.
Definition: CampClass.h:75
EMERGENCY 5 damage component class.
Definition: DamageComponent.h:49
#define QSF_CAMP_TYPE_NONCOPYABLE(type)
See "CAMP_TYPE_NONCOPYABLE" for details.
Definition: CampClass.h:112
Mesh component class.
Definition: MeshComponent.h:51
Prototype class.
Definition: Prototype.h:100
EMERGENCY 5 tree component class.
Definition: TreeComponent.h:44
Abstract EMERGENCY 5 freeplay event base class.
Definition: FreeplayEvent.h:66
Binary serializer class.
Definition: BinarySerializer.h:35
static const uint32 COMPONENT_ID
"em5::TreeComponent" unique component ID
Definition: TreeComponent.h:58