Class Ability

java.lang.Object
de.gurkenlabs.litiengine.abilities.Ability
All Implemented Interfaces:
IRenderable

public abstract class Ability extends Object implements IRenderable
The Ability class represents a special skill or power that a Creature can use in a game. Each ability has a set of effects, attributes, and listeners that define its behavior.
  • Constructor Details

    • Ability

      protected Ability(Creature executor)
      Initializes a new instance of the Ability class.
      Parameters:
      executor - The executing entity
  • Method Details

    • onCast

      public void onCast(Ability.AbilityCastListener listener)
      Adds a listener that will be notified when the ability is cast.
      Parameters:
      listener - The listener to add
    • removeAbilityCastListener

      public void removeAbilityCastListener(Ability.AbilityCastListener listener)
      Removes a listener that was previously added with onCast(de.gurkenlabs.litiengine.abilities.Ability.AbilityCastListener).
      Parameters:
      listener - The listener to remove
    • onEffectApplied

      public void onEffectApplied(Effect.EffectAppliedListener listener)
      Adds a listener that will be notified when an effect of this ability is applied.
      Parameters:
      listener - The listener to add
    • onEffectCeased

      public void onEffectCeased(Effect.EffectCeasedListener listener)
      Adds a listener that will be notified when an effect of this ability ceases.
      Parameters:
      listener - The listener to add
    • addEffect

      public void addEffect(Effect effect)
      Adds an effect to this ability.
      Parameters:
      effect - The effect to add
    • calculateImpactArea

      public Shape calculateImpactArea()
      Calculates the area of impact of this ability based on the executor's angle.
      Returns:
      The shape representing the area of impact
    • calculatePotentialImpactArea

      public Ellipse2D calculatePotentialImpactArea()
      Calculates the potential area of impact of this ability.
      Returns:
      The ellipse representing the potential area of impact
    • canCast

      public boolean canCast()
      Checks if this ability can be cast.
      Returns:
      true if the executor is not dead and the ability is not on cooldown; false otherwise
    • isOnCooldown

      public boolean isOnCooldown()
      Checks if this ability is on cooldown.
      Returns:
      true if the ability is on cooldown; false otherwise
    • cast

      public AbilityExecution cast()
      Casts the ability by the temporal conditions of the specified game loop and the spatial circumstances of the specified environment. An ability execution will be taken out that start applying all the effects of this ability.
      Returns:
      An AbilityExecution object that wraps all information about this execution of the ability.
    • getAttributes

      public AbilityAttributes getAttributes()
      Gets the attributes of this ability.
      Returns:
      The attributes of this ability
    • getCastType

      public CastType getCastType()
      Gets the cast type of this ability.
      Returns:
      The cast type of this ability
    • getCooldownInSeconds

      public float getCooldownInSeconds()
      Gets the cooldown of this ability in seconds.
      Returns:
      The cooldown of this ability in seconds
    • getCurrentExecution

      public AbilityExecution getCurrentExecution()
      Gets the current execution of this ability.
      Returns:
      The current execution of this ability
    • getDescription

      public String getDescription()
      Gets the description of this ability.
      Returns:
      The description of this ability
    • getExecutor

      public Creature getExecutor()
      Gets the executor of this ability.
      Returns:
      The executor of this ability
    • getName

      public String getName()
      Gets the name of this ability.
      Returns:
      The name of this ability
    • getPivot

      public EntityPivot getPivot()
      Gets the pivot of this ability.
      Returns:
      The pivot of this ability
    • getRemainingCooldownInSeconds

      public float getRemainingCooldownInSeconds()
      Gets the remaining cooldown of this ability in seconds.
      Returns:
      The remaining cooldown of this ability in seconds
    • isActive

      public boolean isActive()
      Checks if this ability is active.
      Returns:
      true if the ability is active; false otherwise
    • isMultiTarget

      public boolean isMultiTarget()
      Checks if this ability is multi-target.
      Returns:
      true if the ability is multi-target; false otherwise
    • render

      public void render(Graphics2D g)
      Renders the impact area of this ability.
      Specified by:
      render in interface IRenderable
      Parameters:
      g - The graphics context to render on
      See Also:
    • setName

      public void setName(String name)
      Sets the name of this ability.
      Parameters:
      name - The new name of this ability
    • setDescription

      public void setDescription(String description)
      Sets the description of this ability.
      Parameters:
      description - The new description of this ability
    • setMultiTarget

      public void setMultiTarget(boolean multiTarget)
      Sets whether this ability is multi-target.
      Parameters:
      multiTarget - true if the ability is multi-target; false otherwise
    • setCastType

      public void setCastType(CastType castType)
      Sets the cast type of this ability.
      Parameters:
      castType - The new cast type of this ability
    • getEffects

      public List<Effect> getEffects()
      Gets the effects of this ability.
      Returns:
      The effects of this ability
    • internalCalculateImpactArea

      protected Shape internalCalculateImpactArea(double angle)
      Calculates the impact area of this ability based on the given angle.
      Parameters:
      angle - The angle to calculate the impact area
      Returns:
      The shape representing the impact area