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

88 lines
2.1 KiB
TypeScript
Raw Normal View History

2020-08-11 11:07:20 +08:00
module es {
export class SceneComponent implements IComparer<SceneComponent> {
2020-08-11 11:07:20 +08:00
/**
*
*/
public scene: Scene;
/**
* SceneComponenttrueonEnabled/onDisable
*/
public get enabled() {
2020-08-11 11:07:20 +08:00
return this._enabled;
}
/**
* SceneComponenttrueonEnabled/onDisable
* @param value
*/
public set enabled(value: boolean) {
2020-08-11 11:07:20 +08:00
this.setEnabled(value);
}
/**
* SceneComponents的顺序
*/
public updateOrder: number = 0;
public _enabled: boolean = true;
/**
* SceneComponent时调用
*/
public onEnabled() {
2020-08-11 11:07:20 +08:00
}
/**
* SceneComponent时调用
*/
public onDisabled() {
2020-08-11 11:07:20 +08:00
}
/**
* SceneComponent从场景中移除时调用
*/
public onRemovedFromScene() {
2020-08-11 11:07:20 +08:00
}
/**
*
*/
public update() {
2020-08-11 11:07:20 +08:00
}
/**
* /SceneComponent
* @param isEnabled
*/
public setEnabled(isEnabled: boolean): SceneComponent {
if (this._enabled != isEnabled) {
2020-08-11 11:07:20 +08:00
this._enabled = isEnabled;
if (this._enabled) {
this.onEnabled();
} else {
this.onDisabled();
2020-08-11 11:07:20 +08:00
}
}
return this;
}
/**
* SceneComponent的updateOrder并触发某种SceneComponent
* @param updateOrder
*/
public setUpdateOrder(updateOrder: number) {
if (this.updateOrder != updateOrder) {
2020-08-11 11:07:20 +08:00
this.updateOrder = updateOrder;
}
return this;
}
public compare(other: SceneComponent): number {
2020-08-11 11:07:20 +08:00
return this.updateOrder - other.updateOrder;
}
}
}