Files
kunpocc-behaviortree/src/behaviortree/BTNode/Condition.ts

24 lines
574 B
TypeScript
Raw Normal View History

2025-06-04 23:10:59 +08:00
import { Status } from "../header";
import { Ticker } from "../Ticker";
import { Action } from "./Action";
/**
*
*/
export class Condition extends Action {
/** 执行函数 @internal */
private _func: (subject: any) => boolean = null;
constructor(func: (subject: any) => boolean) {
super();
this._func = func;
}
/**
*
* @param {Ticker} ticker
* @returns {Status}
*/
public tick(ticker: Ticker): Status {
return this._func(ticker.subject) ? Status.SUCCESS : Status.FAILURE;
}
}