using Cryville.Common; using Cryville.Common.Collections.Specialized; using System; using UnityEngine; namespace Cryville.Crtr.Skin { public class EffectManager { readonly IntKeyedDictionary _groups = new(); public EffectManager(PdtSkin skin) { foreach (var e in skin.effects) { _groups.Add(e.Key.Key, new EffectGroup(e.Value)); } } public void Tick(double time) { foreach (var g in _groups) g.Value.Tick(time); } public void Emit(int id, float index) { GetGroup(id).Emit(index); } public void EmitSelf(int id, float index, Transform target) { GetGroup(id).Emit(index, target); } EffectGroup GetGroup(int id) { if (_groups.TryGetValue(id, out EffectGroup result)) return result; throw new ArgumentException(string.Format("The effect \"{0}\" is not found", IdentifierManager.Shared.Retrieve(id))); } public void Dispose() { foreach (var g in _groups) g.Value.Dispose(); } } }