Emergency 20 Dokumentation  4.2.0
DamageComponent-inl.h
Go to the documentation of this file.
1 // Copyright (C) 2012-2018 Promotion Software GmbH
2 
3 
4 //[-------------------------------------------------------]
5 //[ Namespace ]
6 //[-------------------------------------------------------]
7 namespace em5
8 {
9 
10 
11  //[-------------------------------------------------------]
12  //[ Public methods ]
13  //[-------------------------------------------------------]
15  Component(prototype),
16  mPeakFireEnergyPercent(0.0f),
17  mDamageState(DAMAGESTATE_INTACT),
18  mFireGlowIntensity(1.0f),
19  mFireLifePercentage(1.0f),
20  mIsDamageSimulationActive(true),
21  mEmissiveMapStrength(0.0f)
22  {
23  // Nothing to do in here
24  }
25 
27  {
28  // Nothing to do in here
29  }
30 
32  {
33  return mDamageState;
34  }
35 
37  {
38  return mFireGlowIntensity;
39  }
40 
41  inline void DamageComponent::setFireGlowIntensity(float fireGlowIntensity)
42  {
43  if (mFireGlowIntensity != fireGlowIntensity)
44  {
45  mFireGlowIntensity = fireGlowIntensity;
46  if (isRunning())
47  {
49  }
50  }
51  }
52 
54  {
55  return mIsDamageSimulationActive;
56  }
57 
58  inline void DamageComponent::setDamageSimulation(bool damageSimulation)
59  {
60  assignAndPromoteChange(mIsDamageSimulationActive, damageSimulation, DAMAGE_SIMULATION);
61  }
62 
64  {
65  return mFireLifePercentage;
66  }
67 
68 
69  //[-------------------------------------------------------]
70  //[ Public virtual em5::DamageComponent methods ]
71  //[-------------------------------------------------------]
72  inline bool DamageComponent::isIntact() const
73  {
74  return (mDamageState == DAMAGESTATE_INTACT);
75  }
76 
77  inline bool DamageComponent::isDamaged() const
78  {
79  return (mDamageState != DAMAGESTATE_INTACT && mDamageState != DAMAGESTATE_DESTROYED);
80  }
81 
83  {
84  return (mDamageState == DAMAGESTATE_DAMAGE_LEVEL1);
85  }
86 
88  {
89  return (mDamageState == DAMAGESTATE_DAMAGE_LEVEL2);
90  }
91 
92  inline bool DamageComponent::isDestroyed() const
93  {
94  return (mDamageState == DAMAGESTATE_DESTROYED);
95  }
96 
97  inline bool DamageComponent::isBurning() const
98  {
99  return (nullptr != getBurningFireComponent());
100  }
101 
103  {
104  const DamageState currentDamageState = getDamageState();
105  return (currentDamageState != DamageState::DAMAGESTATE_INTACT);
106  }
107 
108 
109  //[-------------------------------------------------------]
110  //[ Protected virtual em5::DamageComponent methods ]
111  //[-------------------------------------------------------]
113  {
114  // Default implementation is empty
115  }
116 
118  {
119  // Default implementation is empty
120  }
121 
123  {
124  // Default implementation is empty
125  }
126 
128  {
129  // Default implementation is empty
130  }
131 
133  {
134  // Default implementation is empty
135  }
136 
138  {
139  // Default implementation is empty
140  }
141 
143  {
144  // Default implementation is empty
145  }
146 
148  {
149  // Default implementation is empty
150  }
151 
152 
153 //[-------------------------------------------------------]
154 //[ Namespace ]
155 //[-------------------------------------------------------]
156 } // em5
DamageState getDamageState() const
Definition: DamageComponent-inl.h:31
Definition: ActionPriority.h:13
virtual void setCustomParametersForFireGlowAndSmutOverlay(const qsf::MeshComponent &meshComponent)
virtual bool isDamagedLevel1() const
Definition: DamageComponent-inl.h:82
void setFireGlowIntensity(float fireGlowIntensity)
Definition: DamageComponent-inl.h:41
Abstract component class.
Definition: Component.h:105
virtual void onSetDamagedLevel1()
Definition: DamageComponent-inl.h:122
virtual bool isDamagedLevel2() const
Definition: DamageComponent-inl.h:87
const FireComponent * getBurningFireComponent() const
Helper function to retrieve a burning FireComponent with the highest energy.
DamageComponent(qsf::Prototype *prototype)
Constructor.
Definition: DamageComponent-inl.h:14
virtual void onFireDamageReceived(float amount, qsf::Component *sender, bool damageJustStarted)
Definition: DamageComponent-inl.h:147
float getFireGlowIntensity() const
Definition: DamageComponent-inl.h:36
virtual ~DamageComponent()
Destructor.
Definition: DamageComponent-inl.h:26
virtual void onSetDamageState(DamageState damageState)
Definition: DamageComponent-inl.h:112
virtual void onSetFireLifePercentage(float fireLifePercentage)
Definition: DamageComponent-inl.h:137
virtual void onSetDestroyed()
Definition: DamageComponent-inl.h:132
virtual bool isDestroyed() const
Definition: DamageComponent-inl.h:92
bool isRunning() const
Return whether or not the component is up-and-running.
Definition: Component-inl.h:67
EMERGENCY 5 fire component class.
Definition: FireComponent.h:64
bool getDamageSimulation() const
Definition: DamageComponent-inl.h:53
virtual bool isDamaged() const
Definition: DamageComponent-inl.h:77
Definition: DamageComponent.h:72
virtual void onSetIntact()
Definition: DamageComponent-inl.h:117
Definition: DamageComponent.h:74
void setDamageSimulation(bool damageSimulation)
Definition: DamageComponent-inl.h:58
static const uint32 DAMAGE_SIMULATION
"DamageSimulation" unique class property ID inside the class
Definition: DamageComponent.h:67
Definition: DamageComponent.h:73
Prototype class.
Definition: Prototype.h:100
virtual void onSetDamagedLevel2()
Definition: DamageComponent-inl.h:127
float getFireLifePercentage() const
Definition: DamageComponent-inl.h:63
virtual bool isBurning() const
Definition: DamageComponent-inl.h:97
Definition: DamageComponent.h:75
DamageState
Definition: DamageComponent.h:70
bool assignAndPromoteChange(T &variable, const S &newValue, uint32 propertyId)
Comfort function for updating an exported member variable and promoting any change that happened...
Definition: Component-inl.h:141
virtual bool isIntact() const
Definition: DamageComponent-inl.h:72
virtual bool isReadyForCleanup() const
Definition: DamageComponent-inl.h:102
virtual void onExplosion(FireComponent *fireComponent)
Definition: DamageComponent-inl.h:142