Newer
Older
TheVengeance-Project-IADE-Unity2D / Assets / Scripts / NPC / Orc / Actions / RequestPosition.cs
@Rackday Rackday on 29 Oct 857 bytes Major Update
using UnityEngine;
using MyCollections.AI.FinitStateMachine;

[CreateAssetMenu(menuName = "Finite State Machine/Action/RequestPosition")]
public class RequestPosition : Action
{
    public override void Run(FSM fsm)
    {
        fsm.Controller.Agent.agentStop = true;

        if (fsm == null)
        {
            Debug.Log("Fsm is null");
        }

        if (fsm.Controller == null)
        {
            Debug.Log("Controller is NUll");
        }

        if (fsm.Controller.Agent == null)
        {
            Debug.Log("Agent is NUll");
        }

        if (fsm.Controller.timer > 0f)
        {
            fsm.Controller.timer -= Time.deltaTime;
        }

        else
        {
            //Request a path
            fsm.Controller.NPCManager.RequestPosition(fsm.Controller.Agent);
            fsm.Controller.timer = 0f;
        }
    }
}