using Monkey.UI;
using Monkey.UI.Windows;

namespace Monkey.Core
{

    public static class PluginManager
    {

        private static readonly string _pluginWindowTitle = $"{Settings.PLUGIN_NAME} Ver. {Settings.PLUGIN_VERSION}";
        private static readonly UnityEngine.Vector2 _pluginWindowSize = new UnityEngine.Vector2(360f, 640f);

        private static readonly string _pluginGameObjectPath = $"/{Settings.PLUGIN_NAME}:{Settings.PLUGIN_VERSION}:{Settings.PLUGIN_NAMESPACE}";

        private static UnityEngine.GameObject _pluginGameObject;

        static PluginManager()
        {
            _pluginGameObject = null;
        }

        public static void Initialize()
        {
            UIManager.RegisterWindow<PluginWindow>(
                _pluginWindowTitle,
                new UnityEngine.Rect(0f, 0f, _pluginWindowSize.x, _pluginWindowSize.y));

            CreatePluginGameObject();

            _pluginGameObject.AddComponent<PluginBehaviour>();
        }

        private static void CreatePluginGameObject()
        {
            _pluginGameObject = new UnityEngine.GameObject(_pluginGameObjectPath);

            _pluginGameObject.hideFlags |= UnityEngine.HideFlags.HideAndDontSave;

            UnityEngine.GameObject.DontDestroyOnLoad(_pluginGameObject);
        }

    }

}
