Client and backend. This class is shared: the same code is compiled into your app and into your server, so everything on this page works in both.

public abstract class Ability

  1. Object
  2. Ability

Known subtypesCrouchAbility, DashAbility, FlyAbility, GlideAbility, GripAbility, JetpackAbility, JumpAbility, LadderAbility, LookAbility, MoveAbility, SwimAbility, WallJumpAbility, WeaponAbility

One thing a Actor can do – walk, jump, dash, climb – as a small, separately tunable unit, in the manner of Corgi Engine’s character abilities.

An actor runs its abilities in the order they were added, three times a tick: earlyProcess before anything moves, process to set velocity and state, and lateProcess after the body has moved and its contacts are known. Order matters where two abilities read the same button: an ability that consumes the jump press (a wall jump, a ladder jump) belongs before JumpAbility.

Abilities must be deterministic: they read only the actor, the world and the tick’s input, use Fx arithmetic and the world’s Rng, and keep their state in fields so Actor#hash can fold it in through hashState.

Constructors

public Ability()

Methods

public boolean isEnabled()Whether the ability runs.
public void setEnabled(boolean enabled)Enables or disables the ability.
public void earlyProcess(Actor c, PlatformWorld world)Runs before any ability sets velocity: timers and input edges.
public abstract void process(Actor c, PlatformWorld world)Sets velocity and claims a MovementState.
public void reset()Forgets what the ability was in the middle of, when its actor respawns: a dash, a buffered jump or a grip does not outlive a death.
public void lateProcess(Actor c, PlatformWorld world)Runs after the body moved, with the new contacts.
public long hashState(long h)Mixes the ability’s own state into a hash, so two runs that diverge inside an ability are caught.
protected static long mix(long h, long v)FNV-1a step used by hashState implementations.

Inherited methods

Constructor details

Ability

public Ability()

Method details

isEnabled

public boolean isEnabled()
Whether the ability runs. A disabled ability is skipped, which is how a power-up grants it mid-level.

Returns

true when enabled

setEnabled

public void setEnabled(boolean enabled)
Enables or disables the ability.

Parameters

enabled boolean
true to run it

earlyProcess

public void earlyProcess(Actor c, PlatformWorld world)
Runs before any ability sets velocity: timers and input edges.

Parameters

c Actor
the actor
world PlatformWorld
the world

process

public abstract void process(Actor c, PlatformWorld world)
Sets velocity and claims a MovementState.

Parameters

c Actor
the actor
world PlatformWorld
the world

reset

public void reset()
Forgets what the ability was in the middle of, when its actor respawns: a dash, a buffered jump or a grip does not outlive a death. The default does nothing; an ability with per-run state overrides it.

lateProcess

public void lateProcess(Actor c, PlatformWorld world)
Runs after the body moved, with the new contacts.

Parameters

c Actor
the actor
world PlatformWorld
the world

hashState

public long hashState(long h)
Mixes the ability’s own state into a hash, so two runs that diverge inside an ability are caught. The default mixes nothing.

Parameters

h long
the running hash

Returns

the updated hash

mix

protected static long mix(long h, long v)
FNV-1a step used by hashState implementations.

Parameters

h long
the running hash
v long
the value to mix in

Returns

the updated hash