using FairyGUI;
using UnityEngine;
using XGame.Framework.Map;
using XGame.Framework.ObjectCollection;

namespace FL.Map.UI
{
    public class MainMapUIView : EntityView<MainMapUIVM>
    {
        public Transform CombatValRoot => VM.CombatValRoot;
        public Transform PlayerRoot => VM.PlayerRoot;
        public Transform MonsterRoot => VM.MonsterRoot;
        protected override void OnEnable(object intent)
        {
            VM.Canvas.worldCamera = StageCamera.main;
        }
        protected override void OnDisable()
        {
            VM.Canvas.worldCamera = null;
        }
    }
    public class MainMapUIVM : EntityViewModel
    {
        public Canvas Canvas { get; private set; }
        public Transform MonsterRoot { get; private set; }
        public Transform PlayerRoot { get; private set; }
        public Transform CombatValRoot { get; private set; }
        protected override void OnInit(IObjectCollector collector)
        {
            Canvas = collector.GetComponent<Canvas>("Canvas");
            MonsterRoot = collector.GetGameObject("MonsterRoot").transform;
            PlayerRoot = collector.GetGameObject("PlayerRoot").transform;
            CombatValRoot = collector.GetGameObject("CombatValRoot").transform;
        }
    }
}
