using System.Collections.Generic; namespace Invector.vCharacterController.AI.FSMBehaviour { #if UNITY_EDITOR [vFSMHelpbox("Verify if you can see the target based on the Detection Settings of the AI Controller and Check if the AI Controller has received any Damage or a specific DamageType", UnityEditor.MessageType.Info)] #endif public class vAICanSeeOrCheckDamageTargetDecision : vStateDecision { public override string categoryName { get { return ""; } } public override string defaultName { get { return "Can See Or Check Damage"; } } public List damageTypeToCheck; public override bool Decide(vIFSMBehaviourController fsmBehaviour) { var canSee = CanSeeTarget(fsmBehaviour); var hasDamage = (HasDamage(fsmBehaviour)); return canSee || hasDamage; } protected virtual bool HasDamage(vIFSMBehaviourController fsmBehaviour) { if (fsmBehaviour.aiController == null) return false; var hasDamage = (fsmBehaviour.aiController.receivedDamage.isValid) && (damageTypeToCheck.Count == 0 || damageTypeToCheck.Contains(fsmBehaviour.aiController.receivedDamage.lasType)); if (fsmBehaviour.debugMode) { fsmBehaviour.SendDebug(Name + " " + (fsmBehaviour.aiController.receivedDamage.isValid) + " " + fsmBehaviour.aiController.receivedDamage.lastSender, this); } return hasDamage; } protected virtual bool CanSeeTarget(vIFSMBehaviourController fsmBehaviour) { return fsmBehaviour.aiController.targetInLineOfSight; } } }