import BehaviorNode, { BehaviorNodeType } from "../behavior/BehaviorNode";
import BehaviorTree from "../behavior/BehaviorTree";
/**
 * 气血条件节点 
 * < 0 执行死亡
 * > 0 搜寻目标
 */
export default class BehaviorHP extends BehaviorNode {
    
    constructor(behaviorTree:BehaviorTree){
        super(behaviorTree);
        this.type = BehaviorNodeType.Conditinals
    }

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