using UnityEngine;
using ScrambleKit.FX;

public class HumanCommands : MonoBehaviour 
{
    public FXTrigger CmereFX;
    public FXTrigger WiffFX;

    void Update () 
	{
        if (HumanControl.ActiveHuman != transform)
            return;

        if (Input.GetKeyDown(KeyCode.Space))
            CommandCmere();
    }

    private void CommandCmere()
    {
        bool someoneHeard = false;
        foreach(Transform human in HumanControl.HumansWithLoS(transform.position))
        {
            if (human == transform)
                continue;

            human.GetComponent<HumanAI>().AssignGoal(transform.position);
            someoneHeard = true;
        }

        if (someoneHeard)
            CmereFX.Trigger(transform);
        else
            WiffFX.Trigger(transform);
    }
}
