31 lines
711 B
TypeScript
Raw Normal View History

2022-11-27 23:23:47 +08:00
import State from './State'
import StateMachine from './StateMachine'
/***
*
* idle的statestate都封装在子状态机中
*/
export default abstract class SubStateMachine {
private _currentState: State = null
stateMachines: Map<string, State> = new Map()
constructor(public fsm: StateMachine) {}
get currentState() {
return this._currentState
}
set currentState(newState) {
if (!newState) {
return
}
this._currentState = newState
this._currentState.run()
}
/***
*
*/
abstract run(): void
}