using System.Collections.Generic; using System.Linq; using UnityEngine; using WallstopStudios.UnityHelpers.Tags; namespace MB6 { [CreateAssetMenu(menuName = "Wallstop Studios/Unity Helpers/Attribute Effect Registry")] public class EffectRegistry : ScriptableObject { [SerializeField] private List _effects = new(); private Dictionary _effectRegistry = new Dictionary(); public void OnEnable() { _effectRegistry = _effects.ToDictionary(e=> e.name, e => e); } public void AddEffect(AttributeEffect effect) => _effects.Add(effect); public void RemoveEffect(string lookupName) => _effects.RemoveAll(x => x.name == lookupName); public AttributeEffect GetEffect(string lookupName) => _effectRegistry.TryGetValue(lookupName, out var effect) ? effect : null; public IEnumerable GetEffects() => _effects; } }