using UnityEngine;

public class GetPatient : AI_Action
{
    GameObject m_Resource;
    public override bool PrePerform()
    {
        target = AI_World.Instance.RemovePatient();
        if(target == null)
        {
            return false;
        }

        m_Resource = AI_World.Instance.RemoveTreatmentBed();
        if (m_Resource != null)
        {
            inventory.AddItem(m_Resource);
        } else {
            AI_World.Instance.AddPatient(target);
            target = null;
            return false;
        }

        return true;
    }

    public override bool PostPerform()
    {
        AI_World.Instance.GetWorld().ModifyState("Waiting", -1);
        if (target)
        {
            target.GetComponent<AI_Agent>().inventory.AddItem(m_Resource);
        }
        return true;
    }
}
