using System.Collections; using System.Collections.Generic; using UnityEngine; namespace MoreMountains.Tools { /// /// Decisions are components that will be evaluated by transitions, every frame, and will return true or false. Examples include time spent in a state, distance to a target, or object detection within an area. /// public abstract class AIDecision : MonoBehaviour { /// Decide will be performed every frame while the Brain is in a state this Decision is in. Should return true or false, which will then determine the transition's outcome. public abstract bool Decide(); public string Label; public bool DecisionInProgress { get; set; } protected AIBrain _brain; /// /// On Awake we grab our Brain /// protected virtual void Awake() { _brain = this.gameObject.GetComponentInParent(); } /// /// On Start we initialize our Decision /// protected virtual void Start() { Initialization(); } /// /// Meant to be overridden, called when the game starts /// public virtual void Initialization() { } /// /// Meant to be overridden, called when the Brain enters a State this Decision is in /// public virtual void OnEnterState() { DecisionInProgress = true; } /// /// Meant to be overridden, called when the Brain exits a State this Decision is in /// public virtual void OnExitState() { DecisionInProgress = false; } } }