diff --git a/src/behaviortree/BTNode/Action.ts b/src/behaviortree/BTNode/Action.ts index b75df39..9c29263 100644 --- a/src/behaviortree/BTNode/Action.ts +++ b/src/behaviortree/BTNode/Action.ts @@ -9,7 +9,7 @@ import { LeafNode } from "./AbstractNodes"; */ @BT.ActionNode("WaitTicks", { name: "等待次数", - group: "等待行为", + group: "基础行为节点", desc: "等待指定次数后返回成功", }) export class WaitTicks extends LeafNode { @@ -42,7 +42,7 @@ export class WaitTicks extends LeafNode { */ @BT.ActionNode("WaitTime", { name: "等待时间", - group: "等待行为", + group: "基础行为节点", desc: "等待指定时间(秒)后返回成功", }) export class WaitTime extends LeafNode { diff --git a/src/behaviortree/BTNode/Condition.ts b/src/behaviortree/BTNode/Condition.ts new file mode 100644 index 0000000..12f4be4 --- /dev/null +++ b/src/behaviortree/BTNode/Condition.ts @@ -0,0 +1,20 @@ +/** + * @Author: Gongxh + * @Date: 2025-09-17 + * @Description: 条件节点基类 + */ + +import { Status } from "../header"; +import { LeafNode } from "./AbstractNodes"; + +export abstract class Condition extends LeafNode { + /** + * 判断是否满足条件 + * @returns 是否满足条件 + */ + protected abstract isEligible(): boolean; + + public tick(): Status { + return this.isEligible() ? Status.SUCCESS : Status.FAILURE; + } +} diff --git a/src/index.ts b/src/index.ts index 67c8290..9127dda 100644 --- a/src/index.ts +++ b/src/index.ts @@ -7,9 +7,11 @@ export * from "./behaviortree/BTNode/AbstractNodes"; export * from "./behaviortree/BTNode/Action"; export { IBTNode } from "./behaviortree/BTNode/BTNode"; export * from "./behaviortree/BTNode/Composite"; +export * from "./behaviortree/BTNode/Condition"; export * from "./behaviortree/BTNode/Decorator"; export { createBehaviorTree } from "./behaviortree/Factory"; +export { Status } from "./behaviortree/header"; // 导出装饰器内容 import { BT } from "./behaviortree/BT"; -export const { ActionNode, ConditionNode, CompositeNode, DecoratorNode, prop } = BT; \ No newline at end of file +export const { ActionNode, ConditionNode, CompositeNode, DecoratorNode, prop, ParamType } = BT; \ No newline at end of file