using BepInEx;
using BepInEx.Logging;
using System.Reflection;
using UnityEngine;
using Dawn;
using Dawn.Utils;
using HarmonyLib;
using Dusk;
using BepInEx.Configuration;
using HookahPlace.Content;

namespace HookahPlace;

[BepInPlugin(MyPluginInfo.PLUGIN_GUID, MyPluginInfo.PLUGIN_NAME, MyPluginInfo.PLUGIN_VERSION)]
[BepInDependency(DawnLib.PLUGIN_GUID)]
public class HookahPlace : BaseUnityPlugin
{
    internal new static ManualLogSource Logger { get; private set; } = null!;
    internal new static ConfigFile Config { get; private set; } = null!;

    internal static DuskMod Mod { get; private set; } = null!;

    private void Awake()
    {
        Logger = base.Logger;
        Config = base.Config;

        Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), MyPluginInfo.PLUGIN_GUID);

        AssetBundle mainBundle = AssetBundleUtils.LoadBundle(Assembly.GetExecutingAssembly(), "hookahplaceasset");
        Mod = DuskMod.RegisterMod(this, mainBundle);

        // Effectively the same as `Mod.RegisterContentHandlers();` but simpler and faster
        _ = new HookahContentHandler(Mod);

        Logger.LogInfo($"{MyPluginInfo.PLUGIN_GUID} v{MyPluginInfo.PLUGIN_VERSION} has loaded!");
    }
}
