Class ForceEffect
java.lang.Object
de.gurkenlabs.litiengine.abilities.effects.Effect
de.gurkenlabs.litiengine.abilities.effects.ForceEffect
- All Implemented Interfaces:
IUpdateable
The `ForceEffect` represents an effect that applies a physical force to mobile entities.
It extends the `Effect` class and is used to manipulate the movement of entities based on the applied force,
such as knockbacks or pulls.
This effect can be applied to entities that implement the `IMobileEntity` interface. The `ForceEffect` uses a targeting strategy to determine which entities are affected and applies a force with a given strength to them.
-
Nested Class Summary
Nested classes/interfaces inherited from class de.gurkenlabs.litiengine.abilities.effects.Effect
Effect.EffectAppliedListener, Effect.EffectCeasedListener -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedForceEffect(TargetingStrategy targetingStrategy, float strength) Constructs a new `ForceEffect` with the specified targeting strategy and force strength.protectedForceEffect(TargetingStrategy targetingStrategy, ICombatEntity executingEntity, float strength) Constructs a new `ForceEffect` with the specified targeting strategy, executing entity, and force strength. -
Method Summary
Modifier and TypeMethodDescriptionvoidapply(ICombatEntity affectedEntity) Applies the effect to a specified combat entity.voidcease(ICombatEntity entity) Stops the effect on a specified entity.protected abstract ForcecreateForce(IMobileEntity affectedEntity) Abstract method that must be implemented to define how the force is created for each entity.floatGets the strength of the applied force.protected booleanhasEnded(EffectApplication appliance) Checks whether the effect has ended.Methods inherited from class de.gurkenlabs.litiengine.abilities.effects.Effect
apply, cease, getActiveAppliances, getDelay, getDuration, getExecutingEntity, getFollowUpEffects, getTargetingStrategy, getTotalDuration, isActive, onEffectApplied, onEffectCeased, removeEffectAppliedListener, removeEffectCeasedListener, setDelay, setDuration, update
-
Constructor Details
-
ForceEffect
Constructs a new `ForceEffect` with the specified targeting strategy and force strength.- Parameters:
targetingStrategy- The strategy used to select which entities will be affected by the effect.strength- The strength of the applied force.
-
ForceEffect
protected ForceEffect(TargetingStrategy targetingStrategy, ICombatEntity executingEntity, float strength) Constructs a new `ForceEffect` with the specified targeting strategy, executing entity, and force strength.- Parameters:
targetingStrategy- The strategy used to select which entities will be affected by the effect.executingEntity- The entity executing the effect (e.g., a player or NPC).strength- The strength of the applied force.
-
-
Method Details
-
apply
Applies the effect to a specified combat entity. If the affected entity is mobile, a force is created and applied to manipulate its movement. The applied force is stored in a map for later reference. -
getStrength
public float getStrength()Gets the strength of the applied force.- Returns:
- The force strength.
-
createForce
Abstract method that must be implemented to define how the force is created for each entity.- Parameters:
affectedEntity- The mobile entity to which the force is applied.- Returns:
- The created `Force` object representing the force to be applied.
-
cease
Stops the effect on a specified entity. If a force was applied to the entity, it is ended and removed from the map tracking applied forces. -
hasEnded
Checks whether the effect has ended. The effect is considered ended if it has naturally ended according to its duration, or if all forces applied have ended.
-