支持先加入实体后加入系统以让matcher进行实体匹配/优化行为树节点效果及逻辑

This commit is contained in:
YHH
2025-06-19 15:00:14 +08:00
parent 8c86d6b696
commit 310f5f2349
22 changed files with 1809 additions and 84 deletions

View File

@@ -7,7 +7,7 @@ import { PoolManager } from './Utils/Pool';
import { ECSFluentAPI, createECSAPI } from './ECS/Core/FluentAPI';
import { Scene } from './ECS/Scene';
import { DebugReporter } from './Utils/DebugReporter';
import { ICoreConfig, IECSDebugConfig } from './Types';
import { ICoreConfig, IECSDebugConfig } from './types';
/**
* 游戏引擎核心类

View File

@@ -1,4 +1,4 @@
import type { IComponent } from '../Types';
import type { IComponent } from '../types';
/**
* 游戏组件基类

View File

@@ -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';
/**
* 实体查询构建器

View File

@@ -8,7 +8,7 @@ import {
ISystemEventData,
ISceneEventData,
IPerformanceEventData
} from '../../Types';
} from '../../types';
import {
TypeSafeEventSystem,
EventListenerConfig,

View File

@@ -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';
/**
* 实体比较器

View File

@@ -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);
}
}
// 子类可以重写此方法进行额外初始化
}
/**

View File

@@ -6,7 +6,7 @@ import {
IPerformanceDebugData,
IComponentDebugData,
ISceneDebugData
} from '../Types';
} from '../types';
import { Core } from '../Core';
import { Time } from './Time';

View File

@@ -18,4 +18,4 @@ export * from './ECS';
// 工具类和类型定义
export * from './Utils';
export * from './Types';
export * from './types';