Add health and damage system under HealthAndDamagePlugin. Entities with a Health component can take damage via entities with a DamageApplied component and can replenish health via entities with HealApplied component
Objective
Fixes #1
To implement a health and damage system that gives entities health, enables the removal of HP from entities, and can query for `Dead' entities
Solution
Created a Health component that tracks an entities maximum and current HP.
To enable damage, I created a Damage component that can be added to an entity to determine how much damage is to be applied. I also created a DamageApplied component that represents how much damage an entity does.
The same pattern is applied for healing (Heal and HealApplied components).
The HealthAndDamage plugin queries for entities that have Heal or Damage components then performs the appropriate calculation.
When an entities current health reaches 0, the Dead tag is applied.
New components
Alive/Dead Components: Pointer components that represent an entities status
Health Component: Component representing entity health that is comprised of the entities max and current health
HealthBundle Bundle: Bundle for all health related components. Added to allow for future additions of features
Damage Component: Component that holds the value for how much damage to apply to an entity
DammageApplied Component: Component that represents how much damage an entity does
DamageBundle Bundle: Bundle for Damage related Components. Added to allow for future addition of features
Heal Component: Component that holds the value for how much health to heal
HealApplied Component: Component that represents how much health an entity can replenish
HealBundle Bundle: Bundle of Heal related components. Added to allow for future addition of features
New systems
HealthAndDamage plugin: Queries for entities with a Heal or Damage tag, performs the calculation, applies the result to the entities, and removes the appropriate tag.
Testing
Tested using the debug plugin
Spawned an entity with 90/100 health, entity that causes 5 damage, entity that causes 2 damage, entity that replenishes 6 health, entity that replenishes 5 health, and an entity that has 0/100 health and is marked as Dead.
Verified that the Alive entities health changes as expected and stops printing once marked as Dead
Add health and damage system under HealthAndDamagePlugin. Entities with a Health component can take damage via entities with a DamageApplied component and can replenish health via entities with HealApplied component
Objective
Fixes #1 To implement a health and damage system that gives entities health, enables the removal of HP from entities, and can query for `Dead' entities
Solution
New components
New systems
Testing