export class StateMachine { constructor(owner) { this.owner = owner; this.state = null; } get() { return this.state; } set(next) { if (next === this.state) return; const prev = this.state; if (prev && typeof prev.exit === 'function') { prev.exit(this.owner, next); } this.state = next || null; if (this.state && typeof this.state.enter === 'function') { this.state.enter(this.owner, prev); } } update(dt) { if (this.state && typeof this.state.update === 'function') { this.state?.update?.(this.owner, dt); } } }