using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; 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(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("DestroyItemInSlotFix")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("DestroyItemInSlotFix")] [assembly: AssemblyTitle("DestroyItemInSlotFix")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace DestroyItemInSlotFix { [BepInPlugin("JacobG5.DestroyItemInSlotFix", "DestroyItemInSlotFix", "1.0.0")] public class Plugin : BaseUnityPlugin { [CompilerGenerated] private sealed class d__6 : IEnumerable, IEnumerable, IEnumerator, IEnumerator, IDisposable { private int <>1__state; private CodeInstruction <>2__current; private int <>l__initialThreadId; private IEnumerable instructions; public IEnumerable <>3__instructions; private MethodBase original; public MethodBase <>3__original; private MethodInfo 5__1; private FieldInfo 5__2; private MethodInfo 5__3; private MethodInfo 5__4; private int 5__5; private List 5__6; private int 5__7; private IEnumerator <>s__8; private CodeInstruction 5__9; private int <>s__10; private CodeInstruction 5__11; private List.Enumerator <>s__12; private CodeInstruction 5__13; CodeInstruction IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__6(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if ((uint)(num - -4) <= 1u || (uint)(num - 1) <= 3u) { try { if (num == -4 || num == 3) { try { } finally { <>m__Finally2(); } } } finally { <>m__Finally1(); } } 5__1 = null; 5__2 = null; 5__3 = null; 5__4 = null; 5__6 = null; <>s__8 = null; 5__9 = null; 5__11 = null; <>s__12 = default(List.Enumerator); 5__13 = null; <>1__state = -2; } private bool MoveNext() { //IL_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Expected O, but got Unknown //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Expected O, but got Unknown try { switch (<>1__state) { default: return false; case 0: <>1__state = -1; 5__1 = AccessTools.Method(typeof(HUDManager), "get_Instance", (Type[])null, (Type[])null); 5__2 = AccessTools.Field(typeof(HUDManager), "itemSlotIcons"); 5__3 = AccessTools.Method(typeof(Behaviour), "set_enabled", (Type[])null, (Type[])null); 5__4 = AccessTools.Method(typeof(Plugin), "UpdateSlotIcons", (Type[])null, (Type[])null); 5__5 = 0; 5__6 = new List(); 5__7 = 0; <>s__8 = instructions.GetEnumerator(); <>1__state = -3; goto IL_03e2; case 1: <>1__state = -3; <>2__current = new CodeInstruction(OpCodes.Call, (object)5__4); <>1__state = 2; return true; case 2: <>1__state = -3; 5__6.Clear(); 5__11 = null; goto IL_03da; case 3: <>1__state = -4; 5__13 = null; goto IL_038d; case 4: { <>1__state = -3; goto IL_03da; } IL_03e2: if (<>s__8.MoveNext()) { 5__9 = <>s__8.Current; <>s__10 = 5__6.Count; if (1 == 0) { } bool flag = <>s__10 switch { 0 => 5__9.opcode == OpCodes.Call && CodeInstructionExtensions.Calls(5__9, 5__1), 1 => 5__9.opcode == OpCodes.Ldfld && CodeInstructionExtensions.LoadsField(5__9, 5__2, false), 2 => 5__9.opcode == OpCodes.Ldarg_1, 3 => 5__9.opcode == OpCodes.Ldelem_Ref, 4 => 5__9.opcode == OpCodes.Ldc_I4_0, 5 => 5__9.opcode == OpCodes.Callvirt && CodeInstructionExtensions.Calls(5__9, 5__3), _ => false, }; if (1 == 0) { } if (flag) { 5__6.Add(5__9); 5__7 = Mathf.Max(5__6.Count, 5__7); if (5__6.Count >= 6) { 5__5++; 5__11 = new CodeInstruction(OpCodes.Ldarg_1, (object)null); 5__11.labels.AddRange(5__6[0].labels); <>2__current = 5__11; <>1__state = 1; return true; } goto IL_03da; } if (5__6.Count > 0) { <>s__12 = 5__6.GetEnumerator(); <>1__state = -4; goto IL_038d; } goto IL_03ba; } <>m__Finally1(); <>s__8 = null; mls.LogInfo((object)$"found {5__5} in {original.DeclaringType.FullName} | {5__7}"); return false; IL_038d: if (<>s__12.MoveNext()) { 5__13 = <>s__12.Current; <>2__current = 5__13; <>1__state = 3; return true; } <>m__Finally2(); <>s__12 = default(List.Enumerator); 5__6.Clear(); goto IL_03ba; IL_03ba: <>2__current = 5__9; <>1__state = 4; return true; IL_03da: 5__9 = null; goto IL_03e2; } } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<>s__8 != null) { <>s__8.Dispose(); } } private void <>m__Finally2() { <>1__state = -3; ((IDisposable)<>s__12).Dispose(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { d__6 d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; d__ = this; } else { d__ = new d__6(0); } d__.instructions = <>3__instructions; d__.original = <>3__original; return d__; } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)this).GetEnumerator(); } } private const string modGUID = "JacobG5.DestroyItemInSlotFix"; private const string modName = "DestroyItemInSlotFix"; private const string modVersion = "1.0.0"; private readonly Harmony harmony = new Harmony("JacobG5.DestroyItemInSlotFix"); private static ManualLogSource mls; public void Awake() { mls = Logger.CreateLogSource("JacobG5.DestroyItemInSlotFix"); harmony.PatchAll(typeof(Plugin)); } [IteratorStateMachine(typeof(d__6))] [HarmonyPatch(typeof(PlayerControllerB), "DestroyItemInSlot")] [HarmonyTranspiler] public static IEnumerable FindObjectTranspiler(IEnumerable instructions, MethodBase original) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__6(-2) { <>3__instructions = instructions, <>3__original = original }; } public static void UpdateSlotIcons(int itemSlot) { if (itemSlot == 50) { ((Behaviour)HUDManager.Instance.itemOnlySlotIcon).enabled = false; } else { ((Behaviour)HUDManager.Instance.itemSlotIcons[itemSlot]).enabled = false; } } } }