import BehaviorNode, { BehaviorNodeType } from "../behavior/BehaviorNode";
import BehaviorTree from "../behavior/BehaviorTree";
/**
 * 目标条件节点
 * 0:没有目标
 * 1:有目标
 */
export default class BehaviorTarget extends BehaviorNode {

    constructor(behaviorTree:BehaviorTree){
        super(behaviorTree);
        this.type = BehaviorNodeType.Conditinals
    }

    public isOK():boolean{
        return true
    }
    /**
     * 执行当前节点
     * @param callback 执行结束后回调
     */
    public run(callback:(behaviorNode)=>void){
        let sprite = this.behaviorTree.sprite;
        let enemy = sprite.findEnemy(600)
        if(enemy.sprite == null){
            callback(this.childNode[0])
        }else{
            callback(this.childNode[1])
        }
    }
}
