Class Effect
java.lang.Object
de.gurkenlabs.litiengine.abilities.effects.Effect
- All Implemented Interfaces:
IUpdateable
- Direct Known Subclasses:
AbilityEffect,AttributeEffect,ForceEffect,SoundEffect
The `Effect` class represents an abstract base class for applying effects to combat entities. Effects are applied based on a `TargetingStrategy`
and may affect multiple entities within a defined impact area. Effects are applied for a set duration and may have follow-up effects.
This class handles effect application, event listeners for when effects are applied or ceased, and the management of active appliances (ongoing effect instances).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceListener interface for receiving notifications when an effect is applied.static interfaceListener interface for receiving notifications when an effect ceases. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedEffect(TargetingStrategy targetingStrategy) Constructs a new `Effect` with the specified targeting strategy.protectedEffect(TargetingStrategy targetingStrategy, ICombatEntity executor) Constructs a new `Effect` with the specified targeting strategy and executor.protectedEffect(TargetingStrategy targetingStrategy, ICombatEntity executor, int duration) Constructs a new `Effect` with the specified targeting strategy, executor, and duration. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidapply(ICombatEntity entity) Applies the effect to the specified entity, adding this effect to the entity's list of applied effects and notifying all registered listeners that the effect has been applied.voidApplies the effect to all entities within the specified impact area.protected voidcease(EffectApplication appliance) Ceases the effect for the specified application and applies follow-up effects.voidcease(ICombatEntity entity) Ceases the effect for the specified entity.Returns the list of active effect applications.intgetDelay()Returns the delay before this effect is applied.intReturns the duration this effect lasts once applied.Returns the entity that is executing this effect.Returns the list of follow-up effects that are applied after the main effect ends.Returns the targeting strategy used by this effect.protected longReturns the total duration of the effect, including the delay.protected booleanhasEnded(EffectApplication appliance) Checks if the specified effect application has ended.booleanisActive(ICombatEntity entity) Checks if the effect is active on the specified entity.voidonEffectApplied(Effect.EffectAppliedListener listener) Registers a listener for when the effect is applied.voidonEffectCeased(Effect.EffectCeasedListener listener) Registers a listener for when the effect ceases.voidvoidvoidsetDelay(int delay) Sets the delay before this effect is applied.voidsetDuration(int duration) Sets the duration this effect lasts once applied.voidupdate()Updates the effect, checking for appliances that have reached their duration and applying follow-up effects if needed.
-
Constructor Details
-
Effect
Constructs a new `Effect` with the specified targeting strategy.- Parameters:
targetingStrategy- The strategy used to target entities for this effect.
-
Effect
Constructs a new `Effect` with the specified targeting strategy and executor.- Parameters:
targetingStrategy- The strategy used to target entities for this effect.executor- The entity applying the effect, or null if none.
-
Effect
Constructs a new `Effect` with the specified targeting strategy, executor, and duration.- Parameters:
targetingStrategy- The strategy used to target entities for this effect.executor- The entity applying the effect, or null if none.duration- The duration the effect will last.
-
-
Method Details
-
onEffectApplied
Registers a listener for when the effect is applied.- Parameters:
listener- The listener to register.
-
removeEffectAppliedListener
-
onEffectCeased
Registers a listener for when the effect ceases.- Parameters:
listener- The listener to register.
-
removeEffectCeasedListener
-
apply
Applies the effect to all entities within the specified impact area.- Parameters:
impactArea- The area where the effect is applied.
-
cease
Ceases the effect for the specified entity.- Parameters:
entity- The entity for which the effect will cease.
-
getExecutingEntity
Returns the entity that is executing this effect.- Returns:
- The executor of this effect.
-
getActiveAppliances
Returns the list of active effect applications.- Returns:
- The list of active effect applications.
-
getDelay
public int getDelay()Returns the delay before this effect is applied.- Returns:
- The delay in ticks.
-
getDuration
public int getDuration()Returns the duration this effect lasts once applied.- Returns:
- The effect duration in ticks.
-
getTargetingStrategy
Returns the targeting strategy used by this effect.- Returns:
- The targeting strategy.
-
getFollowUpEffects
-
isActive
Checks if the effect is active on the specified entity.- Parameters:
entity- The entity to check.- Returns:
- True if the effect is active on the entity, false otherwise.
-
setDelay
public void setDelay(int delay) Sets the delay before this effect is applied.- Parameters:
delay- the delay in ticks
-
setDuration
public void setDuration(int duration) Sets the duration this effect lasts once applied.- Parameters:
duration- the effect duration in ticks
-
update
public void update()Updates the effect, checking for appliances that have reached their duration and applying follow-up effects if needed. Removes appliances that have ended and detaches the effect from the game loop if no active appliances remain.- Specified by:
updatein interfaceIUpdateable- See Also:
-
apply
Applies the effect to the specified entity, adding this effect to the entity's list of applied effects and notifying all registered listeners that the effect has been applied.- Parameters:
entity- the entity to which the effect is applied
-
cease
Ceases the effect for the specified application and applies follow-up effects.- Parameters:
appliance- The application to cease.
-
getTotalDuration
protected long getTotalDuration()Returns the total duration of the effect, including the delay.- Returns:
- The total effect duration.
-
hasEnded
Checks if the specified effect application has ended.- Parameters:
appliance- The application to check.- Returns:
- True if the effect duration has passed, false otherwise.
-