Decompiled source of Fix XP Divide By Zero Error v1.0.0

LC_FixXpDbzError.dll

Decompiled 8 months ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("LC_FixXpDbzError")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LC_FixXpDbzError")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("1A234A95-815A-48C7-BA28-7DE4EBE61415")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace LC_FixXpDbzError;

[BepInPlugin("SimplexityDev.LC_FixXpDbzError", "Fix XP DivideByZero Error", "1.0.0.0")]
[HarmonyPatch]
public class Main : BaseUnityPlugin
{
	private const string modGUID = "SimplexityDev.LC_FixXpDbzError";

	private const string modName = "Fix XP DivideByZero Error";

	private const string modVersion = "1.0.0.0";

	private readonly Harmony harmony = new Harmony("SimplexityDev.LC_FixXpDbzError");

	private static ManualLogSource logger;

	private void Awake()
	{
		logger = Logger.CreateLogSource("SimplexityDev.LC_FixXpDbzError");
		harmony.PatchAll();
	}

	[HarmonyPatch(typeof(HUDManager), "SetPlayerLevel")]
	private static void Prefix(HUDManager __instance)
	{
		logger.LogInfo((object)"Testing for XPMax == 0");
		if (__instance.playerLevels[__instance.localPlayerLevel].XPMax == 0)
		{
			__instance.playerLevels[__instance.localPlayerLevel].XPMax = 1;
			logger.LogWarning((object)$"Detected localPlayerLevel ({__instance.localPlayerLevel}) XPMax as 0, setting to 1.");
		}
	}
}