Talos docs

AnimatorMachine

Since 0.6
Plain text

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

MemberSignatureDescription
labelreadonly label: string
initialreadonly initial: string
statesreadonly states: Map<string, AnimState>
interruptBlendsreadonly interruptBlends: boolean
currentcurrent: stringThe state the machine believes is playing (the destination of a blend, once one starts).
blendblend: BlendInfo | null = nullThe blend in flight, or null.
constructorconstructor(component: AnimatorComponent, opts: AnimatorOptions = {})
stateNamesget stateNames(): string[]
blendingget blending(): boolean
blendRemainingget blendRemaining(): numberSeconds left on the running blend, 0 when none is running.
deferringget deferring(): booleanTrue while a blend is running and this machine was told not to interrupt one.
deferredEventget deferredEvent(): string | nullThe event waiting for the running blend to finish, if any.
hashas(state: string): booleanWhether a state name exists in this animator.
statestate(name: string): AnimState | nullThe state record, for callers that want the clip or the loop flag.
transitionFortransitionFor(event: string, from = this.current): AnimTransition | nullThe transition the current state (or from) takes for event, or null. First match wins.
startstart(animator: Animator | null): stringPut the animator into its initial state. Safe to call again after a hot reload.
sendsend(event: string, animator: Animator | null): booleanOffer 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.
goTogoTo(state: string, animator: Animator | null, blend = 0): voidGo 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.
updateupdate(dt: number, animator: Animator | null = null): voidAdvance the blend clock, and release a transition that was waiting for it.
isStartedget isStarted(): booleanTrue once start has run.