HealthComponent class
Health component - HP system
Constructors
- HealthComponent({required double maxHealth, double? health, bool isInvulnerable = false})
- Create a health component
Properties
- componentType → Type
-
Type identifier for this component
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- health ↔ double
-
Current health
getter/setter pair
- healthPercent → double
-
Get health percentage (0 to 1)
no setter
- isAlive → bool
-
Check if alive
no setter
- isDead → bool
-
Check if dead
no setter
- isInvulnerable ↔ bool
-
Is entity invulnerable
getter/setter pair
- maxHealth ↔ double
-
Maximum health
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
damage(
double amount) → void - Damage the entity
-
heal(
double amount) → void - Heal the entity
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
reset(
) → void - Reset to full health
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited