AnimatorMachine
Since 0.6
Signature
export class AnimatorMachine {
readonly label: string
readonly initial: string
readonly states: Map<string, AnimState>
readonly interruptBlends: boolean
current: string
blend: BlendInfo | null = null
constructor(component: AnimatorComponent, opts: AnimatorOptions = {})
get stateNames(): string[]
get blending(): boolean
get blendRemaining(): number
get deferring(): boolean
get deferredEvent(): string | null
has(state: string): boolean
state(name: string): AnimState | null
transitionFor(event: string, from = this.current): AnimTransition | null
start(animator: Animator | null): string
send(event: string, animator: Animator | null): boolean
goTo(state: string, animator: Animator | null, blend = 0): void
update(dt: number, animator: Animator | null = null): void
get isStarted(): boolean
}
Import: import { AnimatorMachine } from "@argus/gameplay"
Members
| Member | Signature | Description |
|---|---|---|
label | readonly label: string | |
initial | readonly initial: string | |
states | readonly states: Map<string, AnimState> | |
interruptBlends | readonly interruptBlends: boolean | |
current | current: string | The state the machine believes is playing (the destination of a blend, once one starts). |
blend | blend: BlendInfo | null = null | The blend in flight, or null. |
constructor | constructor(component: AnimatorComponent, opts: AnimatorOptions = {}) | |
stateNames | get stateNames(): string[] | |
blending | get blending(): boolean | |
blendRemaining | get blendRemaining(): number | Seconds left on the running blend, 0 when none is running. |
deferring | get deferring(): boolean | True while a blend is running and this machine was told not to interrupt one. |
deferredEvent | get deferredEvent(): string | null | The event waiting for the running blend to finish, if any. |
has | has(state: string): boolean | Whether a state name exists in this animator. |
state | state(name: string): AnimState | null | The state record, for callers that want the clip or the loop flag. |
transitionFor | transitionFor(event: string, from = this.current): AnimTransition | null | The transition the current state (or from) takes for event, or null. First match wins. |
start | start(animator: Animator | null): string | Put the animator into its initial state. Safe to call again after a hot reload. |
send | send(event: string, animator: Animator | null): boolean | Offer an event to the machine. Returns true when it caused a transition. An event the current state has no transition for is ignored — that is how a state machine says "not from here", not an error. |
goTo | goTo(state: string, animator: Animator | null, blend = 0): void | Go straight to a state, bypassing the transition table (a cutscene, a behavior that knows better). An undefined state throws with the list of the ones that exist. |
update | update(dt: number, animator: Animator | null = null): void | Advance the blend clock, and release a transition that was waiting for it. |
isStarted | get isStarted(): boolean | True once start has run. |