Decompiled source of Maxwell v1.0.0

Maxwell-IL2CPP.dll

Decompiled 2 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using Il2CppFishNet;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppScheduleOne.DevUtilities;
using Il2CppScheduleOne.Dragging;
using Il2CppScheduleOne.Interaction;
using Il2CppScheduleOne.PlayerScripts;
using Il2CppSystem;
using Il2CppSystem.Collections;
using Il2CppSystem.Collections.Generic;
using Maxwell;
using Maxwell.Helpers;
using Maxwell.Persistence;
using MelonLoader;
using MelonLoader.Preferences;
using Microsoft.CodeAnalysis;
using S1API.Internal.Abstraction;
using S1API.Saveables;
using S1MAPI.Gltf;
using S1MAPI.Utils;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(global::Maxwell.Maxwell), "Maxwell", "1.0.0", "k073l", null)]
[assembly: MelonColor(1, 255, 255, 255)]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: MelonPlatformDomain(/*Could not decode attribute arguments.*/)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("Maxwell-IL2CPP")]
[assembly: AssemblyConfiguration("IL2CPP")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Maxwell-IL2CPP")]
[assembly: AssemblyTitle("Maxwell-IL2CPP")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Maxwell
{
	public static class BuildInfo
	{
		public const string Name = "Maxwell";

		public const string Description = "Adds Maxwell the cat";

		public const string Author = "k073l";

		public const string Version = "1.0.0";
	}
	public class Maxwell : MelonMod
	{
		private static Instance _logger;

		private byte[] _maxwellModel;

		private const string MaxwellModelResourcePath = "Maxwell.assets.maxwell_the_cat_dingus.glb";

		private Transform _maxwellTransform;

		private List<GameObject> _cats = new List<GameObject>();

		private MelonPreferences_Category _preferencesCategory;

		private MelonPreferences_Entry<KeyCode> _spawnKeyPreference;

		private MelonPreferences_Entry<KeyCode> _removeKeyPreference;

		public override void OnInitializeMelon()
		{
			_logger = ((MelonBase)this).LoggerInstance;
			_logger.Msg("Maxwell initialized");
			_maxwellModel = EmbeddedResourceLoader.LoadBytes("Maxwell.assets.maxwell_the_cat_dingus.glb", (Assembly)null);
			if (_maxwellModel == null)
			{
				_logger.Error("Failed to load Maxwell model from embedded resources!");
			}
			else
			{
				_logger.Msg("Successfully loaded Maxwell model from embedded resources.");
			}
			_preferencesCategory = MelonPreferences.CreateCategory("MaxwellSettings", "Maxwell Mod Settings");
			_spawnKeyPreference = _preferencesCategory.CreateEntry<KeyCode>("SpawnMaxwellKey", (KeyCode)278, "Spawn Maxwell Key", "Key to spawn Maxwell the cat.", false, false, (ValueValidator)null, (string)null);
			_removeKeyPreference = _preferencesCategory.CreateEntry<KeyCode>("RemoveMaxwellKey", (KeyCode)279, "Remove Maxwell Key", "Key to remove Maxwell the cat.", false, false, (ValueValidator)null, (string)null);
		}

		public override void OnSceneWasLoaded(int buildIndex, string sceneName)
		{
			if (!(sceneName != "Menu"))
			{
				MaxwellSave.Instance.MaxwellsData.Clear();
				_cats.Clear();
			}
		}

		public override void OnUpdate()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			Scene activeScene = SceneManager.GetActiveScene();
			if (!(((Scene)(ref activeScene)).name != "Main") && _maxwellModel != null)
			{
				if (Input.GetKeyDown(_spawnKeyPreference.Value))
				{
					SpawnMaxwell();
				}
				if (Input.GetKeyDown(_removeKeyPreference.Value))
				{
					RemoveMaxwell();
				}
				if (Time.frameCount % 60 == 0)
				{
					MaxwellSave.Instance.MaxwellsData = MaxwellSave.ConvertToDto(_cats);
				}
			}
		}

		public void SpawnMaxwell()
		{
			//IL_0012: 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_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: 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_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			Camera camera = PlayerSingleton<PlayerCamera>.Instance.Camera;
			Vector3 position = ((Component)camera).transform.position + ((Component)camera).transform.forward * 2f;
			Quaternion identity = Quaternion.identity;
			SpawnMaxwellInternal(position, identity, null, dragging: true);
		}

		public void SpawnMaxwell(Vector3 position, Quaternion rotation, Guid guid)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			SpawnMaxwellInternal(position, rotation, guid);
		}

		private void SpawnMaxwellInternal(Vector3 position, Quaternion rotation, Guid? guid, bool dragging = false)
		{
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			Shader val = Shader.Find("Universal Render Pipeline/Lit");
			GameObject val2 = GltfLoader.LoadGlb(_maxwellModel, val);
			if ((Object)(object)val2 == (Object)null)
			{
				_logger.Error("Failed to load Maxwell model into scene!");
				return;
			}
			if ((Object)(object)_maxwellTransform == (Object)null)
			{
				_maxwellTransform = new GameObject("MaxwellRoot").transform;
			}
			val2.transform.parent = _maxwellTransform;
			((Object)val2).name = "Maxwell";
			val2.transform.position = position;
			val2.transform.rotation = rotation;
			val2.transform.localScale = Vector3.one * 0.03f;
			ModelUtils.AddMeshCollidersRecursively(val2);
			Rigidbody rigidbody = ModelUtils.AddAndConfigureRigidbody(val2);
			Guid valueOrDefault = guid.GetValueOrDefault();
			if (!guid.HasValue)
			{
				valueOrDefault = Guid.NewGuid();
				guid = valueOrDefault;
			}
			ModelUtils.AddDraggableIntObj(val2, rigidbody, guid.Value);
			_cats.Add(val2);
			_logger.Msg($"Maxwell has been created in the scene at position {val2.transform.position}");
			if (dragging)
			{
				Draggable component = val2.GetComponent<Draggable>();
				if (component != null)
				{
					component.Interacted();
				}
			}
		}

		public void RemoveMaxwell()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			Camera camera = PlayerSingleton<PlayerCamera>.Instance.Camera;
			Ray val = default(Ray);
			((Ray)(ref val))..ctor(((Component)camera).transform.position, ((Component)camera).transform.forward);
			DrawVisualRay(((Ray)(ref val)).origin, ((Ray)(ref val)).direction, 20f, Color.red);
			RaycastHit val2 = default(RaycastHit);
			if (Physics.Raycast(val, ref val2, 20f))
			{
				GameObject gameObject = ((Component)((RaycastHit)(ref val2)).collider).gameObject;
				MelonLogger.Msg("Hit object: " + ((Object)gameObject).name);
				Draggable component = gameObject.GetComponent<Draggable>();
				int num = 0;
				Transform parent = gameObject.transform.parent;
				while ((Object)(object)component == (Object)null && (Object)(object)parent != (Object)null && num < 10)
				{
					component = ((Component)parent).GetComponent<Draggable>();
					parent = parent.parent;
					num++;
				}
				if ((Object)(object)component != (Object)null && ((Object)((Component)component).gameObject).name == "Maxwell")
				{
					RemoveMaxwell(((Component)component).gameObject);
				}
				else
				{
					_logger.Msg("No Maxwell found at the targeted location.");
				}
			}
		}

		private void RemoveMaxwell(GameObject maxwellObj)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)maxwellObj == (Object)null))
			{
				Draggable component = maxwellObj.GetComponent<Draggable>();
				if ((Object)(object)component != (Object)null && component.IsBeingDragged)
				{
					NetworkSingleton<DragManager>.Instance.StopDragging(Vector3.zero);
				}
				_cats.Remove(maxwellObj);
				Object.Destroy((Object)(object)maxwellObj);
				_logger.Msg("Maxwell has been removed from the scene.");
			}
		}

		private static void DrawVisualRay(Vector3 origin, Vector3 direction, float length, Color color)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: 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_007e: Expected O, but got Unknown
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("VisualRay");
			LineRenderer val2 = val.AddComponent<LineRenderer>();
			val2.positionCount = 2;
			val2.useWorldSpace = true;
			val2.SetPosition(0, origin);
			val2.SetPosition(1, origin + ((Vector3)(ref direction)).normalized * length);
			val2.startWidth = 0.02f;
			val2.endWidth = 0.02f;
			Shader val3 = Shader.Find("Universal Render Pipeline/Lit");
			if ((Object)(object)val3 != (Object)null)
			{
				Material val4 = new Material(val3);
				if (val4.HasProperty("_BaseColor"))
				{
					val4.SetColor("_BaseColor", color);
				}
				((Renderer)val2).material = val4;
			}
			Object.Destroy((Object)(object)val, 0.5f);
		}
	}
}
namespace Maxwell.Persistence
{
	public class MaxwellSave : Saveable
	{
		[SaveableField("maxwell_data")]
		public List<MaxwellSaveData> MaxwellsData = new List<MaxwellSaveData>();

		public static MaxwellSave Instance { get; private set; } = new MaxwellSave();


		public MaxwellSave()
		{
			Instance = this;
		}

		protected override void OnLoaded()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			Instance = this;
			foreach (MaxwellSaveData maxwellsDatum in MaxwellsData)
			{
				Melon<Maxwell>.Instance.SpawnMaxwell(maxwellsDatum.Position, maxwellsDatum.Rotation, maxwellsDatum.Guid);
			}
		}

		public static List<MaxwellSaveData> ConvertToDto(List<GameObject> gameObjects)
		{
			//IL_0074: 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)
			gameObjects.RemoveAll((GameObject x) => (Object)(object)x == (Object)null);
			List<MaxwellSaveData> list = new List<MaxwellSaveData>();
			foreach (GameObject gameObject in gameObjects)
			{
				Draggable component = gameObject.GetComponent<Draggable>();
				if ((Object)(object)component != (Object)null && Guid.TryParse(component.BakedGUID, out var result))
				{
					list.Add(new MaxwellSaveData
					{
						Position = gameObject.transform.position,
						Rotation = gameObject.transform.rotation,
						Guid = result
					});
				}
			}
			return list;
		}
	}
	public record MaxwellSaveData
	{
		public Vector3 Position { get; set; }

		public Quaternion Rotation { get; set; }

		public Guid Guid { get; set; }

		[CompilerGenerated]
		protected virtual bool PrintMembers(StringBuilder builder)
		{
			//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_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			RuntimeHelpers.EnsureSufficientExecutionStack();
			builder.Append("Position = ");
			Vector3 position = Position;
			builder.Append(((object)(Vector3)(ref position)).ToString());
			builder.Append(", Rotation = ");
			Quaternion rotation = Rotation;
			builder.Append(((object)(Quaternion)(ref rotation)).ToString());
			builder.Append(", Guid = ");
			builder.Append(Guid.ToString());
			return true;
		}
	}
}
namespace Maxwell.Helpers
{
	public static class MelonLoggerExtensions
	{
		public static void Debug(this Instance logger, string message, bool stacktrace = true)
		{
			MelonDebug.Msg(stacktrace ? ("[" + GetCallerInfo() + "] " + message) : message);
		}

		private static string GetCallerInfo()
		{
			StackTrace stackTrace = new StackTrace();
			for (int i = 2; i < stackTrace.FrameCount; i++)
			{
				StackFrame frame = stackTrace.GetFrame(i);
				MethodBase method = frame.GetMethod();
				if (!(method?.DeclaringType == null))
				{
					return method.DeclaringType.FullName + "." + method.Name;
				}
			}
			return "unknown";
		}
	}
	public static class ModelUtils
	{
		public static void AddMeshCollidersRecursively(GameObject obj)
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			MeshFilter component = obj.GetComponent<MeshFilter>();
			if ((Object)(object)component != (Object)null && (Object)(object)component.sharedMesh != (Object)null)
			{
				MeshCollider val = obj.AddComponent<MeshCollider>();
				val.sharedMesh = component.sharedMesh;
				val.convex = true;
			}
			IEnumerator enumerator = obj.transform.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					Transform val2 = (Transform)enumerator.Current;
					AddMeshCollidersRecursively(((Component)val2).gameObject);
				}
			}
			finally
			{
				if (enumerator is IDisposable disposable)
				{
					disposable.Dispose();
				}
			}
		}

		public static Rigidbody AddAndConfigureRigidbody(GameObject obj)
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)obj == (Object)null)
			{
				return null;
			}
			Rigidbody val = obj.AddComponent<Rigidbody>();
			val.mass = 1f;
			val.drag = 0.5f;
			val.angularDrag = 0.5f;
			val.centerOfMass = new Vector3(0f, 0.5f, 0f);
			val.interpolation = (RigidbodyInterpolation)1;
			return val;
		}

		public static void AddDraggableIntObj(GameObject obj, Rigidbody rigidbody, Guid guid)
		{
			InteractableObject intObj = obj.AddComponent<InteractableObject>();
			obj.SetActive(false);
			Draggable val = obj.AddComponent<Draggable>();
			val.IntObj = intObj;
			val.Rigidbody = rigidbody;
			val.BakedGUID = guid.ToString();
			obj.SetActive(true);
		}
	}
	public static class Il2CppListExtensions
	{
		public static IEnumerable<T> AsEnumerable<T>(this List<T> list)
		{
			return list ?? new List<T>();
		}

		public static object ToNativeList<T>(this List<T> source)
		{
			return source.ToIl2CppList();
		}

		public static List<T> ToIl2CppList<T>(this IEnumerable<T> source)
		{
			List<T> val = new List<T>();
			foreach (T item in source)
			{
				val.Add(item);
			}
			return val;
		}

		public static List<T> ConvertToList<T>(List<T> il2CppList)
		{
			List<T> list = new List<T>();
			T[] collection = Il2CppArrayBase<T>.op_Implicit(il2CppList.ToArray());
			list.AddRange(collection);
			return list;
		}

		public static IEnumerable<T> AsEnumerable<T>(this List<T> list)
		{
			IEnumerable<T> result;
			if (list != null)
			{
				result = ((IEnumerable<T>)list._items).Take(list._size);
			}
			else
			{
				IEnumerable<T> enumerable = Array.Empty<T>();
				result = enumerable;
			}
			return result;
		}

		public static object ToNativeList<T>(this List<T> source)
		{
			return source;
		}
	}
	public static class Utils
	{
		[CompilerGenerated]
		private sealed class <WaitForCondition>d__6 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public Func<bool> condition;

			public float timeout;

			public Action onTimeout;

			public Action onFinish;

			private float <startTime>5__1;

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

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

			[DebuggerHidden]
			public <WaitForCondition>d__6(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<startTime>5__1 = Time.time;
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				if (!condition())
				{
					if (!float.IsNaN(timeout) && Time.time - <startTime>5__1 > timeout)
					{
						onTimeout?.Invoke();
						return false;
					}
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				onFinish?.Invoke();
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <WaitForNetwork>d__5 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public IEnumerator routine;

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

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

			[DebuggerHidden]
			public <WaitForNetwork>d__5(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				if (!InstanceFinder.IsServer && !InstanceFinder.IsClient)
				{
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				MelonCoroutines.Start(routine);
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <WaitForPlayer>d__4 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public IEnumerator routine;

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

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

			[DebuggerHidden]
			public <WaitForPlayer>d__4(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				if ((Object)(object)Player.Local == (Object)null || (Object)(object)((Component)Player.Local).gameObject == (Object)null)
				{
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				MelonCoroutines.Start(routine);
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		private static readonly Instance Logger = new Instance("Maxwell-Utils");

		public static T? FindObjectByName<T>(string objectName) where T : Object
		{
			try
			{
				foreach (T item in Resources.FindObjectsOfTypeAll<T>())
				{
					if (((Object)item).name != objectName)
					{
						continue;
					}
					Logger.Debug($"Found {typeof(T).Name} '{objectName}' directly in loaded objects");
					return item;
				}
				return default(T);
			}
			catch (Exception ex)
			{
				Logger.Error($"Error finding {typeof(T).Name} '{objectName}': {ex.Message}");
				return default(T);
			}
		}

		public static List<T> GetAllComponentsInChildrenRecursive<T>(GameObject obj) where T : Component
		{
			List<T> list = new List<T>();
			if ((Object)(object)obj == (Object)null)
			{
				return list;
			}
			T[] array = Il2CppArrayBase<T>.op_Implicit(obj.GetComponents<T>());
			if (array.Length != 0)
			{
				list.AddRange(array);
			}
			for (int i = 0; i < obj.transform.childCount; i++)
			{
				Transform child = obj.transform.GetChild(i);
				list.AddRange(GetAllComponentsInChildrenRecursive<T>(((Component)child).gameObject));
			}
			return list;
		}

		public static bool Is<T>(object obj, out T? result) where T : Object
		{
			Object val = (Object)((obj is Object) ? obj : null);
			if (val != null)
			{
				Type val2 = Il2CppType.Of<T>();
				Type il2CppType = val.GetIl2CppType();
				if (val2.IsAssignableFrom(il2CppType))
				{
					result = ((Il2CppObjectBase)val).TryCast<T>();
					return result != null;
				}
			}
			result = default(T);
			return false;
		}

		[IteratorStateMachine(typeof(<WaitForPlayer>d__4))]
		public static IEnumerator WaitForPlayer(IEnumerator routine)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <WaitForPlayer>d__4(0)
			{
				routine = routine
			};
		}

		[IteratorStateMachine(typeof(<WaitForNetwork>d__5))]
		public static IEnumerator WaitForNetwork(IEnumerator routine)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <WaitForNetwork>d__5(0)
			{
				routine = routine
			};
		}

		[IteratorStateMachine(typeof(<WaitForCondition>d__6))]
		public static IEnumerator WaitForCondition(Func<bool> condition, float timeout = float.NaN, Action? onTimeout = null, Action? onFinish = null)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <WaitForCondition>d__6(0)
			{
				condition = condition,
				timeout = timeout,
				onTimeout = onTimeout,
				onFinish = onFinish
			};
		}

		public static string GetHierarchyPath(this Transform transform)
		{
			if ((Object)(object)transform == (Object)null)
			{
				return "null";
			}
			string text = ((Object)transform).name;
			Transform parent = transform.parent;
			while ((Object)(object)parent != (Object)null)
			{
				text = ((Object)parent).name + "/" + text;
				parent = parent.parent;
			}
			return text;
		}

		public static T GetOrAddComponent<T>(this GameObject gameObject) where T : Component
		{
			T component = gameObject.GetComponent<T>();
			if ((Object)(object)component != (Object)null)
			{
				return component;
			}
			component = gameObject.AddComponent<T>();
			Logger.Debug("Added component " + typeof(T).Name + " to GameObject " + ((Object)gameObject).name);
			return component;
		}

		public static Material? DrawDebugVisuals(this GameObject gameObject, Color? color = null)
		{
			//IL_0040: 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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Expected O, but got Unknown
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: 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_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: 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_0147: Unknown result type (might be due to invalid IL or missing references)
			Renderer component = gameObject.GetComponent<Renderer>();
			if ((Object)(object)component == (Object)null)
			{
				Logger.Error("GameObject " + ((Object)gameObject).name + " has no Renderer component");
				return null;
			}
			Color valueOrDefault = color.GetValueOrDefault();
			if (!color.HasValue)
			{
				((Color)(ref valueOrDefault))..ctor(1f, 0f, 1f, 0.5f);
				color = valueOrDefault;
			}
			Shader val = Shader.Find("Universal Render Pipeline/Lit");
			if ((Object)(object)val == (Object)null)
			{
				return null;
			}
			Material val2 = new Material(val);
			if (val2.HasProperty("_Surface"))
			{
				val2.SetFloat("_Surface", 1f);
			}
			Color value = color.Value;
			if (value.a <= 0f)
			{
				value.a = 0.2f;
			}
			if (val2.HasProperty("_BaseColor"))
			{
				val2.SetColor("_BaseColor", value);
			}
			if (val2.HasProperty("_EmissionColor"))
			{
				val2.EnableKeyword("_EMISSION");
				val2.SetColor("_EmissionColor", new Color(value.r, value.g, value.b) * 1.5f);
			}
			val2.SetInt("_ZWrite", 0);
			val2.renderQueue = 3000;
			Material material = component.material;
			component.material = val2;
			return material;
		}
	}
}

Maxwell-Mono.dll

Decompiled 2 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using FishNet;
using Maxwell;
using Maxwell.Helpers;
using Maxwell.Persistence;
using MelonLoader;
using MelonLoader.Preferences;
using Microsoft.CodeAnalysis;
using S1API.Internal.Abstraction;
using S1API.Saveables;
using S1MAPI.Gltf;
using S1MAPI.Utils;
using ScheduleOne.DevUtilities;
using ScheduleOne.Dragging;
using ScheduleOne.Interaction;
using ScheduleOne.PlayerScripts;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(global::Maxwell.Maxwell), "Maxwell", "1.0.0", "k073l", null)]
[assembly: MelonColor(1, 255, 255, 255)]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: MelonPlatformDomain(/*Could not decode attribute arguments.*/)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("Maxwell-Mono")]
[assembly: AssemblyConfiguration("Mono")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Maxwell-Mono")]
[assembly: AssemblyTitle("Maxwell-Mono")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Maxwell
{
	public static class BuildInfo
	{
		public const string Name = "Maxwell";

		public const string Description = "Adds Maxwell the cat";

		public const string Author = "k073l";

		public const string Version = "1.0.0";
	}
	public class Maxwell : MelonMod
	{
		private static Instance _logger;

		private byte[] _maxwellModel;

		private const string MaxwellModelResourcePath = "Maxwell.assets.maxwell_the_cat_dingus.glb";

		private Transform _maxwellTransform;

		private List<GameObject> _cats = new List<GameObject>();

		private MelonPreferences_Category _preferencesCategory;

		private MelonPreferences_Entry<KeyCode> _spawnKeyPreference;

		private MelonPreferences_Entry<KeyCode> _removeKeyPreference;

		public override void OnInitializeMelon()
		{
			_logger = ((MelonBase)this).LoggerInstance;
			_logger.Msg("Maxwell initialized");
			_maxwellModel = EmbeddedResourceLoader.LoadBytes("Maxwell.assets.maxwell_the_cat_dingus.glb", (Assembly)null);
			if (_maxwellModel == null)
			{
				_logger.Error("Failed to load Maxwell model from embedded resources!");
			}
			else
			{
				_logger.Msg("Successfully loaded Maxwell model from embedded resources.");
			}
			_preferencesCategory = MelonPreferences.CreateCategory("MaxwellSettings", "Maxwell Mod Settings");
			_spawnKeyPreference = _preferencesCategory.CreateEntry<KeyCode>("SpawnMaxwellKey", (KeyCode)278, "Spawn Maxwell Key", "Key to spawn Maxwell the cat.", false, false, (ValueValidator)null, (string)null);
			_removeKeyPreference = _preferencesCategory.CreateEntry<KeyCode>("RemoveMaxwellKey", (KeyCode)279, "Remove Maxwell Key", "Key to remove Maxwell the cat.", false, false, (ValueValidator)null, (string)null);
		}

		public override void OnSceneWasLoaded(int buildIndex, string sceneName)
		{
			if (!(sceneName != "Menu"))
			{
				MaxwellSave.Instance.MaxwellsData.Clear();
				_cats.Clear();
			}
		}

		public override void OnUpdate()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			Scene activeScene = SceneManager.GetActiveScene();
			if (!(((Scene)(ref activeScene)).name != "Main") && _maxwellModel != null)
			{
				if (Input.GetKeyDown(_spawnKeyPreference.Value))
				{
					SpawnMaxwell();
				}
				if (Input.GetKeyDown(_removeKeyPreference.Value))
				{
					RemoveMaxwell();
				}
				if (Time.frameCount % 60 == 0)
				{
					MaxwellSave.Instance.MaxwellsData = MaxwellSave.ConvertToDto(_cats);
				}
			}
		}

		public void SpawnMaxwell()
		{
			//IL_0012: 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_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: 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_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			Camera camera = PlayerSingleton<PlayerCamera>.Instance.Camera;
			Vector3 position = ((Component)camera).transform.position + ((Component)camera).transform.forward * 2f;
			Quaternion identity = Quaternion.identity;
			SpawnMaxwellInternal(position, identity, null, dragging: true);
		}

		public void SpawnMaxwell(Vector3 position, Quaternion rotation, Guid guid)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			SpawnMaxwellInternal(position, rotation, guid);
		}

		private void SpawnMaxwellInternal(Vector3 position, Quaternion rotation, Guid? guid, bool dragging = false)
		{
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			Shader val = Shader.Find("Universal Render Pipeline/Lit");
			GameObject val2 = GltfLoader.LoadGlb(_maxwellModel, val);
			if ((Object)(object)val2 == (Object)null)
			{
				_logger.Error("Failed to load Maxwell model into scene!");
				return;
			}
			if ((Object)(object)_maxwellTransform == (Object)null)
			{
				_maxwellTransform = new GameObject("MaxwellRoot").transform;
			}
			val2.transform.parent = _maxwellTransform;
			((Object)val2).name = "Maxwell";
			val2.transform.position = position;
			val2.transform.rotation = rotation;
			val2.transform.localScale = Vector3.one * 0.03f;
			ModelUtils.AddMeshCollidersRecursively(val2);
			Rigidbody rigidbody = ModelUtils.AddAndConfigureRigidbody(val2);
			Guid valueOrDefault = guid.GetValueOrDefault();
			if (!guid.HasValue)
			{
				valueOrDefault = GUIDManager.GenerateUniqueGUID();
				guid = valueOrDefault;
			}
			ModelUtils.AddDraggableIntObj(val2, rigidbody, guid.Value);
			_cats.Add(val2);
			_logger.Msg($"Maxwell has been created in the scene at position {val2.transform.position}");
			if (dragging)
			{
				Draggable component = val2.GetComponent<Draggable>();
				if (component != null)
				{
					component.Interacted();
				}
			}
		}

		public void RemoveMaxwell()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			Camera camera = PlayerSingleton<PlayerCamera>.Instance.Camera;
			Ray val = default(Ray);
			((Ray)(ref val))..ctor(((Component)camera).transform.position, ((Component)camera).transform.forward);
			DrawVisualRay(((Ray)(ref val)).origin, ((Ray)(ref val)).direction, 20f, Color.red);
			RaycastHit val2 = default(RaycastHit);
			if (Physics.Raycast(val, ref val2, 20f))
			{
				GameObject gameObject = ((Component)((RaycastHit)(ref val2)).collider).gameObject;
				MelonLogger.Msg("Hit object: " + ((Object)gameObject).name);
				Draggable component = gameObject.GetComponent<Draggable>();
				int num = 0;
				Transform parent = gameObject.transform.parent;
				while ((Object)(object)component == (Object)null && (Object)(object)parent != (Object)null && num < 10)
				{
					component = ((Component)parent).GetComponent<Draggable>();
					parent = parent.parent;
					num++;
				}
				if ((Object)(object)component != (Object)null && ((Object)((Component)component).gameObject).name == "Maxwell")
				{
					RemoveMaxwell(((Component)component).gameObject);
				}
				else
				{
					_logger.Msg("No Maxwell found at the targeted location.");
				}
			}
		}

		private void RemoveMaxwell(GameObject maxwellObj)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)maxwellObj == (Object)null))
			{
				Draggable component = maxwellObj.GetComponent<Draggable>();
				if ((Object)(object)component != (Object)null && component.IsBeingDragged)
				{
					NetworkSingleton<DragManager>.Instance.StopDragging(Vector3.zero);
				}
				_cats.Remove(maxwellObj);
				Object.Destroy((Object)(object)maxwellObj);
				_logger.Msg("Maxwell has been removed from the scene.");
			}
		}

		private static void DrawVisualRay(Vector3 origin, Vector3 direction, float length, Color color)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: 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_007e: Expected O, but got Unknown
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("VisualRay");
			LineRenderer val2 = val.AddComponent<LineRenderer>();
			val2.positionCount = 2;
			val2.useWorldSpace = true;
			val2.SetPosition(0, origin);
			val2.SetPosition(1, origin + ((Vector3)(ref direction)).normalized * length);
			val2.startWidth = 0.02f;
			val2.endWidth = 0.02f;
			Shader val3 = Shader.Find("Universal Render Pipeline/Lit");
			if ((Object)(object)val3 != (Object)null)
			{
				Material val4 = new Material(val3);
				if (val4.HasProperty("_BaseColor"))
				{
					val4.SetColor("_BaseColor", color);
				}
				((Renderer)val2).material = val4;
			}
			Object.Destroy((Object)(object)val, 0.5f);
		}
	}
}
namespace Maxwell.Persistence
{
	public class MaxwellSave : Saveable
	{
		[SaveableField("maxwell_data")]
		public List<MaxwellSaveData> MaxwellsData = new List<MaxwellSaveData>();

		public static MaxwellSave Instance { get; private set; } = new MaxwellSave();


		public MaxwellSave()
		{
			Instance = this;
		}

		protected override void OnLoaded()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			Instance = this;
			foreach (MaxwellSaveData maxwellsDatum in MaxwellsData)
			{
				Melon<Maxwell>.Instance.SpawnMaxwell(maxwellsDatum.Position, maxwellsDatum.Rotation, maxwellsDatum.Guid);
			}
		}

		public static List<MaxwellSaveData> ConvertToDto(List<GameObject> gameObjects)
		{
			//IL_0074: 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)
			gameObjects.RemoveAll((GameObject x) => (Object)(object)x == (Object)null);
			List<MaxwellSaveData> list = new List<MaxwellSaveData>();
			foreach (GameObject gameObject in gameObjects)
			{
				Draggable component = gameObject.GetComponent<Draggable>();
				if ((Object)(object)component != (Object)null && Guid.TryParse(component.BakedGUID, out var result))
				{
					list.Add(new MaxwellSaveData
					{
						Position = gameObject.transform.position,
						Rotation = gameObject.transform.rotation,
						Guid = result
					});
				}
			}
			return list;
		}
	}
	public record MaxwellSaveData
	{
		public Vector3 Position { get; set; }

		public Quaternion Rotation { get; set; }

		public Guid Guid { get; set; }

		[CompilerGenerated]
		protected virtual bool PrintMembers(StringBuilder builder)
		{
			//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_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			RuntimeHelpers.EnsureSufficientExecutionStack();
			builder.Append("Position = ");
			Vector3 position = Position;
			builder.Append(((object)(Vector3)(ref position)).ToString());
			builder.Append(", Rotation = ");
			Quaternion rotation = Rotation;
			builder.Append(((object)(Quaternion)(ref rotation)).ToString());
			builder.Append(", Guid = ");
			builder.Append(Guid.ToString());
			return true;
		}
	}
}
namespace Maxwell.Helpers
{
	public static class MelonLoggerExtensions
	{
		public static void Debug(this Instance logger, string message, bool stacktrace = true)
		{
			MelonDebug.Msg(stacktrace ? ("[" + GetCallerInfo() + "] " + message) : message);
		}

		private static string GetCallerInfo()
		{
			StackTrace stackTrace = new StackTrace();
			for (int i = 2; i < stackTrace.FrameCount; i++)
			{
				StackFrame frame = stackTrace.GetFrame(i);
				MethodBase method = frame.GetMethod();
				if (!(method?.DeclaringType == null))
				{
					return method.DeclaringType.FullName + "." + method.Name;
				}
			}
			return "unknown";
		}
	}
	public static class ModelUtils
	{
		public static void AddMeshCollidersRecursively(GameObject obj)
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			MeshFilter component = obj.GetComponent<MeshFilter>();
			if ((Object)(object)component != (Object)null && (Object)(object)component.sharedMesh != (Object)null)
			{
				MeshCollider val = obj.AddComponent<MeshCollider>();
				val.sharedMesh = component.sharedMesh;
				val.convex = true;
			}
			foreach (Transform item in obj.transform)
			{
				Transform val2 = item;
				AddMeshCollidersRecursively(((Component)val2).gameObject);
			}
		}

		public static Rigidbody AddAndConfigureRigidbody(GameObject obj)
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)obj == (Object)null)
			{
				return null;
			}
			Rigidbody val = obj.AddComponent<Rigidbody>();
			val.mass = 1f;
			val.drag = 0.5f;
			val.angularDrag = 0.5f;
			val.centerOfMass = new Vector3(0f, 0.5f, 0f);
			val.interpolation = (RigidbodyInterpolation)1;
			return val;
		}

		public static void AddDraggableIntObj(GameObject obj, Rigidbody rigidbody, Guid guid)
		{
			InteractableObject intObj = obj.AddComponent<InteractableObject>();
			obj.SetActive(false);
			Draggable val = obj.AddComponent<Draggable>();
			val.IntObj = intObj;
			val.Rigidbody = rigidbody;
			val.BakedGUID = guid.ToString();
			obj.SetActive(true);
		}
	}
	public static class Il2CppListExtensions
	{
		public static IEnumerable<T> AsEnumerable<T>(this List<T> list)
		{
			return list ?? new List<T>();
		}

		public static object ToNativeList<T>(this List<T> source)
		{
			return source ?? new List<T>();
		}
	}
	public static class Utils
	{
		[CompilerGenerated]
		private sealed class <WaitForCondition>d__6 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public Func<bool> condition;

			public float timeout;

			public Action onTimeout;

			public Action onFinish;

			private float <startTime>5__1;

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

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

			[DebuggerHidden]
			public <WaitForCondition>d__6(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<startTime>5__1 = Time.time;
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				if (!condition())
				{
					if (!float.IsNaN(timeout) && Time.time - <startTime>5__1 > timeout)
					{
						onTimeout?.Invoke();
						return false;
					}
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				onFinish?.Invoke();
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <WaitForNetwork>d__5 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public IEnumerator routine;

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

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

			[DebuggerHidden]
			public <WaitForNetwork>d__5(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				if (!InstanceFinder.IsServer && !InstanceFinder.IsClient)
				{
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				MelonCoroutines.Start(routine);
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <WaitForPlayer>d__4 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public IEnumerator routine;

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

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

			[DebuggerHidden]
			public <WaitForPlayer>d__4(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				if ((Object)(object)Player.Local == (Object)null || (Object)(object)((Component)Player.Local).gameObject == (Object)null)
				{
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				MelonCoroutines.Start(routine);
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		private static readonly Instance Logger = new Instance("Maxwell-Utils");

		public static T? FindObjectByName<T>(string objectName) where T : Object
		{
			try
			{
				T[] array = Resources.FindObjectsOfTypeAll<T>();
				foreach (T val in array)
				{
					if (!(((Object)val).name != objectName))
					{
						Logger.Debug("Found " + typeof(T).Name + " '" + objectName + "' directly in loaded objects");
						return val;
					}
				}
				return default(T);
			}
			catch (Exception ex)
			{
				Logger.Error("Error finding " + typeof(T).Name + " '" + objectName + "': " + ex.Message);
				return default(T);
			}
		}

		public static List<T> GetAllComponentsInChildrenRecursive<T>(GameObject obj) where T : Component
		{
			List<T> list = new List<T>();
			if ((Object)(object)obj == (Object)null)
			{
				return list;
			}
			T[] components = obj.GetComponents<T>();
			if (components.Length != 0)
			{
				list.AddRange(components);
			}
			for (int i = 0; i < obj.transform.childCount; i++)
			{
				Transform child = obj.transform.GetChild(i);
				list.AddRange(GetAllComponentsInChildrenRecursive<T>(((Component)child).gameObject));
			}
			return list;
		}

		public static bool Is<T>(object obj, out T? result) where T : class
		{
			if (obj is T val)
			{
				result = val;
				return true;
			}
			result = null;
			return false;
		}

		[IteratorStateMachine(typeof(<WaitForPlayer>d__4))]
		public static IEnumerator WaitForPlayer(IEnumerator routine)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <WaitForPlayer>d__4(0)
			{
				routine = routine
			};
		}

		[IteratorStateMachine(typeof(<WaitForNetwork>d__5))]
		public static IEnumerator WaitForNetwork(IEnumerator routine)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <WaitForNetwork>d__5(0)
			{
				routine = routine
			};
		}

		[IteratorStateMachine(typeof(<WaitForCondition>d__6))]
		public static IEnumerator WaitForCondition(Func<bool> condition, float timeout = float.NaN, Action? onTimeout = null, Action? onFinish = null)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <WaitForCondition>d__6(0)
			{
				condition = condition,
				timeout = timeout,
				onTimeout = onTimeout,
				onFinish = onFinish
			};
		}

		public static string GetHierarchyPath(this Transform transform)
		{
			if ((Object)(object)transform == (Object)null)
			{
				return "null";
			}
			string text = ((Object)transform).name;
			Transform parent = transform.parent;
			while ((Object)(object)parent != (Object)null)
			{
				text = ((Object)parent).name + "/" + text;
				parent = parent.parent;
			}
			return text;
		}

		public static T GetOrAddComponent<T>(this GameObject gameObject) where T : Component
		{
			T component = gameObject.GetComponent<T>();
			if ((Object)(object)component != (Object)null)
			{
				return component;
			}
			component = gameObject.AddComponent<T>();
			Logger.Debug("Added component " + typeof(T).Name + " to GameObject " + ((Object)gameObject).name);
			return component;
		}

		public static Material? DrawDebugVisuals(this GameObject gameObject, Color? color = null)
		{
			//IL_0040: 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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Expected O, but got Unknown
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: 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_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: 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_0147: Unknown result type (might be due to invalid IL or missing references)
			Renderer component = gameObject.GetComponent<Renderer>();
			if ((Object)(object)component == (Object)null)
			{
				Logger.Error("GameObject " + ((Object)gameObject).name + " has no Renderer component");
				return null;
			}
			Color valueOrDefault = color.GetValueOrDefault();
			if (!color.HasValue)
			{
				((Color)(ref valueOrDefault))..ctor(1f, 0f, 1f, 0.5f);
				color = valueOrDefault;
			}
			Shader val = Shader.Find("Universal Render Pipeline/Lit");
			if ((Object)(object)val == (Object)null)
			{
				return null;
			}
			Material val2 = new Material(val);
			if (val2.HasProperty("_Surface"))
			{
				val2.SetFloat("_Surface", 1f);
			}
			Color value = color.Value;
			if (value.a <= 0f)
			{
				value.a = 0.2f;
			}
			if (val2.HasProperty("_BaseColor"))
			{
				val2.SetColor("_BaseColor", value);
			}
			if (val2.HasProperty("_EmissionColor"))
			{
				val2.EnableKeyword("_EMISSION");
				val2.SetColor("_EmissionColor", new Color(value.r, value.g, value.b) * 1.5f);
			}
			val2.SetInt("_ZWrite", 0);
			val2.renderQueue = 3000;
			Material material = component.material;
			component.material = val2;
			return material;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		internal IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}