public abstract class AbstractHealEntityEvent extends AbstractModifierEvent<HealthFunction,HealthModifier> implements HealEntityEvent
| Modifier and Type | Field and Description |
|---|---|
protected double |
baseHealAmount |
protected List<HealthFunction> |
originalFunctions |
protected double |
originalHealAmount |
modifierFunctions, modifiers, originalFinalAmount, originalModifierMap, originalModifierscurrentOrder| Constructor and Description |
|---|
AbstractHealEntityEvent() |
| Modifier and Type | Method and Description |
|---|---|
protected HealthFunction |
convertTuple(HealthModifier obj,
DoubleUnaryOperator function) |
double |
getBaseHealAmount()
Gets the "base" healing amount to apply to the targeted
Entity. |
double |
getFinalHealAmount()
Gets the final heal amount that will be applied to the entity.
|
double |
getHealAmount(HealthModifier healthModifier)
Gets the heal amount for the provided
HealthModifier. |
double |
getOriginalFinalHealAmount()
Gets the original "final" amount of healing after all original
HealthModifiers are applied to HealEntityEvent.getOriginalHealAmount(). |
Map<HealthModifier,Double> |
getOriginalHealingAmounts()
Gets an
Map of all original HealthModifiers and their
associated "modified" heal amount. |
double |
getOriginalHealingModifierAmount(HealthModifier healthModifier)
Gets the original healing amount for the provided
HealthModifier. |
protected void |
init()
Called once all fields have been set by the generated
constructor in a subclass.
|
boolean |
isModifierApplicable(HealthModifier healthModifier)
Checks whether the provided
HealthModifier is applicable to the
current available HealthModifiers. |
void |
setBaseHealAmount(double baseHealAmount)
Sets the "base" healing amount to apply to the targeted
Entity. |
void |
setHealAmount(HealthModifier healthModifier,
DoubleUnaryOperator function)
Sets the provided
DoubleUnaryOperator to be used for the given
HealthModifier. |
getFinalAmount, getModifiers, init, recalculateDamagesclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetModifiers, getOriginalFunctions, getOriginalHealAmountgetTargetEntitygetCause, getContext, getSourceisCancelled, setCancelledprotected double originalHealAmount
protected List<HealthFunction> originalFunctions
protected double baseHealAmount
protected final void init()
AbstractEventThis method should be used to initialize any fields that depend on parameters passed to the constructor.
init in class AbstractEventpublic final double getOriginalHealingModifierAmount(HealthModifier healthModifier)
HealEntityEventHealthModifier.
If the provided HealthModifier was not included in
HealEntityEvent.getOriginalHealingAmounts(), an IllegalArgumentException
is thrown.getOriginalHealingModifierAmount in interface HealEntityEventhealthModifier - The original healing modifierpublic final double getOriginalFinalHealAmount()
HealEntityEventHealthModifiers are applied to HealEntityEvent.getOriginalHealAmount().
The "final" heal amount is considered the amount gained by the
Entity, if health is tracked.getOriginalFinalHealAmount in interface HealEntityEventpublic final Map<HealthModifier,Double> getOriginalHealingAmounts()
HealEntityEventMap of all original HealthModifiers and their
associated "modified" heal amount. Note that ordering is not retained.getOriginalHealingAmounts in interface HealEntityEventpublic final double getFinalHealAmount()
HealEntityEventHealEntityEvent.getBaseHealAmount() being
applied in DoubleUnaryOperator.applyAsDouble(double) available
from all the Tuples of HealthModifier to
DoubleUnaryOperator in HealEntityEvent.getOriginalFunctions().getFinalHealAmount in interface HealEntityEventpublic final boolean isModifierApplicable(HealthModifier healthModifier)
HealEntityEventHealthModifier is applicable to the
current available HealthModifiers.isModifierApplicable in interface HealEntityEventhealthModifier - The health modifier to checkpublic final double getHealAmount(HealthModifier healthModifier)
HealEntityEventHealthModifier. Providing
that HealEntityEvent.isModifierApplicable(HealthModifier) returns
true, the cached "heal amount" for the
HealthModifier is returned.getHealAmount in interface HealEntityEventhealthModifier - The heal amount modifier to get the heal amount forpublic final void setHealAmount(HealthModifier healthModifier, DoubleUnaryOperator function)
HealEntityEventDoubleUnaryOperator to be used for the given
HealthModifier. If the HealthModifier is already included
in HealEntityEvent.getModifiers(), the DoubleUnaryOperator replaces the
existing function. If there is no HealthFunction for the
HealthModifier, a new one is created and added to the end of the
list of DoubleUnaryOperators to be applied to the
HealEntityEvent.getBaseHealAmount().
If needing to create a custom HealthModifier is required,
usage of the
HealthModifier.Builder
is recommended.
setHealAmount in interface HealEntityEventhealthModifier - The heal amount modifierfunction - The function to map to the modifierpublic double getBaseHealAmount()
HealEntityEventEntity.
The "base" heal amount is the original value before passing along the
chain of DoubleUnaryOperators for all known
HealthModifiers.getBaseHealAmount in interface HealEntityEventpublic final void setBaseHealAmount(double baseHealAmount)
HealEntityEventEntity.
The "base" heal amount is the original value passed along the chain of
DoubleUnaryOperators for all known HealthModifiers.setBaseHealAmount in interface HealEntityEventbaseHealAmount - The base heal amountprotected HealthFunction convertTuple(HealthModifier obj, DoubleUnaryOperator function)
convertTuple in class AbstractModifierEvent<HealthFunction,HealthModifier>