2025-06-07 20:32:43 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 可更新接口
|
2025-09-26 10:09:23 +08:00
|
|
|
|
* @deprecated 不符合ECS架构规范,建议使用EntitySystem来处理更新逻辑而非在组件中实现
|
2025-06-07 20:32:43 +08:00
|
|
|
|
*/
|
|
|
|
|
|
export interface IUpdatable {
|
|
|
|
|
|
enabled: boolean;
|
|
|
|
|
|
updateOrder: number;
|
|
|
|
|
|
update(): void;
|
|
|
|
|
|
}
|
2020-10-27 18:08:49 +08:00
|
|
|
|
|
2025-06-07 20:32:43 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 用于比较组件更新排序的比较器
|
|
|
|
|
|
*/
|
|
|
|
|
|
export class IUpdatableComparer {
|
|
|
|
|
|
public compare(a: IUpdatable, b: IUpdatable): number {
|
|
|
|
|
|
return a.updateOrder - b.updateOrder;
|
2020-07-22 23:30:31 +08:00
|
|
|
|
}
|
2025-06-07 20:32:43 +08:00
|
|
|
|
}
|
2020-11-23 16:05:06 +08:00
|
|
|
|
|
2025-06-07 20:32:43 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 检查对象是否实现了IUpdatable接口
|
|
|
|
|
|
* @param props 要检查的对象
|
|
|
|
|
|
* @returns 如果实现了IUpdatable接口返回true,否则返回false
|
|
|
|
|
|
*/
|
|
|
|
|
|
export function isIUpdatable(props: any): props is IUpdatable {
|
|
|
|
|
|
return typeof (props as IUpdatable)['update'] !== 'undefined';
|
2020-07-22 23:30:31 +08:00
|
|
|
|
}
|