Emergency 20 Dokumentation  4.2.0
HealthComponent-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  qsf::game::HealthComponent(prototype),
16  mHealthEnergy(1000.0f),
17  mMaximumHealthEnergy(1000.0f),
18  mLifeEnergy(1000.0f),
19  mMaximumLifeEnergy(1000.0f),
20  mDeathEnergy(100.0f),
21  mMaximumDeathEnergy(100.0f),
22  mState(STATE_HEALTHY),
23  mEnergyChangeThisUpdate(0.0f),
24  mFireDamageThisUpdate(0.0f),
25  mHealthBarShown(StatusOverlayComponent::BAR_TYPE_NONE),
26  mInjury(nullptr),
27  mContamination(Injury::CONTAMINATION_NONE),
28  mInvincible(false),
29  mCanDoContaminationQuickTest(true),
30  mElapsedTimeAfterLastHeatEnergyReceived(qsf::Time::ZERO),
31  mCanSendReceivedHeatEnergyMessage(true),
32  mAttackHintWaitingTime(qsf::Time::ZERO),
33  mHealthIconType(StatusOverlayComponent::STATUS_ICON_UNDEFINED)
34  {
35  // Set all resistances to zero
36  for (int i = 0; i < damagetype::NUM_DAMAGETYPES; ++i)
37  {
38  mResistances[i] = 0.0f;
39  }
40  }
41 
43  {
44  mSpreadInfectionJobProxy.unregister();
45  }
46 
47  inline const Injury* HealthComponent::getInjury() const
48  {
49  return mInjury;
50  }
51 
53  {
54  return (nullptr != mInjury) ? mInjury->getInjuryId() : qsf::getUninitialized<uint32>();
55  }
56 
58  {
59  return mImmunities;
60  }
61 
63  {
64  return mCanDoContaminationQuickTest;
65  }
66 
67  inline void HealthComponent::setCanDoContaminationQuickTest(bool canDoContaminationQuickTest)
68  {
69  mCanDoContaminationQuickTest = canDoContaminationQuickTest;
70  }
71 
72  inline bool HealthComponent::isInvincible() const
73  {
74  return mInvincible;
75  }
76 
77  inline void HealthComponent::setInvincible(bool invincible)
78  {
79  mInvincible = invincible;
80 
81  // In case the persons is invincible, reset all incoming fire damage
82  if (mInvincible)
83  {
84  mFireDamageThisUpdate = 0.0f;
85  mRegenerationBlockedTime = qsf::Time::ZERO;
86  }
87  }
88 
89  inline float HealthComponent::getHealthEnergy() const
90  {
91  return mHealthEnergy;
92  }
93 
95  {
96  return mMaximumHealthEnergy;
97  }
98 
99  inline float HealthComponent::getLifeEnergy() const
100  {
101  return mLifeEnergy;
102  }
103 
105  {
106  return mMaximumLifeEnergy;
107  }
108 
109  inline float HealthComponent::getDeathEnergy() const
110  {
111  return mDeathEnergy;
112  }
113 
115  {
116  return mMaximumDeathEnergy;
117  }
118 
120  {
121  return mState;
122  }
123 
124  inline bool HealthComponent::isHealthy() const
125  {
126  return (mState == STATE_HEALTHY);
127  }
128 
129  inline bool HealthComponent::isInjured() const
130  {
131  return (nullptr != mInjury);
132  }
133 
134  inline bool HealthComponent::isDead() const
135  {
136  return (mState == STATE_DEAD);
137  }
138 
139  inline bool HealthComponent::isMovable() const
140  {
141  // The entity can move on default so return "true"on default
142 
143  // Check the persons condition
144  if (isInjured() || isDead() || isContaminated())
145  {
146  // If the person is unable to move return "false"
147  return false;
148  }
149 
150  // This person is fine so return true
151  return true;
152  }
153 
155  {
156  return (nullptr != mInjury) ? mInjury->getInjuryBitmask() : Injury::InjuryBitmask();
157  }
158 
160  {
161  return mVisualVitalSigns;
162  }
163 
164  inline bool HealthComponent::getIsDrowning() const
165  {
166  return (nullptr != mInjury) ? mInjury->getIsDrowning() : false;
167  }
168 
169  inline bool HealthComponent::getIsKneeing() const
170  {
171  if (mState == HealthComponent::STATE_DEAD)
172  return false;
173 
174  return (nullptr != mInjury) ? mInjury->getIsKneeing() : false;
175  }
176 
178  {
179  return mInternalFlags.isSet(HEALTH_ACTIVE_TREATMENT);
180  }
181 
183  {
184  return mInternalFlags.isSet(HEALTH_ACTIVE_DIAGNOSIS);
185  }
186 
188  {
189  return mInternalFlags.isSet(HEALTH_DIAGNOSIS_COMPLETE);
190  }
191 
192  inline void HealthComponent::setTreatmentActive(bool treatment)
193  {
194  mInternalFlags.set(HEALTH_ACTIVE_TREATMENT, treatment);
195  }
196 
197  inline void HealthComponent::setDiagnosisActive(bool diagnosis)
198  {
199  mInternalFlags.set(HEALTH_ACTIVE_DIAGNOSIS, diagnosis);
200  }
201 
203  {
204  mInternalFlags.set(HEALTH_ACTIVE_MEDICAL_CARE, care);
205  }
206 
207  inline void HealthComponent::setReanimationActive(bool reanimation)
208  {
209  mInternalFlags.set(HEALTH_ACTIVE_REANIMATION, reanimation);
210  }
211 
213  {
214  mInternalFlags.set(HEALTH_DIAGNOSIS_COMPLETE, true);
215  mInternalFlags.set(HEALTH_TREATMENT_COMPLETE, true);
216  mInternalFlags.set(HEALTH_INJURY_HEALED, true);
217  }
218 
220  {
221  // Get the right diagnosis from the injury
222  return (nullptr != mInjury) ? static_cast<uint32>(mInjury->getDiagnosisId()) : qsf::getUninitialized<uint32>();
223  }
224 
226  {
227  return (mContamination != Injury::CONTAMINATION_NONE);
228  }
229 
231  {
232  return mContamination;
233  }
234 
236  {
237  // Condition for cleanup: person is dead
238  return isDead();
239  }
240 
241 
242 //[-------------------------------------------------------]
243 //[ Namespace ]
244 //[-------------------------------------------------------]
245 } // em5
void setDiagnosisActive(bool diagnosis)
Definition: HealthComponent-inl.h:197
InjuryBitmask getInjuryBitmask() const
Definition: ActionPriority.h:13
HealthComponent(qsf::Prototype *prototype)
Constructor.
Definition: HealthComponent-inl.h:14
bool isMovable() const
Definition: HealthComponent-inl.h:139
bool getIsDrowning() const
Return if the person is drowning.
Definition: HealthComponent-inl.h:164
float getMaximumDeathEnergy() const
Definition: HealthComponent-inl.h:114
const ImmunityBitmask & getImmunities() const
Definition: HealthComponent-inl.h:57
bool getCanDoContaminationQuickTest() const
Definition: HealthComponent-inl.h:62
unsigned int uint32
Definition: PlatformTypes.h:181
bool getIsDrowning() const
void setInvincible(bool invincible)
Definition: HealthComponent-inl.h:77
void setReanimationActive(bool reanimantion)
Definition: HealthComponent-inl.h:207
void setTreatmentActive(bool treatment)
Definition: HealthComponent-inl.h:192
void set(ENUM flag)
Set a single flag.
Definition: BitFlagSet.h:172
bool isHealthy() const
Definition: HealthComponent-inl.h:124
void setMedicalCareActive(bool care)
Definition: HealthComponent-inl.h:202
static const Time ZERO
A zero value for time.
Definition: Time.h:40
bool isContaminated() const
Definition: HealthComponent-inl.h:225
bool isSet(ENUM flag) const
Check whether a certain flag is set.
Definition: BitFlagSet.h:103
float getLifeEnergy() const
Definition: HealthComponent-inl.h:99
EMERGENCY 5 visual vital sign class.
Definition: VisualVitalSigns.h:36
EMERGENCY 5 health component class.
Definition: HealthComponent.h:66
virtual ~HealthComponent()
Destructor.
Definition: HealthComponent-inl.h:42
Definition: PickupPersonByParamedicAction.h:21
No contamination.
Definition: Injury.h:69
bool getIsKneeing() const
Return if the person is kneeing due injury.
Definition: HealthComponent-inl.h:169
bool isDiagnosisComplete() const
Definition: HealthComponent-inl.h:187
float getMaximumLifeEnergy() const
Definition: HealthComponent-inl.h:104
void setCanDoContaminationQuickTest(bool canDoContaminationQuickTest)
Definition: HealthComponent-inl.h:67
bool isInvincible() const
Definition: HealthComponent-inl.h:72
uint32 getDiagnosisId() const
Definition: HealthComponent-inl.h:219
VisualVitalSigns & getVisualVitalSigns()
Definition: HealthComponent-inl.h:159
ContaminationType getContaminationType() const
Definition: HealthComponent-inl.h:230
EMERGENCY 5 status overlay component class.
Definition: StatusOverlayComponent.h:44
bool isInjured() const
Definition: HealthComponent-inl.h:129
bool unregister()
Unregister at current job manager.
Definition: JobProxy-inl.h:48
Person is not injured.
Definition: HealthComponent.h:95
uint32 getInjuryId() const
State
Definition: HealthComponent.h:93
Prototype class.
Definition: Prototype.h:100
bool isDead() const
Definition: HealthComponent-inl.h:134
float getHealthEnergy() const
Definition: HealthComponent-inl.h:89
bool isTreatmentActive() const
Definition: HealthComponent-inl.h:177
ContaminationType
Definition: Injury.h:67
float getDeathEnergy() const
Definition: HealthComponent-inl.h:109
bool isReadyForCleanup() const
Check whether this component is ready for cleanup.
Definition: HealthComponent-inl.h:235
void setInjuredHealed()
Definition: HealthComponent-inl.h:212
bool getIsKneeing() const
Injury definition class.
Definition: Injury.h:44
bool isDiagnosisActive() const
Definition: HealthComponent-inl.h:182
Injury::InjuryBitmask getInjuryBitmask() const
Definition: HealthComponent-inl.h:154
const Injury * getInjury() const
Definition: HealthComponent-inl.h:47
Definition: DamageType.h:26
float getMaximumHealthEnergy() const
Definition: HealthComponent-inl.h:94
DiagnosisIdentifier getDiagnosisId() const
State getState() const
Definition: HealthComponent-inl.h:119
uint32 getInjuryId() const
Definition: HealthComponent-inl.h:52
Person is dead.
Definition: HealthComponent.h:98
qsf::BitFlagSet< uint8, InjuryFlags > InjuryBitmask
Definition: Injury.h:64