using FL.Battle.Components;
using FL.Map.TestMainMap;
using UnityEngine;
using XGame.Framework.Components;
using XGame.Framework.Map;
using XGame.Framework.ObjectCollection;
using XGame.Framework.Time;

namespace FL.Map
{
    public static partial class MapKeys
    {
        private static MapKey _TestMainMap;
        public static MapKey TestMainMap => _TestMainMap ?? (_TestMainMap = new MapKey("TestMainMap", typeof(TestMainMapView)));
    }

    public class TestMainMapView : MapView<TestMainMapVM>, IEntitiesContext, IMapUIContext, IVfxContext
    {
        public IMapAssetModule Asset => Context.Asset;
        public ITimeModule Time => Context.Time;
        public VfxComponent Vfx => GetComponent<VfxComponent>();
        public MapUIComponent MapUI => GetComponent<MapUIComponent>();

        #region 
        Transform IVfxContext.WorldTr => VM.VfxRoot;
        Transform IVfxContext.CenterTr => VM.VfxRoot;
        Transform IVfxContext.CastTr => VM.VfxRoot;
        #endregion

        protected override void AddComponent(IComponentGroup group)
        {
            group.Add(new EntitiesComponent());
            group.Add(new MapUIComponent());
            group.Add(new VfxComponent());
        }

        protected override TestMainMapVM CtreatViewModel(IObjectCollector collector)
        {
            return new TestMainMapVM(collector);
        }

        protected override void OnDispose()
        {
        }
    }
}
