Health (component)#
Component for keeping track of an Entity
’s health,
updating it, and toggling invincibility.
-
class Health : public Component#
Public Functions
-
inline Health(float starter_hp, float max_hp, float rate = 0)#
-
virtual void update() override#
Calls update_hp if m_rate != 0.
-
void update_hp(float damage = 0)#
Updates hp according to rate, deletes entity if hp <= 0.
This function is defined separately of “update” because health updates will most likely comme from collisions rather than the update loop. In this case, it doesn’t make sense to call it all the time.
- Parameters:
damage – Optional damage to inflict (could also be negative which would amount to healing).
-
void set_invincibility(bool value)#
Updating invincibility value.
Private Members
-
bool m_invincible#
Whether the entity is at an invincible state.
-
inline Health(float starter_hp, float max_hp, float rate = 0)#