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 BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using BepInEx.NET.Common; using BepInExResoniteShim; using Elements.Core; using FrooxEngine; using FrooxEngine.UIX; using HarmonyLib; [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("art0007i")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.1.1.0")] [assembly: AssemblyInformationalVersion("1.1.1+1796397cd00d2412b768710007e35dbc48a3ba7f")] [assembly: AssemblyProduct("ExtrasButtonTweaks")] [assembly: AssemblyTitle("ExtrasButtonTweaks")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/art0007i/ExtrasButtonTweaks")] [assembly: AssemblyVersion("1.1.1.0")] [module: RefSafetyRules(11)] namespace ExtrasButtonTweaks; [ResonitePlugin("art0007i.ExtrasButtonTweaks", "ExtrasButtonTweaks", "1.1.1", "art0007i", "https://github.com/art0007i/ExtrasButtonTweaks")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BasePlugin { private class ExtrasButtonTweaksPatch { [CompilerGenerated] private sealed class d__0 : 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__0(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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: 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 (!5__2) { object operand = current.operand; MethodInfo val = (MethodInfo)((operand is MethodInfo) ? operand : null); if (val != null && ((MemberInfo)val).Name == "Button") { 5__2 = true; <>2__current = new CodeInstruction(OpCodes.Call, (object)typeof(ExtrasButtonTweaksPatch).GetMethod("CreateExtrasButton")); <>1__state = 1; return true; } } <>2__current = current; <>1__state = 2; return true; } <>m__Finally1(); <>7__wrap2 = null; 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__0 d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; d__ = this; } else { d__ = new d__0(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(); } } [IteratorStateMachine(typeof(d__0))] public static global::System.Collections.Generic.IEnumerable Transpiler(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 (!found) { object operand = current.operand; MethodInfo val = (MethodInfo)((operand is MethodInfo) ? operand : null); if (val != null && ((MemberInfo)val).Name == "Button") { found = true; yield return new CodeInstruction(OpCodes.Call, (object)typeof(ExtrasButtonTweaksPatch).GetMethod("CreateExtrasButton")); continue; } } yield return current; } } finally { ((global::System.IDisposable)enumerator)?.Dispose(); } } public static Button CreateExtrasButton(UIBuilder ui, IAssetProvider s, in colorX color, LocaleString text, float buttonTextSplit, float buttonTextSplitGap) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) colorX val = ((colorX)(ref color)).MulRGB(0.66f); ui.PushStyle(); ui.Style.ButtonSprite = (IAssetProvider)(object)RadiantUI_Constants.GetOutlinedSprite(ui.World); ui.Style.ButtonColor = val; LocaleString val2 = LocaleString.op_Implicit("☰"); colorX? val3 = val; Button result = ui.Button(ref val2, ref val3); ui.PopStyle(); return result; } } private class RemoveVectorActionsPatch { [CompilerGenerated] private sealed class d__0 : 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 MethodInfo 5__2; private MethodInfo 5__3; private global::System.Collections.Generic.IEnumerator <>7__wrap3; 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__0(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) <= 2u) { try { } finally { <>m__Finally1(); } } 5__2 = null; 5__3 = null; <>7__wrap3 = null; <>1__state = -2; } private bool MoveNext() { //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Expected O, but got Unknown //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Expected O, but got Unknown try { switch (<>1__state) { default: return false; case 0: <>1__state = -1; 5__2 = AccessTools.Method(typeof(ContextMenu), "AddItem", new global::System.Type[4] { typeof(LocaleString).MakeByRefType(), typeof(Uri), typeof(colorX?).MakeByRefType(), typeof(ButtonEventHandler) }, (global::System.Type[])null); 5__3 = AccessTools.Method(typeof(ReflectionExtensions), "GetVectorDimensions", (global::System.Type[])null, (global::System.Type[])null); <>7__wrap3 = codes.GetEnumerator(); <>1__state = -3; break; case 1: <>1__state = -3; break; case 2: <>1__state = -3; break; case 3: <>1__state = -3; break; } if (((global::System.Collections.IEnumerator)<>7__wrap3).MoveNext()) { CodeInstruction current = <>7__wrap3.Current; if (CodeInstructionExtensions.Calls(current, 5__2)) { <>2__current = new CodeInstruction(OpCodes.Call, (object)typeof(RemoveVectorActionsPatch).GetMethod("AddItemProxy")); <>1__state = 1; return true; } if (CodeInstructionExtensions.Calls(current, 5__3)) { <>2__current = new CodeInstruction(OpCodes.Call, (object)typeof(RemoveVectorActionsPatch).GetMethod("VectorDimensionsProxy")); <>1__state = 2; return true; } <>2__current = current; <>1__state = 3; return true; } <>m__Finally1(); <>7__wrap3 = null; 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__wrap3 != null) { ((global::System.IDisposable)<>7__wrap3).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__0 d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; d__ = this; } else { d__ = new d__0(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(); } } public static MethodInfo averageFunc = AccessTools.Method(typeof(InspectorMemberActions), "SetAllToAvg", (global::System.Type[])null, (global::System.Type[])null); [IteratorStateMachine(typeof(d__0))] public static global::System.Collections.Generic.IEnumerable Transpiler(global::System.Collections.Generic.IEnumerable codes) { MethodInfo lookFor = AccessTools.Method(typeof(ContextMenu), "AddItem", new global::System.Type[4] { typeof(LocaleString).MakeByRefType(), typeof(Uri), typeof(colorX?).MakeByRefType(), typeof(ButtonEventHandler) }, (global::System.Type[])null); MethodInfo lookFor2 = AccessTools.Method(typeof(ReflectionExtensions), "GetVectorDimensions", (global::System.Type[])null, (global::System.Type[])null); global::System.Collections.Generic.IEnumerator enumerator = codes.GetEnumerator(); try { while (((global::System.Collections.IEnumerator)enumerator).MoveNext()) { CodeInstruction current = enumerator.Current; if (CodeInstructionExtensions.Calls(current, lookFor)) { yield return new CodeInstruction(OpCodes.Call, (object)typeof(RemoveVectorActionsPatch).GetMethod("AddItemProxy")); } else if (CodeInstructionExtensions.Calls(current, lookFor2)) { yield return new CodeInstruction(OpCodes.Call, (object)typeof(RemoveVectorActionsPatch).GetMethod("VectorDimensionsProxy")); } else { yield return current; } } } finally { ((global::System.IDisposable)enumerator)?.Dispose(); } } public static ContextMenuItem AddItemProxy(ContextMenu menu, in LocaleString label, Uri icon, in colorX? color, ButtonEventHandler action) { if (HideVectorAverage.Value && ((global::System.Delegate)(object)action).Method == averageFunc) { return null; } return menu.AddItem(ref label, icon, ref color, action); } public static int VectorDimensionsProxy(global::System.Type type) { if (HideVectorSetTo.Value) { return 0; } return ReflectionExtensions.GetVectorDimensions(type); } } private class AllowDropPatch { [CompilerGenerated] private sealed class d__0 : 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 MethodInfo 5__2; private global::System.Collections.Generic.IEnumerator <>7__wrap2; private CodeInstruction 5__4; 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__0(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) <= 2u) { try { } finally { <>m__Finally1(); } } 5__2 = null; <>7__wrap2 = null; 5__4 = null; <>1__state = -2; } private bool MoveNext() { //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Expected O, but got Unknown //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Expected O, but got Unknown try { switch (<>1__state) { default: return false; case 0: <>1__state = -1; 5__2 = AccessTools.Property(typeof(IValueFieldProxySource), "Field").SetMethod; <>7__wrap2 = codes.GetEnumerator(); <>1__state = -3; goto IL_012f; case 1: <>1__state = -3; goto IL_00bc; case 2: <>1__state = -3; if (CodeInstructionExtensions.Calls(5__4, 5__2)) { <>2__current = new CodeInstruction(OpCodes.Call, (object)typeof(AllowDropPatch).GetMethod("Inject")); <>1__state = 3; return true; } goto IL_0128; case 3: { <>1__state = -3; goto IL_0128; } IL_00bc: <>2__current = 5__4; <>1__state = 2; return true; IL_0128: 5__4 = null; goto IL_012f; IL_012f: if (((global::System.Collections.IEnumerator)<>7__wrap2).MoveNext()) { 5__4 = <>7__wrap2.Current; if (CodeInstructionExtensions.Is(5__4, OpCodes.Castclass, (MemberInfo)(object)typeof(IValueFieldProxySource))) { <>2__current = new CodeInstruction(OpCodes.Dup, (object)null); <>1__state = 1; return true; } goto IL_00bc; } <>m__Finally1(); <>7__wrap2 = null; 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__0 d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; d__ = this; } else { d__ = new d__0(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(); } } [IteratorStateMachine(typeof(d__0))] public static global::System.Collections.Generic.IEnumerable Transpiler(global::System.Collections.Generic.IEnumerable codes) { MethodInfo lookFor = AccessTools.Property(typeof(IValueFieldProxySource), "Field").SetMethod; global::System.Collections.Generic.IEnumerator enumerator = codes.GetEnumerator(); try { while (((global::System.Collections.IEnumerator)enumerator).MoveNext()) { CodeInstruction code = enumerator.Current; if (CodeInstructionExtensions.Is(code, OpCodes.Castclass, (MemberInfo)(object)typeof(IValueFieldProxySource))) { yield return new CodeInstruction(OpCodes.Dup, (object)null); } yield return code; if (CodeInstructionExtensions.Calls(code, lookFor)) { yield return new CodeInstruction(OpCodes.Call, (object)typeof(AllowDropPatch).GetMethod("Inject")); } } } finally { ((global::System.IDisposable)enumerator)?.Dispose(); } } public static void Inject(IValueFieldProxySource source) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) ((IValueReceiver)((ContainerWorker)(object)((IComponent)source).Slot).AttachComponent(typeof(ValueReceiver<>).MakeGenericType(new global::System.Type[1] { ((object)source).GetType().GetGenericArguments()[0] }), true, (Action)null)).TryAssignField(source.Field); } } internal static ManualLogSource Log; internal static ConfigEntry ButtonVisuals; internal static ConfigEntry HideVectorAverage; internal static ConfigEntry HideVectorSetTo; internal static ConfigEntry AllowDrop; public override void Load() { //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Expected O, but got Unknown //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Expected O, but got Unknown //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Expected O, but got Unknown Log = ((BasePlugin)this).Log; ButtonVisuals = ((BasePlugin)this).Config.Bind("General", "ButtonVisuals", true, "When true button visuals will be changed."); HideVectorAverage = ((BasePlugin)this).Config.Bind("General", "HideVectorAverage", false, "When true vector average option will be hidden."); HideVectorSetTo = ((BasePlugin)this).Config.Bind("General", "HideVectorSetTo", false, "When true vector set to options will be hidden."); AllowDrop = ((BasePlugin)this).Config.Bind("General", "AllowDrop", true, "When true you can drop onto the extras button."); MethodInfo val = typeof(InspectorMemberActions).GetNestedType("<>c__DisplayClass5_0", AccessTools.all)?.GetNestedType("<b__0>d", AccessTools.all)?.GetMethod("MoveNext", AccessTools.all); if (val != (MethodInfo)null) { ((BasePlugin)this).HarmonyInstance.Patch((MethodBase)(object)val, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(RemoveVectorActionsPatch).GetMethod("Transpiler")), (HarmonyMethod)null, (HarmonyMethod)null); } else { Log.LogWarning((object)"Failed to patch context menu, options to disable 'Vector Average' and 'Vector Set To' will not work!"); } MethodInfo toPatch = AccessTools.Method(typeof(SyncMemberEditorBuilder), "GenerateMemberField", (global::System.Type[])null, (global::System.Type[])null); MethodInfo patchFunc = AccessTools.Method(typeof(ExtrasButtonTweaksPatch), "Transpiler", (global::System.Type[])null, (global::System.Type[])null); ApplyPatch(((BasePlugin)this).HarmonyInstance, ButtonVisuals.Value, toPatch, patchFunc); ButtonVisuals.SettingChanged += (EventHandler)delegate { ApplyPatch(((BasePlugin)this).HarmonyInstance, ButtonVisuals.Value, toPatch, patchFunc); }; MethodInfo patchFunc2 = AccessTools.Method(typeof(AllowDropPatch), "Transpiler", (global::System.Type[])null, (global::System.Type[])null); ApplyPatch(((BasePlugin)this).HarmonyInstance, AllowDrop.Value, toPatch, patchFunc2); AllowDrop.SettingChanged += (EventHandler)delegate { ApplyPatch(((BasePlugin)this).HarmonyInstance, AllowDrop.Value, toPatch, patchFunc2); }; } private void ApplyPatch(Harmony harmony, bool b, MethodInfo toPatch, MethodInfo patchFunc) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown if (b) { harmony.Patch((MethodBase)(object)toPatch, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(patchFunc), (HarmonyMethod)null, (HarmonyMethod)null); } else { harmony.Unpatch((MethodBase)(object)toPatch, patchFunc); } } } public static class PluginMetadata { public const string GUID = "art0007i.ExtrasButtonTweaks"; public const string NAME = "ExtrasButtonTweaks"; public const string VERSION = "1.1.1"; public const string AUTHORS = "art0007i"; public const string REPOSITORY_URL = "https://github.com/art0007i/ExtrasButtonTweaks"; }