using System.Collections; using System.Collections.Generic; using BITKit.Entities; using NodeCanvas.BehaviourTrees; using NodeCanvas.Framework; using UnityEngine; namespace BITKit { public class EntityBehaviourTree :EntityBehavior { public BehaviourTreeOwner behaviourTree; [SerializeField] private Blackboard blackboard; private readonly ValidHandle _allow=new(); [Inject] private IHealth _health; [Inject(true)] private IEntityOverride _override; public override void OnAwake() { _allow.AddListener(OnAllow); _health.OnSetAlive += OnSetAlive; _health.OnSetHealthPoint += OnSetHP; _override.OnOverride += OnEntryOverride; } public void OnSetAlive(bool alive) { _allow.SetElements(this,alive); blackboard.SetVariableValue("IsAlive", alive); } public void OnSetHP(int hp) { blackboard.SetVariableValue("HP", hp); } public void OnEntryOverride(bool @override) { _allow.SetDisableElements(this,@override); } private void OnAllow(bool allow) { if (allow) { behaviourTree.StartBehaviour(); } else { behaviourTree.StopBehaviour(); } } } }