支持先加入实体后加入系统以让matcher进行实体匹配/优化行为树节点效果及逻辑
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import type { IComponent } from '../Types';
|
||||
import type { IComponent } from '../types';
|
||||
|
||||
/**
|
||||
* 游戏组件基类
|
||||
|
||||
@@ -6,8 +6,6 @@ import { ComponentIndexManager, IndexType } from './ComponentIndex';
|
||||
import { ArchetypeSystem } from './ArchetypeSystem';
|
||||
import { DirtyTrackingSystem, DirtyFlag } from './DirtyTrackingSystem';
|
||||
import { EventBus } from './EventBus';
|
||||
import { ECSEventType } from '../CoreEvents';
|
||||
import { IEntityEventData, IComponentEventData } from '../../Types';
|
||||
|
||||
/**
|
||||
* 实体查询构建器
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
ISystemEventData,
|
||||
ISceneEventData,
|
||||
IPerformanceEventData
|
||||
} from '../../Types';
|
||||
} from '../../types';
|
||||
import {
|
||||
TypeSafeEventSystem,
|
||||
EventListenerConfig,
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import { Component } from './Component';
|
||||
import { ComponentRegistry, ComponentType } from './Core/ComponentStorage';
|
||||
import { EventBus } from './Core/EventBus';
|
||||
import { ECSEventType } from './CoreEvents';
|
||||
import { IComponentEventData } from '../Types';
|
||||
|
||||
/**
|
||||
* 实体比较器
|
||||
|
||||
@@ -3,7 +3,7 @@ import { Core } from '../../Core';
|
||||
import { Matcher } from '../Utils/Matcher';
|
||||
import { PerformanceMonitor } from '../../Utils/PerformanceMonitor';
|
||||
import type { Scene } from '../Scene';
|
||||
import type { ISystemBase } from '../../Types';
|
||||
import type { ISystemBase } from '../../types';
|
||||
|
||||
/**
|
||||
* 实体系统的基类
|
||||
@@ -115,10 +115,17 @@ export abstract class EntitySystem implements ISystemBase {
|
||||
/**
|
||||
* 系统初始化
|
||||
*
|
||||
* 在系统创建时调用,子类可以重写此方法进行初始化操作。
|
||||
* 在系统创建时调用,自动检查场景中已存在的实体是否匹配此系统。
|
||||
* 子类可以重写此方法进行额外的初始化操作。
|
||||
*/
|
||||
public initialize(): void {
|
||||
// 子类可以重写此方法
|
||||
if (this.scene?.entities?.buffer) {
|
||||
for (const entity of this.scene.entities.buffer) {
|
||||
this.onChanged(entity);
|
||||
}
|
||||
}
|
||||
|
||||
// 子类可以重写此方法进行额外初始化
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user