using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("Erenshor-LowLevelXP")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Erenshor-LowLevelXP")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("94b45ee5-5d6d-42f3-ae85-a86d3da11c5a")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Erenshor_LowLevelXP;
[BepInPlugin("Brad522.LowLevelXP", "Low Level XP", "1.0.0")]
public class LowLevelXP : BaseUnityPlugin
{
[HarmonyPatch(typeof(Character))]
[HarmonyPatch("DoDeath")]
public static class AlwaysGainXPPatch
{
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
List<CodeInstruction> list = new List<CodeInstruction>(instructions);
for (int i = 0; i < list.Count - 2; i++)
{
if (list[i].opcode == OpCodes.Sub && list[i + 1].opcode == OpCodes.Ldc_I4_4 && list[i + 2].opcode == OpCodes.Bgt)
{
CodeInstruction val = list[i + 3];
if (val.labels.Count == 0)
{
Label label = default(Label);
val.labels.Add(label);
list[i + 2].operand = label;
}
else
{
list[i + 2].operand = val.labels[0];
}
break;
}
}
return list.AsEnumerable();
}
}
internal const string ModName = "LowLevelXP";
internal const string ModVersion = "1.0.0";
internal const string ModDescription = "Low Level XP";
internal const string Author = "Brad522";
private const string ModGUID = "Brad522.LowLevelXP";
private readonly Harmony harmony = new Harmony("Brad522.LowLevelXP");
public void Awake()
{
harmony.PatchAll();
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin LowLevelXP is loaded!");
}
private void OnDestroy()
{
harmony.UnpatchAll("Brad522.LowLevelXP");
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin LowLevelXP is unloaded!");
}
}