using UnityEngine;

public class Darkness : MonoBehaviour 
{
    public float AggroRadius = 1f;
    public LayerMask AggroMask;
    private Collider2D[] aggroList = new Collider2D[5];

    public void Clear()
    {
        AggroAnyCoveredMonsters();
        Destroy(gameObject);
    }

    private void AggroAnyCoveredMonsters()
    {
        int aggs = Physics2D.OverlapCircleNonAlloc(transform.position, AggroRadius, aggroList, AggroMask);
        for (int i = 0; i < aggs; i++)
        {
            Aggro(aggroList[i]);
        }
    }

    private void Aggro(Collider2D c)
    {
        c.GetComponent<AggroTrigger>().Trigger();
    }
}
