using System; using CommonLang; using CommonAIClient.Unity.Utils; namespace CommonAIClient.Unity.Battle { public partial class ComAICell { private HashMap> mObjectEvens = new HashMap>(); public void DoObjectEvent(CommonAI.Zone.ObjectEvent ev) { Action action = null; if (mObjectEvens.TryGetValue(ev.GetType(), out action)) { action(ev); } } protected virtual void RegistAllObjectEvent() { RegistObjectEvent(ObjectEvent_UnitEffectEvent); } protected void RegistObjectEvent(Action action) where T : CommonAI.Zone.ObjectEvent { Type type = typeof(T); Action outVal = null; if (!mObjectEvens.TryGetValue(type, out outVal)) { mObjectEvens.Add(type, (e) => { action((T)e); }); } } protected virtual void ObjectEvent_UnitEffectEvent(CommonAI.Zone.UnitEffectEvent ev) { PlayEffect(ev.effect, EffectRoot.Position(), EffectRoot.Rotation()); } } }