using System;
using CommonLang;

namespace CommonAIClient.Unity.Battle
{
    public partial class BattleScene
    {
        private HashMap<Type, Action<CommonAI.Zone.ZoneEvent>> mZoneEvens = new HashMap<Type, Action<CommonAI.Zone.ZoneEvent>>();


        protected virtual void RegistAllZoneEvent()
        {
            RegistZoneEvent<CommonAI.Zone.AddEffectEvent>(ZoneEvent_AddEffectEvent);
        }

        protected void RegistZoneEvent<T>(Action<T> action) where T : CommonAI.Zone.ZoneEvent
        {
            Type type = typeof(T);
            Action<CommonAI.Zone.ZoneEvent> outVal = null;
            if (!mZoneEvens.TryGetValue(type, out outVal))
            {
                mZoneEvens.Add(type, (e) =>
                {
                    action((T)e);
                });
            }
        }

        protected virtual void ZoneEvent_AddEffectEvent(CommonAI.Zone.AddEffectEvent ev)
        {
            PlayEffectWithZoneCoord(ev.effect, ev.x, ev.y, ev.direction);
        }
    }

}