3 Commits
0.1.0 ... 0.1.1

Author SHA1 Message Date
gongxh
50e29feeb8 行为树节点参数添加复合类型参数,更新demo 2025-09-18 22:56:35 +08:00
gongxh
f60bf869a1 修改内置节点的描述信息 2025-09-18 16:49:59 +08:00
gongxh
eb6934ce6a 重新导出行为树配置 2025-10-06 11:15:33 +08:00
10 changed files with 160 additions and 196 deletions

View File

@@ -1,138 +1,8 @@
{ {
"bt-tree1": [
{
"id": "1759488688188_qejfcso50",
"className": "Selector",
"parameters": {},
"children": [
"1759488707759_2bmdm1fqt",
"1759488725107_v8u160t95",
"1759488737637_axpz9aqaz",
"1759482034741_cf3mqaqdj"
]
},
{
"id": "1759479318405_bptb8ltcp",
"className": "LimitTime",
"parameters": {
"_max": 2
},
"children": [
"1758089736854_t55n54hkh"
]
},
{
"id": "1759479295671_jflit2ek8",
"className": "LimitTime",
"parameters": {
"_max": 2
},
"children": [
"1758089659917_vjumiu9hy"
]
},
{
"id": "1758089659917_vjumiu9hy",
"className": "BTAnimation",
"parameters": {
"_name": "walk",
"_loop": true
},
"children": []
},
{
"id": "1758089736854_t55n54hkh",
"className": "BTAnimation",
"parameters": {
"_name": "run",
"_loop": true
},
"children": []
},
{
"id": "1758089757615_dp9tw9ka1",
"className": "BTAnimation",
"parameters": {
"_name": "jump",
"_loop": false
},
"children": []
},
{
"id": "1759478407706_w30m4btux",
"className": "BTAnimation",
"parameters": {
"_name": "idle",
"_loop": true
},
"children": []
},
{
"id": "1759481172259_xou25wj2n",
"className": "BTConditionRandom",
"parameters": {
"_value": 0.3
},
"children": []
},
{
"id": "1759481282875_5orqavi5y",
"className": "BTConditionRandom",
"parameters": {
"_value": 0.4
},
"children": []
},
{
"id": "1759481307863_ja6q4q9bz",
"className": "BTConditionRandom",
"parameters": {
"_value": 0.3
},
"children": []
},
{
"id": "1759482034741_cf3mqaqdj",
"className": "LimitTime",
"parameters": {
"_max": 3
},
"children": [
"1759478407706_w30m4btux"
]
},
{
"id": "1759488707759_2bmdm1fqt",
"className": "Sequence",
"parameters": {},
"children": [
"1759481172259_xou25wj2n",
"1759479295671_jflit2ek8"
]
},
{
"id": "1759488725107_v8u160t95",
"className": "Sequence",
"parameters": {},
"children": [
"1759481282875_5orqavi5y",
"1759479318405_bptb8ltcp"
]
},
{
"id": "1759488737637_axpz9aqaz",
"className": "Sequence",
"parameters": {},
"children": [
"1759481307863_ja6q4q9bz",
"1758089757615_dp9tw9ka1"
]
}
],
"bt-tree2": [ "bt-tree2": [
{ {
"id": "1757930589538_qisfksbwz", "id": "1758206972710_bhxebhy7o",
"className": "MemSequence", "className": "Sequence",
"parameters": {}, "parameters": {},
"children": [ "children": [
"1758090634327_mf36nwkdt" "1758090634327_mf36nwkdt"
@@ -142,6 +12,17 @@
"id": "1758090634327_mf36nwkdt", "id": "1758090634327_mf36nwkdt",
"className": "Selector", "className": "Selector",
"parameters": {}, "parameters": {},
"children": [
"1758206988178_55b7kk5va"
]
},
{
"id": "1758206988178_55b7kk5va",
"className": "BTAnimation",
"parameters": {
"_name": "",
"_loop": false
},
"children": [] "children": []
} }
] ]

View File

@@ -7,6 +7,33 @@
import { sp } from "cc"; import { sp } from "cc";
import { BT } from "./Header"; import { BT } from "./Header";
@BT.ClassAction("BTTestNode", { name: "嵌套数据测试节点", group: "测试", desc: "测试节点" })
export class BTTestNode extends BT.LeafNode {
@BT.prop({
type: BT.ParamType.object,
properties: {
x: { type: BT.ParamType.int, min: 0 },
y: { type: BT.ParamType.int, min: 0 }
}
})
position: { x: number, y: number };
// 对象数组参数
@BT.prop({
type: BT.ParamType.array,
itemType: BT.ParamType.object,
itemProperties: {
name: { type: BT.ParamType.string },
value: { type: BT.ParamType.int }
}
})
configs: Array<{ name: string, value: number }>;
public tick(): BT.Status {
return BT.Status.SUCCESS;
}
}
@BT.ClassAction("BTAnimation", { name: "播放动画", group: "动画", desc: "通过动画名播放动画,播放完成后返回成功" }) @BT.ClassAction("BTAnimation", { name: "播放动画", group: "动画", desc: "通过动画名播放动画,播放完成后返回成功" })
export class BTAnimation extends BT.LeafNode { export class BTAnimation extends BT.LeafNode {
@BT.prop({ type: BT.ParamType.string, description: "动画名" }) @BT.prop({ type: BT.ParamType.string, description: "动画名" })
@@ -54,7 +81,7 @@ export class BTConditionRandom extends BT.Condition {
private _value: number = 0.5; private _value: number = 0.5;
public isEligible(): boolean { public isEligible(): boolean {
return Math.random() > this._value; return Math.random() < this._value;
} }
} }

View File

@@ -1,6 +1,6 @@
{ {
"name": "bt-tree1", "name": "bt-tree2",
"description": "", "description": "这是一个描述",
"nodes": [ "nodes": [
{ {
"id": "1759488688188_qejfcso50", "id": "1759488688188_qejfcso50",
@@ -15,16 +15,39 @@
"1759488707759_2bmdm1fqt", "1759488707759_2bmdm1fqt",
"1759488725107_v8u160t95", "1759488725107_v8u160t95",
"1759488737637_axpz9aqaz", "1759488737637_axpz9aqaz",
"1759482034741_cf3mqaqdj" "1759482034741_cf3mqaqdj",
"1758190139303_t5o7vv3ak"
], ],
"alias": "根节点" "alias": "根选择节点"
},
{
"id": "1758190139303_t5o7vv3ak",
"className": "BTTestNode",
"name": "嵌套数据测试节点",
"position": {
"x": 440,
"y": -80
},
"parameters": {
"position": {
"x": 10,
"y": 20
},
"configs": [
{
"name": "hahaa",
"value": 1
}
]
},
"children": []
}, },
{ {
"id": "1759479318405_bptb8ltcp", "id": "1759479318405_bptb8ltcp",
"className": "LimitTime", "className": "LimitTime",
"name": "时间限制器", "name": "时间限制器",
"position": { "position": {
"x": -40, "x": -120,
"y": 40 "y": 40
}, },
"parameters": { "parameters": {
@@ -39,7 +62,7 @@
"className": "LimitTime", "className": "LimitTime",
"name": "时间限制器", "name": "时间限制器",
"position": { "position": {
"x": -360, "x": -400,
"y": 40 "y": 40
}, },
"parameters": { "parameters": {
@@ -54,7 +77,7 @@
"className": "BTAnimation", "className": "BTAnimation",
"name": "播放动画", "name": "播放动画",
"position": { "position": {
"x": -360, "x": -400,
"y": 160 "y": 160
}, },
"parameters": { "parameters": {
@@ -68,7 +91,7 @@
"className": "BTAnimation", "className": "BTAnimation",
"name": "播放动画", "name": "播放动画",
"position": { "position": {
"x": -40, "x": -120,
"y": 160 "y": 160
}, },
"parameters": { "parameters": {
@@ -82,7 +105,7 @@
"className": "BTAnimation", "className": "BTAnimation",
"name": "播放动画", "name": "播放动画",
"position": { "position": {
"x": 260, "x": 160,
"y": 40 "y": 40
}, },
"parameters": { "parameters": {
@@ -96,7 +119,7 @@
"className": "BTAnimation", "className": "BTAnimation",
"name": "播放动画", "name": "播放动画",
"position": { "position": {
"x": 420, "x": 300,
"y": 40 "y": 40
}, },
"parameters": { "parameters": {
@@ -110,7 +133,7 @@
"className": "BTConditionRandom", "className": "BTConditionRandom",
"name": "随机条件节点", "name": "随机条件节点",
"position": { "position": {
"x": -520, "x": -540,
"y": 40 "y": 40
}, },
"parameters": { "parameters": {
@@ -123,7 +146,7 @@
"className": "BTConditionRandom", "className": "BTConditionRandom",
"name": "随机条件节点", "name": "随机条件节点",
"position": { "position": {
"x": -200, "x": -260,
"y": 40 "y": 40
}, },
"parameters": { "parameters": {
@@ -136,7 +159,7 @@
"className": "BTConditionRandom", "className": "BTConditionRandom",
"name": "随机条件节点", "name": "随机条件节点",
"position": { "position": {
"x": 120, "x": 20,
"y": 40 "y": 40
}, },
"parameters": { "parameters": {
@@ -149,11 +172,11 @@
"className": "LimitTime", "className": "LimitTime",
"name": "时间限制器", "name": "时间限制器",
"position": { "position": {
"x": 420, "x": 300,
"y": -80 "y": -80
}, },
"parameters": { "parameters": {
"_max": 3 "_max": 2
}, },
"children": [ "children": [
"1759478407706_w30m4btux" "1759478407706_w30m4btux"
@@ -165,7 +188,7 @@
"className": "Sequence", "className": "Sequence",
"name": "顺序节点", "name": "顺序节点",
"position": { "position": {
"x": -440, "x": -480,
"y": -80 "y": -80
}, },
"parameters": {}, "parameters": {},
@@ -180,7 +203,7 @@
"className": "Sequence", "className": "Sequence",
"name": "顺序节点", "name": "顺序节点",
"position": { "position": {
"x": -120, "x": -200,
"y": -80 "y": -80
}, },
"parameters": {}, "parameters": {},
@@ -188,14 +211,14 @@
"1759481282875_5orqavi5y", "1759481282875_5orqavi5y",
"1759479318405_bptb8ltcp" "1759479318405_bptb8ltcp"
], ],
"alias": "奔跑动画分支" "alias": "奔跑动画"
}, },
{ {
"id": "1759488737637_axpz9aqaz", "id": "1759488737637_axpz9aqaz",
"className": "Sequence", "className": "Sequence",
"name": "顺序节点", "name": "顺序节点",
"position": { "position": {
"x": 180, "x": 80,
"y": -80 "y": -80
}, },
"parameters": {}, "parameters": {},
@@ -297,6 +320,18 @@
"targetNodeId": "1758089757615_dp9tw9ka1", "targetNodeId": "1758089757615_dp9tw9ka1",
"sourcePointType": "child", "sourcePointType": "child",
"targetPointType": "parent" "targetPointType": "parent"
},
{
"id": "conn_1758204108181_90iaioyvg",
"sourceNodeId": "1759488688188_qejfcso50",
"targetNodeId": "1758190139303_t5o7vv3ak",
"sourcePointType": "child",
"targetPointType": "parent"
}
],
"canvasScale": 1.0006385665653545,
"canvasOffset": {
"x": 584.9936143343465,
"y": 498.99074078480237
} }
]
} }

View File

@@ -3,12 +3,12 @@
"description": "", "description": "",
"nodes": [ "nodes": [
{ {
"id": "1757930589538_qisfksbwz", "id": "1758206972710_bhxebhy7o",
"className": "MemSequence", "className": "Sequence",
"name": "记忆顺序节点", "name": "顺序节点",
"position": { "position": {
"x": -60, "x": 80,
"y": -280 "y": -320
}, },
"parameters": {}, "parameters": {},
"children": [ "children": [
@@ -20,20 +20,49 @@
"className": "Selector", "className": "Selector",
"name": "选择节点", "name": "选择节点",
"position": { "position": {
"x": 20, "x": -80,
"y": -80 "y": -220
}, },
"parameters": {}, "parameters": {},
"children": [
"1758206988178_55b7kk5va"
],
"alias": "是的发放是的发放"
},
{
"id": "1758206988178_55b7kk5va",
"className": "BTAnimation",
"name": "播放动画",
"position": {
"x": -20,
"y": -40
},
"parameters": {
"_name": "",
"_loop": false
},
"children": [] "children": []
} }
], ],
"connections": [ "connections": [
{ {
"id": "conn_1758090635620_zajj5r8g0", "id": "conn_1758206976733_208tneycs",
"sourceNodeId": "1757930589538_qisfksbwz", "sourceNodeId": "1758206972710_bhxebhy7o",
"targetNodeId": "1758090634327_mf36nwkdt", "targetNodeId": "1758090634327_mf36nwkdt",
"sourcePointType": "child", "sourcePointType": "child",
"targetPointType": "parent" "targetPointType": "parent"
},
{
"id": "conn_1758206989897_46hw88z7h",
"sourceNodeId": "1758090634327_mf36nwkdt",
"targetNodeId": "1758206988178_55b7kk5va",
"sourcePointType": "child",
"targetPointType": "parent"
}
],
"canvasScale": 1.139190980775211,
"canvasOffset": {
"x": 549.4323607689915,
"y": 698.6185343759718
} }
]
} }

View File

@@ -5,7 +5,7 @@
"version": "3.8.6" "version": "3.8.6"
}, },
"dependencies": { "dependencies": {
"kunpocc-behaviortree": "^0.1.0", "kunpocc-behaviortree": "^0.1.1",
"ts-node": "^10.9.2" "ts-node": "^10.9.2"
} }
} }

View File

@@ -1,6 +1,6 @@
{ {
"name": "kunpocc-behaviortree", "name": "kunpocc-behaviortree",
"version": "0.1.0", "version": "0.1.1",
"description": "行为树", "description": "行为树",
"main": "./dist/kunpocc-behaviortree.cjs", "main": "./dist/kunpocc-behaviortree.cjs",
"module": "./dist/kunpocc-behaviortree.mjs", "module": "./dist/kunpocc-behaviortree.mjs",

View File

@@ -11,7 +11,9 @@ export namespace BT {
int = "number", int = "number",
float = "float", float = "float",
string = "string", string = "string",
bool = "boolean" bool = "boolean",
object = "object",
array = "array"
} }
/** /**
@@ -46,6 +48,12 @@ export namespace BT {
min?: number, min?: number,
/** 最大值 */ /** 最大值 */
max?: number, max?: number,
/** 对象属性定义 - 仅当type为object时使用 */
properties?: { [key: string]: Omit<ParameterInfo, "name"> };
/** 数组元素类型 - 仅当type为array时使用 */
itemType?: ParamType;
/** 数组元素对象定义 - 仅当type为array且itemType为object时使用 */
itemProperties?: { [key: string]: Omit<ParameterInfo, "name"> };
} }
/** /**

View File

@@ -17,11 +17,7 @@ export abstract class LeafNode extends BTNode {
* 次数内返回RUNNING * 次数内返回RUNNING
* 超次返回SUCCESS * 超次返回SUCCESS
*/ */
@BT.ClassAction("WaitTicks", { @BT.ClassAction("WaitTicks", { name: "次数等待节点", group: "基础行为节点", desc: "指定次数后返回成功, 否则返回执行中" })
name: "等待次数",
group: "基础行为节点",
desc: "等待指定次数后返回成功",
})
export class WaitTicks extends LeafNode { export class WaitTicks extends LeafNode {
@BT.prop({ type: BT.ParamType.int, description: "最大等待次数", defaultValue: 0, step: 1 }) @BT.prop({ type: BT.ParamType.int, description: "最大等待次数", defaultValue: 0, step: 1 })
private _max: number; private _max: number;
@@ -50,11 +46,7 @@ export class WaitTicks extends LeafNode {
* 时间等待节点 时间(秒) * 时间等待节点 时间(秒)
* 时间到后返回SUCCESS否则返回RUNNING * 时间到后返回SUCCESS否则返回RUNNING
*/ */
@BT.ClassAction("WaitTime", { @BT.ClassAction("WaitTime", { name: "时间等待节点", group: "基础行为节点", desc: "等待指定时间(秒)后返回成功, 否则返回执行中" })
name: "等待时间",
group: "基础行为节点",
desc: "等待指定时间(秒)后返回成功",
})
export class WaitTime extends LeafNode { export class WaitTime extends LeafNode {
@BT.prop({ type: BT.ParamType.float, description: "等待时间(秒)", defaultValue: 0, step: 0.01 }) @BT.prop({ type: BT.ParamType.float, description: "等待时间(秒)", defaultValue: 0, step: 0.01 })
private _max: number; private _max: number;

View File

@@ -21,7 +21,7 @@ export abstract class Composite extends BTNode {
* *
* 遇到 RUNNING 返回 RUNNING 下次从该节点开始 * 遇到 RUNNING 返回 RUNNING 下次从该节点开始
*/ */
@BT.ClassComposite("Selector", { name: "选择节点", group: "基础组合节点", desc: "选择节点" }) @BT.ClassComposite("Selector", { name: "选择节点", group: "基础组合节点", desc: "子节点从左到右执行, 子节点状态: 成功则选择成立, 失败继续下一个, 执行中则返回执行中, 下次从该节点开始" })
export class Selector extends Composite { export class Selector extends Composite {
public override _initialize(global: IBlackboard, branch: IBlackboard): void { public override _initialize(global: IBlackboard, branch: IBlackboard): void {
super._initialize(global, branch); super._initialize(global, branch);
@@ -57,7 +57,7 @@ export class Selector extends Composite {
* *
* 遇到 RUNNING 返回 RUNNING 下次从该节点开始 * 遇到 RUNNING 返回 RUNNING 下次从该节点开始
*/ */
@BT.ClassComposite("Sequence", { name: "顺序节点", group: "基础组合节点", desc: "顺序节点" }) @BT.ClassComposite("Sequence", { name: "顺序节点", group: "基础组合节点", desc: "子节点从左到右执行, 子节点状态: 成功则继续下一个, 失败则停止迭代返回失败, 执行中返回执行中, 下次从该节点开始" })
export class Sequence extends Composite { export class Sequence extends Composite {
public override _initialize(global: IBlackboard, branch: IBlackboard): void { public override _initialize(global: IBlackboard, branch: IBlackboard): void {
super._initialize(global, branch); super._initialize(global, branch);
@@ -90,7 +90,7 @@ export class Sequence extends Composite {
* 并行节点 从上到下执行 全部执行一遍 * 并行节点 从上到下执行 全部执行一遍
* 返回优先级 FAILURE > RUNNING > SUCCESS * 返回优先级 FAILURE > RUNNING > SUCCESS
*/ */
@BT.ClassComposite("Parallel", { name: "并行节点", group: "基础组合节点", desc: "同时执行所有子节点全部成功才返回成功" }) @BT.ClassComposite("Parallel", { name: "并行节点", group: "基础组合节点", desc: "同时执行所有子节点, 子节点状态: 任意失败则失败 > 任意执行中则执行中 > 全部成功成功" })
export class Parallel extends Composite { export class Parallel extends Composite {
public tick(dt: number): Status { public tick(dt: number): Status {
let result = Status.SUCCESS; let result = Status.SUCCESS;
@@ -112,11 +112,7 @@ export class Parallel extends Composite {
* 随机选择一个子节点执行 * 随机选择一个子节点执行
* 返回子节点状态 * 返回子节点状态
*/ */
@BT.ClassComposite("RandomSelector", { @BT.ClassComposite("RandomSelector", { name: "随机选择节点", group: "基础组合节点", desc: "随机选择一个子节点执行, 返回子节点状态" })
name: "随机选择节点",
group: "基础组合节点",
desc: "随机选择一个子节点执行",
})
export class RandomSelector extends Composite { export class RandomSelector extends Composite {
private _totalWeight: number = 0; private _totalWeight: number = 0;
private _weights: number[] = []; private _weights: number[] = [];
@@ -168,11 +164,7 @@ export class RandomSelector extends Composite {
* 并行节点 从上到下执行 全部执行一遍 * 并行节点 从上到下执行 全部执行一遍
* 返回优先级 SUCCESS > RUNNING > FAILURE * 返回优先级 SUCCESS > RUNNING > FAILURE
*/ */
@BT.ClassComposite("ParallelAnySuccess", { @BT.ClassComposite("ParallelAnySuccess", { name: "并行任意成功节点", group: "基础组合节点", desc: "任意一个成功则成功 > 任意一个执行中则执行中 > 全部失败则失败" })
name: "并行任意成功",
group: "基础组合节点",
desc: "同时执行所有子节点,任意一个成功即返回成功",
})
export class ParallelAnySuccess extends Composite { export class ParallelAnySuccess extends Composite {
public tick(dt: number): Status { public tick(dt: number): Status {
let result = Status.FAILURE; let result = Status.FAILURE;

View File

@@ -40,7 +40,7 @@ export abstract class ConditionDecorator extends Decorator {
* 第一个Child Node节点, 返回 FAILURE, 本Node向自己的Parent Node也返回 SUCCESS * 第一个Child Node节点, 返回 FAILURE, 本Node向自己的Parent Node也返回 SUCCESS
* 第一个Child Node节点, 返回 SUCCESS, 本Node向自己的Parent Node也返回 FAILURE * 第一个Child Node节点, 返回 SUCCESS, 本Node向自己的Parent Node也返回 FAILURE
*/ */
@BT.ClassDecorator("Inverter", { name: "反转器", group: "基础装饰节点", desc: "反转子节点的执行结果成功变失败失败变成功" }) @BT.ClassDecorator("Inverter", { name: "结果反转节点", group: "基础装饰节点", desc: "反转子节点的执行结果, 成功变失败, 失败变成功, 执行中保持不变" })
export class Inverter extends Decorator { export class Inverter extends Decorator {
public tick(dt: number): Status { public tick(dt: number): Status {
const status = this.children[0]!._execute(dt); const status = this.children[0]!._execute(dt);
@@ -61,7 +61,7 @@ export class Inverter extends Decorator {
* 规定时间内, 根据Child Node的结果, 本节点向自己的父节点也返回相同的结果 * 规定时间内, 根据Child Node的结果, 本节点向自己的父节点也返回相同的结果
* 超时后, 直接返回 FAILURE * 超时后, 直接返回 FAILURE
*/ */
@BT.ClassDecorator("LimitTime", { name: "时间限制", group: "基础装饰节点", desc: "限制子节点执行时间,超时返回失败" }) @BT.ClassDecorator("LimitTime", { name: "时间限制节点", group: "基础装饰节点", desc: "限制时间内返回子节点状态, 超时返回失败" })
export class LimitTime extends Decorator { export class LimitTime extends Decorator {
@BT.prop({ type: BT.ParamType.float, description: "最大时间(秒)", defaultValue: 1 }) @BT.prop({ type: BT.ParamType.float, description: "最大时间(秒)", defaultValue: 1 })
protected _max: number = 1; protected _max: number = 1;
@@ -96,7 +96,7 @@ export class LimitTime extends Decorator {
* 必须且只能包含一个子节点 * 必须且只能包含一个子节点
* 次数超过后, 直接返回失败; 次数未超过, 返回子节点状态 * 次数超过后, 直接返回失败; 次数未超过, 返回子节点状态
*/ */
@BT.ClassDecorator("LimitTicks", { name: "次数限制", group: "基础装饰节点", desc: "限制子节点执行次数,超过次数返回失败" }) @BT.ClassDecorator("LimitTicks", { name: "次数限制节点", group: "基础装饰节点", desc: "子节点成功, 次数+1, 限制次数内返回子节点状态, 超过限制次数返回失败" })
export class LimitTicks extends Decorator { export class LimitTicks extends Decorator {
@BT.prop({ type: BT.ParamType.int, description: "最大次数", defaultValue: 1 }) @BT.prop({ type: BT.ParamType.int, description: "最大次数", defaultValue: 1 })
protected _max: number = 1; protected _max: number = 1;
@@ -130,7 +130,7 @@ export class LimitTicks extends Decorator {
* 子节点是成功或失败,累加计数 * 子节点是成功或失败,累加计数
* 次数超过之后返回子节点状态,否则返回 RUNNING * 次数超过之后返回子节点状态,否则返回 RUNNING
*/ */
@BT.ClassDecorator("Repeat", { name: "重复节点", group: "基础装饰节点", desc: "重复执行子节点指定次数" }) @BT.ClassDecorator("Repeat", { name: "重复节点", group: "基础装饰节点", desc: "子节点成功或失败次数+1, 重复执行指定次数" })
export class Repeat extends Decorator { export class Repeat extends Decorator {
@BT.prop({ type: BT.ParamType.int, description: "重复次数", defaultValue: 1, min: 1 }) @BT.prop({ type: BT.ParamType.int, description: "重复次数", defaultValue: 1, min: 1 })
protected _max: number = 1; protected _max: number = 1;
@@ -167,7 +167,7 @@ export class Repeat extends Decorator {
* *
* 子节点成功 计数+1 * 子节点成功 计数+1
*/ */
@BT.ClassDecorator("RepeatUntilFailure", { name: "重复直到失败", group: "基础装饰节点", desc: "重复执行子节点直到失败或达到最大次数" }) @BT.ClassDecorator("RepeatUntilFailure", { name: "重复直到失败", group: "基础装饰节点", desc: "子节点成功则次数+1, 限制次数内返回执行中, 重复执行子节点直到子节点返回失败, 超过限制次数返回失败" })
export class RepeatUntilFailure extends Decorator { export class RepeatUntilFailure extends Decorator {
@BT.prop({ type: BT.ParamType.int, description: "最大重试次数", defaultValue: 1, min: 1 }) @BT.prop({ type: BT.ParamType.int, description: "最大重试次数", defaultValue: 1, min: 1 })
protected _max: number = 1; protected _max: number = 1;
@@ -205,7 +205,7 @@ export class RepeatUntilFailure extends Decorator {
* *
* 子节点失败, 计数+1 * 子节点失败, 计数+1
*/ */
@BT.ClassDecorator("RepeatUntilSuccess", { name: "重复直到成功", group: "基础装饰节点", desc: "重复执行子节点直到成功或达到最大次数" }) @BT.ClassDecorator("RepeatUntilSuccess", { name: "重复直到成功", group: "基础装饰节点", desc: "子节点失败则次数+1, 限制次数内返回执行中, 重复执行子节点直到子节点返回成功, 超过限制次数返回失败" })
export class RepeatUntilSuccess extends Decorator { export class RepeatUntilSuccess extends Decorator {
@BT.prop({ type: BT.ParamType.int, description: "最大重试次数", defaultValue: 1, step: 1 }) @BT.prop({ type: BT.ParamType.int, description: "最大重试次数", defaultValue: 1, step: 1 })
protected _max: number = 1; protected _max: number = 1;
@@ -240,7 +240,7 @@ export class RepeatUntilSuccess extends Decorator {
/** /**
* 权重装饰节点 * 权重装饰节点
*/ */
@BT.ClassDecorator("WeightDecorator", { name: "权重装饰", group: "基础装饰节点", desc: "权重装饰节点" }) @BT.ClassDecorator("WeightDecorator", { name: "权重装饰节点", group: "基础装饰节点", desc: "根据权重随机选择子节点执行, 用于随机选择节点的子节点" })
export class WeightDecorator extends Decorator { export class WeightDecorator extends Decorator {
@BT.prop({ type: BT.ParamType.int, description: "权重", defaultValue: 1, step: 1 }) @BT.prop({ type: BT.ParamType.int, description: "权重", defaultValue: 1, step: 1 })
private _weight: number; private _weight: number;