Decompiled source of ExposeEditorlessMembers v1.1.0

plugins/ExposeEditorlessMembers.dll

Decompiled 2 weeks ago
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 FrooxEngine;
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("eia485")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0+e6dc55e824a051ac259f8b18444da9fb4b8514cc")]
[assembly: AssemblyProduct("ExposeEditorlessMembers")]
[assembly: AssemblyTitle("ExposeEditorlessMembers")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/EIA485/NeosExposeEditorlessMembers")]
[assembly: AssemblyVersion("1.1.0.0")]
[module: RefSafetyRules(11)]
namespace ExposeEditorlessMembers;

[ResonitePlugin("net.eia485.ExposeEditorlessMembers", "ExposeEditorlessMembers", "1.1.0", "eia485", "https://github.com/EIA485/NeosExposeEditorlessMembers")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class ExposeEditorlessMembers : BasePlugin
{
	[HarmonyPatch(typeof(SyncMemberEditorBuilder), "Build")]
	private class SyncMemberEditorBuilderPatch
	{
		private static global::System.Collections.Generic.IEnumerable<CodeInstruction> Transpiler(global::System.Collections.Generic.IEnumerable<CodeInstruction> codes)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Expected O, but got Unknown
			List<CodeInstruction> val = new List<CodeInstruction>(codes);
			int num = -1;
			object obj = null;
			for (int i = 1; i < val.Count - 1; i++)
			{
				if (val[i].opcode == OpCodes.Isinst && val[i].operand == typeof(EmptySyncElement) && val[i - 1].opcode == OpCodes.Ldarg_0 && val[i + 1].opcode == OpCodes.Stloc_S)
				{
					obj = val[i + 1].operand;
					num = i - 1;
					break;
				}
			}
			if (obj != null)
			{
				val.RemoveAt(num);
				val.RemoveAt(num);
				val.RemoveAt(num);
				for (int j = 0; j < val.Count; j++)
				{
					if (val[j].opcode == OpCodes.Ldloc_S && val[j].operand == obj)
					{
						val[j] = new CodeInstruction(OpCodes.Ldarg_0, (object)null);
					}
				}
			}
			else
			{
				log.Log((LogLevel)2, (object)"SyncMemberEditorBuilder.Build Transpiler Failed");
			}
			return (global::System.Collections.Generic.IEnumerable<CodeInstruction>)val;
		}
	}

	[HarmonyPatch(typeof(BagEditor), "BuildBagElement")]
	private class BuildBagElementPatch
	{
		[CompilerGenerated]
		private sealed class <Transpiler>d__0 : global::System.Collections.Generic.IEnumerable<CodeInstruction>, global::System.Collections.IEnumerable, global::System.Collections.Generic.IEnumerator<CodeInstruction>, 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<CodeInstruction> codes;

			public global::System.Collections.Generic.IEnumerable<CodeInstruction> <>3__codes;

			private global::System.Collections.Generic.IEnumerator<CodeInstruction> <>7__wrap1;

			CodeInstruction global::System.Collections.Generic.IEnumerator<CodeInstruction>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object global::System.Collections.IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <Transpiler>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 || num == 1)
				{
					try
					{
					}
					finally
					{
						<>m__Finally1();
					}
				}
				<>7__wrap1 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0041: Unknown result type (might be due to invalid IL or missing references)
				//IL_0046: Unknown result type (might be due to invalid IL or missing references)
				try
				{
					switch (<>1__state)
					{
					default:
						return false;
					case 0:
						<>1__state = -1;
						<>7__wrap1 = codes.GetEnumerator();
						<>1__state = -3;
						break;
					case 1:
						<>1__state = -3;
						break;
					}
					while (((global::System.Collections.IEnumerator)<>7__wrap1).MoveNext())
					{
						CodeInstruction current = <>7__wrap1.Current;
						if (current.opcode != OpCodes.Castclass)
						{
							<>2__current = current;
							<>1__state = 1;
							return true;
						}
					}
					<>m__Finally1();
					<>7__wrap1 = 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__wrap1 != null)
				{
					((global::System.IDisposable)<>7__wrap1).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<CodeInstruction> global::System.Collections.Generic.IEnumerable<CodeInstruction>.GetEnumerator()
			{
				<Transpiler>d__0 <Transpiler>d__;
				if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
				{
					<>1__state = 0;
					<Transpiler>d__ = this;
				}
				else
				{
					<Transpiler>d__ = new <Transpiler>d__0(0);
				}
				<Transpiler>d__.codes = <>3__codes;
				return <Transpiler>d__;
			}

			[DebuggerHidden]
			global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator()
			{
				return (global::System.Collections.IEnumerator)((global::System.Collections.Generic.IEnumerable<CodeInstruction>)this).GetEnumerator();
			}
		}

		[IteratorStateMachine(typeof(<Transpiler>d__0))]
		private static global::System.Collections.Generic.IEnumerable<CodeInstruction> Transpiler(global::System.Collections.Generic.IEnumerable<CodeInstruction> codes)
		{
			global::System.Collections.Generic.IEnumerator<CodeInstruction> enumerator = codes.GetEnumerator();
			try
			{
				while (((global::System.Collections.IEnumerator)enumerator).MoveNext())
				{
					CodeInstruction current = enumerator.Current;
					if (current.opcode != OpCodes.Castclass)
					{
						yield return current;
					}
				}
			}
			finally
			{
				((global::System.IDisposable)enumerator)?.Dispose();
			}
		}
	}

	[HarmonyPatchCategory("HiddenToggle")]
	[HarmonyPatch(typeof(WorkerInspector), "BuildInspectorUI")]
	private class WorkerInspectorPatch
	{
		private static global::System.Collections.Generic.IEnumerable<CodeInstruction> Transpiler(global::System.Collections.Generic.IEnumerable<CodeInstruction> codes)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			List<CodeInstruction> val = new List<CodeInstruction>(codes);
			int num = -1;
			for (int i = 2; i < val.Count - 1; i++)
			{
				if (val[i - 2].opcode == OpCodes.Ldarg_0 && val[i].opcode == OpCodes.Callvirt && val[i + 1].opcode == OpCodes.Call)
				{
					object operand = val[i + 1].operand;
					object obj = ((operand is MethodInfo) ? operand : null);
					if (((obj != null) ? ((MemberInfo)obj).Name : null) == "GetCustomAttribute")
					{
						num = i - 2;
						break;
					}
				}
			}
			if (num > -1)
			{
				val.RemoveAt(num);
				val.RemoveAt(num);
				val.RemoveAt(num);
				val.RemoveAt(num);
				val.RemoveAt(num);
			}
			else
			{
				log.Log((LogLevel)2, (object)"WorkerInspector.BuildInspectorUI Transpiler Failed");
			}
			return (global::System.Collections.Generic.IEnumerable<CodeInstruction>)val;
		}
	}

	private static ManualLogSource log;

	private static ConfigEntry<bool> ShowHidden;

	private static bool HiddenPatched;

	private const string HiddenCat = "HiddenToggle";

	public override void Load()
	{
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Expected O, but got Unknown
		ShowHidden = ((BasePlugin)this).Config.Bind<bool>("ExposeEditorlessMembers", "Ignore HideInInspectorAttribute", true, (ConfigDescription)null);
		log = ((BasePlugin)this).Log;
		((BasePlugin)this).HarmonyInstance.PatchAllUncategorized();
		ShowHidden.SettingChanged += new EventHandler(ShowHidden_SettingChanged);
		ShowHidden_SettingChanged();
	}

	private void ShowHidden_SettingChanged(object? sender = null, EventArgs e = null)
	{
		if (ShowHidden.Value != HiddenPatched)
		{
			if (ShowHidden.Value)
			{
				((BasePlugin)this).HarmonyInstance.PatchCategory("HiddenToggle");
			}
			else
			{
				((BasePlugin)this).HarmonyInstance.UnpatchCategory("HiddenToggle");
			}
			HiddenPatched = ShowHidden.Value;
		}
	}
}
public static class PluginMetadata
{
	public const string GUID = "net.eia485.ExposeEditorlessMembers";

	public const string NAME = "ExposeEditorlessMembers";

	public const string VERSION = "1.1.0";

	public const string AUTHORS = "eia485";

	public const string REPOSITORY_URL = "https://github.com/EIA485/NeosExposeEditorlessMembers";
}