2025-10-31 17:27:38 +08:00
|
|
|
|
import { BehaviorTreeData, BehaviorNodeData } from './Runtime/BehaviorTreeData';
|
|
|
|
|
|
import { NodeType } from './Types/TaskStatus';
|
2025-10-27 09:29:11 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 行为树构建器
|
|
|
|
|
|
*
|
2025-10-31 17:27:38 +08:00
|
|
|
|
* 提供流式API构建行为树数据结构
|
2025-10-27 09:29:11 +08:00
|
|
|
|
*/
|
|
|
|
|
|
export class BehaviorTreeBuilder {
|
2025-10-31 17:27:38 +08:00
|
|
|
|
private treeData: BehaviorTreeData;
|
|
|
|
|
|
private nodeStack: string[] = [];
|
|
|
|
|
|
private nodeIdCounter: number = 0;
|
2025-10-27 09:29:11 +08:00
|
|
|
|
|
2025-10-31 17:27:38 +08:00
|
|
|
|
private constructor(treeName: string) {
|
|
|
|
|
|
this.treeData = {
|
|
|
|
|
|
id: `tree_${Date.now()}`,
|
|
|
|
|
|
name: treeName,
|
|
|
|
|
|
rootNodeId: '',
|
|
|
|
|
|
nodes: new Map(),
|
|
|
|
|
|
blackboardVariables: new Map()
|
|
|
|
|
|
};
|
2025-10-27 09:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2025-10-31 17:27:38 +08:00
|
|
|
|
* 创建构建器
|
2025-10-27 09:29:11 +08:00
|
|
|
|
*/
|
2025-10-31 17:27:38 +08:00
|
|
|
|
static create(treeName: string = 'BehaviorTree'): BehaviorTreeBuilder {
|
|
|
|
|
|
return new BehaviorTreeBuilder(treeName);
|
2025-10-27 09:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2025-10-31 17:27:38 +08:00
|
|
|
|
* 定义黑板变量
|
2025-10-27 09:29:11 +08:00
|
|
|
|
*/
|
2025-10-31 17:27:38 +08:00
|
|
|
|
defineBlackboardVariable(key: string, initialValue: any): BehaviorTreeBuilder {
|
|
|
|
|
|
if (!this.treeData.blackboardVariables) {
|
|
|
|
|
|
this.treeData.blackboardVariables = new Map();
|
|
|
|
|
|
}
|
|
|
|
|
|
this.treeData.blackboardVariables.set(key, initialValue);
|
2025-10-27 09:29:11 +08:00
|
|
|
|
return this;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2025-10-31 17:27:38 +08:00
|
|
|
|
* 添加序列节点
|
2025-10-27 09:29:11 +08:00
|
|
|
|
*/
|
2025-10-31 17:27:38 +08:00
|
|
|
|
sequence(name?: string): BehaviorTreeBuilder {
|
|
|
|
|
|
return this.addCompositeNode('Sequence', name || 'Sequence');
|
2025-10-27 09:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2025-10-31 17:27:38 +08:00
|
|
|
|
* 添加选择器节点
|
2025-10-27 09:29:11 +08:00
|
|
|
|
*/
|
2025-10-31 17:27:38 +08:00
|
|
|
|
selector(name?: string): BehaviorTreeBuilder {
|
|
|
|
|
|
return this.addCompositeNode('Selector', name || 'Selector');
|
2025-10-27 09:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2025-10-31 17:27:38 +08:00
|
|
|
|
* 添加并行节点
|
2025-10-27 09:29:11 +08:00
|
|
|
|
*/
|
2025-10-31 17:27:38 +08:00
|
|
|
|
parallel(name?: string, config?: { successPolicy?: string; failurePolicy?: string }): BehaviorTreeBuilder {
|
|
|
|
|
|
return this.addCompositeNode('Parallel', name || 'Parallel', config);
|
2025-10-27 09:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2025-10-31 17:27:38 +08:00
|
|
|
|
* 添加并行选择器节点
|
2025-10-27 09:29:11 +08:00
|
|
|
|
*/
|
2025-10-31 17:27:38 +08:00
|
|
|
|
parallelSelector(name?: string, config?: { failurePolicy?: string }): BehaviorTreeBuilder {
|
|
|
|
|
|
return this.addCompositeNode('ParallelSelector', name || 'ParallelSelector', config);
|
2025-10-27 09:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2025-10-31 17:27:38 +08:00
|
|
|
|
* 添加随机序列节点
|
2025-10-27 09:29:11 +08:00
|
|
|
|
*/
|
2025-10-31 17:27:38 +08:00
|
|
|
|
randomSequence(name?: string): BehaviorTreeBuilder {
|
|
|
|
|
|
return this.addCompositeNode('RandomSequence', name || 'RandomSequence');
|
2025-10-27 09:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2025-10-31 17:27:38 +08:00
|
|
|
|
* 添加随机选择器节点
|
2025-10-27 09:29:11 +08:00
|
|
|
|
*/
|
2025-10-31 17:27:38 +08:00
|
|
|
|
randomSelector(name?: string): BehaviorTreeBuilder {
|
|
|
|
|
|
return this.addCompositeNode('RandomSelector', name || 'RandomSelector');
|
2025-10-27 09:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2025-10-31 17:27:38 +08:00
|
|
|
|
* 添加反转装饰器
|
2025-10-27 09:29:11 +08:00
|
|
|
|
*/
|
2025-10-31 17:27:38 +08:00
|
|
|
|
inverter(name?: string): BehaviorTreeBuilder {
|
|
|
|
|
|
return this.addDecoratorNode('Inverter', name || 'Inverter');
|
2025-10-27 09:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2025-10-31 17:27:38 +08:00
|
|
|
|
* 添加重复装饰器
|
2025-10-27 09:29:11 +08:00
|
|
|
|
*/
|
2025-10-31 17:27:38 +08:00
|
|
|
|
repeater(repeatCount: number, name?: string): BehaviorTreeBuilder {
|
|
|
|
|
|
return this.addDecoratorNode('Repeater', name || 'Repeater', { repeatCount });
|
2025-10-27 09:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2025-10-31 17:27:38 +08:00
|
|
|
|
* 添加总是成功装饰器
|
2025-10-27 09:29:11 +08:00
|
|
|
|
*/
|
2025-10-31 17:27:38 +08:00
|
|
|
|
alwaysSucceed(name?: string): BehaviorTreeBuilder {
|
|
|
|
|
|
return this.addDecoratorNode('AlwaysSucceed', name || 'AlwaysSucceed');
|
2025-10-27 09:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2025-10-31 17:27:38 +08:00
|
|
|
|
* 添加总是失败装饰器
|
2025-10-27 09:29:11 +08:00
|
|
|
|
*/
|
2025-10-31 17:27:38 +08:00
|
|
|
|
alwaysFail(name?: string): BehaviorTreeBuilder {
|
|
|
|
|
|
return this.addDecoratorNode('AlwaysFail', name || 'AlwaysFail');
|
2025-10-27 09:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2025-10-31 17:27:38 +08:00
|
|
|
|
* 添加直到成功装饰器
|
2025-10-27 09:29:11 +08:00
|
|
|
|
*/
|
2025-10-31 17:27:38 +08:00
|
|
|
|
untilSuccess(name?: string): BehaviorTreeBuilder {
|
|
|
|
|
|
return this.addDecoratorNode('UntilSuccess', name || 'UntilSuccess');
|
2025-10-27 09:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2025-10-31 17:27:38 +08:00
|
|
|
|
* 添加直到失败装饰器
|
2025-10-27 09:29:11 +08:00
|
|
|
|
*/
|
2025-10-31 17:27:38 +08:00
|
|
|
|
untilFail(name?: string): BehaviorTreeBuilder {
|
|
|
|
|
|
return this.addDecoratorNode('UntilFail', name || 'UntilFail');
|
2025-10-27 09:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2025-10-31 17:27:38 +08:00
|
|
|
|
* 添加条件装饰器
|
2025-10-27 09:29:11 +08:00
|
|
|
|
*/
|
2025-10-31 17:27:38 +08:00
|
|
|
|
conditional(blackboardKey: string, expectedValue: any, operator?: string, name?: string): BehaviorTreeBuilder {
|
|
|
|
|
|
return this.addDecoratorNode('Conditional', name || 'Conditional', {
|
|
|
|
|
|
blackboardKey,
|
|
|
|
|
|
expectedValue,
|
|
|
|
|
|
operator: operator || 'equals'
|
|
|
|
|
|
});
|
2025-10-27 09:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2025-10-31 17:27:38 +08:00
|
|
|
|
* 添加冷却装饰器
|
2025-10-27 09:29:11 +08:00
|
|
|
|
*/
|
2025-10-31 17:27:38 +08:00
|
|
|
|
cooldown(cooldownTime: number, name?: string): BehaviorTreeBuilder {
|
|
|
|
|
|
return this.addDecoratorNode('Cooldown', name || 'Cooldown', { cooldownTime });
|
2025-10-27 09:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2025-10-31 17:27:38 +08:00
|
|
|
|
* 添加超时装饰器
|
2025-10-27 09:29:11 +08:00
|
|
|
|
*/
|
2025-10-31 17:27:38 +08:00
|
|
|
|
timeout(timeout: number, name?: string): BehaviorTreeBuilder {
|
|
|
|
|
|
return this.addDecoratorNode('Timeout', name || 'Timeout', { timeout });
|
2025-10-27 09:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2025-10-31 17:27:38 +08:00
|
|
|
|
* 添加等待动作
|
2025-10-27 09:29:11 +08:00
|
|
|
|
*/
|
2025-10-31 17:27:38 +08:00
|
|
|
|
wait(duration: number, name?: string): BehaviorTreeBuilder {
|
|
|
|
|
|
return this.addActionNode('Wait', name || 'Wait', { duration });
|
2025-10-27 09:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2025-10-31 17:27:38 +08:00
|
|
|
|
* 添加日志动作
|
2025-10-27 09:29:11 +08:00
|
|
|
|
*/
|
2025-10-31 17:27:38 +08:00
|
|
|
|
log(message: string, name?: string): BehaviorTreeBuilder {
|
|
|
|
|
|
return this.addActionNode('Log', name || 'Log', { message });
|
2025-10-27 09:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2025-10-31 17:27:38 +08:00
|
|
|
|
* 添加设置黑板值动作
|
2025-10-27 09:29:11 +08:00
|
|
|
|
*/
|
2025-10-31 17:27:38 +08:00
|
|
|
|
setBlackboardValue(key: string, value: any, name?: string): BehaviorTreeBuilder {
|
|
|
|
|
|
return this.addActionNode('SetBlackboardValue', name || 'SetBlackboardValue', { key, value });
|
2025-10-27 09:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2025-10-31 17:27:38 +08:00
|
|
|
|
* 添加修改黑板值动作
|
2025-10-27 09:29:11 +08:00
|
|
|
|
*/
|
2025-10-31 17:27:38 +08:00
|
|
|
|
modifyBlackboardValue(key: string, operation: string, value: number, name?: string): BehaviorTreeBuilder {
|
|
|
|
|
|
return this.addActionNode('ModifyBlackboardValue', name || 'ModifyBlackboardValue', {
|
|
|
|
|
|
key,
|
|
|
|
|
|
operation,
|
|
|
|
|
|
value
|
|
|
|
|
|
});
|
2025-10-27 09:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2025-10-31 17:27:38 +08:00
|
|
|
|
* 添加执行动作
|
2025-10-27 09:29:11 +08:00
|
|
|
|
*/
|
2025-10-31 17:27:38 +08:00
|
|
|
|
executeAction(actionName: string, name?: string): BehaviorTreeBuilder {
|
|
|
|
|
|
return this.addActionNode('ExecuteAction', name || 'ExecuteAction', { actionName });
|
2025-10-27 09:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2025-10-31 17:27:38 +08:00
|
|
|
|
* 添加黑板比较条件
|
2025-10-27 09:29:11 +08:00
|
|
|
|
*/
|
2025-10-31 17:27:38 +08:00
|
|
|
|
blackboardCompare(key: string, compareValue: any, operator?: string, name?: string): BehaviorTreeBuilder {
|
|
|
|
|
|
return this.addConditionNode('BlackboardCompare', name || 'BlackboardCompare', {
|
|
|
|
|
|
key,
|
|
|
|
|
|
compareValue,
|
|
|
|
|
|
operator: operator || 'equals'
|
|
|
|
|
|
});
|
2025-10-27 09:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2025-10-31 17:27:38 +08:00
|
|
|
|
* 添加黑板存在检查条件
|
2025-10-27 09:29:11 +08:00
|
|
|
|
*/
|
2025-10-31 17:27:38 +08:00
|
|
|
|
blackboardExists(key: string, name?: string): BehaviorTreeBuilder {
|
|
|
|
|
|
return this.addConditionNode('BlackboardExists', name || 'BlackboardExists', { key });
|
2025-10-27 09:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2025-10-31 17:27:38 +08:00
|
|
|
|
* 添加随机概率条件
|
2025-10-27 09:29:11 +08:00
|
|
|
|
*/
|
2025-10-31 17:27:38 +08:00
|
|
|
|
randomProbability(probability: number, name?: string): BehaviorTreeBuilder {
|
|
|
|
|
|
return this.addConditionNode('RandomProbability', name || 'RandomProbability', { probability });
|
2025-10-27 09:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2025-10-31 17:27:38 +08:00
|
|
|
|
* 添加执行条件
|
2025-10-27 09:29:11 +08:00
|
|
|
|
*/
|
2025-10-31 17:27:38 +08:00
|
|
|
|
executeCondition(conditionName: string, name?: string): BehaviorTreeBuilder {
|
|
|
|
|
|
return this.addConditionNode('ExecuteCondition', name || 'ExecuteCondition', { conditionName });
|
|
|
|
|
|
}
|
2025-10-27 09:29:11 +08:00
|
|
|
|
|
2025-10-31 17:27:38 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 结束当前节点,返回父节点
|
|
|
|
|
|
*/
|
|
|
|
|
|
end(): BehaviorTreeBuilder {
|
|
|
|
|
|
if (this.nodeStack.length > 0) {
|
|
|
|
|
|
this.nodeStack.pop();
|
|
|
|
|
|
}
|
2025-10-27 09:29:11 +08:00
|
|
|
|
return this;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2025-10-31 17:27:38 +08:00
|
|
|
|
* 构建行为树数据
|
2025-10-27 09:29:11 +08:00
|
|
|
|
*/
|
2025-10-31 17:27:38 +08:00
|
|
|
|
build(): BehaviorTreeData {
|
|
|
|
|
|
if (!this.treeData.rootNodeId) {
|
|
|
|
|
|
throw new Error('No root node defined. Add at least one node to the tree.');
|
|
|
|
|
|
}
|
|
|
|
|
|
return this.treeData;
|
|
|
|
|
|
}
|
2025-10-27 09:29:11 +08:00
|
|
|
|
|
2025-10-31 17:27:38 +08:00
|
|
|
|
private addCompositeNode(implementationType: string, name: string, config: Record<string, any> = {}): BehaviorTreeBuilder {
|
|
|
|
|
|
const nodeId = this.generateNodeId();
|
|
|
|
|
|
const node: BehaviorNodeData = {
|
|
|
|
|
|
id: nodeId,
|
|
|
|
|
|
name,
|
|
|
|
|
|
nodeType: NodeType.Composite,
|
|
|
|
|
|
implementationType,
|
|
|
|
|
|
children: [],
|
|
|
|
|
|
config
|
|
|
|
|
|
};
|
2025-10-27 09:29:11 +08:00
|
|
|
|
|
2025-10-31 17:27:38 +08:00
|
|
|
|
this.treeData.nodes.set(nodeId, node);
|
|
|
|
|
|
|
|
|
|
|
|
if (!this.treeData.rootNodeId) {
|
|
|
|
|
|
this.treeData.rootNodeId = nodeId;
|
|
|
|
|
|
}
|
2025-10-27 09:29:11 +08:00
|
|
|
|
|
2025-10-31 17:27:38 +08:00
|
|
|
|
if (this.nodeStack.length > 0) {
|
|
|
|
|
|
const parentId = this.nodeStack[this.nodeStack.length - 1]!;
|
|
|
|
|
|
const parentNode = this.treeData.nodes.get(parentId);
|
|
|
|
|
|
if (parentNode && parentNode.children) {
|
|
|
|
|
|
parentNode.children.push(nodeId);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.nodeStack.push(nodeId);
|
2025-10-27 09:29:11 +08:00
|
|
|
|
return this;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-10-31 17:27:38 +08:00
|
|
|
|
private addDecoratorNode(implementationType: string, name: string, config: Record<string, any> = {}): BehaviorTreeBuilder {
|
|
|
|
|
|
const nodeId = this.generateNodeId();
|
|
|
|
|
|
const node: BehaviorNodeData = {
|
|
|
|
|
|
id: nodeId,
|
|
|
|
|
|
name,
|
|
|
|
|
|
nodeType: NodeType.Decorator,
|
|
|
|
|
|
implementationType,
|
|
|
|
|
|
children: [],
|
|
|
|
|
|
config
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
this.treeData.nodes.set(nodeId, node);
|
2025-10-27 09:29:11 +08:00
|
|
|
|
|
2025-10-31 17:27:38 +08:00
|
|
|
|
if (!this.treeData.rootNodeId) {
|
|
|
|
|
|
this.treeData.rootNodeId = nodeId;
|
|
|
|
|
|
}
|
2025-10-27 09:29:11 +08:00
|
|
|
|
|
2025-10-31 17:27:38 +08:00
|
|
|
|
if (this.nodeStack.length > 0) {
|
|
|
|
|
|
const parentId = this.nodeStack[this.nodeStack.length - 1]!;
|
|
|
|
|
|
const parentNode = this.treeData.nodes.get(parentId);
|
|
|
|
|
|
if (parentNode && parentNode.children) {
|
|
|
|
|
|
parentNode.children.push(nodeId);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-10-27 09:29:11 +08:00
|
|
|
|
|
2025-10-31 17:27:38 +08:00
|
|
|
|
this.nodeStack.push(nodeId);
|
2025-10-27 09:29:11 +08:00
|
|
|
|
return this;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-10-31 17:27:38 +08:00
|
|
|
|
private addActionNode(implementationType: string, name: string, config: Record<string, any> = {}): BehaviorTreeBuilder {
|
|
|
|
|
|
const nodeId = this.generateNodeId();
|
|
|
|
|
|
const node: BehaviorNodeData = {
|
|
|
|
|
|
id: nodeId,
|
|
|
|
|
|
name,
|
|
|
|
|
|
nodeType: NodeType.Action,
|
|
|
|
|
|
implementationType,
|
|
|
|
|
|
config
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
this.treeData.nodes.set(nodeId, node);
|
2025-10-27 09:29:11 +08:00
|
|
|
|
|
2025-10-31 17:27:38 +08:00
|
|
|
|
if (!this.treeData.rootNodeId) {
|
|
|
|
|
|
this.treeData.rootNodeId = nodeId;
|
|
|
|
|
|
}
|
2025-10-27 09:29:11 +08:00
|
|
|
|
|
2025-10-31 17:27:38 +08:00
|
|
|
|
if (this.nodeStack.length > 0) {
|
|
|
|
|
|
const parentId = this.nodeStack[this.nodeStack.length - 1]!;
|
|
|
|
|
|
const parentNode = this.treeData.nodes.get(parentId);
|
|
|
|
|
|
if (parentNode && parentNode.children) {
|
|
|
|
|
|
parentNode.children.push(nodeId);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-10-27 09:29:11 +08:00
|
|
|
|
|
|
|
|
|
|
return this;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-10-31 17:27:38 +08:00
|
|
|
|
private addConditionNode(implementationType: string, name: string, config: Record<string, any> = {}): BehaviorTreeBuilder {
|
|
|
|
|
|
const nodeId = this.generateNodeId();
|
|
|
|
|
|
const node: BehaviorNodeData = {
|
|
|
|
|
|
id: nodeId,
|
|
|
|
|
|
name,
|
|
|
|
|
|
nodeType: NodeType.Condition,
|
|
|
|
|
|
implementationType,
|
|
|
|
|
|
config
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
this.treeData.nodes.set(nodeId, node);
|
|
|
|
|
|
|
|
|
|
|
|
if (!this.treeData.rootNodeId) {
|
|
|
|
|
|
this.treeData.rootNodeId = nodeId;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (this.nodeStack.length > 0) {
|
|
|
|
|
|
const parentId = this.nodeStack[this.nodeStack.length - 1]!;
|
|
|
|
|
|
const parentNode = this.treeData.nodes.get(parentId);
|
|
|
|
|
|
if (parentNode && parentNode.children) {
|
|
|
|
|
|
parentNode.children.push(nodeId);
|
|
|
|
|
|
}
|
2025-10-27 09:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return this;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-10-31 17:27:38 +08:00
|
|
|
|
private generateNodeId(): string {
|
|
|
|
|
|
return `node_${this.nodeIdCounter++}`;
|
2025-10-27 09:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|