Package name.moore.kevin.ze.components
Class health
java.lang.Object
name.moore.kevin.ze.components.health
- All Implemented Interfaces:
com.simsilica.es.EntityComponent
A component that tracks the health of an entity. Having this component means
it is damageable.
The more damage an entity has, the less effective it becomes.
- Author:
- Kevin Moore
<dev@kevin.moore.name>
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic doubleprivate doubleHow damageable is this entity going to be.private javax.measure.Measure<Double,javax.measure.quantity.Dimensionless>Health as a percentage. -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
FRAGILE_DEFAULT
public static double FRAGILE_DEFAULT -
health
Health as a percentage. 100 is full health. -
fragility
private double fragilityHow damageable is this entity going to be. A high fragility means it will be damaged in preference to a less fragile entity. Assume this is 0 -> 10 (highly fragile), defaults to 5.
-
-
Constructor Details
-
health
public health()Default new health component with default 100% health, moderate fragility. -
health
The health is from 0 to 100, values outside this range are cropped.- Parameters:
s- a percentage healthf- fragility 0->10
-
-
Method Details
-
setHealth
- Parameters:
h-
-
minus
public javax.measure.Measure<Double,javax.measure.quantity.Dimensionless> minus(javax.measure.Measure<Double,javax.measure.quantity.Dimensionless> loss)- Parameters:
loss- percentage amount to reduce by - clamped to 100%- Returns:
- updated health
-
getHealth
The health can be returned in different formats:getHealth().getValue() = real number eg 76.1 getHealth().doubleValue(Unit.ONE) = decimal eg 0.761- Returns:
- health as a Double
-
getFragility
public double getFragility() -
toString
-