using System.Collections.Generic; using System.Collections.ObjectModel; using UnityEngine; namespace RoR2; public class Highlight : MonoBehaviour { public enum HighlightColor { interactive, teleporter, pickup, custom, unavailable } private static List highlightList = new List(); private static ReadOnlyCollection _readonlyHighlightList = new ReadOnlyCollection(highlightList); private IDisplayNameProvider displayNameProvider; [HideInInspector] public PickupIndex pickupIndex; public Renderer targetRenderer; public float strength = 1f; public HighlightColor highlightColor; public Color CustomColor = Color.magenta; public bool isOn; public static ReadOnlyCollection readonlyHighlightList => _readonlyHighlightList; private void Awake() { displayNameProvider = GetComponent(); } private void RemoveHighlightIfInactive() { if (targetRenderer != null && !targetRenderer.gameObject.activeInHierarchy && highlightList.Contains(this)) { highlightList.Remove(this); } } public Color GetColor() { return highlightColor switch { HighlightColor.interactive => ColorCatalog.GetColor(ColorCatalog.ColorIndex.Interactable), HighlightColor.teleporter => ColorCatalog.GetColor(ColorCatalog.ColorIndex.Teleporter), HighlightColor.pickup => PickupCatalog.GetPickupDef(pickupIndex)?.baseColor ?? PickupCatalog.invalidPickupColor, HighlightColor.custom => CustomColor, _ => Color.magenta, }; } private void Update() { RemoveHighlightIfInactive(); } public void OnDisable() { highlightList.Remove(this); } public void OnEnable() { highlightList.Add(this); } public void ResetHighlight() { } }