using System.Collections; using System.Collections.Generic; using System.Linq; using UnityEngine; [RequireComponent(typeof(Collider))] public class EyePOI : MonoBehaviour, IListener { [SerializeField] [Range(0, 1)] float weight = 1f; [SerializeField] bool startActive = true; [SerializeField] EVENT_TYPE[] activatonEvents = null; [SerializeField] EVENT_TYPE[] deactivatonEvents = null; public bool IsActive { get; private set; } = true; public float Weight { get => weight; } private void Awake() { IsActive = startActive; if (activatonEvents != null) foreach (EVENT_TYPE e in activatonEvents) EventManager.Instance.AddListener(e, this); if (deactivatonEvents != null) foreach (EVENT_TYPE e in deactivatonEvents) EventManager.Instance.AddListener(e, this); } public void OnEvent<T>(EVENT_TYPE eventType, Component Sender, T param = default) { if (Sender.gameObject == gameObject) { if (activatonEvents.Contains(eventType)) { IsActive = true; } else if (deactivatonEvents.Contains(eventType)) { IsActive = false; } } } }