From 63d9855658b1901138b37395c73261a165e6a4a7 Mon Sep 17 00:00:00 2001 From: gongxh Date: Wed, 17 Sep 2025 14:10:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=9D=A1=E4=BB=B6=E8=A3=85?= =?UTF-8?q?=E9=A5=B0=E8=8A=82=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/behaviortree/BTNode/Condition.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/behaviortree/BTNode/Condition.ts b/src/behaviortree/BTNode/Condition.ts index 12f4be4..ced9b5a 100644 --- a/src/behaviortree/BTNode/Condition.ts +++ b/src/behaviortree/BTNode/Condition.ts @@ -5,8 +5,9 @@ */ import { Status } from "../header"; -import { LeafNode } from "./AbstractNodes"; +import { Decorator, LeafNode } from "./AbstractNodes"; +/** 条件叶子节点 */ export abstract class Condition extends LeafNode { /** * 判断是否满足条件 @@ -18,3 +19,16 @@ export abstract class Condition extends LeafNode { return this.isEligible() ? Status.SUCCESS : Status.FAILURE; } } + +/** 条件装饰节点 */ +export abstract class ConditionDecorator extends Decorator { + /** + * 判断是否满足条件 + * @returns 是否满足条件 + */ + protected abstract isEligible(): boolean; + + public tick(): Status { + return this.isEligible() ? this.children[0]!._execute() : Status.FAILURE; + } +} \ No newline at end of file