using System; using System.Collections; 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.Configuration; using BepInEx.Logging; using BepInEx.NET.Common; using BepInExResoniteShim; using BepisLocaleLoader; using Elements.Core; using FrooxEngine; using FrooxEngine.ProtoFlux; using FrooxEngine.UIX; using HarmonyLib; using Renderite.Shared; using SkyFrost.Base; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(/*Could not decode attribute arguments.*/)] [assembly: TargetFramework(".NETCoreApp,Version=v10.0", FrameworkDisplayName = ".NET 10.0")] [assembly: AssemblyCompany("LeCloutPanda, NepuShiro, art0007i")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.1.0.0")] [assembly: AssemblyInformationalVersion("1.1.0+ea4d86f3b53bba6c8742f2f9113dd16f773b5e47")] [assembly: AssemblyProduct("Toggles")] [assembly: AssemblyTitle("Toggles")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/lecloutpanda/Toggles")] [assembly: AssemblyVersion("1.1.0.0")] [module: RefSafetyRules(11)] [CompilerGenerated] internal delegate TResult <>f__AnonymousDelegate0(T1 arg1, T2 arg2, T3 arg3, out T4 arg4, T5 arg5 = default(T5)); namespace Toggles; [ResonitePlugin("dev.lecloutpanda.Toggles", "Toggles", "1.1.0", "LeCloutPanda, NepuShiro, art0007i", "https://github.com/lecloutpanda/Toggles")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BasePlugin { [HarmonyPatch] public static class WikiIntegrationPatches { [CompilerGenerated] private sealed class d__1 : global::System.Collections.Generic.IEnumerable, global::System.Collections.IEnumerable, global::System.Collections.Generic.IEnumerator, global::System.Collections.IEnumerator, global::System.IDisposable { private int <>1__state; private CodeInstruction <>2__current; private int <>l__initialThreadId; private global::System.Collections.Generic.IEnumerable codes; public global::System.Collections.Generic.IEnumerable <>3__codes; private bool 5__2; private global::System.Collections.Generic.IEnumerator <>7__wrap2; CodeInstruction global::System.Collections.Generic.IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object global::System.Collections.IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__1(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void global::System.IDisposable.Dispose() { int num = <>1__state; if (num == -3 || (uint)(num - 1) <= 1u) { try { } finally { <>m__Finally1(); } } <>7__wrap2 = null; <>1__state = -2; } private bool MoveNext() { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Expected O, but got Unknown try { switch (<>1__state) { default: return false; case 0: <>1__state = -1; 5__2 = false; <>7__wrap2 = codes.GetEnumerator(); <>1__state = -3; break; case 1: <>1__state = -3; break; case 2: <>1__state = -3; break; } if (((global::System.Collections.IEnumerator)<>7__wrap2).MoveNext()) { CodeInstruction current = <>7__wrap2.Current; if (CodeInstructionExtensions.Calls(current, wikiFunc)) { 5__2 = true; <>2__current = new CodeInstruction(OpCodes.Call, (object)((global::System.Delegate)(object)new Func(FakeWikiFuncInspector)).Method); <>1__state = 1; return true; } <>2__current = current; <>1__state = 2; return true; } <>m__Finally1(); <>7__wrap2 = null; if (!5__2) { Log.LogError((object)"Failed to patch WikiIntegrationComponentPatch"); } return false; } catch { //try-fault ((global::System.IDisposable)this).Dispose(); throw; } } bool global::System.Collections.IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<>7__wrap2 != null) { ((global::System.IDisposable)<>7__wrap2).Dispose(); } } [DebuggerHidden] void global::System.Collections.IEnumerator.Reset() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(); } [DebuggerHidden] global::System.Collections.Generic.IEnumerator global::System.Collections.Generic.IEnumerable.GetEnumerator() { d__1 d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; d__ = this; } else { d__ = new d__1(0); } d__.codes = <>3__codes; return d__; } [DebuggerHidden] global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator() { return (global::System.Collections.IEnumerator)((global::System.Collections.Generic.IEnumerable)this).GetEnumerator(); } } [CompilerGenerated] private sealed class d__2 : global::System.Collections.Generic.IEnumerable, global::System.Collections.IEnumerable, global::System.Collections.Generic.IEnumerator, global::System.Collections.IEnumerator, global::System.IDisposable { private int <>1__state; private CodeInstruction <>2__current; private int <>l__initialThreadId; private global::System.Collections.Generic.IEnumerable codes; public global::System.Collections.Generic.IEnumerable <>3__codes; private bool 5__2; private global::System.Collections.Generic.IEnumerator <>7__wrap2; CodeInstruction global::System.Collections.Generic.IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object global::System.Collections.IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__2(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void global::System.IDisposable.Dispose() { int num = <>1__state; if (num == -3 || (uint)(num - 1) <= 1u) { try { } finally { <>m__Finally1(); } } <>7__wrap2 = null; <>1__state = -2; } private bool MoveNext() { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Expected O, but got Unknown try { switch (<>1__state) { default: return false; case 0: <>1__state = -1; 5__2 = false; <>7__wrap2 = codes.GetEnumerator(); <>1__state = -3; break; case 1: <>1__state = -3; break; case 2: <>1__state = -3; break; } if (((global::System.Collections.IEnumerator)<>7__wrap2).MoveNext()) { CodeInstruction current = <>7__wrap2.Current; if (CodeInstructionExtensions.Calls(current, wikiFunc)) { 5__2 = true; <>2__current = new CodeInstruction(OpCodes.Call, (object)((global::System.Delegate)(object)new Func(FakeWikiFuncProtoflux)).Method); <>1__state = 1; return true; } <>2__current = current; <>1__state = 2; return true; } <>m__Finally1(); <>7__wrap2 = null; if (!5__2) { Log.LogError((object)"Failed to patch ProtofluxPatch"); } return false; } catch { //try-fault ((global::System.IDisposable)this).Dispose(); throw; } } bool global::System.Collections.IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<>7__wrap2 != null) { ((global::System.IDisposable)<>7__wrap2).Dispose(); } } [DebuggerHidden] void global::System.Collections.IEnumerator.Reset() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(); } [DebuggerHidden] global::System.Collections.Generic.IEnumerator global::System.Collections.Generic.IEnumerable.GetEnumerator() { d__2 d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; d__ = this; } else { d__ = new d__2(0); } d__.codes = <>3__codes; return d__; } [DebuggerHidden] global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator() { return (global::System.Collections.IEnumerator)((global::System.Collections.Generic.IEnumerable)this).GetEnumerator(); } } private static MethodInfo wikiFunc = AccessTools.Method(typeof(Hyperlink), "AttachForWikiPage", (global::System.Type[])null, (global::System.Type[])null); [IteratorStateMachine(typeof(d__1))] [HarmonyPatch(typeof(WorkerInspector), "BuildUIForComponent")] [HarmonyTranspiler] public static global::System.Collections.Generic.IEnumerable InspectorTranspiler(global::System.Collections.Generic.IEnumerable codes) { bool found = false; global::System.Collections.Generic.IEnumerator enumerator = codes.GetEnumerator(); try { while (((global::System.Collections.IEnumerator)enumerator).MoveNext()) { CodeInstruction current = enumerator.Current; if (CodeInstructionExtensions.Calls(current, wikiFunc)) { found = true; yield return new CodeInstruction(OpCodes.Call, (object)((global::System.Delegate)(object)new Func(FakeWikiFuncInspector)).Method); } else { yield return current; } } } finally { ((global::System.IDisposable)enumerator)?.Dispose(); } if (!found) { Log.LogError((object)"Failed to patch WikiIntegrationComponentPatch"); } } [IteratorStateMachine(typeof(d__2))] [HarmonyPatch(typeof(ProtoFluxTool), "GenerateMenuItems")] [HarmonyTranspiler] public static global::System.Collections.Generic.IEnumerable ProtofluxToolTranspiler(global::System.Collections.Generic.IEnumerable codes) { bool found = false; global::System.Collections.Generic.IEnumerator enumerator = codes.GetEnumerator(); try { while (((global::System.Collections.IEnumerator)enumerator).MoveNext()) { CodeInstruction current = enumerator.Current; if (CodeInstructionExtensions.Calls(current, wikiFunc)) { found = true; yield return new CodeInstruction(OpCodes.Call, (object)((global::System.Delegate)(object)new Func(FakeWikiFuncProtoflux)).Method); } else { yield return current; } } } finally { ((global::System.IDisposable)enumerator)?.Dispose(); } if (!found) { Log.LogError((object)"Failed to patch ProtofluxPatch"); } } public static Hyperlink? FakeWikiFuncInspector(Slot slot, global::System.Type type) { if (WIKI_INTEGRATION_INSPECTOR.Value) { return Hyperlink.AttachForWikiPage(slot, type); } slot.Destroy(); return null; } public static Hyperlink? FakeWikiFuncProtoflux(Slot slot, global::System.Type type) { if (WIKI_INTEGRATION_PROTOFLUX.Value) { return Hyperlink.AttachForWikiPage(slot, type); } slot.Destroy(); return null; } } [HarmonyPatch(typeof(InventoryBrowser))] public static class InventoryBrowserPatch { [HarmonyPatch("OnItemSelected")] [HarmonyPostfix] public static void Postfix(SyncRef