Files
esengine/src/ECS/Components/SceneComponent.ts

64 lines
1.3 KiB
TypeScript
Raw Normal View History

import type { Scene } from '../Scene';
2020-08-11 11:07:20 +08:00
/**
*
*
*/
export class SceneComponent {
/** 组件所属的场景 */
public scene!: Scene;
/** 更新顺序 */
public updateOrder: number = 0;
/** 是否启用 */
private _enabled: boolean = true;
2020-08-11 11:07:20 +08:00
/** 获取是否启用 */
public get enabled(): boolean {
return this._enabled;
}
2020-08-11 11:07:20 +08:00
/** 设置是否启用 */
public set enabled(value: boolean) {
if (this._enabled !== value) {
this._enabled = value;
if (this._enabled) {
this.onEnabled();
} else {
this.onDisabled();
}
2020-08-11 11:07:20 +08:00
}
}
2020-08-11 11:07:20 +08:00
/**
*
*/
public onEnabled(): void {
}
2020-08-11 11:07:20 +08:00
/**
*
*/
public onDisabled(): void {
}
2020-08-11 11:07:20 +08:00
/**
*
*/
public onRemovedFromScene(): void {
}
2020-08-11 11:07:20 +08:00
/**
*
*/
public update(): void {
}
2020-08-11 11:07:20 +08:00
/**
*
* @param other
* @returns
*/
public compare(other: SceneComponent): number {
return this.updateOrder - other.updateOrder;
2020-08-11 11:07:20 +08:00
}
}