
using BingoBrain.Core;
using BingoBrain.HotFix;
using UnityEngine;

namespace BingoBrain
{
    public class GodPleAcUICtrl : BaseUICtrl
    {
        private GodPleAcUI ui;
        private GodPleAcModel model;

        private uint openUIMsg = SkinInfo.GodPleAcUI_Open;
        private uint closeUIMsg = SkinInfo.GodPleAcUI_Close;

        #region 生命周期

        protected override void OnInit()
        {
        }

        protected override void OnDispose()
        {
        }

        public override void OpenUI(object args = null)
        {
            ui = new GodPleAcUI(this);
            ui.Open(args);
        }

        public override void CloseUI(object args = null)
        {
            if (args != null && ui.ui_index != (int)args) return;
            if (ui != null && !ui.isClose)
            {
                ui.Close();
            }

            ui = null;
        }

        #endregion

        #region 消息

        public override uint GetOpenUIMsg(string uiName)
        {
            return openUIMsg;
        }

        public override uint GetCloseUIMsg(string uiName)
        {
            return closeUIMsg;
        }

        protected override void AddListener()
        {
            uiCtrlDispatcher.AddListener(openUIMsg, OpenUI);
            uiCtrlDispatcher.AddListener(closeUIMsg, CloseUI);
        }

        protected override void RemoveListener()
        {
            uiCtrlDispatcher.RemoveListener(openUIMsg, OpenUI);
            uiCtrlDispatcher.RemoveListener(closeUIMsg, CloseUI);
        }

        #endregion
    }
}