380 lines
9.9 KiB
JSON
380 lines
9.9 KiB
JSON
{
|
||
"id": "worker-ai",
|
||
"name": "工人AI行为树",
|
||
"description": "工人单位的智能行为系统,包含资源收集、建造、修理等功能",
|
||
"version": "1.0.0",
|
||
"author": "ECS Framework",
|
||
"nodes": [
|
||
{
|
||
"id": "root",
|
||
"type": "root",
|
||
"name": "工人AI根节点",
|
||
"description": "工人AI的根节点,管理所有工人行为",
|
||
"children": ["main-selector"]
|
||
},
|
||
{
|
||
"id": "main-selector",
|
||
"type": "selector",
|
||
"name": "主行为选择器",
|
||
"description": "按优先级选择工人行为:逃跑 > 执行命令 > 空闲",
|
||
"children": ["flee-behavior", "command-behavior", "idle-behavior"]
|
||
},
|
||
{
|
||
"id": "flee-behavior",
|
||
"type": "conditional-decorator",
|
||
"name": "逃跑行为",
|
||
"description": "生命值低时逃跑到安全区域",
|
||
"children": ["flee-sequence"],
|
||
"condition": {
|
||
"type": "blackboard-value-comparison",
|
||
"properties": {
|
||
"variableName": "isLowHealth",
|
||
"compareOperator": "equals",
|
||
"compareValue": true
|
||
}
|
||
}
|
||
},
|
||
{
|
||
"id": "flee-sequence",
|
||
"type": "sequence",
|
||
"name": "逃跑序列",
|
||
"description": "执行逃跑行为的完整序列",
|
||
"children": ["set-flee-state", "move-to-safety", "heal-self"]
|
||
},
|
||
{
|
||
"id": "set-flee-state",
|
||
"type": "set-blackboard-value",
|
||
"name": "设置逃跑状态",
|
||
"description": "将工人状态设置为逃跑",
|
||
"properties": {
|
||
"variableName": "currentState",
|
||
"value": "fleeing"
|
||
}
|
||
},
|
||
{
|
||
"id": "move-to-safety",
|
||
"type": "event-action",
|
||
"name": "移动到安全区域",
|
||
"description": "移动到最近的安全建筑",
|
||
"properties": {
|
||
"eventName": "move-to-safety"
|
||
}
|
||
},
|
||
{
|
||
"id": "heal-self",
|
||
"type": "event-action",
|
||
"name": "自我治疗",
|
||
"description": "使用治疗物品恢复生命值",
|
||
"properties": {
|
||
"eventName": "heal-self"
|
||
}
|
||
},
|
||
{
|
||
"id": "command-behavior",
|
||
"type": "conditional-decorator",
|
||
"name": "命令行为",
|
||
"description": "有命令时执行相应行为",
|
||
"children": ["command-selector"],
|
||
"condition": {
|
||
"type": "blackboard-value-comparison",
|
||
"properties": {
|
||
"variableName": "hasTarget",
|
||
"compareOperator": "equals",
|
||
"compareValue": true
|
||
}
|
||
}
|
||
},
|
||
{
|
||
"id": "command-selector",
|
||
"type": "selector",
|
||
"name": "命令选择器",
|
||
"description": "根据命令类型选择行为",
|
||
"children": ["gather-behavior", "build-behavior", "repair-behavior", "move-behavior"]
|
||
},
|
||
{
|
||
"id": "gather-behavior",
|
||
"type": "conditional-decorator",
|
||
"name": "收集行为",
|
||
"description": "收集资源的行为",
|
||
"children": ["gather-sequence"],
|
||
"condition": {
|
||
"type": "blackboard-value-comparison",
|
||
"properties": {
|
||
"variableName": "currentCommand",
|
||
"compareOperator": "equals",
|
||
"compareValue": "gather"
|
||
}
|
||
}
|
||
},
|
||
{
|
||
"id": "gather-sequence",
|
||
"type": "sequence",
|
||
"name": "收集序列",
|
||
"description": "完整的资源收集流程",
|
||
"children": ["move-to-resource", "collect-resource", "return-to-base"]
|
||
},
|
||
{
|
||
"id": "move-to-resource",
|
||
"type": "event-action",
|
||
"name": "移动到资源",
|
||
"description": "移动到目标资源点",
|
||
"properties": {
|
||
"eventName": "move-to-target"
|
||
}
|
||
},
|
||
{
|
||
"id": "collect-resource",
|
||
"type": "event-action",
|
||
"name": "收集资源",
|
||
"description": "执行资源收集动作",
|
||
"properties": {
|
||
"eventName": "gather-resource"
|
||
}
|
||
},
|
||
{
|
||
"id": "return-to-base",
|
||
"type": "event-action",
|
||
"name": "返回基地",
|
||
"description": "将资源运回基地",
|
||
"properties": {
|
||
"eventName": "return-to-base"
|
||
}
|
||
},
|
||
{
|
||
"id": "build-behavior",
|
||
"type": "conditional-decorator",
|
||
"name": "建造行为",
|
||
"description": "建造建筑的行为",
|
||
"children": ["build-sequence"],
|
||
"condition": {
|
||
"type": "blackboard-value-comparison",
|
||
"properties": {
|
||
"variableName": "currentCommand",
|
||
"compareOperator": "equals",
|
||
"compareValue": "build"
|
||
}
|
||
}
|
||
},
|
||
{
|
||
"id": "build-sequence",
|
||
"type": "sequence",
|
||
"name": "建造序列",
|
||
"description": "完整的建造流程",
|
||
"children": ["move-to-build-site", "construct-building"]
|
||
},
|
||
{
|
||
"id": "move-to-build-site",
|
||
"type": "event-action",
|
||
"name": "移动到建筑工地",
|
||
"description": "移动到指定的建筑位置",
|
||
"properties": {
|
||
"eventName": "move-to-target"
|
||
}
|
||
},
|
||
{
|
||
"id": "construct-building",
|
||
"type": "event-action",
|
||
"name": "建造建筑",
|
||
"description": "执行建筑建造动作",
|
||
"properties": {
|
||
"eventName": "construct-building"
|
||
}
|
||
},
|
||
{
|
||
"id": "repair-behavior",
|
||
"type": "conditional-decorator",
|
||
"name": "修理行为",
|
||
"description": "修理损坏建筑的行为",
|
||
"children": ["repair-sequence"],
|
||
"condition": {
|
||
"type": "blackboard-value-comparison",
|
||
"properties": {
|
||
"variableName": "currentCommand",
|
||
"compareOperator": "equals",
|
||
"compareValue": "repair"
|
||
}
|
||
}
|
||
},
|
||
{
|
||
"id": "repair-sequence",
|
||
"type": "sequence",
|
||
"name": "修理序列",
|
||
"description": "完整的修理流程",
|
||
"children": ["move-to-building", "repair-building"]
|
||
},
|
||
{
|
||
"id": "move-to-building",
|
||
"type": "event-action",
|
||
"name": "移动到建筑",
|
||
"description": "移动到需要修理的建筑",
|
||
"properties": {
|
||
"eventName": "move-to-target"
|
||
}
|
||
},
|
||
{
|
||
"id": "repair-building",
|
||
"type": "event-action",
|
||
"name": "修理建筑",
|
||
"description": "执行建筑修理动作",
|
||
"properties": {
|
||
"eventName": "repair-building"
|
||
}
|
||
},
|
||
{
|
||
"id": "move-behavior",
|
||
"type": "conditional-decorator",
|
||
"name": "移动行为",
|
||
"description": "单纯的移动行为",
|
||
"children": ["simple-move"],
|
||
"condition": {
|
||
"type": "blackboard-value-comparison",
|
||
"properties": {
|
||
"variableName": "currentCommand",
|
||
"compareOperator": "equals",
|
||
"compareValue": "move"
|
||
}
|
||
}
|
||
},
|
||
{
|
||
"id": "simple-move",
|
||
"type": "event-action",
|
||
"name": "简单移动",
|
||
"description": "移动到指定位置",
|
||
"properties": {
|
||
"eventName": "move-to-target"
|
||
}
|
||
},
|
||
{
|
||
"id": "idle-behavior",
|
||
"type": "sequence",
|
||
"name": "空闲行为",
|
||
"description": "没有任务时的默认行为",
|
||
"children": ["set-idle-state", "idle-wait"]
|
||
},
|
||
{
|
||
"id": "set-idle-state",
|
||
"type": "set-blackboard-value",
|
||
"name": "设置空闲状态",
|
||
"description": "将工人状态设置为空闲",
|
||
"properties": {
|
||
"variableName": "currentState",
|
||
"value": "idle"
|
||
}
|
||
},
|
||
{
|
||
"id": "idle-wait",
|
||
"type": "wait-action",
|
||
"name": "空闲等待",
|
||
"description": "空闲时等待一段时间",
|
||
"properties": {
|
||
"waitTime": 1.0
|
||
}
|
||
}
|
||
],
|
||
"blackboard": [
|
||
{
|
||
"name": "currentState",
|
||
"type": "string",
|
||
"value": "idle",
|
||
"description": "工人当前状态(idle、working、fleeing、gathering、building、repairing)",
|
||
"group": "状态"
|
||
},
|
||
{
|
||
"name": "currentCommand",
|
||
"type": "string",
|
||
"value": "idle",
|
||
"description": "当前接收的命令(idle、move、gather、build、repair、attack)",
|
||
"group": "命令"
|
||
},
|
||
{
|
||
"name": "hasTarget",
|
||
"type": "boolean",
|
||
"value": false,
|
||
"description": "是否有目标任务",
|
||
"group": "目标"
|
||
},
|
||
{
|
||
"name": "targetPosition",
|
||
"type": "object",
|
||
"value": {"x": 0, "y": 0, "z": 0},
|
||
"description": "目标位置坐标",
|
||
"group": "目标"
|
||
},
|
||
{
|
||
"name": "currentHealth",
|
||
"type": "number",
|
||
"value": 100,
|
||
"description": "当前生命值",
|
||
"group": "状态"
|
||
},
|
||
{
|
||
"name": "maxHealth",
|
||
"type": "number",
|
||
"value": 100,
|
||
"description": "最大生命值",
|
||
"group": "状态"
|
||
},
|
||
{
|
||
"name": "healthPercentage",
|
||
"type": "number",
|
||
"value": 1.0,
|
||
"description": "生命值百分比",
|
||
"group": "状态"
|
||
},
|
||
{
|
||
"name": "isLowHealth",
|
||
"type": "boolean",
|
||
"value": false,
|
||
"description": "是否生命值较低(低于30%)",
|
||
"group": "状态"
|
||
},
|
||
{
|
||
"name": "moveSpeed",
|
||
"type": "number",
|
||
"value": 3.0,
|
||
"description": "移动速度",
|
||
"group": "属性"
|
||
},
|
||
{
|
||
"name": "gatherSpeed",
|
||
"type": "number",
|
||
"value": 1.0,
|
||
"description": "资源收集速度",
|
||
"group": "属性"
|
||
},
|
||
{
|
||
"name": "buildSpeed",
|
||
"type": "number",
|
||
"value": 1.0,
|
||
"description": "建造速度",
|
||
"group": "属性"
|
||
},
|
||
{
|
||
"name": "carryCapacity",
|
||
"type": "number",
|
||
"value": 10,
|
||
"description": "携带容量",
|
||
"group": "属性"
|
||
},
|
||
{
|
||
"name": "currentLoad",
|
||
"type": "number",
|
||
"value": 0,
|
||
"description": "当前携带量",
|
||
"group": "状态"
|
||
},
|
||
{
|
||
"name": "resourceType",
|
||
"type": "string",
|
||
"value": "none",
|
||
"description": "携带的资源类型",
|
||
"group": "状态"
|
||
}
|
||
],
|
||
"metadata": {
|
||
"created": "2024-01-01T00:00:00.000Z",
|
||
"nodeCount": 30,
|
||
"editorVersion": "1.0.0",
|
||
"description": "工人AI展示了完整的RTS单位行为模式,包括生存、工作、建造等多种行为的优先级管理和状态切换。"
|
||
}
|
||
} |