mirror of
https://github.com/gongxh0901/kunpocc-behaviortree.git
synced 2025-12-26 16:48:56 +00:00
导出 Status 枚举;导出参数类型;添加条件节点基类
This commit is contained in:
@@ -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 {
|
||||
|
||||
20
src/behaviortree/BTNode/Condition.ts
Normal file
20
src/behaviortree/BTNode/Condition.ts
Normal 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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
export const { ActionNode, ConditionNode, CompositeNode, DecoratorNode, prop, ParamType } = BT;
|
||||
Reference in New Issue
Block a user