refactor(editor): 重构编辑器架构并增强行为树执行可视化
This commit is contained in:
@@ -63,6 +63,9 @@ export interface NodeRuntimeState {
|
||||
/** 当前执行的子节点索引(复合节点使用) */
|
||||
currentChildIndex: number;
|
||||
|
||||
/** 执行顺序号(用于调试和可视化) */
|
||||
executionOrder?: number;
|
||||
|
||||
/** 开始执行时间(某些节点需要) */
|
||||
startTime?: number;
|
||||
|
||||
|
||||
@@ -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}`);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user