22 lines
495 B
TypeScript
Raw Permalink Normal View History

2022-12-08 21:14:02 +08:00
import { _decorator, Component } from "cc";
import { EntityStateEnum } from "../Enum";
import StateMachine from "./StateMachine";
2022-11-27 23:23:47 +08:00
const { ccclass, property } = _decorator;
2022-12-08 21:14:02 +08:00
@ccclass("EntityManager")
2022-11-27 23:23:47 +08:00
export abstract class EntityManager extends Component {
2022-12-08 21:14:02 +08:00
fsm: StateMachine;
private _state: EntityStateEnum;
2022-12-01 22:26:41 +08:00
2022-11-27 23:23:47 +08:00
get state() {
2022-12-08 21:14:02 +08:00
return this._state;
2022-11-27 23:23:47 +08:00
}
set state(newState) {
2022-12-08 21:14:02 +08:00
this._state = newState;
this.fsm.setParams(newState, true);
2022-11-27 23:23:47 +08:00
}
2022-12-08 21:14:02 +08:00
abstract init(...args: any[]): void;
2022-11-27 23:23:47 +08:00
}