ECS Framework API / Updatable
Function: Updatable()
Updatable(
priority):ClassDecorator
Defined in: packages/core/src/Core/DI/Decorators.ts:119
@Updatable() 装饰器
标记服务类为可更新的,使其在每帧自动被ServiceContainer调用update方法。 使用此装饰器的类必须实现IUpdatable接口(包含update方法)。
Parameters
priority
number = 0
更新优先级(数值越小越先执行,默认0)
Returns
ClassDecorator
Throws
如果类没有实现update方法,将在运行时抛出错误
Example
typescript
@Injectable()
@Updatable()
class TimerManager implements IService, IUpdatable {
update(deltaTime?: number) {
// 每帧更新逻辑
}
dispose() {}
}
// 指定优先级
@Injectable()
@Updatable(10)
class PhysicsManager implements IService, IUpdatable {
update() { }
dispose() {}
}