Decompiled source of ShowUserspaceSpawnButton v1.0.3

plugins/ShowUserspaceSpawnButton.dll

Decompiled 2 weeks ago
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 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.0.3.0")]
[assembly: AssemblyInformationalVersion("1.0.3+1853da452c070f402f8ff5269e5bd6e6bc67a89c")]
[assembly: AssemblyProduct("ShowUserspaceSpawnButton")]
[assembly: AssemblyTitle("ShowUserspaceSpawnButton")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/EIA485/NeosShowUserspaceSpawnButton")]
[assembly: AssemblyVersion("1.0.3.0")]
[module: RefSafetyRules(11)]
namespace ShowUserspaceSpawnButton;

[ResonitePlugin("net.eia485.ShowUserspaceSpawnButton", "ShowUserspaceSpawnButton", "1.0.3", "eia485", "https://github.com/EIA485/NeosShowUserspaceSpawnButton")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class ShowUserspaceSpawnButton : BasePlugin
{
	[HarmonyPatch(typeof(InventoryBrowser), "OnItemSelected")]
	private class ShowUserspaceSpawnButtonPatch
	{
		private static global::System.Collections.Generic.IEnumerable<CodeInstruction> Transpiler(global::System.Collections.Generic.IEnumerable<CodeInstruction> instructions)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: 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)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Expected O, but got Unknown
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			bool flag = false;
			List<CodeInstruction> val = Enumerable.ToList<CodeInstruction>(instructions);
			for (int i = 0; i < val.Count; i++)
			{
				if (val[i].opcode == OpCodes.Ldloc_1 && val[i + 1].opcode == OpCodes.Ldc_I4_5 && val[i + 5].opcode == OpCodes.Brfalse)
				{
					val[i] = new CodeInstruction(OpCodes.Ldloc_0, (object)null);
					val[i + 1] = val[i + 5];
					val.RemoveRange(i + 2, 4);
					val[i - 2].opcode = OpCodes.Ldc_I4_1;
					flag = true;
					break;
				}
			}
			if (!flag)
			{
				log.LogError((object)"Transpiler failed on InventoryBrowser.OnItemSelected");
			}
			return Enumerable.AsEnumerable<CodeInstruction>((global::System.Collections.Generic.IEnumerable<CodeInstruction>)val);
		}

		[HarmonyPostfix]
		[HarmonyPatch("OnAttach")]
		private static void OnAttachPostFixSync(Sync<SpecialItemType> ____lastSpecialItemType)
		{
			((SyncField<SpecialItemType>)(object)____lastSpecialItemType).Value = (SpecialItemType)(-1);
		}
	}

	private static ManualLogSource log;

	public override void Load()
	{
		log = ((BasePlugin)this).Log;
		((BasePlugin)this).HarmonyInstance.PatchAll();
	}

	public override bool Unload()
	{
		((BasePlugin)this).HarmonyInstance.UnpatchSelf();
		return true;
	}
}
public static class PluginMetadata
{
	public const string GUID = "net.eia485.ShowUserspaceSpawnButton";

	public const string NAME = "ShowUserspaceSpawnButton";

	public const string VERSION = "1.0.3";

	public const string AUTHORS = "eia485";

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