Decompiled source of SpawnPumpkin v1.0.1

Mods/SpawnPumpkin.dll

Decompiled 4 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using Il2Cpp;
using Il2CppFemur;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem.Collections.Generic;
using MelonLoader;
using MelonLoader.Utils;
using Microsoft.CodeAnalysis;
using SpawnPumpkinMod;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(SpawnPumpkin), "SpawnPumpkin", "1.0.0", "Zooks", null)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("SpawnPumpkin")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("mod for Gang Beasts")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SpawnPumpkin")]
[assembly: AssemblyTitle("SpawnPumpkin")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 SpawnPumpkinMod
{
	public class SpawnPumpkin : MelonMod
	{
		private const string BundleName = "pumpkinbundle";

		private const string ModelAssetPath = "assets/pumpkin.fbx";

		private const float TargetSize = 0.8f;

		private const float SpawnHeight = 2.5f;

		private AssetBundle pumpkinBundle;

		private GameObject pumpkinTemplate;

		private Material litTemplate;

		private bool pipelineLogged;

		public override void OnInitializeMelon()
		{
			MelonLogger.Msg("[SpawnPumpkin] Starting version 1.0.0.");
			MelonLogger.Msg("[SpawnPumpkin] Unity version: " + Application.unityVersion);
			MelonLogger.Msg("[SpawnPumpkin] MelonLoader version: " + typeof(MelonMod).Assembly.GetName().Version);
			EnsurePumpkinLoaded();
		}

		public override void OnUpdate()
		{
			if (Keyboard.current != null && ((ButtonControl)Keyboard.current.nKey).wasPressedThisFrame)
			{
				SpawnPumpkinObject();
			}
		}

		private AssetBundle LoadEmbeddedBundle()
		{
			try
			{
				Assembly executingAssembly = Assembly.GetExecutingAssembly();
				string[] manifestResourceNames = executingAssembly.GetManifestResourceNames();
				MelonLogger.Msg("[SpawnPumpkin] Embedded resources: " + manifestResourceNames.Length);
				string[] array = manifestResourceNames;
				foreach (string text in array)
				{
					MelonLogger.Msg("[SpawnPumpkin] Embedded resource: " + text);
					if (text.IndexOf("pumpkinbundle", StringComparison.OrdinalIgnoreCase) < 0 || text.EndsWith(".manifest", StringComparison.OrdinalIgnoreCase))
					{
						continue;
					}
					using Stream stream = executingAssembly.GetManifestResourceStream(text);
					if (stream != null)
					{
						byte[] array2;
						using (MemoryStream memoryStream = new MemoryStream())
						{
							stream.CopyTo(memoryStream);
							array2 = memoryStream.ToArray();
						}
						MelonLogger.Msg("[SpawnPumpkin] Loading embedded bundle (" + array2.Length + " bytes).");
						AssetBundle val = AssetBundle.LoadFromMemory(Il2CppStructArray<byte>.op_Implicit(array2));
						if ((Object)(object)val != (Object)null)
						{
							MelonLogger.Msg("[SpawnPumpkin] Embedded bundle loaded.");
							return val;
						}
						MelonLogger.Warning("[SpawnPumpkin] Embedded bundle failed to load. It may already be loaded, or it was built with a different Unity version.");
					}
				}
			}
			catch (Exception ex)
			{
				MelonLogger.Warning("[SpawnPumpkin] Embedded bundle error:\n" + ex);
			}
			return null;
		}

		private void AddSearchDirectory(List<KeyValuePair<string, bool>> directories, string path, bool recursive)
		{
			if (!string.IsNullOrEmpty(path))
			{
				directories.Add(new KeyValuePair<string, bool>(path, recursive));
			}
		}

		private List<string> FindBundleFiles()
		{
			List<string> list = new List<string>();
			HashSet<string> hashSet = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
			List<KeyValuePair<string, bool>> list2 = new List<KeyValuePair<string, bool>>();
			try
			{
				AddSearchDirectory(list2, MelonEnvironment.UserDataDirectory, recursive: true);
			}
			catch
			{
			}
			try
			{
				AddSearchDirectory(list2, MelonEnvironment.ModsDirectory, recursive: true);
			}
			catch
			{
			}
			try
			{
				AddSearchDirectory(list2, MelonEnvironment.GameRootDirectory, recursive: false);
			}
			catch
			{
			}
			try
			{
				string location = Assembly.GetExecutingAssembly().Location;
				if (!string.IsNullOrEmpty(location))
				{
					AddSearchDirectory(list2, Path.GetDirectoryName(location), recursive: true);
				}
			}
			catch
			{
			}
			foreach (KeyValuePair<string, bool> item in list2)
			{
				string key = item.Key;
				MelonLogger.Msg("[SpawnPumpkin] Searching: " + key + (item.Value ? " (including subfolders)" : ""));
				if (!Directory.Exists(key))
				{
					MelonLogger.Warning("[SpawnPumpkin] Folder does not exist: " + key);
					continue;
				}
				try
				{
					string[] files = Directory.GetFiles(key, "pumpkinbundle*", item.Value ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly);
					foreach (string text in files)
					{
						switch (Path.GetExtension(text).ToLowerInvariant())
						{
						case ".manifest":
						case ".dll":
						case ".cs":
						case ".csproj":
							continue;
						}
						if (hashSet.Add(text))
						{
							list.Add(text);
						}
					}
				}
				catch (Exception ex)
				{
					MelonLogger.Warning("[SpawnPumpkin] Could not search " + key + ": " + ex.Message);
				}
			}
			return list;
		}

		private AssetBundle LoadBundleFromFiles()
		{
			List<string> list = FindBundleFiles();
			if (list.Count == 0)
			{
				MelonLogger.Error("[SpawnPumpkin] No file named 'pumpkinbundle' was found. Put it in the game's UserData folder. Make sure Windows is not hiding a file extension such as .txt.");
				return null;
			}
			foreach (string item in list)
			{
				try
				{
					FileInfo fileInfo = new FileInfo(item);
					MelonLogger.Msg("[SpawnPumpkin] Trying file: " + item + " (" + fileInfo.Length + " bytes)");
					if (fileInfo.Length == 0L)
					{
						MelonLogger.Warning("[SpawnPumpkin] File is empty. Skipping.");
						continue;
					}
					AssetBundle val = AssetBundle.LoadFromFile(item);
					if ((Object)(object)val != (Object)null)
					{
						MelonLogger.Msg("[SpawnPumpkin] Bundle loaded from: " + item);
						return val;
					}
					MelonLogger.Warning("[SpawnPumpkin] Unity refused to load this file. It may be corrupted, already loaded, or built with a different Unity version. Game Unity version: " + Application.unityVersion);
				}
				catch (Exception ex)
				{
					MelonLogger.Warning("[SpawnPumpkin] Error loading " + item + ":\n" + ex);
				}
			}
			return null;
		}

		private GameObject FindModelInBundle(AssetBundle bundle)
		{
			Il2CppStringArray allAssetNames = bundle.GetAllAssetNames();
			if (allAssetNames == null || ((Il2CppArrayBase<string>)(object)allAssetNames).Length == 0)
			{
				MelonLogger.Error("[SpawnPumpkin] Bundle contains no named assets.");
				return null;
			}
			foreach (string item in (Il2CppArrayBase<string>)(object)allAssetNames)
			{
				MelonLogger.Msg("[SpawnPumpkin] Bundle asset: " + item);
			}
			GameObject val = bundle.LoadAsset<GameObject>("assets/pumpkin.fbx");
			if ((Object)(object)val != (Object)null)
			{
				return val;
			}
			MelonLogger.Warning("[SpawnPumpkin] Expected asset path failed. Trying every model or prefab in the bundle.");
			foreach (string item2 in (Il2CppArrayBase<string>)(object)allAssetNames)
			{
				if (item2.EndsWith(".fbx", StringComparison.OrdinalIgnoreCase) || item2.EndsWith(".prefab", StringComparison.OrdinalIgnoreCase))
				{
					val = bundle.LoadAsset<GameObject>(item2);
					if ((Object)(object)val != (Object)null)
					{
						MelonLogger.Msg("[SpawnPumpkin] Using asset: " + item2);
						return val;
					}
				}
			}
			return null;
		}

		private bool EnsurePumpkinLoaded()
		{
			if ((Object)(object)pumpkinTemplate != (Object)null)
			{
				return true;
			}
			try
			{
				if ((Object)(object)pumpkinBundle == (Object)null)
				{
					pumpkinBundle = LoadEmbeddedBundle();
				}
				if ((Object)(object)pumpkinBundle == (Object)null)
				{
					pumpkinBundle = LoadBundleFromFiles();
				}
				if ((Object)(object)pumpkinBundle == (Object)null)
				{
					MelonLogger.Error("[SpawnPumpkin] Could not load the pumpkin bundle.");
					return false;
				}
				GameObject val = FindModelInBundle(pumpkinBundle);
				if ((Object)(object)val == (Object)null)
				{
					MelonLogger.Error("[SpawnPumpkin] Pumpkin model could not be loaded from the bundle.");
					return false;
				}
				((Object)val).hideFlags = (HideFlags)32;
				pumpkinTemplate = Object.Instantiate<GameObject>(val);
				((Object)pumpkinTemplate).name = "SpawnPumpkin Template";
				((Object)pumpkinTemplate).hideFlags = (HideFlags)32;
				pumpkinTemplate.SetActive(false);
				Object.DontDestroyOnLoad((Object)(object)pumpkinTemplate);
				MelonLogger.Msg("[SpawnPumpkin] Model template ready. Press N in a match to spawn a pumpkin.");
				return true;
			}
			catch (Exception ex)
			{
				MelonLogger.Error("[SpawnPumpkin] Loading failed:\n" + ex);
				return false;
			}
		}

		private bool IsScriptableRenderPipeline()
		{
			bool flag = false;
			try
			{
				RenderPipelineAsset currentRenderPipeline = GraphicsSettings.currentRenderPipeline;
				flag = (Object)(object)currentRenderPipeline != (Object)null;
				if (!pipelineLogged)
				{
					pipelineLogged = true;
					MelonLogger.Msg("[SpawnPumpkin] Render pipeline: " + (flag ? ((Object)currentRenderPipeline).name : "Built-in"));
				}
			}
			catch (Exception ex)
			{
				MelonLogger.Warning("[SpawnPumpkin] Could not read render pipeline: " + ex.Message);
			}
			return flag;
		}

		private static int ScoreShaderName(string shaderName, bool usingSrp)
		{
			if (string.IsNullOrEmpty(shaderName))
			{
				return 0;
			}
			if (shaderName == "Universal Render Pipeline/Lit" || shaderName == "HDRP/Lit")
			{
				return 100;
			}
			if (shaderName.EndsWith("/Lit", StringComparison.Ordinal) && shaderName.IndexOf("Unlit", StringComparison.OrdinalIgnoreCase) < 0)
			{
				return 90;
			}
			if (shaderName == "Universal Render Pipeline/Simple Lit")
			{
				return 80;
			}
			if (shaderName == "Standard")
			{
				if (!usingSrp)
				{
					return 70;
				}
				return 0;
			}
			return 0;
		}

		private Material GetLitTemplate()
		{
			if ((Object)(object)litTemplate != (Object)null)
			{
				return litTemplate;
			}
			bool usingSrp = IsScriptableRenderPipeline();
			try
			{
				Material val = null;
				int num = 0;
				Il2CppArrayBase<Material> val2 = Resources.FindObjectsOfTypeAll<Material>();
				MelonLogger.Msg("[SpawnPumpkin] Loaded materials scanned: " + val2.Length);
				foreach (Material item in val2)
				{
					if (!((Object)(object)item == (Object)null) && !((Object)(object)item.shader == (Object)null) && !((Object)item).name.StartsWith("SpawnPumpkin") && (item.HasProperty("_BaseColor") || item.HasProperty("_Color")))
					{
						int num2 = ScoreShaderName(((Object)item.shader).name, usingSrp);
						if (num2 > num)
						{
							num = num2;
							val = item;
						}
					}
				}
				if ((Object)(object)val != (Object)null)
				{
					MelonLogger.Msg("[SpawnPumpkin] Using material template '" + ((Object)val).name + "' with shader '" + ((Object)val.shader).name + "'.");
					litTemplate = val;
					return litTemplate;
				}
				MelonLogger.Warning("[SpawnPumpkin] No loaded Lit material found.");
			}
			catch (Exception ex)
			{
				MelonLogger.Error("[SpawnPumpkin] Material search failed:\n" + ex);
			}
			return null;
		}

		private Material CreateMaterial(string name, Color color)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Expected O, but got Unknown
			//IL_0314: Unknown result type (might be due to invalid IL or missing references)
			//IL_032d: Unknown result type (might be due to invalid IL or missing references)
			Material val = null;
			Material val2 = GetLitTemplate();
			string[] array;
			if ((Object)(object)val2 != (Object)null)
			{
				val = new Material(val2);
			}
			else
			{
				string[] obj = new string[5] { "Universal Render Pipeline/Lit", "Universal Render Pipeline/Simple Lit", "HDRP/Lit", "Standard", "Legacy Shaders/Diffuse" };
				bool flag = IsScriptableRenderPipeline();
				array = obj;
				foreach (string text in array)
				{
					if (!flag || !(text == "Standard"))
					{
						Shader val3 = Shader.Find(text);
						if ((Object)(object)val3 != (Object)null && val3.isSupported)
						{
							MelonLogger.Warning("[SpawnPumpkin] Falling back to Shader.Find: " + text);
							val = new Material(val3);
							break;
						}
					}
				}
			}
			if ((Object)(object)val == (Object)null)
			{
				MelonLogger.Error("[SpawnPumpkin] Could not create any material.");
				return null;
			}
			((Object)val).name = name;
			array = new string[10] { "_BaseMap", "_MainTex", "_BumpMap", "_EmissionMap", "_MetallicGlossMap", "_OcclusionMap", "_ParallaxMap", "_DetailMask", "_DetailAlbedoMap", "_DetailNormalMap" };
			foreach (string text2 in array)
			{
				if (val.HasProperty(text2))
				{
					val.SetTexture(text2, (Texture)null);
				}
			}
			array = new string[9] { "_EMISSION", "_ALPHATEST_ON", "_ALPHAPREMULTIPLY_ON", "_ALPHAMODULATE_ON", "_SURFACE_TYPE_TRANSPARENT", "_NORMALMAP", "_PARALLAXMAP", "_DETAIL_MULX2", "_DETAIL_SCALED" };
			foreach (string text3 in array)
			{
				val.DisableKeyword(text3);
			}
			if (val.HasProperty("_Surface"))
			{
				val.SetFloat("_Surface", 0f);
			}
			if (val.HasProperty("_AlphaClip"))
			{
				val.SetFloat("_AlphaClip", 0f);
			}
			if (val.HasProperty("_Cutoff"))
			{
				val.SetFloat("_Cutoff", 0f);
			}
			if (val.HasProperty("_Mode"))
			{
				val.SetFloat("_Mode", 0f);
			}
			if (val.HasProperty("_SrcBlend"))
			{
				val.SetFloat("_SrcBlend", 1f);
			}
			if (val.HasProperty("_DstBlend"))
			{
				val.SetFloat("_DstBlend", 0f);
			}
			if (val.HasProperty("_ZWrite"))
			{
				val.SetFloat("_ZWrite", 1f);
			}
			if (val.HasProperty("_Cull"))
			{
				val.SetFloat("_Cull", 0f);
			}
			if (val.HasProperty("_CullMode"))
			{
				val.SetFloat("_CullMode", 0f);
			}
			if (val.HasProperty("_DoubleSidedEnable"))
			{
				val.SetFloat("_DoubleSidedEnable", 1f);
			}
			val.SetOverrideTag("RenderType", "Opaque");
			val.renderQueue = 2000;
			if (val.HasProperty("_BaseColor"))
			{
				val.SetColor("_BaseColor", color);
			}
			if (val.HasProperty("_Color"))
			{
				val.SetColor("_Color", color);
			}
			if (val.HasProperty("_Smoothness"))
			{
				val.SetFloat("_Smoothness", 0.3f);
			}
			if (val.HasProperty("_Glossiness"))
			{
				val.SetFloat("_Glossiness", 0.3f);
			}
			if (val.HasProperty("_Metallic"))
			{
				val.SetFloat("_Metallic", 0f);
			}
			if (val.HasProperty("_BumpScale"))
			{
				val.SetFloat("_BumpScale", 0f);
			}
			return val;
		}

		private void ApplyLitMaterials(GameObject model)
		{
			//IL_00a1: 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)
			Il2CppArrayBase<Renderer> componentsInChildren = model.GetComponentsInChildren<Renderer>(true);
			MelonLogger.Msg("[SpawnPumpkin] Renderer count: " + componentsInChildren.Length);
			foreach (Renderer item in componentsInChildren)
			{
				if ((Object)(object)item == (Object)null)
				{
					continue;
				}
				bool flag = ((Object)item).name.IndexOf("stem", StringComparison.OrdinalIgnoreCase) >= 0;
				Material val = CreateMaterial(flag ? "SpawnPumpkin Stem Lit" : "SpawnPumpkin Orange Lit", flag ? new Color(0.12f, 0.22f, 0.045f, 1f) : new Color(0.8f, 0.19f, 0.015f, 1f));
				if (!((Object)(object)val == (Object)null))
				{
					int num = ((Il2CppArrayBase<Material>)(object)item.sharedMaterials).Length;
					if (num < 1)
					{
						num = 1;
					}
					Il2CppReferenceArray<Material> val2 = new Il2CppReferenceArray<Material>((long)num);
					for (int i = 0; i < num; i++)
					{
						((Il2CppArrayBase<Material>)(object)val2)[i] = val;
					}
					item.sharedMaterials = val2;
					item.enabled = true;
					item.allowOcclusionWhenDynamic = false;
					item.shadowCastingMode = (ShadowCastingMode)2;
					item.receiveShadows = true;
					MelonLogger.Msg("[SpawnPumpkin] Renderer '" + ((Object)item).name + "' uses shader '" + ((Object)val.shader).name + "'.");
				}
			}
		}

		private static bool TryGetBounds(GameObject target, out Bounds bounds)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			bounds = new Bounds(target.transform.position, Vector3.zero);
			bool flag = false;
			foreach (Renderer componentsInChild in target.GetComponentsInChildren<Renderer>(true))
			{
				if (!((Object)(object)componentsInChild == (Object)null))
				{
					if (!flag)
					{
						bounds = componentsInChild.bounds;
						flag = true;
					}
					else
					{
						((Bounds)(ref bounds)).Encapsulate(componentsInChild.bounds);
					}
				}
			}
			return flag;
		}

		private Actor FindBeast()
		{
			List<Actor> localPlayers = Actor.LocalPlayers;
			if (localPlayers != null)
			{
				MelonLogger.Msg("[SpawnPumpkin] Local player count: " + localPlayers.Count);
				for (int i = 0; i < localPlayers.Count; i++)
				{
					Actor val = localPlayers[i];
					if ((Object)(object)val != (Object)null && ((Component)val).gameObject.activeInHierarchy)
					{
						return val;
					}
				}
			}
			Il2CppArrayBase<Actor> val2 = Object.FindObjectsOfType<Actor>();
			MelonLogger.Msg("[SpawnPumpkin] Active actors found: " + val2.Length);
			Actor val3 = null;
			foreach (Actor item in val2)
			{
				if (!((Object)(object)item == (Object)null) && ((Component)item).gameObject.activeInHierarchy)
				{
					if ((Object)(object)val3 == (Object)null)
					{
						val3 = item;
					}
					if (item.IsLocal)
					{
						return item;
					}
				}
			}
			if ((Object)(object)val3 != (Object)null)
			{
				MelonLogger.Warning("[SpawnPumpkin] No local actor. Using first active actor: " + ((Object)val3).name);
			}
			return val3;
		}

		private bool TryGetSpawnPosition(out Vector3 position)
		{
			//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_0022: 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_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_003b: 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_00ae: 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_00c2: Unknown result type (might be due to invalid IL or missing references)
			position = Vector3.zero;
			try
			{
				Actor val = FindBeast();
				if ((Object)(object)val != (Object)null)
				{
					position = ((Component)val).transform.position + Vector3.up * 2.5f;
					MelonLogger.Msg("[SpawnPumpkin] Spawning above " + ((Object)val).name);
					return true;
				}
			}
			catch (Exception ex)
			{
				MelonLogger.Warning("[SpawnPumpkin] Beast search failed:\n" + ex);
			}
			try
			{
				Camera val2 = Camera.main;
				if ((Object)(object)val2 == (Object)null)
				{
					val2 = Object.FindObjectOfType<Camera>();
				}
				if ((Object)(object)val2 != (Object)null)
				{
					position = ((Component)val2).transform.position + ((Component)val2).transform.forward * 3f;
					MelonLogger.Warning("[SpawnPumpkin] No beast found. Spawning in front of the camera.");
					return true;
				}
			}
			catch (Exception ex2)
			{
				MelonLogger.Warning("[SpawnPumpkin] Camera search failed:\n" + ex2);
			}
			MelonLogger.Warning("[SpawnPumpkin] No beast or camera found. Load into a match first.");
			return false;
		}

		private unsafe void SpawnPumpkinObject()
		{
			//IL_002f: 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_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//IL_005a: 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_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: 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_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0268: Unknown result type (might be due to invalid IL or missing references)
			//IL_02af: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0335: Unknown result type (might be due to invalid IL or missing references)
			//IL_033a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0341: Unknown result type (might be due to invalid IL or missing references)
			//IL_0349: Unknown result type (might be due to invalid IL or missing references)
			//IL_0350: Unknown result type (might be due to invalid IL or missing references)
			//IL_0357: Unknown result type (might be due to invalid IL or missing references)
			//IL_035e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0365: Unknown result type (might be due to invalid IL or missing references)
			//IL_0371: Unknown result type (might be due to invalid IL or missing references)
			//IL_0379: Unknown result type (might be due to invalid IL or missing references)
			//IL_0381: Unknown result type (might be due to invalid IL or missing references)
			//IL_0388: Unknown result type (might be due to invalid IL or missing references)
			//IL_038f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0396: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a2: Expected O, but got Unknown
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: 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_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			MelonLogger.Msg("[SpawnPumpkin] N pressed.");
			if (!EnsurePumpkinLoaded())
			{
				MelonLogger.Error("[SpawnPumpkin] Cannot spawn: model loading failed. See the loading messages above.");
			}
			else
			{
				if (!TryGetSpawnPosition(out var position))
				{
					return;
				}
				GameObject val = null;
				try
				{
					Vector3 val2 = position;
					MelonLogger.Msg("[SpawnPumpkin] Spawn position: " + ((object)(*(Vector3*)(&val2))/*cast due to .constrained prefix*/).ToString());
					val = new GameObject("Spawned Pumpkin");
					val.transform.position = position;
					GameObject val3 = Object.Instantiate<GameObject>(pumpkinTemplate, val.transform);
					if ((Object)(object)val3 == (Object)null)
					{
						throw new Exception("Pumpkin model instantiation returned null.");
					}
					((Object)val3).name = "Pumpkin Model";
					val3.transform.localPosition = Vector3.zero;
					val3.transform.localRotation = Quaternion.identity;
					val3.transform.localScale = Vector3.one;
					val3.SetActive(true);
					foreach (Light componentsInChild in val3.GetComponentsInChildren<Light>(true))
					{
						((Behaviour)componentsInChild).enabled = false;
					}
					foreach (Collider componentsInChild2 in val3.GetComponentsInChildren<Collider>(true))
					{
						componentsInChild2.enabled = false;
					}
					ApplyLitMaterials(val3);
					if (TryGetBounds(val, out var bounds))
					{
						float num = Mathf.Max(((Bounds)(ref bounds)).size.x, Mathf.Max(((Bounds)(ref bounds)).size.y, ((Bounds)(ref bounds)).size.z));
						MelonLogger.Msg("[SpawnPumpkin] Original model size: " + ((object)((Bounds)(ref bounds)).size/*cast due to .constrained prefix*/).ToString());
						if (num > 0.0001f)
						{
							val3.transform.localScale = Vector3.one * (0.8f / num);
							if (TryGetBounds(val, out bounds))
							{
								Vector3 val4 = ((Bounds)(ref bounds)).center - val.transform.position;
								Transform transform = val3.transform;
								transform.position -= val4;
								MelonLogger.Msg("[SpawnPumpkin] Final model size: " + ((object)((Bounds)(ref bounds)).size/*cast due to .constrained prefix*/).ToString());
							}
						}
						else
						{
							MelonLogger.Warning("[SpawnPumpkin] Model bounds are near zero.");
						}
					}
					else
					{
						MelonLogger.Warning("[SpawnPumpkin] No renderers found on the model.");
						val3.transform.localScale = Vector3.one * 0.2f;
					}
					val.SetActive(false);
					SphereCollider val5 = val.AddComponent<SphereCollider>();
					val5.center = Vector3.zero;
					val5.radius = 0.4f;
					((Collider)val5).isTrigger = false;
					Rigidbody val6 = val.AddComponent<Rigidbody>();
					val6.mass = 2f;
					val6.useGravity = true;
					val6.isKinematic = false;
					GameObject val7 = new GameObject("Pumpkin Orange Light");
					val7.transform.SetParent(val.transform, false);
					val7.transform.localPosition = Vector3.zero;
					Light obj = val7.AddComponent<Light>();
					obj.type = (LightType)2;
					obj.color = new Color(1f, 0.24f, 0.025f);
					obj.intensity = 2f;
					obj.range = 3f;
					obj.shadows = (LightShadows)2;
					InteractableObject val8 = val.AddComponent<InteractableObject>();
					Il2CppReferenceArray<Collider> val9 = new Il2CppReferenceArray<Collider>(1L);
					((Il2CppArrayBase<Collider>)(object)val9)[0] = (Collider)(object)val5;
					val8.interactableObjectData = new InteractableObjectData
					{
						gameObject = val,
						mainCollider = (Collider)(object)val5,
						priorityModifier = (Priority)3,
						grabModifier = (Grab)2,
						damageModifier = (Damage)2,
						partOfRagdoll = false,
						cachedTransform = val.transform,
						cachedRigidbody = val6,
						cachedColliders = val9,
						checkVelocity = false,
						alwaysDrain = false,
						movingPlatform = false,
						triggerBudBud = false
					};
					val8.childInteractableObjectData = new List<InteractableObjectData>();
					val.AddComponent<InteractableObjectReference>().interactableObject = val8;
					val.SetActive(true);
					MelonLogger.Msg("[SpawnPumpkin] Pumpkin created and activated.");
				}
				catch (Exception ex)
				{
					if ((Object)(object)val != (Object)null)
					{
						Object.Destroy((Object)(object)val);
					}
					MelonLogger.Error("[SpawnPumpkin] Failed to spawn pumpkin:\n" + ex);
				}
			}
		}
	}
}