Newer
Older
TheVengeance-Project-IADE-Unity2D / Assets / Scripts / NPC / Orc / Conditions / TargetLost.cs
@Rackday Rackday on 10 Nov 692 bytes Minor Update
using MyCollections.AI.FinitStateMachine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[CreateAssetMenu(menuName = "Finite State Machine/Condition/TargetLost")]
public class TargetLost : Condition
{
    [SerializeField] private float distance;

    public override bool CheckCondition(FSM fsm)
    {
        FOV fov = fsm.Controller.AgentFOV;

        if (fov != null)
        {
            if (fov.GetTarget() != null && fov.TargetDistance > distance)
            {
                fov.SetTarget(null);
                return true;
            }

            return false;
        }

        Debug.LogWarning($"FOV is NULL");
        return false;
    }
}