Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of RepoOrbLimits v0.1.0
OrbLimits.dll
Decompiled 2 hours agousing System; using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Configuration; using HarmonyLib; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyVersion("0.0.0.0")] [BepInPlugin("pavuk.repo.orblimits", "R.E.P.O. Orb Limits", "0.1.0")] public sealed class OrbLimits : BaseUnityPlugin { private const string Id = "pavuk.repo.orblimits"; private static ConfigEntry<int> orbLimit; private Harmony harmony; private void Awake() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Expected O, but got Unknown orbLimit = ((BaseUnityPlugin)this).Config.Bind<int>("Orbs", "DropsPerEnemy", 0, new ConfigDescription("0 removes the cap. A positive number sets the cap per enemy.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, int.MaxValue), new object[0])); harmony = new Harmony("pavuk.repo.orblimits"); try { harmony.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(EnemyParent), "Despawn", Type.EmptyTypes, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(OrbLimits), "ReplaceOrbCap", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null); ((BaseUnityPlugin)this).Logger.LogInfo((object)"R.E.P.O. Orb Limits loaded."); } catch (Exception ex) { harmony.UnpatchSelf(); ((BaseUnityPlugin)this).Logger.LogError((object)ex); } } private void OnDestroy() { if (harmony != null) { harmony.UnpatchSelf(); } } private static int GetOrbLimit() { if (orbLimit.Value != 0) { return orbLimit.Value; } return int.MaxValue; } private static IEnumerable<CodeInstruction> ReplaceOrbCap(IEnumerable<CodeInstruction> instructions) { //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Expected O, but got Unknown List<CodeInstruction> list = instructions.ToList(); FieldInfo cap = AccessTools.Field(typeof(EnemyHealth), "spawnValuableMax"); if (cap == null || cap.FieldType != typeof(int)) { throw new InvalidOperationException("The enemy orb limit field has changed."); } CodeInstruction[] array = list.Where((CodeInstruction instruction) => instruction.opcode == OpCodes.Ldfld && object.Equals(instruction.operand, cap)).ToArray(); if (array.Length != 1) { throw new InvalidOperationException("The enemy orb drop check has changed."); } CodeInstruction val = array[0]; int num = list.IndexOf(val); OpCode opcode = list[num + 1].opcode; if (opcode != OpCodes.Bge && opcode != OpCodes.Bge_S) { throw new InvalidOperationException("The enemy orb limit comparison has changed."); } val.opcode = OpCodes.Pop; val.operand = null; list.Insert(num + 1, new CodeInstruction(OpCodes.Call, (object)AccessTools.DeclaredMethod(typeof(OrbLimits), "GetOrbLimit", (Type[])null, (Type[])null))); return list; } }