Merge branch 'master' of https://github.com/esengine/ecs-framework
This commit is contained in:
@@ -343,7 +343,14 @@ export class Scene implements IScene {
|
||||
public removeEntityProcessor(processor: EntitySystem) {
|
||||
this.entityProcessors.remove(processor);
|
||||
processor.reset();
|
||||
processor.scene = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从场景中删除系统(removeEntityProcessor的别名)
|
||||
* @param system 系统
|
||||
*/
|
||||
public removeSystem(system: EntitySystem) {
|
||||
this.removeEntityProcessor(system);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -162,6 +162,7 @@ export abstract class EntitySystem implements ISystemBase {
|
||||
* 当系统从场景中移除时调用,重置初始化状态以便重新添加时能正确初始化。
|
||||
*/
|
||||
public reset(): void {
|
||||
this.scene = null;
|
||||
this._initialized = false;
|
||||
this._trackedEntities.clear();
|
||||
|
||||
|
||||
@@ -65,6 +65,15 @@ export class EntityProcessorList {
|
||||
*/
|
||||
public end(): void {
|
||||
// 清理处理器
|
||||
for (const processor of this._processors) {
|
||||
try {
|
||||
processor.reset();
|
||||
} catch (error) {
|
||||
EntityProcessorList._logger.error(`Error in processor ${getSystemInstanceTypeName(processor)}:`, error);
|
||||
}
|
||||
}
|
||||
this._isDirty = false;
|
||||
this._processors.length = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user