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, originalModifiers
currentOrder
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
HealthModifier s are applied to HealEntityEvent.getOriginalHealAmount() . |
Map<HealthModifier,Double> |
getOriginalHealingAmounts()
Gets an
Map of all original HealthModifier s 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 HealthModifier s. |
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, recalculateDamages
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getModifiers, getOriginalFunctions, getOriginalHealAmount
getTargetEntity
getCause, getContext, getSource
isCancelled, setCancelled
protected double originalHealAmount
protected List<HealthFunction> originalFunctions
protected double baseHealAmount
protected final void init()
AbstractEvent
This method should be used to initialize any fields that depend on parameters passed to the constructor.
init
in class AbstractEvent
public final double getOriginalHealingModifierAmount(HealthModifier healthModifier)
HealEntityEvent
HealthModifier
.
If the provided HealthModifier
was not included in
HealEntityEvent.getOriginalHealingAmounts()
, an IllegalArgumentException
is thrown.getOriginalHealingModifierAmount
in interface HealEntityEvent
healthModifier
- The original healing modifierpublic final double getOriginalFinalHealAmount()
HealEntityEvent
HealthModifier
s are applied to HealEntityEvent.getOriginalHealAmount()
.
The "final" heal amount is considered the amount gained by the
Entity
, if health is tracked.getOriginalFinalHealAmount
in interface HealEntityEvent
public final Map<HealthModifier,Double> getOriginalHealingAmounts()
HealEntityEvent
Map
of all original HealthModifier
s and their
associated "modified" heal amount. Note that ordering is not retained.getOriginalHealingAmounts
in interface HealEntityEvent
public final double getFinalHealAmount()
HealEntityEvent
HealEntityEvent.getBaseHealAmount()
being
applied in DoubleUnaryOperator.applyAsDouble(double)
available
from all the Tuple
s of HealthModifier
to
DoubleUnaryOperator
in HealEntityEvent.getOriginalFunctions()
.getFinalHealAmount
in interface HealEntityEvent
public final boolean isModifierApplicable(HealthModifier healthModifier)
HealEntityEvent
HealthModifier
is applicable to the
current available HealthModifier
s.isModifierApplicable
in interface HealEntityEvent
healthModifier
- The health modifier to checkpublic final double getHealAmount(HealthModifier healthModifier)
HealEntityEvent
HealthModifier
. Providing
that HealEntityEvent.isModifierApplicable(HealthModifier)
returns
true
, the cached "heal amount" for the
HealthModifier
is returned.getHealAmount
in interface HealEntityEvent
healthModifier
- The heal amount modifier to get the heal amount forpublic final void setHealAmount(HealthModifier healthModifier, DoubleUnaryOperator function)
HealEntityEvent
DoubleUnaryOperator
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 DoubleUnaryOperator
s 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 HealEntityEvent
healthModifier
- The heal amount modifierfunction
- The function to map to the modifierpublic double getBaseHealAmount()
HealEntityEvent
Entity
.
The "base" heal amount is the original value before passing along the
chain of DoubleUnaryOperator
s for all known
HealthModifier
s.getBaseHealAmount
in interface HealEntityEvent
public final void setBaseHealAmount(double baseHealAmount)
HealEntityEvent
Entity
.
The "base" heal amount is the original value passed along the chain of
DoubleUnaryOperator
s for all known HealthModifier
s.setBaseHealAmount
in interface HealEntityEvent
baseHealAmount
- The base heal amountprotected HealthFunction convertTuple(HealthModifier obj, DoubleUnaryOperator function)
convertTuple
in class AbstractModifierEvent<HealthFunction,HealthModifier>