refactor(editor): 重构编辑器架构并增强行为树执行可视化

This commit is contained in:
YHH
2025-11-04 18:29:28 +08:00
parent adfc7e91b3
commit f9afa22406
44 changed files with 4942 additions and 546 deletions

View File

@@ -63,6 +63,9 @@ export interface NodeRuntimeState {
/** 当前执行的子节点索引(复合节点使用) */
currentChildIndex: number;
/** 执行顺序号(用于调试和可视化) */
executionOrder?: number;
/** 开始执行时间(某些节点需要) */
startTime?: number;

View File

@@ -125,6 +125,11 @@ export class BehaviorTreeExecutionSystem extends EntitySystem {
runtime.activeNodeIds.add(nodeData.id);
state.isAborted = false;
if (state.executionOrder === undefined) {
runtime.executionOrderCounter++;
state.executionOrder = runtime.executionOrderCounter;
}
const executor = this.executorRegistry.get(nodeData.implementationType);
if (!executor) {
this.logger.error(`未找到执行器: ${nodeData.implementationType}`);

View File

@@ -82,6 +82,12 @@ export class BehaviorTreeRuntimeComponent extends Component {
@IgnoreSerialization()
nodesToAbort: Set<string> = new Set();
/**
* 执行顺序计数器(用于调试和可视化)
*/
@IgnoreSerialization()
executionOrderCounter: number = 0;
/**
* 获取节点运行时状态
*/
@@ -115,6 +121,7 @@ export class BehaviorTreeRuntimeComponent extends Component {
resetAllStates(): void {
this.nodeStates.clear();
this.activeNodeIds.clear();
this.executionOrderCounter = 0;
}
/**