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
- Object
- 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()Returns
setEnabled
public void setEnabled(boolean enabled)Parameters
enabledboolean- true to run it
earlyProcess
public void earlyProcess(Actor c, PlatformWorld world)Parameters
cActor- the actor
worldPlatformWorld- the world
process
public abstract void process(Actor c, PlatformWorld world)MovementState.Parameters
cActor- the actor
worldPlatformWorld- the world
reset
public void reset()lateProcess
public void lateProcess(Actor c, PlatformWorld world)Parameters
cActor- the actor
worldPlatformWorld- the world
hashState
public long hashState(long h)Parameters
hlong- the running hash
Returns
mix
protected static long mix(long h, long v)hashState implementations.Parameters
hlong- the running hash
vlong- the value to mix in