Decompiled source of ResoniteMario64 v1.1.0

plugins/ResoniteMario64/ResoniteMario64.dll

Decompiled 3 weeks ago
using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Cryptography;
using System.Security.Permissions;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Timers;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.NET.Common;
using BepInExResoniteShim;
using BepisResoniteWrapper;
using BepuPhysics.Collidables;
using Elements.Assets;
using Elements.Core;
using FrooxEngine;
using FrooxEngine.CommonAvatar;
using FrooxEngine.ProtoFlux;
using FrooxEngine.UIX;
using HarmonyLib;
using ProtoFlux.Runtimes.Execution.Nodes.Actions;
using Renderite.Shared;
using ResoniteMario64.Mario64;
using ResoniteMario64.Mario64.Components;
using ResoniteMario64.Mario64.Components.Context;
using ResoniteMario64.Mario64.Components.Interfaces;
using ResoniteMario64.Mario64.Components.Objects;
using ResoniteMario64.Mario64.libsm64;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(/*Could not decode attribute arguments.*/)]
[assembly: IgnoresAccessChecksTo("FrooxEngine")]
[assembly: TargetFramework(".NETCoreApp,Version=v10.0", FrameworkDisplayName = ".NET 10.0")]
[assembly: AssemblyCompany("art0007i, NepuShiro")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0+2dcbe7e6496a4b8e529c67436e4c52d67b0c4f7f")]
[assembly: AssemblyProduct("ResoniteMario64")]
[assembly: AssemblyTitle("ResoniteMario64")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/art0007i/ResoniteMario64")]
[assembly: SecurityPermission((SecurityAction)8, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace ResoniteMario64
{
	public class Config
	{
		public static ConfigEntry<int> GameTickMs;

		public static ConfigEntry<int> MarioScaleFactor;

		public static ConfigEntry<int> MarioCollisionChecks;

		public static ConfigEntry<Uri> MarioUrl;

		public static ConfigEntry<bool> ClampedSurfaces;

		public static ConfigEntry<bool> UseGamepad;

		public static ConfigEntry<bool> BlockDashWithMarios;

		public static ConfigEntry<bool> BlockMarioInputWithDash;

		public static ConfigEntry<bool> BlockMarioInputWithUix;

		public static ConfigEntry<Key> UnlockMovementKey;

		public static ConfigEntry<bool> UnlockMovementKeyToggle;

		public static ConfigEntry<bool> DisableAudio;

		public static ConfigEntry<bool> PlayRandomMusic;

		public static ConfigEntry<bool> PlayCapMusic;

		public static ConfigEntry<float> AudioVolume;

		public static ConfigEntry<bool> LocalAudio;

		public static ConfigEntry<bool> DeleteAfterDeath;

		public static ConfigEntry<float> MarioCullDistance;

		public static ConfigEntry<int> MaxMariosPerPerson;

		public static ConfigEntry<int> MaxMeshColliderTris;

		public static ConfigEntry<bool> DebugEnabled;

		public static ConfigEntry<bool> RenderSlotPublic;

		public static ConfigEntry<bool> LogColliderChanges;

		public static ConfigEntry<bool> LibSM64DebugEnabled;

		public static ConfigEntry<Key> LogColliderKey;

		public static ConfigEntry<Key> RefreshCollidersKey;

		internal static bool ConfigInit(ConfigFile config)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Expected O, but got Unknown
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Expected O, but got Unknown
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Expected O, but got Unknown
			//IL_0251: Unknown result type (might be due to invalid IL or missing references)
			//IL_025b: Expected O, but got Unknown
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Expected O, but got Unknown
			//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bc: Expected O, but got Unknown
			GameTickMs = config.Bind<int>("Engine", "Game Tick Ms", 33, new ConfigDescription("How many Milliseconds should a game tick last. This will directly impact the speed of Mario's behavior.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 100), System.Array.Empty<object>()));
			MarioScaleFactor = config.Bind<int>("Engine", "Mario Scale Factor", 200, new ConfigDescription("The base scaling factor used to size Mario and his colliders. Lower values make Mario larger; higher values make him smaller.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 1000), System.Array.Empty<object>()));
			MarioCollisionChecks = config.Bind<int>("Engine", "Mario Collision Checks", 10, new ConfigDescription("The number of evenly spaced points to check along Mario's body for collisions. Higher values increase accuracy but cost more performance.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 100), System.Array.Empty<object>()));
			MarioUrl = config.Bind<Uri>("Engine", "Mario Url", (Uri)null, "The URL for the Non-Modded Renderer for Mario - Null = Default Mario");
			ClampedSurfaces = config.Bind<bool>("Engine", "Clapped Surfaces", true, "Whether to clamp the colliders to the max mario64 size or not.");
			UseGamepad = config.Bind<bool>("Controls", "Use Gamepad", false, "Whether to use gamepads for input or not.");
			BlockDashWithMarios = config.Bind<bool>("Controls", "Block Dash with Marios", true, "Whether to Block opening the dash with marios or not. !VR-Only!");
			BlockMarioInputWithDash = config.Bind<bool>("Controls", "Block Mario Input with Dash", true, "Whether to Block all mario inputs when the dash is open");
			BlockMarioInputWithUix = config.Bind<bool>("Controls", "Block Mario Input with UIX", true, "Whether to Block all mario inputs when hovering over any UIX");
			UnlockMovementKey = config.Bind<Key>("Controls", "Unlock Movement Key", (Key)46, "The key to unlock movement when marios are present.");
			UnlockMovementKeyToggle = config.Bind<bool>("Controls", "Unlock Movement Key Toggle", true, "When true the unlock movement key will toggle, when false it needs to be held the entire time.");
			DisableAudio = config.Bind<bool>("Audio", "Disable Audio", false, "Whether to disable all Super Mario 64 Music/Sounds or not.");
			AudioVolume = config.Bind<float>("Audio", "Audio Volume", 0.1f, new ConfigDescription("The audio volume.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), System.Array.Empty<object>()));
			PlayRandomMusic = config.Bind<bool>("Audio", "Play Random Music", true, "Whether to play a random music when a mario joins or not.");
			PlayCapMusic = config.Bind<bool>("Audio", "Play Cap Music", true, "Whether to play the Cap music when a mario picks one up or not.");
			LocalAudio = config.Bind<bool>("Audio", "Local Audio", true, "Whether to play the Audio Locally or not.");
			DeleteAfterDeath = config.Bind<bool>("Performance", "Delete Mario After Death", false, "Whether to automatically delete our marios after 5 seconds of being dead or not.");
			MarioCullDistance = config.Bind<float>("Performance", "Mario Cull Distance", 15f, new ConfigDescription("The distance where it should stop using the Super Mario 64 Engine to handle other players Marios.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 50f), System.Array.Empty<object>()));
			MaxMariosPerPerson = config.Bind<int>("Performance", "Max Marios Per Person", 5, new ConfigDescription("Max number of Marios per player that will be animated using the Super Mario 64 Engine.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 20), System.Array.Empty<object>()));
			MaxMeshColliderTris = config.Bind<int>("Performance", "Max Mesh Collider Tris", 50000, new ConfigDescription("Maximum total number of triangles of automatically generated from mesh colliders allowed.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 250000), System.Array.Empty<object>()));
			DebugEnabled = config.Bind<bool>("Debug", "Debug Enabled", false, "Whether to enable debug mode or not.");
			RenderSlotPublic = config.Bind<bool>("Debug", "Render Slot Public", false, "When true the renderer slot will not be a local slot.");
			LogColliderChanges = config.Bind<bool>("Debug", "Log Collider Changes", false, "Whether to Log Collider changes or not.");
			LogColliderKey = config.Bind<Key>("Debug", "Log Collider Key", (Key)92, "The key to toggle logging collider changes.");
			LibSM64DebugEnabled = config.Bind<bool>("Debug", "LibSM64 DebugLog Enabled", false, "Whether to enable LibSM64's DebugLog or not.");
			RefreshCollidersKey = config.Bind<Key>("Debug", "Refresh Colliders Key", (Key)59, "The key to refresh the colliders.");
			return true;
		}
	}
	public static class Constants
	{
		public const string TempSlotName = "__TEMP";

		public const string ContextSlotName = "ResoniteMario64 Instance";

		public const string ConfigSlotName = "Config";

		public const string AudioSlotName = "Audio";

		public const string MarioContainersSlotName = "Mario Containers";

		public const string ContextSpaceName = "SM64Context";

		public const string MarioSpaceName = "Mario";

		public const string HostVarName = "Host";

		public const string ScaleVarName = "Scale";

		public const string WaterVarName = "WaterLevel";

		public const string GasVarName = "GasLevel";

		public const string MarioOwnerVarName = "Owner";

		public const string JoystickVarName = "Joystick";

		public const string JumpVarName = "Jump";

		public const string PunchVarName = "Punch";

		public const string CrouchVarName = "Crouch";

		public const string ViewVarName = "View";

		public const string IsShownVarName = "IsShown";

		public const string IsGrabbedVarName = "IsGrabbed";

		public const string HealthPointsVarName = "HealthPoints";

		public const string CoinsVarName = "Coins";

		public const string RedCoinVarName = "RedCoins";

		public const string MarioAlphaVarName = "MarioAlpha";

		public const string StarVarName = "Stars";

		public const string LiveVarName = "Lives";

		public const string AnimIDVarName = "AnimID";

		public const string AnimFlagVarName = "AnimFlags";

		public const string AnimFrameVarName = "AnimFrame";

		public const string StartFrameVarName = "StartFrame";

		public const string LoopStartVarName = "LoopStart";

		public const string LoopEndVarName = "LoopEnd";

		public const string ActionFlagsVarName = "ActionFlags";

		public const string StateFlagsVarName = "StateFlags";

		public const string ContextTag = "SM64 Context";

		public const string MarioTag = "SM64 Mario";

		public const string MarioContainersTag = "SM64 Mario Containers";

		public const string MarioContainerTag = "SM64 Mario Container";

		public const string MarioNonMRendererTag = "SM64 Non-Modded Renderer";

		public const string AudioTag = "SM64 Audio";

		public const string ConfigTag = "SM64 Config";

		public const string InputBlockTag = "SM64 InputBlock";
	}
	public static class Logger
	{
		private static ManualLogSource Log => Plugin.Log;

		private static string Format(object message, string caller, int line)
		{
			return $"[{caller}|{line}] {message?.ToString() ?? "null"}";
		}

		public static void Debug(object message, [CallerMemberName] string caller = "", [CallerLineNumber] int line = 0)
		{
			Log.LogDebug((object)Format(message, caller, line));
		}

		public static void Info(object message, [CallerMemberName] string caller = "", [CallerLineNumber] int line = 0)
		{
			Log.LogInfo((object)Format(message, caller, line));
		}

		public static void Msg(object message, [CallerMemberName] string caller = "", [CallerLineNumber] int line = 0)
		{
			Log.LogMessage((object)Format(message, caller, line));
		}

		public static void Warn(object message, [CallerMemberName] string caller = "", [CallerLineNumber] int line = 0)
		{
			Log.LogWarning((object)Format(message, caller, line));
		}

		public static void Error(object message, [CallerMemberName] string caller = "", [CallerLineNumber] int line = 0)
		{
			Log.LogError((object)Format(message, caller, line));
		}

		public static void Fatal(object message, [CallerMemberName] string caller = "", [CallerLineNumber] int line = 0)
		{
			Log.LogFatal((object)Format(message, caller, line));
		}
	}
	[ResonitePlugin("art0007i.ResoniteMario64", "ResoniteMario64", "1.1.0", "art0007i, NepuShiro", "https://github.com/art0007i/ResoniteMario64")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BasePlugin
	{
		[CompilerGenerated]
		private sealed class <>c__DisplayClass2_0
		{
			[StructLayout((LayoutKind)3)]
			private struct <<Load>b__1>d : IAsyncStateMachine
			{
				public int <>1__state;

				public AsyncTaskMethodBuilder <>t__builder;

				public <>c__DisplayClass2_0 <>4__this;

				private <>c__DisplayClass2_1 <>8__1;

				private TaskAwaiter <>u__1;

				private void MoveNext()
				{
					//IL_0064: Unknown result type (might be due to invalid IL or missing references)
					//IL_0069: Unknown result type (might be due to invalid IL or missing references)
					//IL_0070: 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_00b4: Unknown result type (might be due to invalid IL or missing references)
					//IL_00c1: Expected O, but got Unknown
					//IL_004a: 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)
					int num = <>1__state;
					<>c__DisplayClass2_0 cS$<>8__locals = <>4__this;
					try
					{
						if (num != 0)
						{
							<>8__1 = new <>c__DisplayClass2_1();
							<>8__1.CS$<>8__locals1 = cS$<>8__locals;
							goto IL_0086;
						}
						TaskAwaiter val = <>u__1;
						<>u__1 = default(TaskAwaiter);
						num = (<>1__state = -1);
						goto IL_007f;
						IL_007f:
						((TaskAwaiter)(ref val)).GetResult();
						goto IL_0086;
						IL_0086:
						if (Userspace.UserspaceWorld == null)
						{
							val = System.Threading.Tasks.Task.Delay(100).GetAwaiter();
							if (!((TaskAwaiter)(ref val)).IsCompleted)
							{
								num = (<>1__state = 0);
								<>u__1 = val;
								((AsyncTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted<TaskAwaiter, <<Load>b__1>d>(ref val, ref this);
								return;
							}
							goto IL_007f;
						}
						<>8__1.w = Userspace.UserspaceWorld;
						<>8__1.w.RunSynchronously((Action)delegate
						{
							//IL_0021: Unknown result type (might be due to invalid IL or missing references)
							//IL_0030: 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_0044: Unknown result type (might be due to invalid IL or missing references)
							//IL_004c: Unknown result type (might be due to invalid IL or missing references)
							//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
							//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
							//IL_0102: Unknown result type (might be due to invalid IL or missing references)
							//IL_0107: 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_0135: Unknown result type (might be due to invalid IL or missing references)
							//IL_013f: Expected O, but got Unknown
							//IL_014e: Unknown result type (might be due to invalid IL or missing references)
							Slot obj = ((Worker)<>8__1.w.RootSlot).LocalUserSpace.AddSlot("ResoniteMario64 Fatal", false);
							UIBuilder val2 = RadiantUI_Panel.SetupPanel(obj, LocaleString.op_Implicit("ResoniteMario64 - <color=Hero.Red>Fatal</color>"), new float2(700f, 350f), false, true);
							float3 localScale = obj.LocalScale;
							obj.LocalScale = (ref localScale) * 0.0008f;
							RadiantUI_Constants.SetupEditorStyle(val2, false);
							val2.VerticalLayout(4f, 0f, (Alignment?)null, (bool?)null, (bool?)null);
							val2.Style.MinHeight = 48f;
							LocaleString val3 = LocaleString.op_Implicit("ResoniteMario64 has encountered a\n<color=Hero.Red>Fatal Error</color> when loading!\nReason:\n<color=Hero.Red>" + ReflectionExtensions.GetNiceName(<>8__1.CS$<>8__locals1.ex.GetType(), "<", ">", "+") + "</color>\n" + <>8__1.CS$<>8__locals1.ex.Message);
							val2.Text(ref val3, 32f, true, (Alignment?)null, true);
							val3 = LocaleString.op_Implicit("Go to Github");
							colorX? val4 = Sub.GREEN;
							Hyperlink obj2 = ((ContainerWorker<Component>)(object)((Component)val2.Button(ref val3, ref val4)).Slot).AttachComponent<Hyperlink>(true, (Action<Hyperlink>)null);
							((SyncField<Uri>)(object)obj2.URL).Value = new Uri("https://github.com/art0007i/ResoniteMario64");
							((SyncField<string>)(object)obj2.Reason).Value = "Opening ResoniteMario64 Github";
							SlotPositioning.PositionInFrontOfUser(obj, (float3?)float3.Backward, (float3?)null, 3f, (User)null, true, true, false);
						}, false, (IUpdatable)null, false);
					}
					catch (System.Exception exception)
					{
						<>1__state = -2;
						<>8__1 = null;
						((AsyncTaskMethodBuilder)(ref <>t__builder)).SetException(exception);
						return;
					}
					<>1__state = -2;
					<>8__1 = null;
					((AsyncTaskMethodBuilder)(ref <>t__builder)).SetResult();
				}

				[DebuggerHidden]
				private void SetStateMachine(IAsyncStateMachine stateMachine)
				{
					((AsyncTaskMethodBuilder)(ref <>t__builder)).SetStateMachine(stateMachine);
				}
			}

			public System.Exception ex;

			public Func<System.Threading.Tasks.Task?> <>9__1;

			internal void <Load>b__0()
			{
				System.Threading.Tasks.Task.Run((Func<System.Threading.Tasks.Task>)([AsyncStateMachine(typeof(<<Load>b__1>d))] () =>
				{
					//IL_0002: Unknown result type (might be due to invalid IL or missing references)
					//IL_0007: Unknown result type (might be due to invalid IL or missing references)
					<<Load>b__1>d <<Load>b__1>d = default(<<Load>b__1>d);
					<<Load>b__1>d.<>t__builder = AsyncTaskMethodBuilder.Create();
					<<Load>b__1>d.<>4__this = this;
					<<Load>b__1>d.<>1__state = -1;
					((AsyncTaskMethodBuilder)(ref <<Load>b__1>d.<>t__builder)).Start<<<Load>b__1>d>(ref <<Load>b__1>d);
					return ((AsyncTaskMethodBuilder)(ref <<Load>b__1>d.<>t__builder)).Task;
				}));
			}

			[AsyncStateMachine(typeof(<<Load>b__1>d))]
			internal System.Threading.Tasks.Task? <Load>b__1()
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				<<Load>b__1>d <<Load>b__1>d = default(<<Load>b__1>d);
				<<Load>b__1>d.<>t__builder = AsyncTaskMethodBuilder.Create();
				<<Load>b__1>d.<>4__this = this;
				<<Load>b__1>d.<>1__state = -1;
				((AsyncTaskMethodBuilder)(ref <<Load>b__1>d.<>t__builder)).Start<<<Load>b__1>d>(ref <<Load>b__1>d);
				return ((AsyncTaskMethodBuilder)(ref <<Load>b__1>d.<>t__builder)).Task;
			}
		}

		[CompilerGenerated]
		private sealed class <>c__DisplayClass2_1
		{
			public World w;

			public <>c__DisplayClass2_0 CS$<>8__locals1;

			internal void <Load>b__2()
			{
				//IL_0021: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: 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_0044: Unknown result type (might be due to invalid IL or missing references)
				//IL_004c: Unknown result type (might be due to invalid IL or missing references)
				//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
				//IL_0102: Unknown result type (might be due to invalid IL or missing references)
				//IL_0107: 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_0135: Unknown result type (might be due to invalid IL or missing references)
				//IL_013f: Expected O, but got Unknown
				//IL_014e: Unknown result type (might be due to invalid IL or missing references)
				Slot obj = ((Worker)w.RootSlot).LocalUserSpace.AddSlot("ResoniteMario64 Fatal", false);
				UIBuilder val = RadiantUI_Panel.SetupPanel(obj, LocaleString.op_Implicit("ResoniteMario64 - <color=Hero.Red>Fatal</color>"), new float2(700f, 350f), false, true);
				float3 localScale = obj.LocalScale;
				obj.LocalScale = (ref localScale) * 0.0008f;
				RadiantUI_Constants.SetupEditorStyle(val, false);
				val.VerticalLayout(4f, 0f, (Alignment?)null, (bool?)null, (bool?)null);
				val.Style.MinHeight = 48f;
				LocaleString val2 = LocaleString.op_Implicit("ResoniteMario64 has encountered a\n<color=Hero.Red>Fatal Error</color> when loading!\nReason:\n<color=Hero.Red>" + ReflectionExtensions.GetNiceName(CS$<>8__locals1.ex.GetType(), "<", ">", "+") + "</color>\n" + CS$<>8__locals1.ex.Message);
				val.Text(ref val2, 32f, true, (Alignment?)null, true);
				val2 = LocaleString.op_Implicit("Go to Github");
				colorX? val3 = Sub.GREEN;
				Hyperlink obj2 = ((ContainerWorker<Component>)(object)((Component)val.Button(ref val2, ref val3)).Slot).AttachComponent<Hyperlink>(true, (Action<Hyperlink>)null);
				((SyncField<Uri>)(object)obj2.URL).Value = new Uri("https://github.com/art0007i/ResoniteMario64");
				((SyncField<string>)(object)obj2.Reason).Value = "Opening ResoniteMario64 Github";
				SlotPositioning.PositionInFrontOfUser(obj, (float3?)float3.Backward, (float3?)null, 3f, (User)null, true, true, false);
			}
		}

		internal static ManualLogSource Log;

		public static readonly string DllDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

		public override void Load()
		{
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Expected O, but got Unknown
			//IL_001d: 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)
			Log = ((BasePlugin)this).Log;
			try
			{
				if (!Config.ConfigInit(((BasePlugin)this).Config))
				{
					throw new InvalidOperationException("Config initialization failed.");
				}
				if (!Mario64Manager.Init())
				{
					throw new InvalidOperationException("Mario64Manager initialization failed.");
				}
				((BasePlugin)this).HarmonyInstance.PatchAll();
				Logger.Info("Plugin art0007i.ResoniteMario64 loaded successfully.", "Load", 40);
			}
			catch (System.Exception ex)
			{
				<>c__DisplayClass2_0 CS$<>8__locals3 = new <>c__DisplayClass2_0();
				System.Exception ex2 = ex;
				CS$<>8__locals3.ex = ex2;
				Logger.Fatal("Failed to load ResoniteMario64.", "Load", 44);
				Logger.Fatal(CS$<>8__locals3.ex, "Load", 45);
				ResoniteHooks.OnEngineReady += (Action)delegate
				{
					System.Threading.Tasks.Task.Run((Func<System.Threading.Tasks.Task>)([AsyncStateMachine(typeof(<>c__DisplayClass2_0.<<Load>b__1>d))] () =>
					{
						//IL_0002: Unknown result type (might be due to invalid IL or missing references)
						//IL_0007: Unknown result type (might be due to invalid IL or missing references)
						<>c__DisplayClass2_0.<<Load>b__1>d <<Load>b__1>d = default(<>c__DisplayClass2_0.<<Load>b__1>d);
						<<Load>b__1>d.<>t__builder = AsyncTaskMethodBuilder.Create();
						<<Load>b__1>d.<>4__this = CS$<>8__locals3;
						<<Load>b__1>d.<>1__state = -1;
						((AsyncTaskMethodBuilder)(ref <<Load>b__1>d.<>t__builder)).Start<<>c__DisplayClass2_0.<<Load>b__1>d>(ref <<Load>b__1>d);
						return ((AsyncTaskMethodBuilder)(ref <<Load>b__1>d.<>t__builder)).Task;
					}));
				};
			}
		}
	}
	public static class PluginMetadata
	{
		public const string GUID = "art0007i.ResoniteMario64";

		public const string NAME = "ResoniteMario64";

		public const string VERSION = "1.1.0";

		public const string AUTHORS = "art0007i, NepuShiro";

		public const string REPOSITORY_URL = "https://github.com/art0007i/ResoniteMario64";
	}
}
namespace ResoniteMario64.Mario64
{
	public static class ColliderShapeExtensions
	{
		public static MeshX GetColliderMesh(this Collider c)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			//IL_008a: 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: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: 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_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: 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_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0367: Unknown result type (might be due to invalid IL or missing references)
			MeshX val = new MeshX();
			TriangleCollider val2 = (TriangleCollider)(object)((c is TriangleCollider) ? c : null);
			if (val2 == null)
			{
				CapsuleCollider val3 = (CapsuleCollider)(object)((c is CapsuleCollider) ? c : null);
				if (val3 == null)
				{
					ConeCollider val4 = (ConeCollider)(object)((c is ConeCollider) ? c : null);
					if (val4 == null)
					{
						CylinderCollider val5 = (CylinderCollider)(object)((c is CylinderCollider) ? c : null);
						if (val5 == null)
						{
							BoxCollider val6 = (BoxCollider)(object)((c is BoxCollider) ? c : null);
							if (val6 == null)
							{
								SphereCollider val7 = (SphereCollider)(object)((c is SphereCollider) ? c : null);
								if (val7 == null)
								{
									MeshCollider val8 = (MeshCollider)(object)((c is MeshCollider) ? c : null);
									if (val8 == null)
									{
										ConvexHullCollider val9 = (ConvexHullCollider)(object)((c is ConvexHullCollider) ? c : null);
										if (val9 != null)
										{
											if (((MeshBasedCollider<ConvexHull, ConvexHullData>)(object)val9).Mesh.IsAssetAvailable)
											{
												return ((SyncRef<IAssetProvider<Mesh>>)(object)((MeshBasedCollider<ConvexHull, ConvexHullData>)(object)val9).Mesh).Target.Asset.Data;
											}
											if (Config.DebugEnabled.Value)
											{
												Logger.Warn($"- [{((object)val9).GetType()}] {((Component)val9).Slot.Name} ({((Worker)val9).ReferenceID}) Mesh is null or not readable", "GetColliderMesh", 79);
											}
										}
									}
									else
									{
										if (((MeshBasedCollider<Mesh, MeshColliderData>)(object)val8).Mesh.IsAssetAvailable)
										{
											return ((SyncRef<IAssetProvider<Mesh>>)(object)((MeshBasedCollider<Mesh, MeshColliderData>)(object)val8).Mesh).Target.Asset.Data;
										}
										if (Config.DebugEnabled.Value)
										{
											Logger.Warn($"- [{((object)val8).GetType()}] {((Component)val8).Slot.Name} ({((Worker)val8).ReferenceID}) Mesh is null or not readable", "GetColliderMesh", 70);
										}
									}
								}
								else
								{
									((MeshXShape)new UVSphereCapsule(MeshX.op_Implicit(val), 8, 16, (Shading)3, false)
									{
										Radius = ((SyncField<float>)(object)val7.Radius).Value
									}).Update();
								}
							}
							else
							{
								((MeshXShape)new Box(MeshX.op_Implicit(val))
								{
									Size = ((SyncField<float3>)(object)val6.Size).Value
								}).Update();
							}
						}
						else
						{
							((MeshXShape)new ConicalFrustum(MeshX.op_Implicit(val), 8, true, true)
							{
								Radius = ((SyncField<float>)(object)val5.Radius).Value,
								Height = ((SyncField<float>)(object)val5.Height).Value
							}).Update();
						}
					}
					else
					{
						((MeshXShape)new ConicalFrustum(MeshX.op_Implicit(val), 8, true, true)
						{
							Radius = ((SyncField<float>)(object)val4.Radius).Value,
							RadiusTop = 0f,
							Height = ((SyncField<float>)(object)val4.Height).Value
						}).Update();
					}
				}
				else
				{
					((MeshXShape)new UVSphereCapsule(MeshX.op_Implicit(val), 8, 16, (Shading)3, true)
					{
						Radius = ((SyncField<float>)(object)val3.Radius).Value,
						Height = ((SyncField<float>)(object)val3.Height).Value
					}).Update();
				}
			}
			else
			{
				TriangleSubmesh val10 = val.AddSubmesh<TriangleSubmesh>();
				float3 value = ((SyncField<float3>)(object)val2.A).Value;
				float3 value2 = ((SyncField<float3>)(object)((Collider)val2).Offset).Value;
				float3 val11 = (ref value) + (ref value2);
				val.AddVertex(ref val11);
				value = ((SyncField<float3>)(object)val2.B).Value;
				value2 = ((SyncField<float3>)(object)((Collider)val2).Offset).Value;
				val11 = (ref value) + (ref value2);
				val.AddVertex(ref val11);
				value = ((SyncField<float3>)(object)val2.C).Value;
				value2 = ((SyncField<float3>)(object)((Collider)val2).Offset).Value;
				val11 = (ref value) + (ref value2);
				val.AddVertex(ref val11);
				val10.AddTriangle(0, 1, 2);
			}
			return val;
		}
	}
	public static class Mario64Manager
	{
		private const string RomExpectedHash = "20b854b239203baf6c961b850a4a51a2";

		private const string RomFileName = "baserom.us.z64";

		internal static byte[] RomBytes;

		public static readonly string LibName = "sm64" + (OperatingSystem.IsWindows() ? ".dll" : ".so");

		public static readonly string OtherLibName = "sm64" + (OperatingSystem.IsWindows() ? ".so" : ".dll");

		public static readonly string LibPath = Path.Combine(Plugin.DllDirectory, LibName);

		public static readonly string OtherLibPath = Path.Combine(Plugin.DllDirectory, OtherLibName);

		internal static bool Init()
		{
			if (!ExtractNativeLibrary())
			{
				return false;
			}
			if (!LoadRom())
			{
				return false;
			}
			return true;
		}

		private static bool ExtractNativeLibrary()
		{
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			Logger.Info($"Copying {LibName} to {LibPath} from embedded resources.", "ExtractNativeLibrary", 34);
			Stream manifestResourceStream = typeof(Mario64Manager).Assembly.GetManifestResourceStream(LibName);
			try
			{
				if (manifestResourceStream == null)
				{
					throw new FileLoadException("Embedded resource " + LibName + " not found in assembly.");
				}
				FileStream val = File.Open(LibPath, (FileMode)2, (FileAccess)2);
				try
				{
					manifestResourceStream.CopyTo((Stream)(object)val);
					if (File.Exists(OtherLibPath))
					{
						File.Delete(OtherLibPath);
					}
					return true;
				}
				finally
				{
					((System.IDisposable)val)?.Dispose();
				}
			}
			finally
			{
				((System.IDisposable)manifestResourceStream)?.Dispose();
			}
		}

		private static bool LoadRom()
		{
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			string[] obj = new string[4]
			{
				Path.Combine(Plugin.DllDirectory, "baserom.us.z64"),
				Path.Combine(Directory.GetCurrentDirectory(), "baserom.us.z64"),
				Path.Combine(Directory.GetCurrentDirectory(), "rml_libs", "baserom.us.z64"),
				Path.Combine(Directory.GetCurrentDirectory(), "rml_mods", "baserom.us.z64")
			};
			string text = null;
			string[] array = obj;
			foreach (string text2 in array)
			{
				Logger.Msg("Checking for ROM at " + text2, "LoadRom", 66);
				if (File.Exists(text2))
				{
					text = text2;
					break;
				}
				Logger.Debug("ROM not found at " + text2, "LoadRom", 73);
			}
			if (text == null)
			{
				throw new FileLoadException("Missing ROM: Download a \"Super Mario 64 [US].z64\" ROM (MD5 20b854b239203baf6c961b850a4a51a2)");
			}
			Logger.Info("Loading \"Super Mario 64 [US].z64\" ROM from " + text + "...", "LoadRom", 81);
			FileStream val = File.OpenRead(text);
			try
			{
				string text3 = Convert.ToHexStringLower(((HashAlgorithm)MD5.Create()).ComputeHash((Stream)(object)val));
				if (text3 != "20b854b239203baf6c961b850a4a51a2")
				{
					throw new FileLoadException($"Invalid ROM Hash: Found {text3}, expected {"20b854b239203baf6c961b850a4a51a2"}.");
				}
				RomBytes = File.ReadAllBytes(text);
				return true;
			}
			finally
			{
				((System.IDisposable)val)?.Dispose();
			}
		}
	}
	public static class Patches
	{
		[HarmonyPatch(typeof(UpdateManager), "RunUpdates")]
		private class WorldUpdatePatch
		{
			private static readonly Stopwatch updateTimer = new Stopwatch();

			private static World lastWorld;

			private static bool initialized;

			public static void Prefix(UpdateManager __instance)
			{
				//IL_0020: Unknown result type (might be due to invalid IL or missing references)
				//IL_0026: Invalid comparison between Unknown and I4
				//IL_005e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0063: Unknown result type (might be due to invalid IL or missing references)
				try
				{
					World world = __instance.World;
					SM64Context instance = SM64Context.Instance;
					if (instance != null && instance.World == world)
					{
						instance.OnCommonUpdate();
					}
					if ((int)world.Focus == 1)
					{
						if (!initialized || lastWorld != world)
						{
							updateTimer.Reset();
							updateTimer.Start();
							initialized = true;
							lastWorld = world;
						}
						TimeSpan elapsed = updateTimer.Elapsed;
						if (((TimeSpan)(ref elapsed)).TotalSeconds >= 5.0)
						{
							SM64Context.CheckForInstance(world);
							updateTimer.Restart();
						}
					}
				}
				catch (System.Exception message)
				{
					Logger.Error(message, "Prefix", 66);
				}
			}
		}

		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		public class WorldStartRunningPatch
		{
			[Serializable]
			[CompilerGenerated]
			private sealed class <>c
			{
				public static readonly <>c <>9 = new <>c();

				public static SlotChildEvent <>9__1_1;

				public static SlotChildEvent <>9__1_2;

				internal void <Postfix>b__1_1(Slot _, Slot child)
				{
					if (!(child.Name != "__TEMP"))
					{
						SM64Context.TempSlot = child;
					}
				}

				internal void <Postfix>b__1_2(Slot slot, Slot child)
				{
					//IL_003d: Unknown result type (might be due to invalid IL or missing references)
					//IL_0047: Expected O, but got Unknown
					//IL_0042: Unknown result type (might be due to invalid IL or missing references)
					<>c__DisplayClass1_1 CS$<>8__locals3 = new <>c__DisplayClass1_1
					{
						slot = slot
					};
					if (!(child.Name != "__TEMP"))
					{
						CS$<>8__locals3.slot.RunInUpdates((int)((Worker)CS$<>8__locals3.slot).LocalUser.AllocationID, (Action)delegate
						{
							SM64Context.TempSlot = CS$<>8__locals3.slot.FindChildOrAdd("__TEMP", false);
						});
					}
				}
			}

			[CompilerGenerated]
			private sealed class <>c__DisplayClass1_1
			{
				public Slot slot;

				internal void <Postfix>b__3()
				{
					SM64Context.TempSlot = slot.FindChildOrAdd("__TEMP", false);
				}
			}

			private static readonly Dictionary<World, Action<World>> Subscriptions = new Dictionary<World, Action<World>>();

			public static void Postfix(World __instance)
			{
				//IL_008f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0094: Unknown result type (might be due to invalid IL or missing references)
				//IL_009a: Expected O, but got Unknown
				//IL_00be: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c9: Expected O, but got Unknown
				if (WorldExtensions.IsUserspace(__instance))
				{
					return;
				}
				Engine current = Engine.Current;
				if (((current != null) ? current.WorldManager : null) == null || Subscriptions.ContainsKey(__instance))
				{
					return;
				}
				Action<World> val = delegate(World world)
				{
					WorldSubMethod(world, __instance);
				};
				Subscriptions[__instance] = val;
				Engine.Current.WorldManager.WorldFocused += val;
				Slot rootSlot = __instance.RootSlot;
				object obj = <>c.<>9__1_1;
				if (obj == null)
				{
					SlotChildEvent val2 = delegate(Slot _, Slot child)
					{
						if (!(child.Name != "__TEMP"))
						{
							SM64Context.TempSlot = child;
						}
					};
					<>c.<>9__1_1 = val2;
					obj = (object)val2;
				}
				rootSlot.ChildAdded += (SlotChildEvent)obj;
				Slot rootSlot2 = __instance.RootSlot;
				object obj2 = <>c.<>9__1_2;
				if (obj2 == null)
				{
					SlotChildEvent val3 = delegate(Slot slot, Slot child)
					{
						//IL_003d: Unknown result type (might be due to invalid IL or missing references)
						//IL_0047: Expected O, but got Unknown
						//IL_0042: Unknown result type (might be due to invalid IL or missing references)
						if (!(child.Name != "__TEMP"))
						{
							slot.RunInUpdates((int)((Worker)slot).LocalUser.AllocationID, (Action)delegate
							{
								SM64Context.TempSlot = slot.FindChildOrAdd("__TEMP", false);
							});
						}
					};
					<>c.<>9__1_2 = val3;
					obj2 = (object)val3;
				}
				rootSlot2.ChildRemoved += (SlotChildEvent)obj2;
			}

			private static void WorldSubMethod(World world, World instance)
			{
				//IL_0023: Unknown result type (might be due to invalid IL or missing references)
				//IL_0029: Invalid comparison between Unknown and I4
				//IL_0035: Unknown result type (might be due to invalid IL or missing references)
				//IL_003f: Expected O, but got Unknown
				//IL_003a: Unknown result type (might be due to invalid IL or missing references)
				if (world != instance)
				{
					UnsubscribeWorldFocused(instance);
				}
				else
				{
					if ((int)world.Focus != 1)
					{
						return;
					}
					world.RunInUpdates(3, (Action)delegate
					{
						try
						{
							SM64Context.CheckForInstance(instance);
						}
						finally
						{
							UnsubscribeWorldFocused(instance);
						}
					});
				}
			}

			private static void UnsubscribeWorldFocused(World world)
			{
				Action<World> val = default(Action<World>);
				if (Subscriptions.TryGetValue(world, ref val))
				{
					Engine.Current.WorldManager.WorldFocused -= val;
					Subscriptions.Remove(world);
				}
			}
		}

		[HarmonyPatch(typeof(UserRoot))]
		private class UserRootPatch
		{
			private const string VariableName = "User/ResoniteMario64.HasInstance";

			[HarmonyPatch("OnStart")]
			[HarmonyPostfix]
			public static void OnStartPatch(UserRoot __instance)
			{
				//IL_001b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0025: Expected O, but got Unknown
				//IL_0020: Unknown result type (might be due to invalid IL or missing references)
				((ComponentBase<Component>)(object)__instance).RunInUpdates(3, (Action)delegate
				{
					if (__instance.ActiveUser == ((Worker)__instance).LocalUser)
					{
						((SyncField<string>)(object)((DynamicVariableBase<bool>)(object)((ContainerWorker<Component>)(object)((Component)__instance).Slot).AttachComponent<DynamicValueVariable<bool>>(true, (Action<DynamicValueVariable<bool>>)null)).VariableName).Value = "User/ResoniteMario64.HasInstance";
					}
				});
			}

			[HarmonyPatch("OnCommonUpdate")]
			[HarmonyPostfix]
			public static void CommonUpdatePatch(UserRoot __instance)
			{
				//IL_0022: Unknown result type (might be due to invalid IL or missing references)
				if (__instance.ActiveUser == ((Worker)__instance).LocalUser)
				{
					DynamicVariableHelper.WriteDynamicVariable<bool>(((Component)__instance).Slot, "User/ResoniteMario64.HasInstance", SM64Context.Instance != null);
				}
			}
		}

		[HarmonyPatch(typeof(Button))]
		private class ButtonPatches
		{
			[Serializable]
			[CompilerGenerated]
			private sealed class <>c
			{
				public static readonly <>c <>9 = new <>c();

				public static Predicate<Slot> <>9__1_2;

				public static Action <>9__1_1;

				internal bool <RunPressed>b__1_2(Slot x)
				{
					return x.Name == "__TEMP";
				}

				internal void <RunPressed>b__1_1()
				{
					SM64Context.Instance.Dispose();
				}
			}

			private static bool _spawnRunning;

			[HarmonyPatch("RunPressed")]
			[HarmonyPrefix]
			public static bool RunPressed(Button __instance)
			{
				//IL_0047: Unknown result type (might be due to invalid IL or missing references)
				//IL_0052: Expected O, but got Unknown
				//IL_0075: Unknown result type (might be due to invalid IL or missing references)
				//IL_007a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0080: Expected O, but got Unknown
				string tag = ((Component)__instance).Slot.Tag;
				if (!(tag == "SpawnMario"))
				{
					if (tag == "KillInstance")
					{
						if (SM64Context.Instance != null)
						{
							Button obj = __instance;
							object obj2 = <>c.<>9__1_1;
							if (obj2 == null)
							{
								Action val = delegate
								{
									SM64Context.Instance.Dispose();
								};
								<>c.<>9__1_1 = val;
								obj2 = (object)val;
							}
							((ComponentBase<Component>)(object)obj).RunSynchronously((Action)obj2, false);
						}
						return false;
					}
					return true;
				}
				((ComponentBase<Component>)(object)__instance).RunSynchronously((Action)delegate
				{
					//IL_009f: Unknown result type (might be due to invalid IL or missing references)
					//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
					//IL_0104: Expected O, but got Unknown
					//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
					string oldText = __instance.LabelText;
					Slot val2 = (((Worker)__instance).World.RootSlot.FindChild((Predicate<Slot>)((Slot x) => x.Name == "__TEMP"), -1) ?? ((Worker)__instance).World.RootSlot.AddSlot("__TEMP", false)).AddSlot(((Worker)__instance).LocalUser.UserName + "'s Mario", false);
					val2.GlobalPosition = ((Component)__instance).Slot.GlobalPosition;
					ValueUserOverride.OverrideForUser<string>(__instance.LabelTextField, ((Worker)__instance).LocalUser, SM64Context.TryAddMario(val2) ? "Mario Spawned!" : "Mario Spawn Failed!");
					if (!_spawnRunning)
					{
						_spawnRunning = true;
						((ComponentBase<Component>)(object)__instance).RunInSeconds(5f, (Action)delegate
						{
							ValueUserOverride.OverrideForUser<string>(__instance.LabelTextField, ((Worker)__instance).LocalUser, oldText);
							_spawnRunning = false;
						});
					}
				}, false);
				return false;
			}
		}

		[HarmonyPatch(typeof(WorkerInspector), "BuildInspectorUI")]
		private class SlotUIEnumAddon
		{
			private static ConditionalWeakTable<Worker, Dictionary<string, Text>> _conditionalWeakTable = new ConditionalWeakTable<Worker, Dictionary<string, Text>>();

			private static readonly string[] AllColliderTags = new string[6] { "SM64 StaticCollider", "SM64 Collider", "SM64 DynamicCollider", "SM64 Interactable", "SM64 WaterBox", "SM64 Teleporter" };

			public static void Postfix(Worker worker, UIBuilder ui)
			{
				if (!Config.DebugEnabled.Value)
				{
					return;
				}
				Slot val = (Slot)(object)((worker is Slot) ? worker : null);
				if (val == null)
				{
					return;
				}
				Collider component = ((ContainerWorker<Component>)(object)val).GetComponent<Collider>((Predicate<Collider>)null, false);
				if (component != null)
				{
					Dictionary<string, Text> val2 = default(Dictionary<string, Text>);
					if (!_conditionalWeakTable.TryGetValue(worker, ref val2) || val2 == null)
					{
						val2 = new Dictionary<string, Text>(3);
						_conditionalWeakTable.Add(worker, val2);
					}
					val2.Clear();
					Utils.ParseTagParts(val.Tag?.Split(',', (StringSplitOptions)0), out var surfaceType, out var terrainType, out var interactableType, out var _, out var _);
					ColliderCategory colliderCategory = Utils.GetColliderCategory(component);
					BuildEnumEditor(ui, val, "ColliderCategory", colliderCategory, val2);
					BuildEnumEditor(ui, val, "SurfaceType", surfaceType, val2);
					BuildEnumEditor(ui, val, "TerrainType", terrainType, val2);
					BuildEnumEditor(ui, val, "InteractableType", interactableType, val2);
				}
			}

			private static void BuildEnumEditor<T>(UIBuilder ui, Slot slot, string name, T enumValue, Dictionary<string, Text> texts) where T : System.Enum
			{
				//IL_0063: Unknown result type (might be due to invalid IL or missing references)
				//IL_0068: Unknown result type (might be due to invalid IL or missing references)
				//IL_0077: Unknown result type (might be due to invalid IL or missing references)
				//IL_0081: Expected O, but got Unknown
				//IL_0109: Unknown result type (might be due to invalid IL or missing references)
				//IL_010e: Unknown result type (might be due to invalid IL or missing references)
				//IL_011d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0127: Expected O, but got Unknown
				//IL_014d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0152: Unknown result type (might be due to invalid IL or missing references)
				//IL_0161: Unknown result type (might be due to invalid IL or missing references)
				//IL_016b: Expected O, but got Unknown
				ui.HorizontalLayout(4f, 0f, (Alignment?)null);
				ui.Style.FlexibleWidth = -1f;
				ui.Style.MinWidth = 24f;
				LocaleString val = LocaleString.op_Implicit("<<");
				ui.Button(ref val).LocalPressed += (ButtonEventHandler)delegate
				{
					Text val2 = default(Text);
					if (texts.TryGetValue(name, ref val2))
					{
						DecrementEnum(ref enumValue);
						((SyncField<string>)(object)val2.Content).Value = ((object)enumValue/*cast due to .constrained prefix*/).ToString();
						if (typeof(T) == typeof(ColliderCategory))
						{
							SetColliderCategory((ColliderCategory)(object)enumValue, slot);
						}
						else
						{
							SetSlotTag(enumValue, slot);
						}
					}
				};
				ui.Style.FlexibleWidth = 100f;
				ui.Style.MinWidth = -1f;
				Text componentInChildren = ((Component)ui.Button()).Slot.GetComponentInChildren<Text>((Predicate<Text>)null, false, false);
				((SyncField<string>)(object)componentInChildren.Content).Value = ((object)enumValue/*cast due to .constrained prefix*/).ToString();
				texts.Add(name, componentInChildren);
				ui.Style.FlexibleWidth = -1f;
				ui.Style.MinWidth = 24f;
				val = LocaleString.op_Implicit(">>");
				ui.Button(ref val).LocalPressed += (ButtonEventHandler)delegate
				{
					Text val2 = default(Text);
					if (texts.TryGetValue(name, ref val2))
					{
						IncrementEnum(ref enumValue);
						((SyncField<string>)(object)val2.Content).Value = ((object)enumValue/*cast due to .constrained prefix*/).ToString();
						if (typeof(T) == typeof(ColliderCategory))
						{
							SetColliderCategory((ColliderCategory)(object)enumValue, slot);
						}
						else
						{
							SetSlotTag(enumValue, slot);
						}
					}
				};
				ui.Style.FlexibleWidth = -1f;
				ui.Style.MinWidth = 24f;
				val = LocaleString.op_Implicit("∅");
				ui.Button(ref val).LocalPressed += (ButtonEventHandler)delegate
				{
					if (typeof(T) == typeof(ColliderCategory))
					{
						RemoveAllColliderCategories(slot);
					}
					else
					{
						RemoveSlotTagType<T>(slot);
					}
				};
				ui.NestOut();
			}

			private static void SetSlotTag<T>(T enumValue, Slot slot) where T : System.Enum
			{
				RemoveSlotTagType<T>(slot);
				AddSlotTag(enumValue, slot);
			}

			private static void AddSlotTag<T>(T enumValue, Slot slot) where T : System.Enum
			{
				string text = $"{((MemberInfo)typeof(T)).Name.Replace("SM64", "")}_{enumValue}";
				List<string> slotTags = GetSlotTags(slot);
				if (!Enumerable.Contains<string>((System.Collections.Generic.IEnumerable<string>)slotTags, text, (IEqualityComparer<string>)(object)StringComparer.Ordinal))
				{
					slotTags.Add(text);
				}
				slot.Tag = string.Join(",", (System.Collections.Generic.IEnumerable<string>)slotTags);
			}

			private static void RemoveSlotTagType<T>(Slot slot) where T : System.Enum
			{
				string prefix = ((MemberInfo)typeof(T)).Name.Replace("SM64", "") + "_";
				List<string> slotTags = GetSlotTags(slot);
				slotTags.RemoveAll((Predicate<string>)((string x) => x.StartsWith(prefix, (StringComparison)4)));
				slot.Tag = string.Join(",", (System.Collections.Generic.IEnumerable<string>)slotTags);
			}

			private static void SetColliderCategory(ColliderCategory enumValue, Slot slot)
			{
				RemoveAllColliderCategories(slot);
				AddColliderCategory(enumValue, slot);
			}

			private static void AddColliderCategory(ColliderCategory category, Slot slot)
			{
				if (category != ColliderCategory.None)
				{
					List<string> slotTags = GetSlotTags(slot);
					string colliderTag = GetColliderTag(category);
					if (!Enumerable.Contains<string>((System.Collections.Generic.IEnumerable<string>)slotTags, colliderTag, (IEqualityComparer<string>)(object)StringComparer.OrdinalIgnoreCase))
					{
						slotTags.Add(colliderTag);
					}
					slot.Tag = string.Join(",", (System.Collections.Generic.IEnumerable<string>)slotTags);
				}
			}

			private static void RemoveAllColliderCategories(Slot slot)
			{
				List<string> slotTags = GetSlotTags(slot);
				string[] allColliderTags = AllColliderTags;
				foreach (string colliderTag in allColliderTags)
				{
					slotTags.RemoveAll((Predicate<string>)((string x) => string.Equals(x, colliderTag, (StringComparison)5)));
				}
				slot.Tag = string.Join(",", (System.Collections.Generic.IEnumerable<string>)slotTags);
			}

			private static string GetColliderTag(ColliderCategory category)
			{
				return category switch
				{
					ColliderCategory.Static => "SM64 StaticCollider", 
					ColliderCategory.Dynamic => "SM64 DynamicCollider", 
					ColliderCategory.Interactable => "SM64 Interactable", 
					ColliderCategory.WaterBox => "SM64 WaterBox", 
					ColliderCategory.Teleporter => "SM64 Teleporter", 
					_ => string.Empty, 
				};
			}

			private static List<string> GetSlotTags(Slot slot)
			{
				if (!string.IsNullOrWhiteSpace(slot.Tag))
				{
					return Enumerable.ToList<string>(Enumerable.Select<string, string>((System.Collections.Generic.IEnumerable<string>)slot.Tag.Split(',', (StringSplitOptions)1), (Func<string, string>)((string x) => x.Trim())));
				}
				return new List<string>();
			}

			private static void DecrementEnum<T>(ref T value) where T : System.Enum
			{
				value = ShiftEnum(value, -1);
			}

			private static void IncrementEnum<T>(ref T value) where T : System.Enum
			{
				value = ShiftEnum(value, 1);
			}

			private static T ShiftEnum<T>(T value, int delta) where T : System.Enum
			{
				return EnumUtil.ShiftEnum<T>(value, delta, true);
			}
		}

		[HarmonyPatch(typeof(Slot), "BuildInspectorUI")]
		private class SlotUiAddon
		{
			[Serializable]
			[CompilerGenerated]
			private sealed class <>c
			{
				public static readonly <>c <>9 = new <>c();

				public static Predicate<Slot> <>9__0_0;

				public static Predicate<Slot> <>9__0_5;

				public static Action <>9__0_7;

				public static ButtonEventHandler <>9__0_2;

				public static Action <>9__0_8;

				public static ButtonEventHandler <>9__0_3;

				public static Predicate<Slot> <>9__0_9;

				public static ButtonEventHandler <>9__0_20;

				public static ButtonEventHandler <>9__0_21;

				internal bool <Postfix>b__0_0(Slot x)
				{
					return x.Tag == "SM64 Context";
				}

				internal bool <Postfix>b__0_5(Slot x)
				{
					return x.Name == "__TEMP";
				}

				internal void <Postfix>b__0_2(IButton b, ButtonEventData _)
				{
					//IL_0015: Unknown result type (might be due to invalid IL or missing references)
					//IL_001a: Unknown result type (might be due to invalid IL or missing references)
					//IL_0020: Expected O, but got Unknown
					object obj = <>9__0_7;
					if (obj == null)
					{
						Action val = delegate
						{
							SM64Context.Instance?.ReloadAllColliders();
						};
						<>9__0_7 = val;
						obj = (object)val;
					}
					((IComponentBase)b).RunSynchronously((Action)obj, false);
				}

				internal void <Postfix>b__0_7()
				{
					SM64Context.Instance?.ReloadAllColliders();
				}

				internal void <Postfix>b__0_3(IButton b, ButtonEventData _)
				{
					//IL_0015: Unknown result type (might be due to invalid IL or missing references)
					//IL_001a: Unknown result type (might be due to invalid IL or missing references)
					//IL_0020: Expected O, but got Unknown
					object obj = <>9__0_8;
					if (obj == null)
					{
						Action val = delegate
						{
							SM64Context.Instance?.Dispose();
						};
						<>9__0_8 = val;
						obj = (object)val;
					}
					((IComponentBase)b).RunSynchronously((Action)obj, false);
				}

				internal void <Postfix>b__0_8()
				{
					SM64Context.Instance?.Dispose();
				}

				internal bool <Postfix>b__0_9(Slot x)
				{
					return x.Tag == "SM64 Mario";
				}

				internal void <Postfix>b__0_20(IButton _, ButtonEventData _)
				{
					SM64Interop.PlayRandomMusic();
				}

				internal void <Postfix>b__0_21(IButton _, ButtonEventData _)
				{
					SM64Interop.StopMusic();
				}
			}

			public static void Postfix(Slot __instance, UIBuilder ui)
			{
				//IL_007f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0084: Unknown result type (might be due to invalid IL or missing references)
				//IL_0093: Unknown result type (might be due to invalid IL or missing references)
				//IL_009d: Expected O, but got Unknown
				//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
				//IL_00af: Unknown result type (might be due to invalid IL or missing references)
				//IL_0102: Unknown result type (might be due to invalid IL or missing references)
				//IL_0107: Unknown result type (might be due to invalid IL or missing references)
				//IL_010d: Expected O, but got Unknown
				//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d6: Expected O, but got Unknown
				//IL_0417: Unknown result type (might be due to invalid IL or missing references)
				//IL_041c: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
				//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
				//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d5: Expected O, but got Unknown
				//IL_01db: Unknown result type (might be due to invalid IL or missing references)
				//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f9: Expected O, but got Unknown
				//IL_044e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0453: Unknown result type (might be due to invalid IL or missing references)
				//IL_0438: Unknown result type (might be due to invalid IL or missing references)
				//IL_043d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0443: Expected O, but got Unknown
				//IL_046f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0474: Unknown result type (might be due to invalid IL or missing references)
				//IL_047a: Expected O, but got Unknown
				//IL_025c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0261: Unknown result type (might be due to invalid IL or missing references)
				//IL_0271: Unknown result type (might be due to invalid IL or missing references)
				//IL_027b: Expected O, but got Unknown
				//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
				//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
				//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
				//IL_02cb: Expected O, but got Unknown
				//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
				//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
				//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
				//IL_02ef: Expected O, but got Unknown
				//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
				//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
				//IL_0309: Unknown result type (might be due to invalid IL or missing references)
				//IL_0313: Expected O, but got Unknown
				//IL_0325: Unknown result type (might be due to invalid IL or missing references)
				//IL_032a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0339: Unknown result type (might be due to invalid IL or missing references)
				//IL_0343: Expected O, but got Unknown
				//IL_0349: Unknown result type (might be due to invalid IL or missing references)
				//IL_034e: Unknown result type (might be due to invalid IL or missing references)
				//IL_035d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0367: Expected O, but got Unknown
				//IL_0379: Unknown result type (might be due to invalid IL or missing references)
				//IL_037e: Unknown result type (might be due to invalid IL or missing references)
				//IL_038d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0397: Expected O, but got Unknown
				//IL_039d: Unknown result type (might be due to invalid IL or missing references)
				//IL_03a2: Unknown result type (might be due to invalid IL or missing references)
				//IL_03b1: Unknown result type (might be due to invalid IL or missing references)
				//IL_03bb: Expected O, but got Unknown
				//IL_03c1: Unknown result type (might be due to invalid IL or missing references)
				//IL_03c6: Unknown result type (might be due to invalid IL or missing references)
				//IL_03d5: Unknown result type (might be due to invalid IL or missing references)
				//IL_03df: Expected O, but got Unknown
				Slot val = ui.Root.GetComponentInParents<SceneInspector>((Predicate<SceneInspector>)null, true, false)?.ComponentView?.Target;
				if (val == null || (!(val.Tag == "SM64 Context") && val.FindParent((Predicate<Slot>)((Slot x) => x.Tag == "SM64 Context"), -1) == null))
				{
					return;
				}
				LocaleString val2 = LocaleString.op_Implicit("Spawn Mario");
				ui.Button(ref val2).LocalPressed += (ButtonEventHandler)delegate(IButton b, ButtonEventData _)
				{
					//IL_0021: Unknown result type (might be due to invalid IL or missing references)
					//IL_002c: Expected O, but got Unknown
					Action val8 = default(Action);
					((IComponentBase)b).RunSynchronously((Action)delegate
					{
						//IL_0090: Unknown result type (might be due to invalid IL or missing references)
						//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
						//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
						//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
						//IL_00de: Expected O, but got Unknown
						//IL_00e3: Expected O, but got Unknown
						Slot val7 = (((Worker)__instance).World.RootSlot.FindChild((Predicate<Slot>)((Slot x) => x.Name == "__TEMP"), -1) ?? ((Worker)__instance).World.RootSlot.AddSlot("__TEMP", false)).AddSlot(((Worker)__instance).LocalUser.UserName + "'s Mario", false);
						val7.GlobalPosition = __instance.GlobalPosition;
						b.LabelText = (SM64Context.TryAddMario(val7) ? "Mario Spawned!" : "Mario Spawn Failed!");
						IButton obj9 = b;
						Action obj10 = val8;
						if (obj10 == null)
						{
							Action val9 = delegate
							{
								b.LabelText = "Spawn Mario";
							};
							Action val10 = val9;
							val8 = val9;
							obj10 = val10;
						}
						((IComponentBase)obj9).RunInSeconds(5f, obj10);
					}, false);
				};
				if (SM64Interop.IsGlobalInit)
				{
					val2 = LocaleString.op_Implicit("Reload All Colliders");
					Button obj = ui.Button(ref val2);
					object obj2 = <>c.<>9__0_2;
					if (obj2 == null)
					{
						ButtonEventHandler val3 = delegate(IButton b, ButtonEventData _)
						{
							//IL_0015: Unknown result type (might be due to invalid IL or missing references)
							//IL_001a: Unknown result type (might be due to invalid IL or missing references)
							//IL_0020: Expected O, but got Unknown
							object obj9 = <>c.<>9__0_7;
							if (obj9 == null)
							{
								Action val7 = delegate
								{
									SM64Context.Instance?.ReloadAllColliders();
								};
								<>c.<>9__0_7 = val7;
								obj9 = (object)val7;
							}
							((IComponentBase)b).RunSynchronously((Action)obj9, false);
						};
						<>c.<>9__0_2 = val3;
						obj2 = (object)val3;
					}
					obj.LocalPressed += (ButtonEventHandler)obj2;
				}
				val2 = LocaleString.op_Implicit("Destroy Mario64 Context");
				Button obj3 = ui.Button(ref val2);
				object obj4 = <>c.<>9__0_3;
				if (obj4 == null)
				{
					ButtonEventHandler val4 = delegate(IButton b, ButtonEventData _)
					{
						//IL_0015: Unknown result type (might be due to invalid IL or missing references)
						//IL_001a: Unknown result type (might be due to invalid IL or missing references)
						//IL_0020: Expected O, but got Unknown
						object obj9 = <>c.<>9__0_8;
						if (obj9 == null)
						{
							Action val7 = delegate
							{
								SM64Context.Instance?.Dispose();
							};
							<>c.<>9__0_8 = val7;
							obj9 = (object)val7;
						}
						((IComponentBase)b).RunSynchronously((Action)obj9, false);
					};
					<>c.<>9__0_3 = val4;
					obj4 = (object)val4;
				}
				obj3.LocalPressed += (ButtonEventHandler)obj4;
				if (SM64Context.Instance == null || !SM64Interop.IsGlobalInit)
				{
					return;
				}
				try
				{
					SM64Mario mario = default(SM64Mario);
					SM64Context.Instance.AllMarios.TryGetValue(val, ref mario);
					if (mario == null)
					{
						SM64Context.Instance.AllMarios.TryGetValue(val.FindParent((Predicate<Slot>)((Slot x) => x.Tag == "SM64 Mario"), -1), ref mario);
					}
					if (mario != null && mario.IsLocal)
					{
						ui.Spacer(8f);
						val2 = LocaleString.op_Implicit("Goto Mario");
						Action val7 = default(Action);
						ui.Button(ref val2).LocalPressed += (ButtonEventHandler)delegate(IButton b, ButtonEventData _)
						{
							//IL_0013: Unknown result type (might be due to invalid IL or missing references)
							//IL_0018: Unknown result type (might be due to invalid IL or missing references)
							//IL_001a: Expected O, but got Unknown
							//IL_001f: Expected O, but got Unknown
							Action obj9 = val7;
							if (obj9 == null)
							{
								Action val8 = delegate
								{
									//IL_0025: Unknown result type (might be due to invalid IL or missing references)
									((Component)((Worker)__instance).LocalUser.Root).Slot.GlobalPosition = mario.MarioSlot.GlobalPosition;
								};
								Action val9 = val8;
								val7 = val8;
								obj9 = val9;
							}
							((IComponentBase)b).RunSynchronously(obj9, false);
						};
						val2 = LocaleString.op_Implicit("Bring Mario");
						ui.Button(ref val2).LocalPressed += (ButtonEventHandler)delegate(IButton b, ButtonEventData _)
						{
							//IL_0013: Unknown result type (might be due to invalid IL or missing references)
							//IL_0018: Unknown result type (might be due to invalid IL or missing references)
							//IL_001a: Expected O, but got Unknown
							//IL_001f: Expected O, but got Unknown
							Action obj9 = val7;
							if (obj9 == null)
							{
								Action val8 = delegate
								{
									//IL_0014: Unknown result type (might be due to invalid IL or missing references)
									//IL_0038: Unknown result type (might be due to invalid IL or missing references)
									float3 position = default(float3);
									floatQ val10 = default(floatQ);
									SlotPositioning.GetPointInFrontOfUser(((Worker)__instance).LocalUser, ref position, ref val10, (float3?)float3.Forward, (float3?)null, 2f, true);
									mario.SetPosition(position);
								};
								Action val9 = val8;
								val7 = val8;
								obj9 = val9;
							}
							((IComponentBase)b).RunSynchronously(obj9, false);
						};
						ui.Spacer(8f);
						foreach (MarioCapType capType in System.Enum.GetValues(typeof(MarioCapType)))
						{
							val2 = LocaleString.op_Implicit("Wear " + ((object)capType/*cast due to .constrained prefix*/).ToString());
							ui.Button(ref val2).LocalPressed += (ButtonEventHandler)delegate
							{
								mario.WearCap(capType, (capType == MarioCapType.WingCap) ? 40f : 15f, !Config.DisableAudio.Value);
							};
						}
						ui.Spacer(8f);
						val2 = LocaleString.op_Implicit("Heal Mario");
						ui.Button(ref val2).LocalPressed += (ButtonEventHandler)delegate
						{
							mario.Heal(1);
						};
						val2 = LocaleString.op_Implicit("Add Life");
						ui.Button(ref val2).LocalPressed += (ButtonEventHandler)delegate
						{
							mario.SyncedLives++;
						};
						val2 = LocaleString.op_Implicit("Remove Life");
						ui.Button(ref val2).LocalPressed += (ButtonEventHandler)delegate
						{
							mario.SyncedLives--;
						};
						ui.Spacer(8f);
						val2 = LocaleString.op_Implicit("999 Lives");
						ui.Button(ref val2).LocalPressed += (ButtonEventHandler)delegate
						{
							mario.SyncedLives = 999;
						};
						val2 = LocaleString.op_Implicit("0 Lives");
						ui.Button(ref val2).LocalPressed += (ButtonEventHandler)delegate
						{
							mario.SyncedLives = 0;
						};
						ui.Spacer(8f);
						val2 = LocaleString.op_Implicit("Damage Mario");
						ui.Button(ref val2).LocalPressed += (ButtonEventHandler)delegate
						{
							//IL_0011: Unknown result type (might be due to invalid IL or missing references)
							mario.TakeDamage(mario.MarioSlot.GlobalPosition, 1u);
						};
						val2 = LocaleString.op_Implicit("Kill Mario");
						ui.Button(ref val2).LocalPressed += (ButtonEventHandler)delegate
						{
							mario.SetHealthPoints(0f);
						};
						val2 = LocaleString.op_Implicit("Nuke Mario");
						ui.Button(ref val2).LocalPressed += (ButtonEventHandler)delegate
						{
							mario.SetMarioAsNuked(forceDelete: true);
						};
						ui.Spacer(8f);
					}
					else
					{
						if (!(val.Tag == "SM64 Audio"))
						{
							return;
						}
						ui.Spacer(8f);
						val2 = LocaleString.op_Implicit("Play Random Music");
						Button obj5 = ui.Button(ref val2);
						object obj6 = <>c.<>9__0_20;
						if (obj6 == null)
						{
							ButtonEventHandler val5 = delegate
							{
								SM64Interop.PlayRandomMusic();
							};
							<>c.<>9__0_20 = val5;
							obj6 = (object)val5;
						}
						obj5.LocalPressed += (ButtonEventHandler)obj6;
						val2 = LocaleString.op_Implicit("Stop Music");
						Button obj7 = ui.Button(ref val2);
						object obj8 = <>c.<>9__0_21;
						if (obj8 == null)
						{
							ButtonEventHandler val6 = delegate
							{
								SM64Interop.StopMusic();
							};
							<>c.<>9__0_21 = val6;
							obj8 = (object)val6;
						}
						obj7.LocalPressed += (ButtonEventHandler)obj8;
						ui.Spacer(8f);
					}
				}
				catch (System.Exception message)
				{
					Logger.Error(message, "Postfix", 503);
				}
			}
		}
	}
	public enum ColliderCategory
	{
		None,
		Static,
		Dynamic,
		Interactable,
		WaterBox,
		Teleporter,
		FakeObject
	}
	internal enum ColliderOpResult
	{
		Added,
		AlreadyExists,
		Updated,
		Removed
	}
	public static class Utils
	{
		internal static readonly List<Collider> StaticSurfaces = new List<Collider>();

		public static readonly colorX VanishCapColor = new colorX(1f, 1f, 1f, 0.5f, (ColorProfile)1);

		public static void TransformAndGetSurfaces(List<SM64Surface> outSurfaces, MeshX mesh, SurfaceType surfaceType, TerrainType terrainType, SurfaceFlag flags, int force, Func<float3, float3> transformFunc)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < mesh.SubmeshCount; i++)
			{
				Submesh submesh = mesh.GetSubmesh(i);
				float3[] vertices = Enumerable.ToArray<float3>(Enumerable.Select<Vertex, float3>((System.Collections.Generic.IEnumerable<Vertex>)(object)mesh.Vertices, (Func<Vertex, float3>)((Vertex v) => transformFunc.Invoke(((Vertex)(ref v)).Position))));
				SM64Interop.CreateAndAppendSurfaces(outSurfaces, submesh.RawIndicies, vertices, surfaceType, terrainType, flags, force);
			}
		}

		public static ColliderCategory GetColliderCategory(Collider col)
		{
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Invalid comparison between Unknown and I4
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			string text = ((Component)col).Slot.Tag ?? string.Empty;
			bool num = text.Contains("SM64 StaticCollider", (StringComparison)5) || text.Contains("SM64 Collider", (StringComparison)5);
			bool flag = text.Contains("SM64 DynamicCollider", (StringComparison)5);
			bool flag2 = text.Contains("SM64 Interactable", (StringComparison)5);
			bool flag3 = text.Contains("SM64 WaterBox", (StringComparison)5);
			bool flag4 = text.Contains("SM64 Teleporter", (StringComparison)5);
			bool flag5 = text.Contains("SM64 FakeObject", (StringComparison)5) || text.Contains("SM64 Pole", (StringComparison)5);
			bool flag6 = (int)((SyncField<ColliderType>)(object)col.Type).Value == 6 && ((ContainerWorker<Component>)(object)((Component)col).Slot).GetComponent<UserRoot>((Predicate<UserRoot>)null, false) != null;
			bool flag7 = ((ComponentBase<Component>)(object)col).Enabled && ((Component)col).Slot.IsActive;
			if ((num || ((ICollider)col).CollidesWithCharacters) && !flag && flag7)
			{
				return ColliderCategory.Static;
			}
			if (flag || (flag6 && flag7 && !Collider.IsTrigger(((SyncField<ColliderType>)(object)col.Type).Value)))
			{
				return ColliderCategory.Dynamic;
			}
			if (flag2 && ((ComponentBase<Component>)(object)col).Enabled)
			{
				return ColliderCategory.Interactable;
			}
			if (flag3 && flag7)
			{
				return ColliderCategory.WaterBox;
			}
			if (flag4 && flag7)
			{
				return ColliderCategory.Teleporter;
			}
			if (flag5 && flag7)
			{
				return ColliderCategory.FakeObject;
			}
			return ColliderCategory.None;
		}

		internal static SM64Surface[] GetAllStaticSurfaces(World wld)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
			StaticSurfaces.Clear();
			List<SM64Surface> val = new List<SM64Surface>();
			List<ValueTuple<MeshCollider, SurfaceType, TerrainType, int>> val2 = new List<ValueTuple<MeshCollider, SurfaceType, TerrainType, int>>();
			Enumerator<Collider> enumerator = wld.RootSlot.GetComponentsInChildren<Collider>((Predicate<Collider>)null, false, false, (Predicate<Slot>)null).GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					Collider current = enumerator.Current;
					if (GetColliderCategory(current) == ColliderCategory.Static)
					{
						ParseTagParts(((Component)current).Slot.Tag?.Split(',', (StringSplitOptions)0), out var surfaceType, out var terrainType, out var _, out var idx, out var _);
						MeshCollider val3 = (MeshCollider)(object)((current is MeshCollider) ? current : null);
						if (val3 != null)
						{
							val2.Add(new ValueTuple<MeshCollider, SurfaceType, TerrainType, int>(val3, surfaceType, terrainType, idx));
						}
						else
						{
							GetTransformedSurfaces(val, current, surfaceType, terrainType, SurfaceFlag.None, idx);
						}
						StaticSurfaces.Add(current);
					}
				}
			}
			finally
			{
				((System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
			}
			CollectionExtensions.Do<ValueTuple<MeshCollider, SurfaceType, TerrainType, int>>(Enumerable.Where<ValueTuple<MeshCollider, SurfaceType, TerrainType, int>>((System.Collections.Generic.IEnumerable<ValueTuple<MeshCollider, SurfaceType, TerrainType, int>>)val2, (Func<ValueTuple<MeshCollider, SurfaceType, TerrainType, int>, bool>)InvalidCollider), (Action<ValueTuple<MeshCollider, SurfaceType, TerrainType, int>>)delegate(ValueTuple<MeshCollider, SurfaceType, TerrainType, int> invalid)
			{
				//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				//IL_0045: Unknown result type (might be due to invalid IL or missing references)
				//IL_0068: Unknown result type (might be due to invalid IL or missing references)
				//IL_006e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0086: Unknown result type (might be due to invalid IL or missing references)
				if (Config.DebugEnabled.Value)
				{
					Logger.Warn($"- [{((object)invalid.Item1).GetType()}] {((Component)invalid.Item1).Slot.Name} ({((Worker)invalid.Item1).ReferenceID}) Mesh is {((((SyncRef<IAssetProvider<Mesh>>)(object)((MeshBasedCollider<Mesh, MeshColliderData>)(object)invalid.Item1).Mesh).Target == null) ? "null" : "non-readable")}", "GetAllStaticSurfaces", 110);
				}
				StaticSurfaces.Remove((Collider)(object)invalid.Item1);
			});
			val2.RemoveAll((Predicate<ValueTuple<MeshCollider, SurfaceType, TerrainType, int>>)InvalidCollider);
			val2.Sort((Comparison<ValueTuple<MeshCollider, SurfaceType, TerrainType, int>>)((ValueTuple<MeshCollider, SurfaceType, TerrainType, int> a, ValueTuple<MeshCollider, SurfaceType, TerrainType, int> b) => ((MeshBasedCollider<Mesh, MeshColliderData>)(object)a.Item1).Mesh.Asset.Data.TotalTriangleCount.CompareTo(((MeshBasedCollider<Mesh, MeshColliderData>)(object)b.Item1).Mesh.Asset.Data.TotalTriangleCount)));
			int value = Config.MaxMeshColliderTris.Value;
			int num = 0;
			Enumerator<ValueTuple<MeshCollider, SurfaceType, TerrainType, int>> enumerator2 = val2.GetEnumerator();
			try
			{
				while (enumerator2.MoveNext())
				{
					ValueTuple<MeshCollider, SurfaceType, TerrainType, int> current2 = enumerator2.Current;
					MeshCollider item = current2.Item1;
					SurfaceType item2 = current2.Item2;
					TerrainType item3 = current2.Item3;
					int item4 = current2.Item4;
					int totalTriangleCount = ((MeshBasedCollider<Mesh, MeshColliderData>)(object)item).Mesh.Asset.Data.TotalTriangleCount;
					int num2 = num + totalTriangleCount;
					if (num2 > value)
					{
						if (Config.DebugEnabled.Value)
						{
							Logger.Warn($"[{((object)item).GetType()}] {((Component)item).Slot.Name} ({((Worker)item).ReferenceID}) Mesh has too many triangles.", "GetAllStaticSurfaces", 130);
						}
						StaticSurfaces.Remove((Collider)(object)item);
					}
					else
					{
						GetTransformedSurfaces(val, (Collider)(object)item, item2, item3, SurfaceFlag.None, item4);
						num = num2;
					}
				}
			}
			finally
			{
				((System.IDisposable)enumerator2/*cast due to .constrained prefix*/).Dispose();
			}
			SM64Context instance = SM64Context.Instance;
			object obj;
			if (instance == null)
			{
				obj = null;
			}
			else
			{
				SM64ContextTerrain terrain = instance.Terrain;
				obj = ((terrain != null) ? Enumerable.Except<Collider>((System.Collections.Generic.IEnumerable<Collider>)terrain.StaticColliders.Keys, (System.Collections.Generic.IEnumerable<Collider>)StaticSurfaces).GetTempList() : null);
			}
			List<Collider> val4 = (List<Collider>)obj;
			if (val4 != null)
			{
				enumerator = val4.GetEnumerator();
				try
				{
					while (enumerator.MoveNext())
					{
						Collider current3 = enumerator.Current;
						instance?.Terrain?.UnregisterStaticCollider(current3);
					}
				}
				finally
				{
					((System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
				}
			}
			return val.ToArray();
			[CompilerGenerated]
			static bool InvalidCollider(ValueTuple<MeshCollider, SurfaceType, TerrainType, int> col)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				if (((SyncRef<IAssetProvider<Mesh>>)(object)((MeshBasedCollider<Mesh, MeshColliderData>)(object)col.Item1).Mesh).Target != null)
				{
					return !((MeshBasedCollider<Mesh, MeshColliderData>)(object)col.Item1).Mesh.IsAssetAvailable;
				}
				return true;
			}
		}

		public static void GetTransformedSurfaces(List<SM64Surface> surfaces, Collider collider, SurfaceType surfaceType, TerrainType terrainType, SurfaceFlag flags, int force)
		{
			TransformAndGetSurfaces(surfaces, collider.GetColliderMesh(), surfaceType, terrainType, flags, force, delegate(float3 x)
			{
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0020: Unknown result type (might be due to invalid IL or missing references)
				//IL_0025: Unknown result type (might be due to invalid IL or missing references)
				//IL_0028: Unknown result type (might be due to invalid IL or missing references)
				Slot slot = ((Component)collider).Slot;
				float3 val = Sync<float3>.op_Implicit(collider.Offset);
				float3 val2 = (ref x) + (ref val);
				return slot.LocalPointToGlobal(ref val2);
			});
		}

		public static void GetScaledSurfaces(List<SM64Surface> surfaces, Collider collider, SurfaceType surfaceType, TerrainType terrainType, SurfaceFlag flags, int force)
		{
			TransformAndGetSurfaces(surfaces, collider.GetColliderMesh(), surfaceType, terrainType, flags, force, delegate(float3 x)
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				//IL_0020: Unknown result type (might be due to invalid IL or missing references)
				//IL_0025: Unknown result type (might be due to invalid IL or missing references)
				//IL_0028: Unknown result type (might be due to invalid IL or missing references)
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Unknown result type (might be due to invalid IL or missing references)
				float3 globalScale = ((Component)collider).Slot.GlobalScale;
				float3 val = Sync<float3>.op_Implicit(collider.Offset);
				float3 val2 = (ref x) + (ref val);
				return (ref globalScale) * (ref val2);
			});
		}

		public static void ParseTagParts(string[] tagParts, out SurfaceType surfaceType, out TerrainType terrainType, out InteractableType interactableType, out int idx, out int ext)
		{
			surfaceType = SurfaceType.Default;
			terrainType = TerrainType.Grass;
			interactableType = InteractableType.None;
			idx = -1;
			ext = -1;
			if (tagParts == null)
			{
				return;
			}
			SurfaceType surfaceType2 = default(SurfaceType);
			TerrainType terrainType2 = default(TerrainType);
			InteractableType interactableType2 = default(InteractableType);
			int num2 = default(int);
			bool flag = default(bool);
			int num3 = default(int);
			int num4 = default(int);
			int num5 = default(int);
			int num6 = default(int);
			int num7 = default(int);
			for (int i = 0; i < tagParts.Length; i++)
			{
				string text = tagParts[i].Trim();
				if (text.StartsWith("SurfaceType_", (StringComparison)5))
				{
					if (System.Enum.TryParse<SurfaceType>(text.Substring("SurfaceType_".Length), true, ref surfaceType2))
					{
						surfaceType = surfaceType2;
					}
				}
				else if (text.StartsWith("TerrainType_", (StringComparison)5))
				{
					if (System.Enum.TryParse<TerrainType>(text.Substring("TerrainType_".Length), true, ref terrainType2))
					{
						terrainType = terrainType2;
					}
				}
				else if (text.StartsWith("InteractableType_", (StringComparison)5))
				{
					string text2 = text.Substring("InteractableType_".Length);
					int num = text2.Length;
					while (num > 0 && char.IsDigit(text2[num - 1]))
					{
						num--;
					}
					string text3 = text2.Substring(0, num);
					string text4 = text2.Substring(num);
					if (System.Enum.TryParse<InteractableType>(text3, true, ref interactableType2))
					{
						interactableType = interactableType2;
						if (int.TryParse(text4, ref num2))
						{
							idx = num2;
						}
					}
				}
				else if (text.StartsWith("Delete_", (StringComparison)5))
				{
					string text5 = text.Substring("Delete_".Length);
					if (text5.Length == 1 && char.IsDigit(text5[0]))
					{
						ext = text5[0] - 48;
					}
					else if (bool.TryParse(text5, ref flag))
					{
						ext = (flag ? 1 : 0);
					}
				}
				else if (text.StartsWith("Force_", (StringComparison)5))
				{
					string text6 = text.Substring("Force_".Length);
					string[] array = text6.Split('.', (StringSplitOptions)0);
					if (array.Length == 2 && int.TryParse(array[0], ref num3) && int.TryParse(array[1], ref num4))
					{
						idx = (num3 << 8) | num4;
					}
					else if (int.TryParse(text6, ref num5))
					{
						idx = num5;
					}
				}
				else if (text.StartsWith("Teleporter_", (StringComparison)5))
				{
					if (int.TryParse(text.Substring("Teleporter_".Length), ref num6))
					{
						idx = num6;
					}
				}
				else if (text.StartsWith("Group_", (StringComparison)5) && int.TryParse(text.Substring("Group_".Length), ref num7))
				{
					ext = num7;
				}
			}
		}

		public static Sounds GetRedCoinSound(int redIndex)
		{
			if (redIndex < 0 || redIndex > 7)
			{
				return Sounds.SOUND_GENERAL_RED_COIN;
			}
			Sounds[] array = new Sounds[8];
			RuntimeHelpers.InitializeArray((System.Array)array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			return array[redIndex];
		}

		public static string MakeValidDynvarName(this string name)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			if (string.IsNullOrWhiteSpace(name))
			{
				return null;
			}
			StringBuilder val = new StringBuilder(name.Length);
			foreach (char c in name)
			{
				switch (c)
				{
				case ' ':
				case '-':
				case '.':
				case '_':
					val.Append(c);
					continue;
				}
				if (!char.IsSymbol(c) && !char.IsPunctuation(c) && !char.IsWhiteSpace(c))
				{
					val.Append(c);
				}
			}
			return ((object)val).ToString().Trim();
		}

		public static Dictionary<TKey, TValue> GetTempDictionary<TKey, TValue>(this Dictionary<TKey, TValue> source)
		{
			return new Dictionary<TKey, TValue>((IDictionary<TKey, TValue>)(object)source);
		}

		public static List<T> GetTempList<T>(this List<T> source)
		{
			return new List<T>((System.Collections.Generic.IEnumerable<T>)source);
		}

		public static List<T> GetTempList<T>(this System.Collections.Generic.IEnumerable<T> source)
		{
			return new List<T>(source);
		}

		public static List<TValue> GetFilteredSortedList<TKey, TValue, TSortKey>(this Dictionary<TKey, TValue> source, Func<TValue, bool> filter = null, Func<TValue, TSortKey> sortKeySelector = null, bool ascending = true)
		{
			System.Collections.Generic.IEnumerable<TValue> enumerable = (System.Collections.Generic.IEnumerable<TValue>)source.Values;
			if (filter != null)
			{
				enumerable = Enumerable.Where<TValue>(enumerable, filter);
			}
			if (sortKeySelector != null)
			{
				enumerable = (System.Collections.Generic.IEnumerable<TValue>)(ascending ? Enumerable.OrderBy<TValue, TSortKey>(enumerable, sortKeySelector) : Enumerable.OrderByDescending<TValue, TSortKey>(enumerable, sortKeySelector));
			}
			return Enumerable.ToList<TValue>(enumerable);
		}

		public static bool HasCapType(StateFlag flags, MarioCapType capType)
		{
			return ((System.Enum)flags).HasFlag((System.Enum)(StateFlag)capType);
		}

		public static bool IsTeleporting(StateFlag flags)
		{
			return ((System.Enum)flags).HasFlag((System.Enum)StateFlag.Teleporting);
		}

		public static void SafeDestroy(this IDestroyable destroyable)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			if (destroyable != null)
			{
				World world = ((IWorldElement)destroyable).World;
				if (world != null)
				{
					world.RunSynchronously(new Action(destroyable.Destroy), true, (IUpdatable)null, false);
				}
			}
		}
	}
	internal record ColliderOp(ColliderCategory Category, ColliderOpResult Result)
	{
		[CompilerGenerated]
		protected virtual System.Type EqualityContract
		{
			[CompilerGenerated]
			get
			{
				return typeof(ColliderOp);
			}
		}

		[CompilerGenerated]
		public override string ToString()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			StringBuilder val = new StringBuilder();
			val.Append("ColliderOp");
			val.Append(" { ");
			if (PrintMembers(val))
			{
				val.Append(' ');
			}
			val.Append('}');
			return ((object)val).ToString();
		}

		[CompilerGenerated]
		protected virtual bool PrintMembers(StringBuilder builder)
		{
			RuntimeHelpers.EnsureSufficientExecutionStack();
			builder.Append("Category = ");
			builder.Append(((object)Category/*cast due to .constrained prefix*/).ToString());
			builder.Append(", Result = ");
			builder.Append(((object)Result/*cast due to .constrained prefix*/).ToString());
			return true;
		}

		[CompilerGenerated]
		public virtual bool Equals(ColliderOp? other)
		{
			if ((object)this != other)
			{
				if ((object)other != null && EqualityContract == other.EqualityContract && EqualityComparer<ColliderCategory>.Default.Equals(Category, other.Category))
				{
					return EqualityComparer<ColliderOpResult>.Default.Equals(Result, other.Result);
				}
				return false;
			}
			return true;
		}
	}
}
namespace ResoniteMario64.Mario64.libsm64
{
	public static class SM64Constants
	{
		public static readonly ushort[] Musics;

		public static readonly Dictionary<Sounds, uint> SoundBank;

		public const StateFlag SpecialCaps = StateFlag.VanishCap | StateFlag.MetalCap | StateFlag.WingCap;

		public const StateFlag Caps = StateFlag.NormalCap | StateFlag.VanishCap | StateFlag.MetalCap | StateFlag.WingCap;

		public const uint ActionGroupMask = 448u;

		public static readonly List<ActionFlag> BaseFlags;

		public static readonly Dictionary<ActionGroup, List<ActionFlag>> GroupedFlags;

		private static uint SoundArgLoad(uint bank, uint playFlags, uint soundID, uint priority, uint flags2)
		{
			return (bank << 28) | (playFlags << 24) | (soundID << 16) | (priority << 8) | (flags2 << 4) | 1;
		}

		static SM64Constants()
		{
			ushort[] array = new ushort[30];
			RuntimeHelpers.InitializeArray((System.Array)array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			Musics = array;
			Dictionary<Sounds, uint> obj = new Dictionary<Sounds, uint>();
			obj.Add(Sounds.SOUND_GENERAL_COIN, SoundArgLoad(3u, 8u, 17u, 128u, 8u));
			obj.Add(Sounds.SOUND_GENERAL_COIN_WATER, SoundArgLoad(3u, 8u, 18u, 128u, 8u));
			obj.Add(Sounds.SOUND_GENERAL_COIN_SPURT, SoundArgLoad(3u, 0u, 48u, 0u, 8u));
			obj.Add(Sounds.SOUND_GENERAL_COIN_SPURT_2, SoundArgLoad(3u, 8u, 48u, 0u, 8u));
			obj.Add(Sounds.SOUND_GENERAL_COIN_SPURT_EU, SoundArgLoad(3u, 8u, 48u, 32u, 8u));
			obj.Add(Sounds.SOUND_GENERAL_COIN_DROP, SoundArgLoad(3u, 0u, 54u, 64u, 8u));
			obj.Add(Sounds.SOUND_GENERAL_RED_COIN, SoundArgLoad(3u, 0u, 104u, 144u, 8u));
			obj.Add(Sounds.SOUND_MENU_COIN_ITS_A_ME_MARIO, SoundArgLoad(7u, 0u, 20u, 0u, 8u));
			obj.Add(Sounds.SOUND_MENU_COLLECT_RED_COIN, SoundArgLoad(7u, 8u, 40u, 144u, 8u));
			obj.Add(Sounds.Action_TerrainJump, SoundArgLoad(0u, 4u, 0u, 128u, 8u));
			obj.Add(Sounds.Action_TerrainLanding, SoundArgLoad(0u, 4u, 8u, 128u, 8u));
			obj.Add(Sounds.Action_TerrainStep, SoundArgLoad(0u, 6u, 16u, 128u, 8u));
			obj.Add(Sounds.Action_TerrainBodyHitGround, SoundArgLoad(0u, 4u, 24u, 128u, 8u));
			obj.Add(Sounds.Action_TerrainStepTiptoe, SoundArgLoad(0u, 6u, 32u, 128u, 8u));
			obj.Add(Sounds.Action_TerrainStuckInGround, SoundArgLoad(0u, 4u, 72u, 128u, 8u));
			obj.Add(Sounds.Action_TerrainHeavyLanding, SoundArgLoad(0u, 4u, 96u, 128u, 8u));
			obj.Add(Sounds.Action_MetalJump, SoundArgLoad(0u, 4u, 40u, 144u, 8u));
			obj.Add(Sounds.Action_MetalLanding, SoundArgLoad(0u, 4u, 41u, 144u, 8u));
			obj.Add(Sounds.Action_MetalStep, SoundArgLoad(0u, 4u, 42u, 144u, 8u));
			obj.Add(Sounds.Action_MetalHeavyLanding, SoundArgLoad(0u, 4u, 43u, 144u, 8u));
			obj.Add(Sounds.Action_ClapHandsCold, SoundArgLoad(0u, 6u, 44u, 0u, 8u));
			obj.Add(Sounds.Action_HangingStep, SoundArgLoad(0u, 4u, 45u, 160u, 8u));
			obj.Add(Sounds.Action_QuicksandStep, SoundArgLoad(0u, 4u, 46u, 0u, 8u));
			obj.Add(Sounds.Action_MetalStepTiptoe, SoundArgLoad(0u, 4u, 47u, 144u, 8u));
			obj.Add(Sounds.Action_Unknown430, SoundArgLoad(0u, 4u, 48u, 192u, 8u));
			obj.Add(Sounds.Action_Unknown431, SoundArgLoad(0u, 4u, 49u, 96u, 8u));
			obj.Add(Sounds.Action_Unknown432, SoundArgLoad(0u, 4u, 50u, 128u, 8u));
			obj.Add(Sounds.Action_Swim, SoundArgLoad(0u, 4u, 51u, 128u, 8u));
			obj.Add(Sounds.Action_Unknown434, SoundArgLoad(0u, 4u, 52u, 128u, 8u));
			obj.Add(Sounds.Action_Throw, SoundArgLoad(0u, 4u, 53u, 128u, 8u));
			obj.Add(Sounds.Action_KeySwish, SoundArgLoad(0u, 4u, 54u, 128u, 8u));
			obj.Add(Sounds.Action_Spin, SoundArgLoad(0u, 4u, 55u, 128u, 8u));
			obj.Add(Sounds.Action_Twirl, SoundArgLoad(0u, 4u, 56u, 128u, 8u));
			obj.Add(Sounds.Action_ClimbUpTree, SoundArgLoad(0u, 4u, 58u, 128u, 8u));
			obj.Add(Sounds.Action_ClimbDownTree, 3u);
			obj.Add(Sounds.Action_Unk3C, 3u);
			obj.Add(Sounds.Action_Unknown43D, SoundArgLoad(0u, 4u, 61u, 128u, 8u));
			obj.Add(Sounds.Action_Unknown43E, SoundArgLoad(0u, 4u, 62u, 128u, 8u));
			obj.Add(Sounds.Action_PatBack, SoundArgLoad(0u, 4u, 63u, 128u, 8u));
			obj.Add(Sounds.Action_BrushHair, SoundArgLoad(0u, 4u, 64u, 128u, 8u));
			obj.Add(Sounds.Action_ClimbUpPole, SoundArgLoad(0u, 4u, 65u, 128u, 8u));
			obj.Add(Sounds.Action_MetalBonk, SoundArgLoad(0u, 4u, 66u, 128u, 8u));
			obj.Add(Sounds.Action_UnstuckFromGround, SoundArgLoad(0u, 4u, 67u, 128u, 8u));
			obj.Add(Sounds.Action_Hit, SoundArgLoad(0u, 4u, 68u, 192u, 8u));
			obj.Add(Sounds.Action_Hit2, SoundArgLoad(0u, 4u, 68u, 176u, 8u));
			obj.Add(Sounds.Action_Hit3, SoundArgLoad(0u, 4u, 68u, 160u, 8u));
			obj.Add(Sounds.Action_Bonk, SoundArgLoad(0u, 4u, 69u, 160u, 8u));
			obj.Add(Sounds.Action_ShrinkIntoBbh, SoundArgLoad(0u, 4u, 70u, 160u, 8u));
			obj.Add(Sounds.Action_SwimFast, SoundArgLoad(0u, 4u, 71u, 160u, 8u));
			obj.Add(Sounds.Action_MetalJumpWater, SoundArgLoad(0u, 4u, 80u, 144u, 8u));
			obj.Add(Sounds.Action_MetalLandWater, SoundArgLoad(0u, 4u, 81u, 144u, 8u));
			obj.Add(Sounds.Action_MetalStepWater, SoundArgLoad(0u, 4u, 82u, 144u, 8u));
			obj.Add(Sounds.Action_Unk53, 5u);
			obj.Add(Sounds.Action_Unk54, 5u);
			obj.Add(Sounds.Action_Unk55, 5u);
			obj.Add(Sounds.Action_FlyingFast, SoundArgLoad(0u, 4u, 86u, 128u, 8u));
			obj.Add(Sounds.Action_Teleport, SoundArgLoad(0u, 4u, 87u, 192u, 8u));
			obj.Add(Sounds.Action_Unknown458, SoundArgLoad(0u, 4u, 88u, 160u, 8u));
			obj.Add(Sounds.Action_BounceOffObject, SoundArgLoad(0u, 4u, 89u, 176u, 8u));
			obj.Add(Sounds.Action_SideFlipUnk, SoundArgLoad(0u, 4u, 90u, 128u, 8u));
			obj.Add(Sounds.Action_ReadSign, SoundArgLoad(0u, 4u, 91u, 255u, 8u));
			obj.Add(Sounds.Action_Unknown45C, SoundArgLoad(0u, 4u, 92u, 128u, 8u));
			obj.Add(Sounds.Action_Unk5D, 5u);
			obj.Add(Sounds.Action_IntroUnk45E, SoundArgLoad(0u, 4u, 94u, 128u, 8u));
			obj.Add(Sounds.Action_IntroUnk45F, SoundArgLoad(0u, 4u, 95u, 128u, 8u));
			obj.Add(Sounds.Moving_TerrainSlide, SoundArgLoad(1u, 4u, 0u, 0u, 0u));
			obj.Add(Sounds.Moving_TerrainRidingShell, SoundArgLoad(1u, 4u, 32u, 0u, 0u));
			obj.Add(Sounds.Moving_LavaBurn, SoundArgLoad(1u, 4u, 16u, 0u, 0u));
			obj.Add(Sounds.Moving_SlideDownPole, SoundArgLoad(1u, 4u, 17u, 0u, 0u));
			obj.Add(Sounds.Moving_SlideDownTree, SoundArgLoad(1u, 4u, 18u, 128u, 0u));
			obj.Add(Sounds.Moving_QuicksandDeath, SoundArgLoad(1u, 4u, 20u, 0u, 0u));
			obj.Add(Sounds.Moving_Shocked, SoundArgLoad(1u, 4u, 22u, 0u, 0u));
			obj.Add(Sounds.Moving_Flying, SoundArgLoad(1u, 4u, 23u, 0u, 0u));
			obj.Add(Sounds.Moving_AlmostDrowning, SoundArgLoad(1u, 12u, 24u, 0u, 0u));
			obj.Add(Sounds.Moving_AimCannon, SoundArgLoad(1u, 13u, 25u, 32u, 0u));
			obj.Add(Sounds.Moving_Unk1A, 4122u);
			obj.Add(Sounds.Moving_RidingShellLava, SoundArgLoad(1u, 4u, 40u, 0u, 0u));
			obj.Add(Sounds.Mario_YahWahHoo, SoundArgLoad(2u, 4u, 0u, 128u, 8u));
			obj.Add(Sounds.Mario_Hoohoo, SoundArgLoad(2u, 4u, 3u, 128u, 8u));
			obj.Add(Sounds.Mario_Yahoo, SoundArgLoad(2u, 4u, 4u, 128u, 8u));
			obj.Add(Sounds.Mario_Uh, SoundArgLoad(2u, 4u, 5u, 128u, 8u));
			obj.Add(Sounds.Mario_Hrmm, SoundArgLoad(2u, 4u, 6u, 128u, 8u));
			obj.Add(Sounds.Mario_Wah2, SoundArgLoad(2u, 4u, 7u, 128u, 8u));
			obj.Add(Sounds.Mario_Whoa, SoundArgLoad(2u, 4u, 8u, 192u, 8u));
			obj.Add(Sounds.Mario_Eeuh, SoundArgLoad(2u, 4u, 9u, 128u, 8u));
			obj.Add(Sounds.Mario_Attacked, SoundArgLoad(2u, 4u, 10u, 255u, 8u));
			obj.Add(Sounds.Mario_Ooof, SoundArgLoad(2u, 4u, 11u, 128u, 8u));
			obj.Add(Sounds.Mario_Ooof2, SoundArgLoad(2u, 4u, 11u, 208u, 8u));
			obj.Add(Sounds.Mario_HereWeGo, SoundArgLoad(2u, 4u, 12u, 128u, 8u));
			obj.Add(Sounds.Mario_Yawning, SoundArgLoad(2u, 4u, 13u, 128u, 8u));
			obj.Add(Sounds.Mario_Snoring1, SoundArgLoad(2u, 4u, 14u, 128u, 8u));
			obj.Add(Sounds.Mario_Snoring2, SoundArgLoad(2u, 4u, 15u, 128u, 8u));
			obj.Add(Sounds.Mario_WaaaOooW, SoundArgLoad(2u, 4u, 16u, 192u, 8u));
			obj.Add(Sounds.Mario_Haha, SoundArgLoad(2u, 4u, 17u, 128u, 8u));
			obj.Add(Sounds.Mario_Haha2, SoundArgLoad(2u, 4u, 17u, 240u, 8u));
			obj.Add(Sounds.Mario_Uh2, SoundArgLoad(2u, 4u, 19u, 208u, 8u));
			obj.Add(Sounds.Mario_Uh2_2, SoundArgLoad(2u, 4u, 19u, 128u, 8u));
			obj.Add(Sounds.Mario_OnFire, SoundArgLoad(2u, 4u, 20u, 160u, 8u));
			obj.Add(Sounds.Mario_Dying, SoundArgLoad(2u, 4u, 21u, 255u, 8u));
			obj.Add(Sounds.Mario_PantingCold, SoundArgLoad(2u, 4u, 22u, 128u, 8u));
			obj.Add(Sounds.Mario_Panting, SoundArgLoad(2u, 4u, 24u, 128u, 8u));
			obj.Add(Sounds.Mario_Coughing1, SoundArgLoad(2u, 4u, 27u, 128u, 8u));
			obj.Add(Sounds.Mario_Coughing2, SoundArgLoad(2u, 4u, 28u, 128u, 8u));
			obj.Add(Sounds.Mario_Coughing3, SoundArgLoad(2u, 4u, 29u, 128u, 8u));
			obj.Add(Sounds.Mario_PunchYah, SoundArgLoad(2u, 4u, 30u, 128u, 8u));
			obj.Add(Sounds.Mario_PunchHoo, SoundArgLoad(2u, 4u, 31u, 128u, 8u));
			obj.Add(Sounds.Mario_MamaMia, SoundArgLoad(2u, 4u, 32u, 128u, 8u));
			obj.Add(Sounds.Mario_OkeyDokey, 514u);
			obj.Add(Sounds.Mario_GroundPoundWah, SoundArgLoad(2u, 4u, 34u, 128u, 8u));
			obj.Add(Sounds.Mario_Drowning, SoundArgLoad(2u, 4u, 35u, 240u, 8u));
			obj.Add(Sounds.Mario_PunchWah, SoundArgLoad(2u, 4u, 36u, 128u, 8u));
			obj.Add(Sounds.Mario_YahooWahaYippee, SoundArgLoad(2u, 4u, 43u, 128u, 8u));
			obj.Add(Sounds.Mario_Doh, SoundArgLoad(2u, 4u, 48u, 128u, 8u));
			obj.Add(Sounds.Mario_GameOver, SoundArgLoad(2u, 4u, 49u, 255u, 8u));
			obj.Add(Sounds.Mario_Hello, SoundArgLoad(2u, 4u, 50u, 255u, 8u));
			obj.Add(Sounds.Mario_PressStartToPlay, SoundArgLoad(2u, 4u, 51u, 255u, 10u));
			obj.Add(Sounds.Mario_TwirlBounce, SoundArgLoad(2u, 4u, 52u, 128u, 8u));
			obj.Add(Sounds.Mario_Snoring3, SoundArgLoad(2u, 4u, 53u, 255u, 8u));
			obj.Add(Sounds.Mario_SoLongaBowser, SoundArgLoad(2u, 4u, 54u, 128u, 8u));
			obj.Add(Sounds.Mario_ImaTired, SoundArgLoad(2u, 4u, 55u, 128u, 8u));
			obj.Add(Sounds.Peach_DearMario, SoundArgLoad(2u, 4u, 40u, 255u, 8u));
			obj.Add(Sounds.Peach_Mario, SoundArgLoad(2u, 4u, 56u, 255u, 8u));
			obj.Add(Sounds.Peach_PowerOfTheStars, SoundArgLoad(2u, 4u, 57u, 255u, 8u));
			obj.Add(Sounds.Peach_ThanksToYou, SoundArgLoad(2u, 4u, 58u, 255u, 8u));
			obj.Add(Sounds.Peach_ThankYouMario, SoundArgLoad(2u, 4u, 59u, 255u, 8u));
			obj.Add(Sounds.Peach_SomethingSpecial, SoundArgLoad(2u, 4u, 60u, 255u, 8u));
			obj.Add(Sounds.Peach_BakeACake, SoundArgLoad(2u, 4u, 61u, 255u, 8u));
			obj.Add(Sounds.Peach_ForMario, SoundArgLoad(2u, 4u, 62u, 255u, 8u));
			obj.Add(Sounds.Peach_Mario2, SoundArgLoad(2u, 4u, 63u, 255u, 8u));
			obj.Add(Sounds.General_ActivateCapSwitch, SoundArgLoad(3u, 0u, 0u, 128u, 8u));
			obj.Add(Sounds.General_FlameOut, SoundArgLoad(3u, 0u, 3u, 128u, 8u));
			obj.Add(Sounds.General_OpenWoodDoor, SoundArgLoad(3u, 0u, 4u, 192u, 8u));
			obj.Add(Sounds.General_CloseWoodDoor, SoundArgLoad(3u, 0u, 5u, 192u, 8u));
			obj.Add(Sounds.General_OpenIronDoor, SoundArgLoad(3u, 0u, 6u, 192u, 8u));
			obj.Add(Sounds.General_CloseIronDoor, SoundArgLoad(3u, 0u, 7u, 192u, 8u));
			obj.Add(Sounds.General_Bubbles, 768u);
			obj.Add(Sounds.General_MovingWater, SoundArgLoad(3u, 0u, 9u, 0u, 8u));
			obj.Add(Sounds.General_SwishWater, SoundArgLoad(3u, 0u, 10u, 0u, 8u));
			obj.Add(Sounds.General_QuietBubble, SoundArgLoad(3u, 0u, 11u, 0u, 8u));
			obj.Add(Sounds.General_VolcanoExplosion, SoundArgLoad(3u, 0u, 12u, 128u, 8u));
			obj.Add(Sounds.General_QuietBubble2, SoundArgLoad(3u, 0u, 13u, 0u, 8u));
			obj.Add(Sounds.General_CastleTrapOpen, SoundArgLoad(3u, 0u, 14u, 128u, 8u));
			obj.Add(Sounds.General_WallExplosion, SoundArgLoad(3u, 0u, 15u, 0u, 8u));
			obj.Add(Sounds.General_Coin, SoundArgLoad(3u, 8u, 17u, 128u, 8u));
			obj.Add(Sounds.General_CoinWater, SoundArgLoad(3u, 8u, 18u, 128u, 8u));
			obj.Add(Sounds.General_ShortStar, SoundArgLoad(3u, 0u, 22u, 0u, 9u));
			obj.Add(Sounds.General_BigClock, SoundArgLoad(3u, 0u, 23u, 0u, 8u));
			obj.Add(Sounds.General_LoudPound, 12312u);
			obj.Add(Sounds.General_LoudPound2, 769u);
			obj.Add(Sounds.General_ShortPound1, 769u);
			obj.Add(Sounds.General_ShortPound2, 769u);
			obj.Add(Sounds.General_ShortPound3, 769u);
			obj.Add(Sounds.General_ShortPound4, 769u);
			obj.Add(Sounds.General_ShortPound5, 769u);
			obj.Add(Sounds.General_ShortPound6,