﻿using UnityEngine;

namespace JLGames.RocketDriver.Games.PanelManager
{
    public interface IPanelInstance
    {
        /// <summary>
        /// Instance Id
        /// 实例Id
        /// </summary>
        string InstanceId { get; }

        /// <summary>
        /// Panel Id
        /// 面板Id
        /// </summary>
        string PanelId { get; }

        /// <summary>
        /// Panel Info
        /// 面板定义
        /// </summary>
        IPanelInfo Info { get; }

        /// <summary>
        /// Panel view object
        /// 面板显示对象
        /// </summary>
        GameObject DisplayView { get; }

        /// <summary>
        /// Panel container object
        /// 面板显示容器
        /// </summary>
        GameObject DisplayContainer { get; }

        /// <summary>
        /// Panel background view object.
        /// 面板背景
        /// </summary>
        GameObject DisplayBackground { get; }

//        /// <summary>
//        /// 是否为自定义展示面板
//        /// </summary>
//        bool IsCustomShowPanel { get; }

//        /// <summary>
//        /// 是否为自定义关闭面板
//        /// </summary>
//        bool IsCustomClosePanel { get; }

        /// <summary>
        /// Check main script is an implementation of IInitPanel;
        /// 是否为自定义初始化面板
        /// </summary>
        bool IsCustomInitPanel { get; }

        /// <summary>
        /// Check main script is an implementation of IParamsPanel;
        /// 是否为自定义参数面板
        /// </summary>
        bool IsCustomParamsPanel { get; }

        /// <summary>
        /// Check main script is an implementation of IRefreshPanel;
        /// 是否为自定义刷新面板
        /// </summary>
        bool IsCustomRefrshPanel { get; }

        /// <summary>
        /// Check main script is an implementation of IDisposePanel;
        /// 是否为自定义释放面板
        /// </summary>
        bool IsCustomDisposePanel { get; }

        //---------------------------------

        /// <summary>
        /// Get main script in instance field.
        /// 取主脚本
        /// </summary>
        MonoBehaviour MainScript { get; }

        /// <summary>
        /// Get main script to T in instance field.
        /// 取主脚本
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        T CastMainScript<T>() where T : class;

        /// <summary>
        /// Find and return main script if exist
        /// 查找主脚本
        /// Note: 
        /// </summary>
        /// <returns></returns>
        MonoBehaviour FindMainScript();
    }

    internal interface IInternalPanelInstance
    {
        /// <summary>
        /// Set panel info.
        /// 设置定义数据
        /// </summary>
        /// <param name="info"></param>
        void SetPanelInfo(IPanelInfo info);

        /// <summary>
        /// Set panel display vier
        /// 设置显示节点
        /// </summary>
        /// <param name="view"></param>
        void SetDisplayView(GameObject view);

        /// <summary>
        /// Invoke background action with background settings.
        /// 执行背景处理功能
        /// </summary>
        void InvokeBackgroundAction(bool onEndOfFrame);

        /// <summary>
        /// Add panel view to container.
        /// 把显示对象添加到显示容器中
        /// </summary>
        void AppendViewToContainer();

        /// <summary>
        /// Dispose
        /// 销亡处理
        /// </summary>
        void Dispose();
    }
}