Files
BepInEx/Projects/BanquetForFools/BanquetForCyka/Class1.cs

52 lines
1.9 KiB
C#

using System;
using System.Linq;
using System.Collections.Generic;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using HarmonyLib.Tools;
namespace BanquetForCyka {
[BepInPlugin(PluginGuid, PluginName, PluginVersion)]
public class Main : BaseUnityPlugin {
private const string PluginGuid = "BanquetForCyka";
private const string PluginName = "BanquetForCyka";
private const string PluginVersion = "1.0.0";
public static ConfigEntry<bool> debug;
public static ConfigEntry<bool> debugXp;
public static ExpressionConfigEntry xpMultiplier;
public void Awake() {
debug = Config.Bind("Debug", "Global Debug", false);
debugXp = Config.Bind("Debug", "XP Debug", false);
xpMultiplier =
new ExpressionConfigEntry(Config, "General", "XP Multiplier", "v*1",
"XP Multiplier expression. Use 'v' to represent the original value.");
Logger.LogInfo("BanquetForCyka loaded");
HarmonyFileLog.Enabled = true;
Harmony harmony = new Harmony(PluginGuid);
harmony.PatchAll();
var originalMethods = harmony.GetPatchedMethods();
Logger.LogInfo("Patched " + originalMethods.Count() + " methods");
}
public static void LogDebug(string message, ConfigEntry<bool> debugFlag = null) {
if (debug.Value || (debugFlag != null && debugFlag.Value))
Console.WriteLine(message);
}
}
[HarmonyPatch(typeof(Stats), "AddXP")]
public class Stats_AddXP {
public static void Prefix(ref int amt) {
Main.LogDebug("Original XP amount: " + amt, Main.debugXp);
float result = Main.xpMultiplier.Evaluate(amt);
amt = (int)result;
Main.LogDebug("Modified XP amount: " + amt, Main.debugXp);
}
}
}