Class Ability
java.lang.Object
de.gurkenlabs.litiengine.abilities.Ability
- All Implemented Interfaces:
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.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceTheAbilityCastListenerinterface defines a method for listening to ability cast events. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds an effect to this ability.Calculates the area of impact of this ability based on the executor's angle.Calculates the potential area of impact of this ability.booleancanCast()Checks if this ability can be cast.cast()Casts the ability by the temporal conditions of the specified game loop and the spatial circumstances of the specified environment.Gets the attributes of this ability.Gets the cast type of this ability.floatGets the cooldown of this ability in seconds.Gets the current execution of this ability.Gets the description of this ability.Gets the effects of this ability.Gets the executor of this ability.getName()Gets the name of this ability.getPivot()Gets the pivot of this ability.floatGets the remaining cooldown of this ability in seconds.protected ShapeinternalCalculateImpactArea(double angle) Calculates the impact area of this ability based on the given angle.booleanisActive()Checks if this ability is active.booleanChecks if this ability is multi-target.booleanChecks if this ability is on cooldown.voidonCast(Ability.AbilityCastListener listener) Adds a listener that will be notified when the ability is cast.voidonEffectApplied(Effect.EffectAppliedListener listener) Adds a listener that will be notified when an effect of this ability is applied.voidonEffectCeased(Effect.EffectCeasedListener listener) Adds a listener that will be notified when an effect of this ability ceases.voidRemoves a listener that was previously added withonCast(de.gurkenlabs.litiengine.abilities.Ability.AbilityCastListener).voidrender(Graphics2D g) Renders the impact area of this ability.voidsetCastType(CastType castType) Sets the cast type of this ability.voidsetDescription(String description) Sets the description of this ability.voidsetMultiTarget(boolean multiTarget) Sets whether this ability is multi-target.voidSets the name of this ability.
-
Constructor Details
-
Ability
Initializes a new instance of theAbilityclass.- Parameters:
executor- The executing entity
-
-
Method Details
-
onCast
Adds a listener that will be notified when the ability is cast.- Parameters:
listener- The listener to add
-
removeAbilityCastListener
Removes a listener that was previously added withonCast(de.gurkenlabs.litiengine.abilities.Ability.AbilityCastListener).- Parameters:
listener- The listener to remove
-
onEffectApplied
Adds a listener that will be notified when an effect of this ability is applied.- Parameters:
listener- The listener to add
-
onEffectCeased
Adds a listener that will be notified when an effect of this ability ceases.- Parameters:
listener- The listener to add
-
addEffect
Adds an effect to this ability.- Parameters:
effect- The effect to add
-
calculateImpactArea
Calculates the area of impact of this ability based on the executor's angle.- Returns:
- The shape representing the area of impact
-
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:
trueif the executor is not dead and the ability is not on cooldown;falseotherwise
-
isOnCooldown
public boolean isOnCooldown()Checks if this ability is on cooldown.- Returns:
trueif the ability is on cooldown;falseotherwise
-
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
AbilityExecutionobject that wraps all information about this execution of the ability.
-
getAttributes
Gets the attributes of this ability.- Returns:
- The attributes of this ability
-
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
Gets the current execution of this ability.- Returns:
- The current execution of this ability
-
getDescription
Gets the description of this ability.- Returns:
- The description of this ability
-
getExecutor
Gets the executor of this ability.- Returns:
- The executor of this ability
-
getName
Gets the name of this ability.- Returns:
- The name of this ability
-
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:
trueif the ability is active;falseotherwise
-
isMultiTarget
public boolean isMultiTarget()Checks if this ability is multi-target.- Returns:
trueif the ability is multi-target;falseotherwise
-
render
Renders the impact area of this ability.- Specified by:
renderin interfaceIRenderable- Parameters:
g- The graphics context to render on- See Also:
-
setName
Sets the name of this ability.- Parameters:
name- The new name of this ability
-
setDescription
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-trueif the ability is multi-target;falseotherwise
-
setCastType
Sets the cast type of this ability.- Parameters:
castType- The new cast type of this ability
-
getEffects
Gets the effects of this ability.- Returns:
- The effects of this ability
-
internalCalculateImpactArea
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
-