using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using Radium.PingPongPatch.Managers;
using UnityEngine;

namespace Radium.PingPongPatch;

[BepInPlugin("com.radium.pingpong", "Radium.PingPongPatch", "1.0.0")]
internal class Plugin : BasePlugin
{
    internal static new ManualLogSource Log;

    #region Config
    /// <summary>
    /// If this plugin should be enabled or not or if we should break before anything gets patched
    /// </summary>
    internal static ConfigEntry<bool> Enabled;

    /// <summary>
    /// Determines if we should show a UI for FPS
    /// </summary>
    internal static ConfigEntry<bool> ShowFPS;
    /// <summary>
    /// Determines if we should show a UI for local ping
    /// </summary>
    internal static ConfigEntry<bool> ShowPing;
    #endregion

    public override void Load()
    {
        Log = base.Log;

        Enabled = Config.Bind(section: "General", key: "Enabled", defaultValue: true, description: "Determines if the patch is enabled.");
        if (!Enabled.Value) return;

        ShowFPS = Config.Bind(section: "General", key: "Show FPS", defaultValue: true, description: "Determines if we should show a UI for FPS");
        ShowPing = Config.Bind(section: "General", key: "Show Ping", defaultValue: true, description: "Determines if we should show a UI for local ping");

        AddComponent<PingPongManager>();

        Log.LogInfo($"Ping, pong, ping, pong, ping, pong! Scram, you two! This is my bedroom now! No way, this is our REC ROOM");
    }
}