using System.Linq;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using HarmonyLib.Tools;

namespace CykaRaider {
	[BepInPlugin(pluginGuid, pluginName, pluginVersion)]
	public class Main : BaseUnityPlugin {
		private const string pluginGuid = "CykaRaider";
		private const string pluginName = "CykaRaider";
		private const string pluginVersion = "1.0.0";

		public static ConfigEntry<int> lootTimeAdder;
		public static ConfigEntry<float> maxStackMultiplier;
		public static ConfigEntry<bool> autoLoot;
		public static ConfigEntry<float> upgradePriceMultiplier;

		public static ConfigEntry<bool> debugMode;

		public void Awake() {
			debugMode = Config.Bind("General", "Debug Mode", false, new ConfigDescription("Debug Mode"));
			lootTimeAdder = Config.Bind("General", "Loot Time Adder", 0, new ConfigDescription("Loot Time Adder"));
			maxStackMultiplier = Config.Bind("General", "Max Stack Multiplier", 1f, new ConfigDescription("Max Stack Multiplier"));
			autoLoot = Config.Bind("General", "Auto Loot", false, new ConfigDescription("Auto Loot"));
			upgradePriceMultiplier = Config.Bind("General", "Upgrade Price Multiplier", 1f, new ConfigDescription("Upgrade Price Multiplier"));

			Logger.LogInfo("Cyka mod loaded");
			HarmonyFileLog.Enabled = true;
			Harmony harmony = new Harmony(pluginGuid);
			harmony.PatchAll();
			var originalMethods = harmony.GetPatchedMethods();
			Logger.LogInfo("Patched " + originalMethods.Count() + " methods");
			foreach (var method in originalMethods) {
				Logger.LogInfo("Patched " + method.Name);
			}
		}
	}
}
