Skip to content

t1k:cocos:playable:fsm

FieldValue
Moduleplayable
Version0.5.6
Efforthigh
Tools

Keywords: ads, cocos, fsm, playable, state machine, state manager

/t1k:cocos:playable:fsm

Singleton StateManager with type-safe, async state transitions. States self-register via @State decorator at module load time. See t1k-cocos-playable-gameflow for how GameView drives the flow.

  • Importing state files after calling changeState()@State decorator runs at import time; states not imported are not registered
  • Not awaiting changeState()onEnter may not complete before next logic runs
  • Subscribing signals in onEnter without unsubscribing in onExit — signal leaks persist across states
  • Calling sm.reset() mid-transition — leaves currentState inconsistent; only use on scene reload
  • Implementing constructor logic instead of onEnter@State calls new StateClass() at decoration time, before game starts
  • Decorator order matters@State must run before StateManager.start(); if a state-file is tree-shaken out at build, the decorator never runs and the state silently isn’t registered. Import the state files explicitly from a barrel.
  • Async transitions must await previous-state cleanup — racing enter() of state B before exit() of state A finishes leaks subscriptions.
  • Singleton survives scene reload — call StateManager.reset() on scene replay or stale state leaks across replays.