using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Minimum_One_Box; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("MinimumOneBox")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.8.0")] [assembly: AssemblyInformationalVersion("1.0.8")] [assembly: AssemblyProduct("MinimumOneBox")] [assembly: AssemblyTitle("MinimumOneBox")] [assembly: AssemblyVersion("1.0.8.0")] [HarmonyPatch(typeof(ValuableDirector), "SetupHost")] public class ResetPatch { private static void Prefix() { Plugin.ResetRoll(); } } namespace Minimum_One_Box; [BepInPlugin("minimum.one.box", "Minimum One Box", "1.0.0")] public class Plugin : BaseUnityPlugin { internal static ManualLogSource Log; private Harmony harmony; private static bool forcedRollUsed; private void Awake() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; harmony = new Harmony("minimum.one.box"); harmony.PatchAll(); Type type = typeof(ValuableDirector).GetNestedTypes(BindingFlags.NonPublic).First((Type t) => t.Name.Contains("SetupHost")); harmony.Patch((MethodBase)AccessTools.Method(type, "MoveNext", (Type[])null, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "SetupHostTranspiler", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null); Log.LogInfo((object)"Minimum One Box Loaded"); } public static int GuaranteedRoll(int min, int max) { if (!forcedRollUsed) { forcedRollUsed = true; Log.LogInfo((object)"Forcing first cosmetic roll success."); return 0; } return Random.Range(min, max); } private static IEnumerable SetupHostTranspiler(IEnumerable instructions) { List list = new List(instructions); MethodInfo methodInfo = AccessTools.Method(typeof(Random), "Range", new Type[2] { typeof(int), typeof(int) }, (Type[])null); MethodInfo operand = AccessTools.Method(typeof(Plugin), "GuaranteedRoll", (Type[])null, (Type[])null); bool flag = false; for (int i = 0; i < list.Count - 2; i++) { bool flag2 = list[i].opcode == OpCodes.Ldc_I4_0; bool flag3 = (list[i + 1].opcode == OpCodes.Ldc_I4_S || list[i + 1].opcode == OpCodes.Ldc_I4) && Convert.ToInt32(list[i + 1].operand) == 100; bool flag4 = CodeInstructionExtensions.Calls(list[i + 2], methodInfo); if (flag2 && flag3 && flag4) { list[i + 2].operand = operand; flag = true; Log.LogInfo((object)"Patched cosmetic roll."); break; } } if (!flag) { Log.LogError((object)"Failed to patch cosmetic roll."); } return list; } public static void ResetRoll() { forcedRollUsed = false; Log.LogInfo((object)"Reset guaranteed cosmetic roll."); } }