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

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

		public static ConfigEntry<float> moneyMultiplier;

		public void Awake() {
			moneyMultiplier = Config.Bind("General", "MoneyMultiplier", 1f);

			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);
			}
		}
	}

	[HarmonyPatch]
	public class Patches {
		[HarmonyPrefix]
		[HarmonyPatch(typeof(EconomyController), "AddFunds")]
		public static void Prefix(ref float sum) {
			sum *= Main.moneyMultiplier.Value;
		}
	}
}