导出 Status 枚举;导出参数类型;添加条件节点基类

This commit is contained in:
gongxh
2025-09-17 11:05:23 +08:00
parent b582a5d1da
commit b1107805d0
3 changed files with 25 additions and 3 deletions

View File

@@ -9,7 +9,7 @@ import { LeafNode } from "./AbstractNodes";
*/ */
@BT.ActionNode("WaitTicks", { @BT.ActionNode("WaitTicks", {
name: "等待次数", name: "等待次数",
group: "等待行为", group: "基础行为节点",
desc: "等待指定次数后返回成功", desc: "等待指定次数后返回成功",
}) })
export class WaitTicks extends LeafNode { export class WaitTicks extends LeafNode {
@@ -42,7 +42,7 @@ export class WaitTicks extends LeafNode {
*/ */
@BT.ActionNode("WaitTime", { @BT.ActionNode("WaitTime", {
name: "等待时间", name: "等待时间",
group: "等待行为", group: "基础行为节点",
desc: "等待指定时间(秒)后返回成功", desc: "等待指定时间(秒)后返回成功",
}) })
export class WaitTime extends LeafNode { export class WaitTime extends LeafNode {

View File

@@ -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;
}
}

View File

@@ -7,9 +7,11 @@ export * from "./behaviortree/BTNode/AbstractNodes";
export * from "./behaviortree/BTNode/Action"; export * from "./behaviortree/BTNode/Action";
export { IBTNode } from "./behaviortree/BTNode/BTNode"; export { IBTNode } from "./behaviortree/BTNode/BTNode";
export * from "./behaviortree/BTNode/Composite"; export * from "./behaviortree/BTNode/Composite";
export * from "./behaviortree/BTNode/Condition";
export * from "./behaviortree/BTNode/Decorator"; export * from "./behaviortree/BTNode/Decorator";
export { createBehaviorTree } from "./behaviortree/Factory"; export { createBehaviorTree } from "./behaviortree/Factory";
export { Status } from "./behaviortree/header";
// 导出装饰器内容 // 导出装饰器内容
import { BT } from "./behaviortree/BT"; import { BT } from "./behaviortree/BT";
export const { ActionNode, ConditionNode, CompositeNode, DecoratorNode, prop } = BT; export const { ActionNode, ConditionNode, CompositeNode, DecoratorNode, prop, ParamType } = BT;