Decompiled source of RozowySlon v1.0.0

3680666123/DbsContentApi.dll

Decompiled 11 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Cryptography;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using DbsContentApi.Patches;
using DefaultNamespace.ContentProviders;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using TMPro;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Events;
using UnityEngine.Localization;
using UnityEngine.Localization.Tables;
using UnityEngine.SceneManagement;
using Zorro.Core;
using Zorro.Settings;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("DbsContentApi")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("3.1.1.0")]
[assembly: AssemblyInformationalVersion("3.1.1+8e66a3b5c217fc1547fa132823c0d0153a7ec3fa")]
[assembly: AssemblyProduct("DbsContentApi")]
[assembly: AssemblyTitle("DbsContentApi")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("3.1.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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]
	[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]
	[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 DbsContentApi
{
	[ContentWarningPlugin("db.contentapi", "3.1.1", false)]
	[BepInPlugin("db.contentapi", "DB's Content API", "3.1.1")]
	public class DbsContentApiPlugin : BaseUnityPlugin
	{
		private const string ApiAssetBundleFileName = "dbscontentapi";

		private bool _isPatched;

		private Harmony? _harmony;

		internal static List<GameObject> customMonsters = new List<GameObject>();

		internal static List<CustomMap> customMaps = new List<CustomMap>();

		internal static Dictionary<string, CustomMap> customMapsById = new Dictionary<string, CustomMap>(StringComparer.OrdinalIgnoreCase);

		internal static string? selectedCustomMapId;

		internal static string? forcedNextMapId;

		internal static List<Action> customItemsRegistrationCallbacks = new List<Action>();

		internal static List<Item> customArtifacts = new List<Item>();

		internal static List<ContentEvent> customContentEvents = new List<ContentEvent>();

		internal static bool moddedMobsOnly;

		internal static bool moddedMapsOnly;

		internal static bool allItemsFree;

		internal static List<BaseCWInput> _inputs = new List<BaseCWInput>();

		internal static AssetBundle? ApiAssetBundle { get; private set; }

		public static GameObject? TemporaryContentTriggerPrefab { get; private set; }

		private void Awake()
		{
			LoadApiAssetBundle();
			PatchAll();
			ApiLog.Log("Plugin db.contentapi is loaded!");
		}

		private static void LoadApiAssetBundle()
		{
			string location = Assembly.GetExecutingAssembly().Location;
			ApiAssetBundle = ContentLoader.LoadAssetBundle(location, "dbscontentapi");
			if ((Object)(object)ApiAssetBundle == (Object)null)
			{
				ApiLog.LogError("DbsContentApi: failed to load asset bundle 'dbscontentapi' next to " + location);
				return;
			}
			try
			{
				TemporaryContentTriggerPrefab = ContentLoader.LoadPrefabFromBundle(ApiAssetBundle, "TemporaryContentProviderCube.prefab");
			}
			catch (Exception ex)
			{
				ApiLog.LogError("DbsContentApi: failed to load prefab TemporaryContentProviderCube from bundle: " + ex.Message);
			}
		}

		internal static bool RegisterCustomMap(CustomMap map)
		{
			if (customMapsById.ContainsKey(map.MapId))
			{
				ApiLog.LogError("[Maps] Duplicate map id '" + map.MapId + "'. Registration rejected.");
				return false;
			}
			customMaps.Add(map);
			customMapsById[map.MapId] = map;
			ApiLog.Log($"[Maps] Registered custom map: {map.DisplayName} (Id: {map.MapId}, Index: {customMaps.Count - 1})");
			return true;
		}

		internal static bool TryGetCustomMap(string mapId, out CustomMap? map)
		{
			if (customMapsById.TryGetValue(mapId, out CustomMap value))
			{
				map = value;
				return true;
			}
			map = null;
			return false;
		}

		internal static bool TryGetCustomMapByIndex(int index, out CustomMap? map)
		{
			if (index >= 0 && index < customMaps.Count)
			{
				map = customMaps[index];
				return true;
			}
			map = null;
			return false;
		}

		private void PatchAll()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			if (_isPatched)
			{
				ApiLog.LogError("Already patched!");
				return;
			}
			ApiLog.Log("Patching...");
			if (_harmony == null)
			{
				_harmony = new Harmony("db.contentapi");
			}
			try
			{
				ApiLog.LogError("Patching...");
				_harmony.PatchAll();
				_isPatched = true;
				ApiLog.Log("Patched!");
			}
			catch (Exception arg)
			{
				ApiLog.LogError($"Failed to patch: {arg}");
			}
		}

		public void UnpatchAll()
		{
			if (!_isPatched)
			{
				ApiLog.LogError("Already unpatched!");
				return;
			}
			ApiLog.Log("Unpatching...");
			try
			{
				Harmony? harmony = _harmony;
				if (harmony != null)
				{
					harmony.UnpatchSelf();
				}
				_isPatched = false;
				ApiLog.Log("Unpatched!");
			}
			catch (Exception arg)
			{
				ApiLog.LogError($"Failed to unpatch: {arg}");
			}
		}

		public static void SetModdedMobsOnly(bool value)
		{
			moddedMobsOnly = value;
		}

		public static void SetModdedMapsOnly(bool value)
		{
			moddedMapsOnly = value;
		}

		public static void SetAllItemsFree(bool value)
		{
			allItemsFree = value;
		}
	}
	internal static class ApiLog
	{
		internal static void Log(string message)
		{
			Debug.Log((object)("[DbsContentApi] " + message));
		}

		internal static void LogWarning(string message)
		{
			Debug.LogWarning((object)("[DbsContentApi] " + message));
		}

		internal static void LogError(string message)
		{
			Debug.LogError((object)("[DbsContentApi] " + message));
		}
	}
	public abstract class BaseCWInput : KeyCodeSetting
	{
		internal InputKey inputKey;

		protected bool _disabled;

		public void HandleKeys(Player player)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: 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_0030: Unknown result type (might be due to invalid IL or missing references)
			if (!_disabled)
			{
				KeyCode val = ((KeyCodeSetting)this).Keycode();
				if (Input.GetKeyDown(val))
				{
					OnKeyDown(player);
				}
				else if (Input.GetKeyUp(val))
				{
					OnKeyUp(player);
				}
				else if (Input.GetKey(val))
				{
					OnHeld(player);
				}
			}
		}

		protected abstract override KeyCode GetDefaultKey();

		public override int GetDefaultValue()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected I4, but got Unknown
			return (int)((KeyCodeSetting)this).GetDefaultKey();
		}

		protected abstract void OnKeyDown(Player player);

		protected abstract void OnKeyUp(Player player);

		protected abstract void OnHeld(Player player);

		public void Disable()
		{
			_disabled = true;
		}

		public void Enable()
		{
			_disabled = false;
		}

		public BaseCWInput()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			inputKey = new InputKey();
			DbsContentApiPlugin._inputs.Add(this);
			_disabled = false;
			ApiLog.Log($"[BaseCWInput] Created input: {((object)this).GetType().Name}, default key: {((KeyCodeSetting)this).GetDefaultKey()}");
		}
	}
	public class ContentEvents
	{
		public static void RegisterEvent(ContentEvent contentEvent)
		{
			ApiLog.Log("Registering content event for " + contentEvent.GetName());
			DbsContentApiPlugin.customContentEvents.Add(contentEvent);
		}

		public static ushort GetEventID(string contentEventName)
		{
			List<ContentEvent> customContentEvents = DbsContentApiPlugin.customContentEvents;
			int num = customContentEvents.FindIndex((ContentEvent match) => ((object)match).GetType().Name == contentEventName);
			if (num == -1)
			{
				throw new InvalidOperationException("Content event '" + contentEventName + "' is not registered. Call ContentEvents.RegisterEvent before resolving its ID.");
			}
			return (ushort)(2000 + num);
		}
	}
	[HarmonyPatch(typeof(ContentEventIDMapper))]
	internal class ContentEventIDMapperPatches
	{
		[HarmonyPrefix]
		[HarmonyPatch("GetContentEvent")]
		public static bool GetContentEventPrefix(ref ushort id, ref ContentEvent __result)
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected O, but got Unknown
			List<ContentEvent> customContentEvents = DbsContentApiPlugin.customContentEvents;
			ApiLog.Log($"GetContentEvent was called: {id} Normalized: {id - 2000} EventList count: {customContentEvents.Count}");
			if (id - 2000 < 0)
			{
				return true;
			}
			ContentEvent val = customContentEvents[id - 2000];
			if (val == null)
			{
				return true;
			}
			__result = (ContentEvent)Activator.CreateInstance(((object)val).GetType());
			return false;
		}
	}
	public static class ContentLoader
	{
		public static AssetBundle? LoadAssetBundle(Assembly assembly, string bundleName)
		{
			return LoadAssetBundle(assembly.Location, bundleName);
		}

		public static AssetBundle LoadAssetBundle(string assemblyLocation, string bundleName)
		{
			string directoryName = Path.GetDirectoryName(assemblyLocation);
			string text = Path.Combine(directoryName, bundleName);
			AssetBundle val = AssetBundle.LoadFromFile(text);
			if ((Object)(object)val == (Object)null)
			{
				Debug.LogError((object)("Failed to load AssetBundle: " + bundleName + " at path: " + text));
				return null;
			}
			return val;
		}

		public static GameObject LoadPrefabFromBundle(AssetBundle bundle, string prefabName)
		{
			GameObject val = bundle.LoadAsset<GameObject>(prefabName);
			if ((Object)(object)val == (Object)null)
			{
				throw new Exception("Failed to load Prefab: " + prefabName + " from bundle: " + ((Object)bundle).name);
			}
			return val;
		}

		public static void RegisterPrefabInPhotonPool(GameObject prefab)
		{
			IPunPrefabPool prefabPool = PhotonNetwork.PrefabPool;
			DefaultPool val = (DefaultPool)(object)((prefabPool is DefaultPool) ? prefabPool : null);
			if (val != null && !val.ResourceCache.ContainsKey(((Object)prefab).name))
			{
				val.ResourceCache.Add(((Object)prefab).name, prefab);
			}
		}
	}
	public class CustomComment
	{
		public string Language { get; set; }

		public string Comment { get; set; }

		public CustomComment(string language, string comment)
		{
			Language = language;
			Comment = comment;
		}
	}
	public static class CustomCommentRegistry
	{
		private static Dictionary<string, List<CustomComment>> _registeredComments = new Dictionary<string, List<CustomComment>>();

		public static void Register(string key, params CustomComment[] translations)
		{
			if (!_registeredComments.TryGetValue(key, out List<CustomComment> value))
			{
				value = new List<CustomComment>();
				_registeredComments[key] = value;
			}
			foreach (CustomComment translation in translations)
			{
				CustomComment customComment = value.FirstOrDefault((CustomComment c) => c.Language == translation.Language);
				if (customComment != null)
				{
					customComment.Comment = translation.Comment;
				}
				else
				{
					value.Add(translation);
				}
			}
		}

		internal static void ApplyToStringTables(Dictionary<LocaleIdentifier, StringTable> tables)
		{
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			if (tables == null)
			{
				ApiLog.LogError("[CustomCommentRegistry] tables dictionary is null.");
				return;
			}
			foreach (KeyValuePair<string, List<CustomComment>> registeredComment in _registeredComments)
			{
				string key = registeredComment.Key;
				List<CustomComment> value = registeredComment.Value;
				CustomComment customComment = value.FirstOrDefault((CustomComment t) => t.Language == "en");
				foreach (KeyValuePair<LocaleIdentifier, StringTable> table in tables)
				{
					LocaleIdentifier localeId = table.Key;
					StringTable value2 = table.Value;
					if (((DetailedLocalizationTable<StringTableEntry>)(object)value2).GetEntry(key) != null)
					{
						ApiLog.LogError("[CustomCommentRegistry] Key collision for '" + key + "' in table '" + ((LocaleIdentifier)(ref localeId)).Code + "'. Skipping.");
						continue;
					}
					CustomComment customComment2 = value.FirstOrDefault((CustomComment t) => t.Language == ((LocaleIdentifier)(ref localeId)).Code);
					if (customComment2 != null)
					{
						((DetailedLocalizationTable<StringTableEntry>)(object)value2).AddEntry(key, customComment2.Comment);
						continue;
					}
					if (customComment != null)
					{
						((DetailedLocalizationTable<StringTableEntry>)(object)value2).AddEntry(key, customComment.Comment);
						continue;
					}
					ApiLog.LogError("[CustomCommentRegistry] No translation or English fallback for key '" + key + "' in locale '" + ((LocaleIdentifier)(ref localeId)).Code + "'.");
				}
			}
			ApiLog.Log($"[CustomCommentRegistry] Applied {_registeredComments.Count} custom comment keys to {tables.Count} string tables.");
		}
	}
	public enum GameMaterial
	{
		M_Debug,
		M_Projector_1,
		M_BoomMic_2,
		M_Projector_4,
		M_Projector_3,
		M_GreenScreen_3,
		M_GreenScreen_1,
		M_GreenScreen_2,
		M_Projector_2,
		M_Projector_5,
		M_Container_2,
		M_Player,
		M_Winch_4,
		M_Winch_6,
		M_Winch_2,
		M_Winch_3,
		M_Winch_1,
		M_Winch_5,
		M_Shroom_1,
		M_ReporterMic_1,
		M_ReporterMic_3,
		M_ReporterMic_2,
		M_Monster_BlackLocal,
		M_HatShop_4,
		M_Book_2,
		M_BoomMic_3,
		M_Monster,
		M_World,
		M_Pool_6,
		M_Jester_1,
		M_Flashlight_2_2,
		M_Flashlight_1_1,
		M_Pool_4,
		M_Radio_4,
		M_Metal,
		M_Hotdog_1,
		M_Goo_3,
		M_Flare_1,
		M_Shroom_2,
		M_FredGull_2,
		M_World_AlphaClip,
		M_Hotdog_3,
		M_Rugby_3,
		M_Rug_6,
		M_Hug,
		M_Radio_1,
		M_Borkin_2,
		M_DarkBlack,
		M_Flashlight_Bright,
		M_SoundPlayer_4,
		M_Laser_Weak,
		M_BatteryLight_Off,
		M_BatteryLight_Green,
		M_BatteryLight_Yellow,
		M_BatteryLight_Red,
		M_Flashlight_1_2,
		M_Flashlight_Off,
		M_Player_1,
		M_PlayerVisor,
		M_OxygenDisplay,
		M_FlashBeam,
		M_World_Local,
		M_FlatUI,
		M_Hamburger_3,
		M_Norf_1,
		M_Norf_2,
		M_Jester_3,
		M_Splash,
		M_VideoCamera_Recording,
		M_Cinema_2,
		M_Hand,
		M_Cutbox_1,
		M_LongFlashlight_2_1,
		M_Cutbox_2,
		M_CD_Plastic,
		M_CD,
		M_VFX_ShockStick,
		M_Light_Bright,
		M_ShockStick_1,
		M_ShockStick_2,
		M_Pool_7,
		M_Defib_3,
		M_Flashlight_3_2,
		M_Pool_8,
		M_Chef_1,
		M_Helmet,
		M_Pirate_3,
		M_Pirate_1,
		M_PlayerHatColor,
		M_Pirate_2,
		M_Rug_3,
		M_VideoCamera_3,
		M_World_ShelfGrate_3,
		M_HatShop_6,
		M_Horn,
		M_VideoCamera_5,
		M_VideoCamera_1,
		M_VideoCamera_2,
		M_Eye,
		M_CameraScreen,
		M_Flare_2,
		M_FlareEYe,
		M_FlareBeam,
		M_Ushanka_2,
		M_Ushanka_1,
		M_Container_1,
		M_Container_3,
		M_Cutbox_3,
		M_Halo,
		M_Beanie_1,
		M_Monster_Dark,
		M_News2,
		M_World_BarbedWire,
		M_World_ShelfGrate_1,
		M_World_ShelfGrate_2,
		M_DivingBell_1,
		M_DivingBell_2,
		M_DivingBell_3,
		M_DivingBell_3_Local,
		M_DivingBell_3_Local_Actually,
		M_DivingBell_4,
		M_DivingBell_4_Local,
		M_DivingBell_4_Local_Actually,
		M_DivingBell_Lever_Local,
		M_Popper_2,
		M_Popper_1,
		M_Popper_4,
		M_Popper_3,
		M_BigSlapPainting_1,
		ParticlesUnlit,
		M_RescueHook_1,
		M_FredGull_1,
		M_Walkie_Talkie_2,
		M_Walkie_Talkie_1,
		M_Walkie_Talkie_3,
		M_Explosion,
		M_Milk1,
		M_Floppy_1,
		M_Hamburger_1,
		M_Hamburger_2,
		M_Hamburger_4,
		M_Jester_4,
		M_VideoDisplayScreen,
		M_Hair_1,
		M_Clown_2,
		M_Cowboy,
		M_Portrait_3,
		M_RescueHook_2,
		M_HookLight,
		M_Apple_3,
		M_Child_5,
		M_Ears_1,
		M_Radio_2,
		M_Radio_3,
		M_Book_1,
		M_Crane,
		M_Cinema_1,
		M_Screen,
		M_Cursor,
		M_Defib_4,
		M_Defib_2,
		M_LongFlashlight_2_2,
		M_Laser,
		M_SoundPlayer_3,
		M_Goo_1,
		M_TitleCardRender,
		M_TitleCard_1,
		M_TitleCard,
		M_TitleCard_2,
		M_GooBright,
		M_FredGull_4,
		M_FredGull_3,
		M_Flashlight_3_1,
		M_Crown,
		M_Copyright_1,
		M_Rugby_2,
		M_Interior_7,
		M_Clown_1,
		M_Hotdog_4,
		M_Top,
		M_Rug_5,
		M_Borkin_1,
		M_House_Glas,
		M_Portrait_1,
		M_Copyright,
		M_HatShop_3,
		M_BoomMic_1,
		M_Foodora,
		M_Jester_2,
		M_Child_4,
		M_Balaclava,
		M_Child_2,
		M_ShopGlass,
		M_Podcast_4,
		M_Podcast_2,
		M_Portrait_2,
		M_SoundPlayer_2,
		M_Goop,
		M_SoundPlayer_1,
		M_HatShop_8,
		M_News1,
		M_Defib_1,
		M_Apple_2,
		M_HatShop_5,
		M_Rug_1,
		M_FrontScreen,
		M_SoundPlayer_5,
		M_Portrait_4,
		M_Child_3,
		M_TaserBeam,
		M_VFX_BombFuze,
		M_Rug_4,
		M_Flashlight_2_1,
		M_Apple_1,
		M_DefaultParticle,
		M_Knifo,
		M_Bucket_1,
		M_Bomb,
		M_Ears_2,
		M_Child_1,
		M_Ears_3,
		M_Cap_1,
		M_Goo_2,
		M_Party_2,
		M_Party_1,
		M_Milk2,
		M_HatShop_7,
		M_Brain_1,
		M_HatShop_2,
		M_Rugby_1,
		M_Witch,
		M_Hotdog_2,
		M_HatShop_1,
		M_Bowler,
		M_Brain_2,
		Jello_PostShader,
		M_DivingScreen_Nice,
		M_Light_Warm,
		M_Asphalt,
		M_Barrel_1,
		M_Barrel_2,
		M_Bed_1,
		M_Bed_2,
		M_Bed_3,
		M_Bed_4,
		M_Bed_5,
		M_Bed_6,
		M_Bed_7,
		M_Bed_Default_1,
		M_House_1,
		M_House_10,
		M_House_11,
		M_House_12,
		M_House_2,
		M_House_3,
		M_House_4,
		M_House_5,
		M_House_6,
		M_House_8,
		M_House_9,
		M_Interior_1,
		M_Interior_2,
		M_Interior_3,
		M_Interior_4,
		M_Interior_5,
		M_Interior_6,
		M_Interior_8,
		M_Rock,
		M_Rug_2,
		M_Rug_7,
		M_Rug_8,
		M_Rug_9,
		M_Solar_1,
		M_Solar_2,
		M_Sunflower_1,
		M_Sunflower_2,
		M_Sunflower_3,
		M_ThePlan_1,
		M_ThePlan_2,
		M_Trunk,
		M_Surf_Bush,
		M_Surf_Ground,
		M_Surf_GroundGrass,
		M_DivingBell1Nice,
		M_DivingBell2Nice,
		M_DivingBell3Nice,
		M_DivingBell4Nice,
		M_DivingBell5Nice,
		M_DivingBell6Nice,
		M_CloudSphere_2,
		M_CloudSphere,
		M_CloudSphere_Evening_2,
		M_CloudSphere_Evening,
		M_Sky,
		M_Sky_Evening,
		M_Intro,
		M_House_7,
		M_Scraper,
		M_Invis,
		M_Mirror,
		M_ArrowIcon,
		M_CamConverter_1,
		M_CamConverter_2,
		M_CamConverter_3,
		M_CamConverter_4,
		M_CamConverter_5,
		M_CameraIcon,
		M_Charge_1,
		M_Charge_2,
		M_Charge_3,
		M_Charge_4,
		M_Charge_5,
		M_Drone_1,
		M_Drone_2,
		M_Drone_3,
		M_Drone_4,
		M_Drone_5,
		M_FaceMachine,
		M_House_13,
		M_House_Door,
		M_Landing,
		M_Laptop,
		M_Machine,
		M_NetworkDeal_1,
		M_NetworkDeal_2,
		M_NetworkDeal_3,
		M_NetworkDeal_4,
		M_Podcast_1,
		M_Podcast_10,
		M_Podcast_11,
		M_Podcast_3,
		M_Podcast_5,
		M_Podcast_6,
		M_Podcast_7,
		M_Podcast_8,
		M_Podcast_9,
		M_Pool_1,
		M_Pool_11,
		M_Pool_2,
		M_Pool_3,
		M_Pool_5,
		M_Shop_1,
		M_Shop_2,
		M_Shop_3,
		M_TV_1,
		M_TV_2,
		M_TV,
		M_Teleport_1,
		M_Teleport_2,
		M_Trampoline_1,
		M_Trampoline_2,
		M_Trampoline_3,
		M_Trampoline_4,
		M_UpgradeSign,
		M_Water,
		M_Wood,
		M_Surf_Bush_NoWind,
		M_Surf_Ground_Dirt,
		M_Surf_Ground_Side,
		M_Surf_Ground_Side_Dirt,
		M_Charge,
		M_Dust,
		M_Heal
	}
	public enum DescriptiveMaterial
	{
		TRANSPARENT,
		LIGHT_GREY_1,
		WHITE_1,
		GREY_1,
		MOON,
		GREY_2,
		GREEN_1,
		LIGHT_FLAT_GREY_1,
		GLOWING_WHITE_1,
		DARK_GREY_1,
		DARK_GREY_BLACK,
		DARK_BLUE_CYAN,
		VERY_LIGHT_GREY,
		DARK_GREY_2,
		GREY_WHITE_SPOTS,
		DARKISH_RED_1,
		DARKISH_RED_2,
		WHITE_SPOTS_1,
		DARK_FLAT_GREY_1,
		LIGHT_FLAT_GREY_2,
		DARK_BLUE_GREY,
		FULL_BLACK,
		LIGHT_BROWN,
		WHITE_PAPER,
		GREY_3,
		ORANGE_1,
		YELLOW_1,
		GREY_SPOTS_1,
		BROWN_1,
		BROWN_2,
		ORANGE_2,
		NEUTRAL_GREY,
		VERY_LIGHT_BEIGE,
		DARK_GREY_DARK_SPOTS,
		RED_DARK_SPOTS,
		WHITE_SPOTS_2,
		BLUE_1,
		WEIRD_TRANSPARENT_BLACK_SPOTS,
		RED_1,
		BEIGE_1,
		ORANGE_3,
		YELLOW_2,
		GLOWING_WHITE_2,
		WHITE_DARK_SPOTS,
		TRANSPARENT_SLIGHTLY_RED,
		FLAT_GREY,
		LIME_1,
		GLOWING_YELLOW,
		GLOWING_RED,
		BROWN_DARK_SPOTS,
		BLACK_BLUE,
		GREY_SMALL_DARK_SPOTS,
		ICE_BLUE,
		GREY_DARK_OUTLINES,
		DARK_BLACK_DARK_SPOTS,
		WHITE_2,
		YELLOW_3,
		INTENSE_BLUE_ICE,
		ORANGE_WHITE_SPOTS,
		GREEN_2,
		GLOWING_RED_1,
		WHITE_3,
		DARK_GREY_3,
		WHITE_BEIGE,
		FLAT_DARK_GREY,
		ORANGE_4,
		BLUE_CYAN_1,
		GREY_DARK_SPOTS_1,
		YELLOW_4,
		WHITE_DARKER_SPOTS,
		YELLOW_5,
		BLUE_CYAN_2,
		ORANGE_5,
		RED_BEIGE_1,
		GLOWING_WHITE_3,
		BLACK_GRILLAGE,
		ORANGE_BEIGE_PARALAX,
		GLOWING_WHITE_4,
		GLOWING_RED_2,
		DARK_YELLOW,
		DARK_BROWN,
		GREEN_3,
		DARK_GREY_BROWN,
		RED_BEIGE_LIGHT,
		BROWN_3,
		GLOWING_WHITE_RED,
		GREEN_LEAVES,
		CYAN_BLUE,
		WHITE_4,
		RED_2,
		FLAT_RED,
		VIOLET_1,
		GREEN_4,
		TRANSPARENT_GLASS,
		TRANSPARENT_DARK_WEIRD_LIGHTING,
		BROWN_LARGE_LIGHT_SPOTS,
		GREY_BLUE,
		TRANSPARENT_DARK,
		YELLOW_6,
		RED_MERCURY,
		PINK_1,
		LIME_2,
		DARK_VIOLET,
		RED_3,
		PINK_2,
		ICE_1,
		TURQUOISE,
		RED_4
	}
	public static class GameMaterials
	{
		public static readonly Dictionary<GameMaterial, Material> _materials;

		public static readonly Dictionary<string, GameMaterial> _nameToEnum;

		public static readonly Dictionary<DescriptiveMaterial, GameMaterial> _descriptiveToOriginal;

		public static event Action? OnMaterialsLoaded;

		static GameMaterials()
		{
			_materials = new Dictionary<GameMaterial, Material>();
			_nameToEnum = new Dictionary<string, GameMaterial>();
			_descriptiveToOriginal = new Dictionary<DescriptiveMaterial, GameMaterial>
			{
				{
					DescriptiveMaterial.TRANSPARENT,
					GameMaterial.M_Debug
				},
				{
					DescriptiveMaterial.LIGHT_GREY_1,
					GameMaterial.M_Projector_1
				},
				{
					DescriptiveMaterial.WHITE_1,
					GameMaterial.M_Projector_4
				},
				{
					DescriptiveMaterial.GREY_1,
					GameMaterial.M_Projector_3
				},
				{
					DescriptiveMaterial.MOON,
					GameMaterial.M_GreenScreen_3
				},
				{
					DescriptiveMaterial.GREY_2,
					GameMaterial.M_GreenScreen_1
				},
				{
					DescriptiveMaterial.GREEN_1,
					GameMaterial.M_GreenScreen_2
				},
				{
					DescriptiveMaterial.LIGHT_FLAT_GREY_1,
					GameMaterial.M_Projector_2
				},
				{
					DescriptiveMaterial.GLOWING_WHITE_1,
					GameMaterial.M_Projector_5
				},
				{
					DescriptiveMaterial.DARK_GREY_1,
					GameMaterial.M_Container_2
				},
				{
					DescriptiveMaterial.DARK_GREY_BLACK,
					GameMaterial.M_Player
				},
				{
					DescriptiveMaterial.DARK_BLUE_CYAN,
					GameMaterial.M_Winch_4
				},
				{
					DescriptiveMaterial.VERY_LIGHT_GREY,
					GameMaterial.M_Winch_6
				},
				{
					DescriptiveMaterial.DARK_GREY_2,
					GameMaterial.M_Winch_2
				},
				{
					DescriptiveMaterial.GREY_WHITE_SPOTS,
					GameMaterial.M_Winch_3
				},
				{
					DescriptiveMaterial.DARKISH_RED_1,
					GameMaterial.M_Winch_1
				},
				{
					DescriptiveMaterial.DARKISH_RED_2,
					GameMaterial.M_Winch_5
				},
				{
					DescriptiveMaterial.WHITE_SPOTS_1,
					GameMaterial.M_Shroom_1
				},
				{
					DescriptiveMaterial.DARK_FLAT_GREY_1,
					GameMaterial.M_ReporterMic_1
				},
				{
					DescriptiveMaterial.LIGHT_FLAT_GREY_2,
					GameMaterial.M_ReporterMic_3
				},
				{
					DescriptiveMaterial.DARK_BLUE_GREY,
					GameMaterial.M_ReporterMic_2
				},
				{
					DescriptiveMaterial.FULL_BLACK,
					GameMaterial.M_Monster_BlackLocal
				},
				{
					DescriptiveMaterial.LIGHT_BROWN,
					GameMaterial.M_HatShop_4
				},
				{
					DescriptiveMaterial.WHITE_PAPER,
					GameMaterial.M_Book_2
				},
				{
					DescriptiveMaterial.GREY_3,
					GameMaterial.M_BoomMic_3
				},
				{
					DescriptiveMaterial.ORANGE_1,
					GameMaterial.M_Pool_6
				},
				{
					DescriptiveMaterial.YELLOW_1,
					GameMaterial.M_Jester_1
				},
				{
					DescriptiveMaterial.GREY_SPOTS_1,
					GameMaterial.M_Flashlight_2_2
				},
				{
					DescriptiveMaterial.BROWN_1,
					GameMaterial.M_Flashlight_1_1
				},
				{
					DescriptiveMaterial.BROWN_2,
					GameMaterial.M_Pool_4
				},
				{
					DescriptiveMaterial.ORANGE_2,
					GameMaterial.M_Radio_4
				},
				{
					DescriptiveMaterial.NEUTRAL_GREY,
					GameMaterial.M_Metal
				},
				{
					DescriptiveMaterial.VERY_LIGHT_BEIGE,
					GameMaterial.M_Hotdog_1
				},
				{
					DescriptiveMaterial.DARK_GREY_DARK_SPOTS,
					GameMaterial.M_Goo_3
				},
				{
					DescriptiveMaterial.RED_DARK_SPOTS,
					GameMaterial.M_Flare_1
				},
				{
					DescriptiveMaterial.WHITE_SPOTS_2,
					GameMaterial.M_Shroom_2
				},
				{
					DescriptiveMaterial.BLUE_1,
					GameMaterial.M_FredGull_2
				},
				{
					DescriptiveMaterial.WEIRD_TRANSPARENT_BLACK_SPOTS,
					GameMaterial.M_World_AlphaClip
				},
				{
					DescriptiveMaterial.RED_1,
					GameMaterial.M_Hotdog_3
				},
				{
					DescriptiveMaterial.BEIGE_1,
					GameMaterial.M_Rugby_3
				},
				{
					DescriptiveMaterial.ORANGE_3,
					GameMaterial.M_Rug_6
				},
				{
					DescriptiveMaterial.YELLOW_2,
					GameMaterial.M_Borkin_2
				},
				{
					DescriptiveMaterial.GLOWING_WHITE_2,
					GameMaterial.M_Flashlight_Bright
				},
				{
					DescriptiveMaterial.WHITE_DARK_SPOTS,
					GameMaterial.M_SoundPlayer_4
				},
				{
					DescriptiveMaterial.TRANSPARENT_SLIGHTLY_RED,
					GameMaterial.M_Laser_Weak
				},
				{
					DescriptiveMaterial.FLAT_GREY,
					GameMaterial.M_BatteryLight_Off
				},
				{
					DescriptiveMaterial.LIME_1,
					GameMaterial.M_BatteryLight_Green
				},
				{
					DescriptiveMaterial.GLOWING_YELLOW,
					GameMaterial.M_BatteryLight_Yellow
				},
				{
					DescriptiveMaterial.GLOWING_RED,
					GameMaterial.M_BatteryLight_Red
				},
				{
					DescriptiveMaterial.BROWN_DARK_SPOTS,
					GameMaterial.M_Flashlight_1_2
				},
				{
					DescriptiveMaterial.BLACK_BLUE,
					GameMaterial.M_Flashlight_Off
				},
				{
					DescriptiveMaterial.GREY_SMALL_DARK_SPOTS,
					GameMaterial.M_Player_1
				},
				{
					DescriptiveMaterial.ICE_BLUE,
					GameMaterial.M_PlayerVisor
				},
				{
					DescriptiveMaterial.GREY_DARK_OUTLINES,
					GameMaterial.M_OxygenDisplay
				},
				{
					DescriptiveMaterial.DARK_BLACK_DARK_SPOTS,
					GameMaterial.M_World_Local
				},
				{
					DescriptiveMaterial.WHITE_2,
					GameMaterial.M_FlatUI
				},
				{
					DescriptiveMaterial.YELLOW_3,
					GameMaterial.M_Hamburger_3
				},
				{
					DescriptiveMaterial.INTENSE_BLUE_ICE,
					GameMaterial.M_Norf_1
				},
				{
					DescriptiveMaterial.ORANGE_WHITE_SPOTS,
					GameMaterial.M_Norf_2
				},
				{
					DescriptiveMaterial.GREEN_2,
					GameMaterial.M_Jester_3
				},
				{
					DescriptiveMaterial.GLOWING_RED_1,
					GameMaterial.M_VideoCamera_Recording
				},
				{
					DescriptiveMaterial.WHITE_3,
					GameMaterial.M_Cinema_2
				},
				{
					DescriptiveMaterial.DARK_GREY_3,
					GameMaterial.M_Cutbox_1
				},
				{
					DescriptiveMaterial.WHITE_BEIGE,
					GameMaterial.M_CD_Plastic
				},
				{
					DescriptiveMaterial.FLAT_DARK_GREY,
					GameMaterial.M_ShockStick_1
				},
				{
					DescriptiveMaterial.ORANGE_4,
					GameMaterial.M_ShockStick_2
				},
				{
					DescriptiveMaterial.BLUE_CYAN_1,
					GameMaterial.M_Pool_7
				},
				{
					DescriptiveMaterial.GREY_DARK_SPOTS_1,
					GameMaterial.M_Flashlight_3_2
				},
				{
					DescriptiveMaterial.YELLOW_4,
					GameMaterial.M_Pool_8
				},
				{
					DescriptiveMaterial.WHITE_DARKER_SPOTS,
					GameMaterial.M_Chef_1
				},
				{
					DescriptiveMaterial.YELLOW_5,
					GameMaterial.M_Helmet
				},
				{
					DescriptiveMaterial.BLUE_CYAN_2,
					GameMaterial.M_PlayerHatColor
				},
				{
					DescriptiveMaterial.ORANGE_5,
					GameMaterial.M_Pirate_2
				},
				{
					DescriptiveMaterial.RED_BEIGE_1,
					GameMaterial.M_Rug_3
				},
				{
					DescriptiveMaterial.GLOWING_WHITE_3,
					GameMaterial.M_VideoCamera_3
				},
				{
					DescriptiveMaterial.BLACK_GRILLAGE,
					GameMaterial.M_World_ShelfGrate_3
				},
				{
					DescriptiveMaterial.ORANGE_BEIGE_PARALAX,
					GameMaterial.M_HatShop_6
				},
				{
					DescriptiveMaterial.GLOWING_WHITE_4,
					GameMaterial.M_Eye
				},
				{
					DescriptiveMaterial.GLOWING_RED_2,
					GameMaterial.M_FlareEYe
				},
				{
					DescriptiveMaterial.DARK_YELLOW,
					GameMaterial.M_RescueHook_1
				},
				{
					DescriptiveMaterial.DARK_BROWN,
					GameMaterial.M_Walkie_Talkie_1
				},
				{
					DescriptiveMaterial.GREEN_3,
					GameMaterial.M_Hamburger_4
				},
				{
					DescriptiveMaterial.DARK_GREY_BROWN,
					GameMaterial.M_Hair_1
				},
				{
					DescriptiveMaterial.RED_BEIGE_LIGHT,
					GameMaterial.M_Clown_2
				},
				{
					DescriptiveMaterial.BROWN_3,
					GameMaterial.M_Portrait_3
				},
				{
					DescriptiveMaterial.GLOWING_WHITE_RED,
					GameMaterial.M_HookLight
				},
				{
					DescriptiveMaterial.GREEN_LEAVES,
					GameMaterial.M_Apple_3
				},
				{
					DescriptiveMaterial.CYAN_BLUE,
					GameMaterial.M_Child_1
				},
				{
					DescriptiveMaterial.WHITE_4,
					GameMaterial.M_Cap_1
				},
				{
					DescriptiveMaterial.RED_2,
					GameMaterial.M_Apple_1
				},
				{
					DescriptiveMaterial.FLAT_RED,
					GameMaterial.M_TitleCard_2
				},
				{
					DescriptiveMaterial.VIOLET_1,
					GameMaterial.M_Jester_2
				},
				{
					DescriptiveMaterial.GREEN_4,
					GameMaterial.M_Child_2
				},
				{
					DescriptiveMaterial.TRANSPARENT_GLASS,
					GameMaterial.M_ShopGlass
				},
				{
					DescriptiveMaterial.TRANSPARENT_DARK_WEIRD_LIGHTING,
					GameMaterial.M_Goop
				},
				{
					DescriptiveMaterial.BROWN_LARGE_LIGHT_SPOTS,
					GameMaterial.M_Apple_2
				},
				{
					DescriptiveMaterial.GREY_BLUE,
					GameMaterial.M_Rug_1
				},
				{
					DescriptiveMaterial.TRANSPARENT_DARK,
					GameMaterial.M_FrontScreen
				},
				{
					DescriptiveMaterial.YELLOW_6,
					GameMaterial.M_Child_3
				},
				{
					DescriptiveMaterial.RED_MERCURY,
					GameMaterial.M_Apple_1
				},
				{
					DescriptiveMaterial.PINK_1,
					GameMaterial.M_Ears_2
				},
				{
					DescriptiveMaterial.LIME_2,
					GameMaterial.M_HatShop_2
				},
				{
					DescriptiveMaterial.DARK_VIOLET,
					GameMaterial.M_Bowler
				},
				{
					DescriptiveMaterial.RED_3,
					GameMaterial.M_Bed_2
				},
				{
					DescriptiveMaterial.PINK_2,
					GameMaterial.M_Bed_4
				},
				{
					DescriptiveMaterial.ICE_1,
					GameMaterial.M_Bed_5
				},
				{
					DescriptiveMaterial.TURQUOISE,
					GameMaterial.M_Bed_6
				},
				{
					DescriptiveMaterial.RED_4,
					GameMaterial.M_House_2
				}
			};
			_nameToEnum["M_Debug"] = GameMaterial.M_Debug;
			_nameToEnum["M_Projector 1"] = GameMaterial.M_Projector_1;
			_nameToEnum["M_BoomMic 2"] = GameMaterial.M_BoomMic_2;
			_nameToEnum["M_Projector 4"] = GameMaterial.M_Projector_4;
			_nameToEnum["M_Projector 3"] = GameMaterial.M_Projector_3;
			_nameToEnum["M_GreenScreen 3"] = GameMaterial.M_GreenScreen_3;
			_nameToEnum["M_GreenScreen 1"] = GameMaterial.M_GreenScreen_1;
			_nameToEnum["M_GreenScreen 2"] = GameMaterial.M_GreenScreen_2;
			_nameToEnum["M_Projector 2"] = GameMaterial.M_Projector_2;
			_nameToEnum["M_Projector 5"] = GameMaterial.M_Projector_5;
			_nameToEnum["M_Container 2"] = GameMaterial.M_Container_2;
			_nameToEnum["M_Player"] = GameMaterial.M_Player;
			_nameToEnum["M_Winch 4"] = GameMaterial.M_Winch_4;
			_nameToEnum["M_Winch 6"] = GameMaterial.M_Winch_6;
			_nameToEnum["M_Winch 2"] = GameMaterial.M_Winch_2;
			_nameToEnum["M_Winch 3"] = GameMaterial.M_Winch_3;
			_nameToEnum["M_Winch 1"] = GameMaterial.M_Winch_1;
			_nameToEnum["M_Winch 5"] = GameMaterial.M_Winch_5;
			_nameToEnum["M_Shroom 1"] = GameMaterial.M_Shroom_1;
			_nameToEnum["M_ReporterMic 1"] = GameMaterial.M_ReporterMic_1;
			_nameToEnum["M_ReporterMic 3"] = GameMaterial.M_ReporterMic_3;
			_nameToEnum["M_ReporterMic 2"] = GameMaterial.M_ReporterMic_2;
			_nameToEnum["M_Monster_BlackLocal"] = GameMaterial.M_Monster_BlackLocal;
			_nameToEnum["M_HatShop 4"] = GameMaterial.M_HatShop_4;
			_nameToEnum["M_Book 2"] = GameMaterial.M_Book_2;
			_nameToEnum["M_BoomMic 3"] = GameMaterial.M_BoomMic_3;
			_nameToEnum["M_Monster"] = GameMaterial.M_Monster;
			_nameToEnum["M_World"] = GameMaterial.M_World;
			_nameToEnum["M_Pool 6"] = GameMaterial.M_Pool_6;
			_nameToEnum["M_Jester 1"] = GameMaterial.M_Jester_1;
			_nameToEnum["M_Flashlight 2 2"] = GameMaterial.M_Flashlight_2_2;
			_nameToEnum["M_Flashlight 1 1"] = GameMaterial.M_Flashlight_1_1;
			_nameToEnum["M_Pool 4"] = GameMaterial.M_Pool_4;
			_nameToEnum["M_Radio 4"] = GameMaterial.M_Radio_4;
			_nameToEnum["M_Metal"] = GameMaterial.M_Metal;
			_nameToEnum["M_Hotdog 1"] = GameMaterial.M_Hotdog_1;
			_nameToEnum["M_Goo 3"] = GameMaterial.M_Goo_3;
			_nameToEnum["M_Flare 1"] = GameMaterial.M_Flare_1;
			_nameToEnum["M_Shroom 2"] = GameMaterial.M_Shroom_2;
			_nameToEnum["M_FredGull 2"] = GameMaterial.M_FredGull_2;
			_nameToEnum["M_Hotdog 3"] = GameMaterial.M_Hotdog_3;
			_nameToEnum["M_Rugby 3"] = GameMaterial.M_Rugby_3;
			_nameToEnum["M_Rug 6"] = GameMaterial.M_Rug_6;
			_nameToEnum["M_Hug"] = GameMaterial.M_Hug;
			_nameToEnum["M_Radio 1"] = GameMaterial.M_Radio_1;
			_nameToEnum["M_Borkin 2"] = GameMaterial.M_Borkin_2;
			_nameToEnum["M_World_AlphaClip"] = GameMaterial.M_World_AlphaClip;
			_nameToEnum["M_DarkBlack"] = GameMaterial.M_DarkBlack;
			_nameToEnum["M_Flashlight Bright"] = GameMaterial.M_Flashlight_Bright;
			_nameToEnum["M_SoundPlayer 4"] = GameMaterial.M_SoundPlayer_4;
			_nameToEnum["M_Laser Weak"] = GameMaterial.M_Laser_Weak;
			_nameToEnum["M_BatteryLight_Off"] = GameMaterial.M_BatteryLight_Off;
			_nameToEnum["M_BatteryLight_Green"] = GameMaterial.M_BatteryLight_Green;
			_nameToEnum["M_BatteryLight_Yellow"] = GameMaterial.M_BatteryLight_Yellow;
			_nameToEnum["M_BatteryLight_Red"] = GameMaterial.M_BatteryLight_Red;
			_nameToEnum["M_Flashlight 1 2"] = GameMaterial.M_Flashlight_1_2;
			_nameToEnum["M_Flashlight Off"] = GameMaterial.M_Flashlight_Off;
			_nameToEnum["M_Player 1"] = GameMaterial.M_Player_1;
			_nameToEnum["M_PlayerVisor"] = GameMaterial.M_PlayerVisor;
			_nameToEnum["M_OxygenDisplay"] = GameMaterial.M_OxygenDisplay;
			_nameToEnum["M_FlashBeam"] = GameMaterial.M_FlashBeam;
			_nameToEnum["M_World_Local"] = GameMaterial.M_World_Local;
			_nameToEnum["M_FlatUI"] = GameMaterial.M_FlatUI;
			_nameToEnum["M_Hamburger 3"] = GameMaterial.M_Hamburger_3;
			_nameToEnum["M_Norf 1"] = GameMaterial.M_Norf_1;
			_nameToEnum["M_Norf 2"] = GameMaterial.M_Norf_2;
			_nameToEnum["M_Jester 3"] = GameMaterial.M_Jester_3;
			_nameToEnum["M_Splash"] = GameMaterial.M_Splash;
			_nameToEnum["M_VideoCamera_Recording"] = GameMaterial.M_VideoCamera_Recording;
			_nameToEnum["M_Cinema 2"] = GameMaterial.M_Cinema_2;
			_nameToEnum["M_Hand"] = GameMaterial.M_Hand;
			_nameToEnum["M_Cutbox 1"] = GameMaterial.M_Cutbox_1;
			_nameToEnum["M_LongFlashlight 2 1"] = GameMaterial.M_LongFlashlight_2_1;
			_nameToEnum["M_Cutbox 2"] = GameMaterial.M_Cutbox_2;
			_nameToEnum["M_CD_Plastic"] = GameMaterial.M_CD_Plastic;
			_nameToEnum["M_CD"] = GameMaterial.M_CD;
			_nameToEnum["M_VFX_ShockStick"] = GameMaterial.M_VFX_ShockStick;
			_nameToEnum["M_Light_Bright"] = GameMaterial.M_Light_Bright;
			_nameToEnum["M_ShockStick 1"] = GameMaterial.M_ShockStick_1;
			_nameToEnum["M_ShockStick 2"] = GameMaterial.M_ShockStick_2;
			_nameToEnum["M_Pool 7"] = GameMaterial.M_Pool_7;
			_nameToEnum["M_Defib 3"] = GameMaterial.M_Defib_3;
			_nameToEnum["M_Flashlight 3 2"] = GameMaterial.M_Flashlight_3_2;
			_nameToEnum["M_Pool 8"] = GameMaterial.M_Pool_8;
			_nameToEnum["M_Chef 1"] = GameMaterial.M_Chef_1;
			_nameToEnum["M_Helmet"] = GameMaterial.M_Helmet;
			_nameToEnum["M_Pirate 3"] = GameMaterial.M_Pirate_3;
			_nameToEnum["M_Pirate 1"] = GameMaterial.M_Pirate_1;
			_nameToEnum["M_PlayerHatColor"] = GameMaterial.M_PlayerHatColor;
			_nameToEnum["M_Pirate 2"] = GameMaterial.M_Pirate_2;
			_nameToEnum["M_Rug 3"] = GameMaterial.M_Rug_3;
			_nameToEnum["M_VideoCamera 3"] = GameMaterial.M_VideoCamera_3;
			_nameToEnum["M_World_ShelfGrate 3"] = GameMaterial.M_World_ShelfGrate_3;
			_nameToEnum["M_HatShop 6"] = GameMaterial.M_HatShop_6;
			_nameToEnum["M_Horn"] = GameMaterial.M_Horn;
			_nameToEnum["M_VideoCamera 5"] = GameMaterial.M_VideoCamera_5;
			_nameToEnum["M_VideoCamera 1"] = GameMaterial.M_VideoCamera_1;
			_nameToEnum["M_VideoCamera 2"] = GameMaterial.M_VideoCamera_2;
			_nameToEnum["M_Eye"] = GameMaterial.M_Eye;
			_nameToEnum["M_CameraScreen"] = GameMaterial.M_CameraScreen;
			_nameToEnum["M_Flare 2"] = GameMaterial.M_Flare_2;
			_nameToEnum["M_FlareEYe"] = GameMaterial.M_FlareEYe;
			_nameToEnum["M_FlareBeam"] = GameMaterial.M_FlareBeam;
			_nameToEnum["M_Ushanka 2"] = GameMaterial.M_Ushanka_2;
			_nameToEnum["M_Ushanka 1"] = GameMaterial.M_Ushanka_1;
			_nameToEnum["M_Container 1"] = GameMaterial.M_Container_1;
			_nameToEnum["M_Container 3"] = GameMaterial.M_Container_3;
			_nameToEnum["M_Cutbox 3"] = GameMaterial.M_Cutbox_3;
			_nameToEnum["M_Halo"] = GameMaterial.M_Halo;
			_nameToEnum["M_Beanie 1"] = GameMaterial.M_Beanie_1;
			_nameToEnum["M_Monster_Dark"] = GameMaterial.M_Monster_Dark;
			_nameToEnum["M_News2"] = GameMaterial.M_News2;
			_nameToEnum["M_World_BarbedWire"] = GameMaterial.M_World_BarbedWire;
			_nameToEnum["M_World_ShelfGrate 1"] = GameMaterial.M_World_ShelfGrate_1;
			_nameToEnum["M_World_ShelfGrate 2"] = GameMaterial.M_World_ShelfGrate_2;
			_nameToEnum["M_DivingBell 1"] = GameMaterial.M_DivingBell_1;
			_nameToEnum["M_DivingBell 2"] = GameMaterial.M_DivingBell_2;
			_nameToEnum["M_DivingBell 3"] = GameMaterial.M_DivingBell_3;
			_nameToEnum["M_DivingBell 3_Local"] = GameMaterial.M_DivingBell_3_Local;
			_nameToEnum["M_DivingBell 3_Local Actually"] = GameMaterial.M_DivingBell_3_Local_Actually;
			_nameToEnum["M_DivingBell 4"] = GameMaterial.M_DivingBell_4;
			_nameToEnum["M_DivingBell 4_Local"] = GameMaterial.M_DivingBell_4_Local;
			_nameToEnum["M_DivingBell 4_Local Actually"] = GameMaterial.M_DivingBell_4_Local_Actually;
			_nameToEnum["M_DivingBell Lever_Local"] = GameMaterial.M_DivingBell_Lever_Local;
			_nameToEnum["M_Popper 2"] = GameMaterial.M_Popper_2;
			_nameToEnum["M_Popper 1"] = GameMaterial.M_Popper_1;
			_nameToEnum["M_Popper 4"] = GameMaterial.M_Popper_4;
			_nameToEnum["M_Popper 3"] = GameMaterial.M_Popper_3;
			_nameToEnum["M_BigSlapPainting 1"] = GameMaterial.M_BigSlapPainting_1;
			_nameToEnum["ParticlesUnlit"] = GameMaterial.ParticlesUnlit;
			_nameToEnum["M_RescueHook 1"] = GameMaterial.M_RescueHook_1;
			_nameToEnum["M_FredGull 1"] = GameMaterial.M_FredGull_1;
			_nameToEnum["M_Walkie Talkie 2"] = GameMaterial.M_Walkie_Talkie_2;
			_nameToEnum["M_Walkie Talkie 1"] = GameMaterial.M_Walkie_Talkie_1;
			_nameToEnum["M_Walkie Talkie 3"] = GameMaterial.M_Walkie_Talkie_3;
			_nameToEnum["M_Explosion"] = GameMaterial.M_Explosion;
			_nameToEnum["M_Milk1"] = GameMaterial.M_Milk1;
			_nameToEnum["M_Floppy 1"] = GameMaterial.M_Floppy_1;
			_nameToEnum["M_Hamburger 1"] = GameMaterial.M_Hamburger_1;
			_nameToEnum["M_Hamburger 2"] = GameMaterial.M_Hamburger_2;
			_nameToEnum["M_Hamburger 4"] = GameMaterial.M_Hamburger_4;
			_nameToEnum["M_Jester 4"] = GameMaterial.M_Jester_4;
			_nameToEnum["M_VideoDisplayScreen"] = GameMaterial.M_VideoDisplayScreen;
			_nameToEnum["M_Hair 1"] = GameMaterial.M_Hair_1;
			_nameToEnum["M_Clown 2"] = GameMaterial.M_Clown_2;
			_nameToEnum["M_Cowboy"] = GameMaterial.M_Cowboy;
			_nameToEnum["M_Portrait 3"] = GameMaterial.M_Portrait_3;
			_nameToEnum["M_RescueHook 2"] = GameMaterial.M_RescueHook_2;
			_nameToEnum["M_HookLight"] = GameMaterial.M_HookLight;
			_nameToEnum["M_Apple 3"] = GameMaterial.M_Apple_3;
			_nameToEnum["M_Child 5"] = GameMaterial.M_Child_5;
			_nameToEnum["M_Ears 1"] = GameMaterial.M_Ears_1;
			_nameToEnum["M_Radio 2"] = GameMaterial.M_Radio_2;
			_nameToEnum["M_Radio 3"] = GameMaterial.M_Radio_3;
			_nameToEnum["M_Book 1"] = GameMaterial.M_Book_1;
			_nameToEnum["M_Crane"] = GameMaterial.M_Crane;
			_nameToEnum["M_Cinema 1"] = GameMaterial.M_Cinema_1;
			_nameToEnum["M_Screen"] = GameMaterial.M_Screen;
			_nameToEnum["M_Cursor"] = GameMaterial.M_Cursor;
			_nameToEnum["M_Defib 4"] = GameMaterial.M_Defib_4;
			_nameToEnum["M_Defib 2"] = GameMaterial.M_Defib_2;
			_nameToEnum["M_LongFlashlight 2 2"] = GameMaterial.M_LongFlashlight_2_2;
			_nameToEnum["M_Laser"] = GameMaterial.M_Laser;
			_nameToEnum["M_SoundPlayer 3"] = GameMaterial.M_SoundPlayer_3;
			_nameToEnum["M_Goo 1"] = GameMaterial.M_Goo_1;
			_nameToEnum["M_TitleCardRender"] = GameMaterial.M_TitleCardRender;
			_nameToEnum["M_TitleCard 1"] = GameMaterial.M_TitleCard_1;
			_nameToEnum["M_TitleCard"] = GameMaterial.M_TitleCard;
			_nameToEnum["M_TitleCard 2"] = GameMaterial.M_TitleCard_2;
			_nameToEnum["M_GooBright"] = GameMaterial.M_GooBright;
			_nameToEnum["M_FredGull 4"] = GameMaterial.M_FredGull_4;
			_nameToEnum["M_FredGull 3"] = GameMaterial.M_FredGull_3;
			_nameToEnum["M_Flashlight 3 1"] = GameMaterial.M_Flashlight_3_1;
			_nameToEnum["M_Crown"] = GameMaterial.M_Crown;
			_nameToEnum["M_Copyright 1"] = GameMaterial.M_Copyright_1;
			_nameToEnum["M_Rugby 2"] = GameMaterial.M_Rugby_2;
			_nameToEnum["M_Interior 7"] = GameMaterial.M_Interior_7;
			_nameToEnum["M_Clown 1"] = GameMaterial.M_Clown_1;
			_nameToEnum["M_Hotdog 4"] = GameMaterial.M_Hotdog_4;
			_nameToEnum["M_Top"] = GameMaterial.M_Top;
			_nameToEnum["M_Rug 5"] = GameMaterial.M_Rug_5;
			_nameToEnum["M_Borkin 1"] = GameMaterial.M_Borkin_1;
			_nameToEnum["M_House Glas"] = GameMaterial.M_House_Glas;
			_nameToEnum["M_Portrait 1"] = GameMaterial.M_Portrait_1;
			_nameToEnum["M_Copyright"] = GameMaterial.M_Copyright;
			_nameToEnum["M_HatShop 3"] = GameMaterial.M_HatShop_3;
			_nameToEnum["M_BoomMic 1"] = GameMaterial.M_BoomMic_1;
			_nameToEnum["M_Foodora"] = GameMaterial.M_Foodora;
			_nameToEnum["M_Jester 2"] = GameMaterial.M_Jester_2;
			_nameToEnum["M_Child 4"] = GameMaterial.M_Child_4;
			_nameToEnum["M_Balaclava"] = GameMaterial.M_Balaclava;
			_nameToEnum["M_Child 2"] = GameMaterial.M_Child_2;
			_nameToEnum["M_ShopGlass"] = GameMaterial.M_ShopGlass;
			_nameToEnum["M_Podcast 4"] = GameMaterial.M_Podcast_4;
			_nameToEnum["M_Podcast 2"] = GameMaterial.M_Podcast_2;
			_nameToEnum["M_Portrait 2"] = GameMaterial.M_Portrait_2;
			_nameToEnum["M_SoundPlayer 2"] = GameMaterial.M_SoundPlayer_2;
			_nameToEnum["M_Goop"] = GameMaterial.M_Goop;
			_nameToEnum["M_SoundPlayer 1"] = GameMaterial.M_SoundPlayer_1;
			_nameToEnum["M_HatShop 8"] = GameMaterial.M_HatShop_8;
			_nameToEnum["M_News1"] = GameMaterial.M_News1;
			_nameToEnum["M_Defib 1"] = GameMaterial.M_Defib_1;
			_nameToEnum["M_Apple 2"] = GameMaterial.M_Apple_2;
			_nameToEnum["M_HatShop 5"] = GameMaterial.M_HatShop_5;
			_nameToEnum["M_Rug 1"] = GameMaterial.M_Rug_1;
			_nameToEnum["M_FrontScreen"] = GameMaterial.M_FrontScreen;
			_nameToEnum["M_SoundPlayer 5"] = GameMaterial.M_SoundPlayer_5;
			_nameToEnum["M_Portrait 4"] = GameMaterial.M_Portrait_4;
			_nameToEnum["M_Child 3"] = GameMaterial.M_Child_3;
			_nameToEnum["M_TaserBeam"] = GameMaterial.M_TaserBeam;
			_nameToEnum["M_VFX_BombFuze"] = GameMaterial.M_VFX_BombFuze;
			_nameToEnum["M_Rug 4"] = GameMaterial.M_Rug_4;
			_nameToEnum["M_Flashlight 2 1"] = GameMaterial.M_Flashlight_2_1;
			_nameToEnum["M_Apple 1"] = GameMaterial.M_Apple_1;
			_nameToEnum["M_DefaultParticle"] = GameMaterial.M_DefaultParticle;
			_nameToEnum["M_Knifo"] = GameMaterial.M_Knifo;
			_nameToEnum["M_Bucket 1"] = GameMaterial.M_Bucket_1;
			_nameToEnum["M_Bomb"] = GameMaterial.M_Bomb;
			_nameToEnum["M_Ears 2"] = GameMaterial.M_Ears_2;
			_nameToEnum["M_Child 1"] = GameMaterial.M_Child_1;
			_nameToEnum["M_Ears 3"] = GameMaterial.M_Ears_3;
			_nameToEnum["M_Cap 1"] = GameMaterial.M_Cap_1;
			_nameToEnum["M_Goo 2"] = GameMaterial.M_Goo_2;
			_nameToEnum["M_Party 2"] = GameMaterial.M_Party_2;
			_nameToEnum["M_Party 1"] = GameMaterial.M_Party_1;
			_nameToEnum["M_Milk2"] = GameMaterial.M_Milk2;
			_nameToEnum["M_HatShop 7"] = GameMaterial.M_HatShop_7;
			_nameToEnum["M_Brain 1"] = GameMaterial.M_Brain_1;
			_nameToEnum["M_HatShop 2"] = GameMaterial.M_HatShop_2;
			_nameToEnum["M_Rugby 1"] = GameMaterial.M_Rugby_1;
			_nameToEnum["M_Witch"] = GameMaterial.M_Witch;
			_nameToEnum["M_Hotdog 2"] = GameMaterial.M_Hotdog_2;
			_nameToEnum["M_HatShop 1"] = GameMaterial.M_HatShop_1;
			_nameToEnum["M_Bowler"] = GameMaterial.M_Bowler;
			_nameToEnum["M_Brain 2"] = GameMaterial.M_Brain_2;
			_nameToEnum["Jello_PostShader"] = GameMaterial.Jello_PostShader;
			_nameToEnum["M_DivingScreen_Nice"] = GameMaterial.M_DivingScreen_Nice;
			_nameToEnum["M_Light_Warm"] = GameMaterial.M_Light_Warm;
			_nameToEnum["M_Asphalt"] = GameMaterial.M_Asphalt;
			_nameToEnum["M_Barrel 1"] = GameMaterial.M_Barrel_1;
			_nameToEnum["M_Barrel 2"] = GameMaterial.M_Barrel_2;
			_nameToEnum["M_Bed 1"] = GameMaterial.M_Bed_1;
			_nameToEnum["M_Bed 2"] = GameMaterial.M_Bed_2;
			_nameToEnum["M_Bed 3"] = GameMaterial.M_Bed_3;
			_nameToEnum["M_Bed 4"] = GameMaterial.M_Bed_4;
			_nameToEnum["M_Bed 5"] = GameMaterial.M_Bed_5;
			_nameToEnum["M_Bed 6"] = GameMaterial.M_Bed_6;
			_nameToEnum["M_Bed 7"] = GameMaterial.M_Bed_7;
			_nameToEnum["M_Bed Default 1"] = GameMaterial.M_Bed_Default_1;
			_nameToEnum["M_House 1"] = GameMaterial.M_House_1;
			_nameToEnum["M_House 10"] = GameMaterial.M_House_10;
			_nameToEnum["M_House 11"] = GameMaterial.M_House_11;
			_nameToEnum["M_House 12"] = GameMaterial.M_House_12;
			_nameToEnum["M_House 2"] = GameMaterial.M_House_2;
			_nameToEnum["M_House 3"] = GameMaterial.M_House_3;
			_nameToEnum["M_House 4"] = GameMaterial.M_House_4;
			_nameToEnum["M_House 5"] = GameMaterial.M_House_5;
			_nameToEnum["M_House 6"] = GameMaterial.M_House_6;
			_nameToEnum["M_House 8"] = GameMaterial.M_House_8;
			_nameToEnum["M_House 9"] = GameMaterial.M_House_9;
			_nameToEnum["M_Interior 1"] = GameMaterial.M_Interior_1;
			_nameToEnum["M_Interior 2"] = GameMaterial.M_Interior_2;
			_nameToEnum["M_Interior 3"] = GameMaterial.M_Interior_3;
			_nameToEnum["M_Interior 4"] = GameMaterial.M_Interior_4;
			_nameToEnum["M_Interior 5"] = GameMaterial.M_Interior_5;
			_nameToEnum["M_Interior 6"] = GameMaterial.M_Interior_6;
			_nameToEnum["M_Interior 8"] = GameMaterial.M_Interior_8;
			_nameToEnum["M_Rock"] = GameMaterial.M_Rock;
			_nameToEnum["M_Rug 2"] = GameMaterial.M_Rug_2;
			_nameToEnum["M_Rug 7"] = GameMaterial.M_Rug_7;
			_nameToEnum["M_Rug 8"] = GameMaterial.M_Rug_8;
			_nameToEnum["M_Rug 9"] = GameMaterial.M_Rug_9;
			_nameToEnum["M_Solar 1"] = GameMaterial.M_Solar_1;
			_nameToEnum["M_Solar 2"] = GameMaterial.M_Solar_2;
			_nameToEnum["M_Sunflower 1"] = GameMaterial.M_Sunflower_1;
			_nameToEnum["M_Sunflower 2"] = GameMaterial.M_Sunflower_2;
			_nameToEnum["M_Sunflower 3"] = GameMaterial.M_Sunflower_3;
			_nameToEnum["M_ThePlan 1"] = GameMaterial.M_ThePlan_1;
			_nameToEnum["M_ThePlan 2"] = GameMaterial.M_ThePlan_2;
			_nameToEnum["M_Trunk"] = GameMaterial.M_Trunk;
			_nameToEnum["M_Surf_Bush"] = GameMaterial.M_Surf_Bush;
			_nameToEnum["M_Surf_Ground"] = GameMaterial.M_Surf_Ground;
			_nameToEnum["M_Surf_GroundGrass"] = GameMaterial.M_Surf_GroundGrass;
			_nameToEnum["M_DivingBell1Nice"] = GameMaterial.M_DivingBell1Nice;
			_nameToEnum["M_DivingBell2Nice"] = GameMaterial.M_DivingBell2Nice;
			_nameToEnum["M_DivingBell3Nice"] = GameMaterial.M_DivingBell3Nice;
			_nameToEnum["M_DivingBell4Nice"] = GameMaterial.M_DivingBell4Nice;
			_nameToEnum["M_DivingBell5Nice"] = GameMaterial.M_DivingBell5Nice;
			_nameToEnum["M_DivingBell6Nice"] = GameMaterial.M_DivingBell6Nice;
			_nameToEnum["M_CloudSphere 2"] = GameMaterial.M_CloudSphere_2;
			_nameToEnum["M_CloudSphere"] = GameMaterial.M_CloudSphere;
			_nameToEnum["M_CloudSphere_Evening 2"] = GameMaterial.M_CloudSphere_Evening_2;
			_nameToEnum["M_CloudSphere_Evening"] = GameMaterial.M_CloudSphere_Evening;
			_nameToEnum["M_Sky"] = GameMaterial.M_Sky;
			_nameToEnum["M_Sky_Evening"] = GameMaterial.M_Sky_Evening;
			_nameToEnum["M_Intro"] = GameMaterial.M_Intro;
			_nameToEnum["M_House 7"] = GameMaterial.M_House_7;
			_nameToEnum["M_Scraper"] = GameMaterial.M_Scraper;
			_nameToEnum["M_Invis"] = GameMaterial.M_Invis;
			_nameToEnum["M_Mirror"] = GameMaterial.M_Mirror;
			_nameToEnum["M_ArrowIcon"] = GameMaterial.M_ArrowIcon;
			_nameToEnum["M_CamConverter 1"] = GameMaterial.M_CamConverter_1;
			_nameToEnum["M_CamConverter 2"] = GameMaterial.M_CamConverter_2;
			_nameToEnum["M_CamConverter 3"] = GameMaterial.M_CamConverter_3;
			_nameToEnum["M_CamConverter 4"] = GameMaterial.M_CamConverter_4;
			_nameToEnum["M_CamConverter 5"] = GameMaterial.M_CamConverter_5;
			_nameToEnum["M_CameraIcon"] = GameMaterial.M_CameraIcon;
			_nameToEnum["M_Charge 1"] = GameMaterial.M_Charge_1;
			_nameToEnum["M_Charge 2"] = GameMaterial.M_Charge_2;
			_nameToEnum["M_Charge 3"] = GameMaterial.M_Charge_3;
			_nameToEnum["M_Charge 4"] = GameMaterial.M_Charge_4;
			_nameToEnum["M_Charge 5"] = GameMaterial.M_Charge_5;
			_nameToEnum["M_Drone 1"] = GameMaterial.M_Drone_1;
			_nameToEnum["M_Drone 2"] = GameMaterial.M_Drone_2;
			_nameToEnum["M_Drone 3"] = GameMaterial.M_Drone_3;
			_nameToEnum["M_Drone 4"] = GameMaterial.M_Drone_4;
			_nameToEnum["M_Drone 5"] = GameMaterial.M_Drone_5;
			_nameToEnum["M_FaceMachine"] = GameMaterial.M_FaceMachine;
			_nameToEnum["M_House 13"] = GameMaterial.M_House_13;
			_nameToEnum["M_House Door"] = GameMaterial.M_House_Door;
			_nameToEnum["M_Landing"] = GameMaterial.M_Landing;
			_nameToEnum["M_Laptop"] = GameMaterial.M_Laptop;
			_nameToEnum["M_Machine"] = GameMaterial.M_Machine;
			_nameToEnum["M_NetworkDeal 1"] = GameMaterial.M_NetworkDeal_1;
			_nameToEnum["M_NetworkDeal 2"] = GameMaterial.M_NetworkDeal_2;
			_nameToEnum["M_NetworkDeal 3"] = GameMaterial.M_NetworkDeal_3;
			_nameToEnum["M_NetworkDeal 4"] = GameMaterial.M_NetworkDeal_4;
			_nameToEnum["M_Podcast 1"] = GameMaterial.M_Podcast_1;
			_nameToEnum["M_Podcast 10"] = GameMaterial.M_Podcast_10;
			_nameToEnum["M_Podcast 11"] = GameMaterial.M_Podcast_11;
			_nameToEnum["M_Podcast 3"] = GameMaterial.M_Podcast_3;
			_nameToEnum["M_Podcast 5"] = GameMaterial.M_Podcast_5;
			_nameToEnum["M_Podcast 6"] = GameMaterial.M_Podcast_6;
			_nameToEnum["M_Podcast 7"] = GameMaterial.M_Podcast_7;
			_nameToEnum["M_Podcast 8"] = GameMaterial.M_Podcast_8;
			_nameToEnum["M_Podcast 9"] = GameMaterial.M_Podcast_9;
			_nameToEnum["M_Pool 1"] = GameMaterial.M_Pool_1;
			_nameToEnum["M_Pool 11"] = GameMaterial.M_Pool_11;
			_nameToEnum["M_Pool 2"] = GameMaterial.M_Pool_2;
			_nameToEnum["M_Pool 3"] = GameMaterial.M_Pool_3;
			_nameToEnum["M_Pool 5"] = GameMaterial.M_Pool_5;
			_nameToEnum["M_Shop 1"] = GameMaterial.M_Shop_1;
			_nameToEnum["M_Shop 2"] = GameMaterial.M_Shop_2;
			_nameToEnum["M_Shop 3"] = GameMaterial.M_Shop_3;
			_nameToEnum["M_TV 1"] = GameMaterial.M_TV_1;
			_nameToEnum["M_TV 2"] = GameMaterial.M_TV_2;
			_nameToEnum["M_TV"] = GameMaterial.M_TV;
			_nameToEnum["M_Teleport 1"] = GameMaterial.M_Teleport_1;
			_nameToEnum["M_Teleport 2"] = GameMaterial.M_Teleport_2;
			_nameToEnum["M_Trampoline 1"] = GameMaterial.M_Trampoline_1;
			_nameToEnum["M_Trampoline 2"] = GameMaterial.M_Trampoline_2;
			_nameToEnum["M_Trampoline 3"] = GameMaterial.M_Trampoline_3;
			_nameToEnum["M_Trampoline 4"] = GameMaterial.M_Trampoline_4;
			_nameToEnum["M_UpgradeSign"] = GameMaterial.M_UpgradeSign;
			_nameToEnum["M_Water"] = GameMaterial.M_Water;
			_nameToEnum["M_Wood"] = GameMaterial.M_Wood;
			_nameToEnum["M_Surf_Bush_NoWind"] = GameMaterial.M_Surf_Bush_NoWind;
			_nameToEnum["M_Surf_Ground_Dirt"] = GameMaterial.M_Surf_Ground_Dirt;
			_nameToEnum["M_Surf_Ground_Side"] = GameMaterial.M_Surf_Ground_Side;
			_nameToEnum["M_Surf_Ground_Side_Dirt"] = GameMaterial.M_Surf_Ground_Side_Dirt;
			_nameToEnum["M_Charge"] = GameMaterial.M_Charge;
			_nameToEnum["M_Dust"] = GameMaterial.M_Dust;
			_nameToEnum["M_Heal"] = GameMaterial.M_Heal;
		}

		public static void ApplyOnLoad(GameObject target, GameMaterial material, bool recursive = false)
		{
			OnMaterialsLoaded += delegate
			{
				ApplyMaterial(target, material, recursive);
			};
		}

		public static void InitMaterials()
		{
			Material[] array = Resources.FindObjectsOfTypeAll<Material>();
			HashSet<string> hashSet = new HashSet<string>();
			List<Material> list = new List<Material>();
			Material[] array2 = array;
			foreach (Material val in array2)
			{
				if (hashSet.Add(((Object)val).name))
				{
					list.Add(val);
				}
			}
			ApiLog.Log($"Found {list.Count} unique materials in game resources");
			ApiLog.Log("Unique material names: " + string.Join(", ", hashSet.ToList()));
			foreach (Material item in list)
			{
				if (_nameToEnum.TryGetValue(((Object)item).name, out var value))
				{
					if (!_materials.ContainsKey(value))
					{
						_materials[value] = item;
					}
				}
				else
				{
					ApiLog.LogError("Could not find material: " + ((Object)item).name + " in _nameToEnum, skipping");
				}
			}
			ApiLog.Log($"Loaded {_materials.Count} materials");
			GameMaterials.OnMaterialsLoaded?.Invoke();
		}

		public static Material GetMaterial(GameMaterial type)
		{
			if (!_materials.TryGetValue(type, out Material value))
			{
				return null;
			}
			return value;
		}

		public static Material GetMaterial(DescriptiveMaterial type)
		{
			if (_descriptiveToOriginal.TryGetValue(type, out var value))
			{
				return GetMaterial(value);
			}
			return null;
		}

		public static void ApplyMaterial(GameObject target, GameMaterial type, bool deepApply = true)
		{
			Material material = GetMaterial(type);
			if ((Object)(object)material != (Object)null)
			{
				ApplyToTarget(target, material, deepApply);
			}
		}

		public static void ApplyMaterial(GameObject target, DescriptiveMaterial type, bool deepApply = true)
		{
			Material material = GetMaterial(type);
			if ((Object)(object)material != (Object)null)
			{
				ApplyToTarget(target, material, deepApply);
			}
		}

		public static void ApplyToChild(GameObject root, string childPath, GameMaterial material, bool deep = false)
		{
			Transform val = root.transform.Find(childPath);
			if ((Object)(object)val != (Object)null)
			{
				ApplyMaterial(((Component)val).gameObject, material, deep);
				return;
			}
			ApiLog.Log("Warning: GameMaterials.ApplyToChild: Child path '" + childPath + "' not found on '" + ((Object)root).name + "'");
		}

		public static void ApplyToChild(GameObject root, string childPath, DescriptiveMaterial material, bool deep = false)
		{
			Transform val = root.transform.Find(childPath);
			if ((Object)(object)val != (Object)null)
			{
				ApplyMaterial(((Component)val).gameObject, material, deep);
				return;
			}
			ApiLog.Log("Warning: GameMaterials.ApplyToChild: Child path '" + childPath + "' not found on '" + ((Object)root).name + "'");
		}

		public static void ApplyMaterial(GameObject root, string childPath, GameMaterial material, bool deep = false)
		{
			ApplyToChild(root, childPath, material, deep);
		}

		public static void ApplyMaterial(GameObject root, string childPath, DescriptiveMaterial material, bool deep = false)
		{
			ApplyToChild(root, childPath, material, deep);
		}

		public static void SetMaterials(Renderer renderer, params GameMaterial[] materials)
		{
			if (!((Object)(object)renderer == (Object)null))
			{
				Material[] array = (Material[])(object)new Material[materials.Length];
				for (int i = 0; i < materials.Length; i++)
				{
					array[i] = GetMaterial(materials[i]);
				}
				renderer.materials = array;
			}
		}

		public static void SetMaterials(Renderer renderer, params DescriptiveMaterial[] materials)
		{
			if (!((Object)(object)renderer == (Object)null))
			{
				Material[] array = (Material[])(object)new Material[materials.Length];
				for (int i = 0; i < materials.Length; i++)
				{
					array[i] = GetMaterial(materials[i]);
				}
				renderer.materials = array;
			}
		}

		public static void SetMaterialAt(Renderer renderer, int slot, GameMaterial material)
		{
			if (!((Object)(object)renderer == (Object)null))
			{
				Material[] materials = renderer.materials;
				if (slot >= 0 && slot < materials.Length)
				{
					materials[slot] = GetMaterial(material);
					renderer.materials = materials;
				}
			}
		}

		public static void SetMaterialAt(Renderer renderer, int slot, DescriptiveMaterial material)
		{
			if (!((Object)(object)renderer == (Object)null))
			{
				Material[] materials = renderer.materials;
				if (slot >= 0 && slot < materials.Length)
				{
					materials[slot] = GetMaterial(material);
					renderer.materials = materials;
				}
			}
		}

		public static void SetMaterialAt(GameObject target, int slot, GameMaterial material)
		{
			Renderer component = target.GetComponent<Renderer>();
			if ((Object)(object)component != (Object)null)
			{
				SetMaterialAt(component, slot, material);
			}
		}

		public static void SetMaterialAt(GameObject target, int slot, DescriptiveMaterial material)
		{
			Renderer component = target.GetComponent<Renderer>();
			if ((Object)(object)component != (Object)null)
			{
				SetMaterialAt(component, slot, material);
			}
		}

		public static void ApplyMaterial(ParticleSystem ps, GameMaterial material, bool trailMaterial = false)
		{
			if ((Object)(object)ps == (Object)null)
			{
				return;
			}
			ParticleSystemRenderer component = ((Component)ps).GetComponent<ParticleSystemRenderer>();
			if (!((Object)(object)component == (Object)null))
			{
				Material material2 = GetMaterial(material);
				if (trailMaterial)
				{
					component.trailMaterial = material2;
				}
				else
				{
					((Renderer)component).material = material2;
				}
			}
		}

		public static void ApplyMaterial(ParticleSystem ps, DescriptiveMaterial material, bool trailMaterial = false)
		{
			if ((Object)(object)ps == (Object)null)
			{
				return;
			}
			ParticleSystemRenderer component = ((Component)ps).GetComponent<ParticleSystemRenderer>();
			if (!((Object)(object)component == (Object)null))
			{
				Material material2 = GetMaterial(material);
				if (trailMaterial)
				{
					component.trailMaterial = material2;
				}
				else
				{
					((Renderer)component).material = material2;
				}
			}
		}

		public static Material CloneMaterial(GameMaterial source, string? name = null)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			Material material = GetMaterial(source);
			if ((Object)(object)material == (Object)null)
			{
				ApiLog.Log($"Warning: GameMaterials.CloneMaterial: Base material {source} not found (maybe materials not loaded yet?)");
				return null;
			}
			Material val = new Material(material);
			if (name != null)
			{
				((Object)val).name = name;
			}
			return val;
		}

		public static Material CloneMaterial(GameMaterial source, Texture2D texture, string? name = null)
		{
			Material val = CloneMaterial(source, name);
			if ((Object)(object)val != (Object)null && (Object)(object)texture != (Object)null)
			{
				if (val.HasProperty("_Variation"))
				{
					val.SetTexture("_Variation", (Texture)(object)texture);
				}
				else if (val.HasProperty("_MainTex"))
				{
					val.SetTexture("_MainTex", (Texture)(object)texture);
				}
				else
				{
					val.mainTexture = (Texture)(object)texture;
				}
			}
			return val;
		}

		public static MaterialApplicator Batch(GameObject root)
		{
			return new MaterialApplicator(root);
		}

		private static void ApplyToTarget(GameObject target, Material mat, bool deepApply)
		{
			if (deepApply)
			{
				Renderer[] componentsInChildren = target.GetComponentsInChildren<Renderer>(true);
				foreach (Renderer r in componentsInChildren)
				{
					ApplyToRenderer(r, mat);
				}
			}
			else
			{
				Renderer component = target.GetComponent<Renderer>();
				if ((Object)(object)component != (Object)null)
				{
					ApplyToRenderer(component, mat);
				}
			}
		}

		private static void ApplyToRenderer(Renderer r, Material mat)
		{
			Material[] materials = r.materials;
			for (int i = 0; i < materials.Length; i++)
			{
				materials[i] = mat;
			}
			r.materials = materials;
		}
	}
	public class MaterialApplicator
	{
		private readonly GameObject _root;

		public MaterialApplicator(GameObject root)
		{
			_root = root;
		}

		public MaterialApplicator Root(GameMaterial material, bool deep = true)
		{
			GameMaterials.ApplyMaterial(_root, material, deep);
			return this;
		}

		public MaterialApplicator Root(DescriptiveMaterial material, bool deep = true)
		{
			GameMaterials.ApplyMaterial(_root, material, deep);
			return this;
		}

		public MaterialApplicator At(string childPath, GameMaterial material, bool deep = false)
		{
			GameMaterials.ApplyToChild(_root, childPath, material, deep);
			return this;
		}

		public MaterialApplicator At(string childPath, DescriptiveMaterial material, bool deep = false)
		{
			GameMaterials.ApplyToChild(_root, childPath, material, deep);
			return this;
		}

		public MaterialApplicator Slots(string childPath, params GameMaterial[] materials)
		{
			Transform val = _root.transform.Find(childPath);
			if ((Object)(object)val != (Object)null)
			{
				Renderer component = ((Component)val).GetComponent<Renderer>();
				if ((Object)(object)component != (Object)null)
				{
					GameMaterials.SetMaterials(component, materials);
				}
			}
			return this;
		}

		public MaterialApplicator Slots(string childPath, params DescriptiveMaterial[] materials)
		{
			Transform val = _root.transform.Find(childPath);
			if ((Object)(object)val != (Object)null)
			{
				Renderer component = ((Component)val).GetComponent<Renderer>();
				if ((Object)(object)component != (Object)null)
				{
					GameMaterials.SetMaterials(component, materials);
				}
			}
			return this;
		}

		public MaterialApplicator Slots(Renderer renderer, params GameMaterial[] materials)
		{
			GameMaterials.SetMaterials(renderer, materials);
			return this;
		}

		public MaterialApplicator Slots(Renderer renderer, params DescriptiveMaterial[] materials)
		{
			GameMaterials.SetMaterials(renderer, materials);
			return this;
		}

		public MaterialApplicator AtSlot(string childPath, int slot, GameMaterial material)
		{
			Transform val = _root.transform.Find(childPath);
			if ((Object)(object)val != (Object)null)
			{
				GameMaterials.SetMaterialAt(((Component)val).gameObject, slot, material);
			}
			return this;
		}

		public MaterialApplicator AtSlot(string childPath, int slot, DescriptiveMaterial material)
		{
			Transform val = _root.transform.Find(childPath);
			if ((Object)(object)val != (Object)null)
			{
				GameMaterials.SetMaterialAt(((Component)val).gameObject, slot, material);
			}
			return this;
		}

		public MaterialApplicator AtParticle(ParticleSystem ps, GameMaterial material, bool trailMaterial = false)
		{
			GameMaterials.ApplyMaterial(ps, material, trailMaterial);
			return this;
		}

		public MaterialApplicator AtParticle(ParticleSystem ps, DescriptiveMaterial material, bool trailMaterial = false)
		{
			GameMaterials.ApplyMaterial(ps, material, trailMaterial);
			return this;
		}
	}
	internal static class GuidHelper
	{
		public static Guid ToDeterministicGuid(string input)
		{
			using MD5 mD = MD5.Create();
			byte[] b = mD.ComputeHash(Encoding.Default.GetBytes(input));
			return new Guid(b);
		}
	}
	public enum ImpactSoundType
	{
		None,
		PlasticBounce1,
		PlasticBounce2,
		PlasticBounce3,
		PlasticBounce4,
		PlasticBounce5,
		PlasticBounce6,
		BombBounce1,
		BombBounce2,
		CDBounce1,
		CDBounce2,
		ContainerBounce1,
		ContainerBounce2,
		ShroomBounce1,
		CanBounce,
		CanBounce1,
		Burger1,
		Burger2
	}
	internal static class ImpactSoundScanner
	{
		public static Dictionary<string, SFX_Instance> FoundImpactSounds = new Dictionary<string, SFX_Instance>();

		public static Dictionary<ImpactSoundType, SFX_Instance> ImpactSounds = new Dictionary<ImpactSoundType, SFX_Instance>();

		private static readonly Dictionary<string, Dictionary<string, ImpactSoundType>> ItemExtractionMap = new Dictionary<string, Dictionary<string, ImpactSoundType>>
		{
			{
				"Boom Mic",
				new Dictionary<string, ImpactSoundType>
				{
					{
						"SFX Plastic Bounce 3",
						ImpactSoundType.PlasticBounce3
					},
					{
						"SFX Plastic Bounce 4",
						ImpactSoundType.PlasticBounce4
					}
				}
			},
			{
				"Camera",
				new Dictionary<string, ImpactSoundType> { 
				{
					"SFX Plastic Bounce 5",
					ImpactSoundType.PlasticBounce5
				} }
			},
			{
				"Defibrilator",
				new Dictionary<string, ImpactSoundType>
				{
					{
						"SFX Bomb Bounce 1",
						ImpactSoundType.BombBounce1
					},
					{
						"SFX Bomb Bounce 2",
						ImpactSoundType.BombBounce2
					}
				}
			},
			{
				"Disc",
				new Dictionary<string, ImpactSoundType>
				{
					{
						"SFX CD Bounce 1",
						ImpactSoundType.CDBounce1
					},
					{
						"SFX CD Bounce 2",
						ImpactSoundType.CDBounce2
					}
				}
			},
			{
				"Goo Ball",
				new Dictionary<string, ImpactSoundType> { 
				{
					"SFX Plastic Bounce 6",
					ImpactSoundType.PlasticBounce6
				} }
			},
			{
				"FredGull",
				new Dictionary<string, ImpactSoundType>
				{
					{
						"SFX Can Bounce",
						ImpactSoundType.CanBounce
					},
					{
						"SFX Can Bounce 1",
						ImpactSoundType.CanBounce1
					}
				}
			},
			{
				"SirMonsterBurger",
				new Dictionary<string, ImpactSoundType>
				{
					{
						"SFX Burger 1",
						ImpactSoundType.Burger1
					},
					{
						"SFX Burger 2",
						ImpactSoundType.Burger2
					}
				}
			},
			{
				"",
				new Dictionary<string, ImpactSoundType>
				{
					{
						"SFX Plastic Bounce 1",
						ImpactSoundType.PlasticBounce1
					},
					{
						"SFX Plastic Bounce 2",
						ImpactSoundType.PlasticBounce2
					},
					{
						"SFX Container Bounce 1",
						ImpactSoundType.ContainerBounce1
					},
					{
						"SFX Container Bounce 2",
						ImpactSoundType.ContainerBounce2
					},
					{
						"SFX Shroom Bounce 1",
						ImpactSoundType.ShroomBounce1
					}
				}
			}
		};

		public static void ScanImpactSounds()
		{
			Debug.Log((object)"[ImpactSoundScanner] Starting scan via ItemDatabase...");
			ItemDatabase instance = SingletonAsset<ItemDatabase>.Instance;
			if ((Object)(object)instance == (Object)null)
			{
				Debug.LogError((object)"[ImpactSoundScanner] ItemDatabase instance not found!");
				return;
			}
			FieldInfo objectsField = Items.GetObjectsField(instance);
			List<Item> itemsFromField = Items.GetItemsFromField(objectsField, instance);
			if (itemsFromField == null || itemsFromField.Count == 0)
			{
				Debug.LogError((object)"[ImpactSoundScanner] No items found in ItemDatabase.");
				return;
			}
			foreach (Item item in itemsFromField)
			{
				if ((Object)(object)item == (Object)null)
				{
					continue;
				}
				string text = item.displayName ?? ((Object)item).name ?? "Unknown Item";
				if ((Object)(object)item.itemObject == (Object)null)
				{
					Debug.Log((object)("[ImpactSoundScanner] Skipping item '" + text + "': No itemObject (prefab) assigned."));
					continue;
				}
				PhysicsSound[] componentsInChildren = item.itemObject.GetComponentsInChildren<PhysicsSound>(true);
				if (componentsInChildren.Length == 0)
				{
					continue;
				}
				Debug.Log((object)$"[ImpactSoundScanner] Checking item '{text}' ({componentsInChildren.Length} PhysicsSound components)...");
				PhysicsSound[] array = componentsInChildren;
				foreach (PhysicsSound val in array)
				{
					if (val.impactSounds == null)
					{
						continue;
					}
					SFX_Instance[] impactSounds = val.impactSounds;
					foreach (SFX_Instance val2 in impactSounds)
					{
						if (!((Object)(object)val2 == (Object)null))
						{
							string name = ((Object)val2).name;
							if (!FoundImpactSounds.ContainsKey(name))
							{
								FoundImpactSounds.Add(name, val2);
								Debug.Log((object)("[ImpactSoundScanner] >>> NEW SOUND FOUND: '" + name + "' (Source: " + text + ")"));
							}
						}
					}
				}
			}
			Debug.Log((object)$"[ImpactSoundScanner] Scan complete: {FoundImpactSounds.Count} unique impact sounds cached.");
		}

		public static void InitImpactSounds()
		{
			Debug.Log((object)"[ImpactSoundScanner] Initializing Impact Sounds association...");
			ItemDatabase instance = SingletonAsset<ItemDatabase>.Instance;
			if ((Object)(object)instance == (Object)null)
			{
				Debug.LogError((object)"[ImpactSoundScanner] Failed to initialize: ItemDatabase is null!");
				return;
			}
			FieldInfo objectsField = Items.GetObjectsField(instance);
			List<Item> itemsFromField = Items.GetItemsFromField(objectsField, instance);
			int num = 0;
			int num2 = 0;
			foreach (Item item in itemsFromField)
			{
				if ((Object)(object)item == (Object)null || (Object)(object)item.itemObject == (Object)null)
				{
					continue;
				}
				string text = item.displayName ?? "";
				if (!ItemExtractionMap.TryGetValue(text, out Dictionary<string, ImpactSoundType> value))
				{
					continue;
				}
				num++;
				PhysicsSound[] componentsInChildren = item.itemObject.GetComponentsInChildren<PhysicsSound>(true);
				PhysicsSound[] array = componentsInChildren;
				foreach (PhysicsSound val in array)
				{
					if (val.impactSounds == null)
					{
						continue;
					}
					SFX_Instance[] impactSounds = val.impactSounds;
					foreach (SFX_Instance val2 in impactSounds)
					{
						if (!((Object)(object)val2 == (Object)null) && value.TryGetValue(((Object)val2).name, out var value2) && !ImpactSounds.ContainsKey(value2))
						{
							ImpactSounds.Add(value2, val2);
							num2++;
							Debug.Log((object)$"[ImpactSoundScanner] Associated '{((Object)val2).name}' with ImpactSoundType.{value2} (from item '{text}')");
						}
					}
				}
			}
			Debug.Log((object)$"[ImpactSoundScanner] Association phase complete. Processed {num} mapped items, associated {num2} unique sounds.");
			ValidateExtraction();
		}

		private static void ValidateExtraction()
		{
			Debug.Log((object)"[ImpactSoundScanner] Starting extraction validation...");
			int num = 0;
			int num2 = 0;
			foreach (ImpactSoundType value in Enum.GetValues(typeof(ImpactSoundType)))
			{
				if (value != ImpactSoundType.None)
				{
					num2++;
					if (!ImpactSounds.ContainsKey(value))
					{
						Debug.LogError((object)$"[ImpactSoundScanner] VALIDATION FAILURE: Missing sound for type '{value}'");
						num++;
					}
				}
			}
			if (num == 0)
			{
				Debug.Log((object)$"[ImpactSoundScanner] VALIDATION SUCCESS: All {num2} impact sound types are correctly associated.");
			}
			else
			{
				Debug.LogError((object)$"[ImpactSoundScanner] VALIDATION FAILED: {num} / {num2} sounds were not found. Check ItemExtractionMap and logs above.");
			}
		}

		public static SFX_Instance GetImpactSound(ImpactSoundType type)
		{
			if (!ImpactSounds.TryGetValue(type, out SFX_Instance value) || (Object)(object)value == (Object)null)
			{
				return null;
			}
			return Object.Instantiate<SFX_Instance>(value);
		}

		public static SFX_Instance[] GetImpactSounds(params ImpactSoundType[] types)
		{
			List<SFX_Instance> list = new List<SFX_Instance>();
			foreach (ImpactSoundType type in types)
			{
				SFX_Instance impactSound = GetImpactSound(type);
				if ((Object)(object)impactSound != (Object)null)
				{
					list.Add(impactSound);
				}
			}
			return list.ToArray();
		}
	}
	public static class ItemPersistence
	{
		private static readonly List<Func<IEnumerable<Item?>>> InventoryItemProviders = new List<Func<IEnumerable<Item>>>();

		public static void RegisterInventoryItemProvider(Func<IEnumerable<Item?>> provider)
		{
			if (provider == null)
			{
				throw new ArgumentNullException("provider");
			}
			InventoryItemProviders.Add(provider);
		}

		internal static SavedInventoryItem[] AppendProviderItems(SavedInventoryItem[] vanillaResult)
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Expected O, but got Unknown
			if (InventoryItemProviders.Count == 0)
			{
				return vanillaResult;
			}
			List<SavedInventoryItem> list = vanillaResult?.ToList() ?? new List<SavedInventoryItem>();
			int num = 0;
			foreach (Func<IEnumerable<Item>> inventoryItemProvider in InventoryItemProviders)
			{
				try
				{
					foreach (Item item in inventoryItemProvider())
					{
						if (!((Object)(object)item == (Object)null))
						{
							list.Add(new SavedInventoryItem(item));
							num++;
						}
					}
				}
				catch (Exception arg)
				{
					ApiLog.LogError($"[ItemPersistence] Provider failed: {arg}");
				}
			}
			if (num > 0)
			{
				ApiLog.Log($"[ItemPersistence] Added {num} extra inventory item(s) to save.");
			}
			return list.ToArray();
		}
	}
	public class CustomShopItemCategory
	{
		public byte index;

		public string name = "Category Name";
	}
	public class ItemConfig
	{
		public string displayName = "";

		public string? persistentId;

		public int price = 100;

		public ShopItemCategory category = (ShopItemCategory)3;

		public bool purchasable = true;

		public int quantity = 1;

		public ItemType itemType = (ItemType)1;

		public float mass = 3f;

		public float groundSizeMultiplier = 1f;

		public float groundMassMultiplier = 1f;

		public bool spawnable = true;

		public RARITY toolSpawnRarity = (RARITY)100;

		public int toolBudgetCost = 1;

		public int budgetCost;

		public float rarity = 1f;

		public Vector3 holdPos = new Vector3(0.3f, -0.3f, 0.7f);

		public Vector3 holdRot = Vector3.zero;

		public bool useAlternativeHoldPos;

		public bool useAlternativeHoldRot;

		public Vector3 alternativeHoldPos = new Vector3(0.3f, -0.3f, 0.7f);

		public Vector3 alternativeHoldRot = Vector3.zero;

		public Sprite? icon;

		[Obsolete("Assign config.icon yourself after loading from a bundle or other source. RegisterItem no longer loads icons from AssetBundles.")]
		public string? iconName;

		public SFX_Instance[]? impactSounds;

		public ImpactSoundType[]? impactSoundTypes;

		public List<ItemKeyTooltip> tooltips = new List<ItemKeyTooltip>();
	}
	public class ArtifactConfig : ItemConfig
	{
		public float contentValue = 50f;

		public string? commentKeyPrefix;

		public string[] comments = Array.Empty<string>();

		public string[] commentKeys = Array.Empty<string>();

		public ushort? contentId;

		public bool registerInRoundSpawns = true;

		public ArtifactConfig()
		{
			//IL_0030: 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)
			itemType = (ItemType)2;
			purchasable = false;
			price = 0;
			category = (ShopItemCategory)1;
			spawnable = true;
			budgetCost = 3;
			rarity = 1f;
		}
	}
	public static class Items
	{
		public static List<CustomShopItemCategory> customCategories = new List<CustomShopItemCategory>();

		public static ShopItemCategory RegisterCustomCategory(string categoryName)
		{
			byte b = (byte)(customCategories.Count + 20);
			customCategories.Add(new CustomShopItemCategory
			{
				index = b,
				name = categoryName
			});
			return (ShopItemCategory)b;
		}

		public static void DeferRegistration(Action callback)
		{
			DbsContentApiPlugin.customItemsRegistrationCallbacks.Add(callback);
		}

		public static void SetupPrefab(GameObject prefab)
		{
			EnsureComponents(prefab);
		}

		private static void EnsureComponents(GameObject prefab)
		{
			if ((Object)(object)prefab.GetComponent<ItemInstance>() == (Object)null)
			{
				prefab.AddComponent<ItemInstance>();
				ApiLog.Log("Added ItemInstance component");
			}
			EnsureHandGizmo(prefab);
		}

		public static void EnsureHandGizmo(GameObject prefab)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)prefab.GetComponentInChildren<HandGizmo>(true) != (Object)null))
			{
				GameObject val = new GameObject("HandGizmo");
				val.transform.SetParent(prefab.transform);
				val.AddComponent<HandGizmo>();
				GameObject val2 = new GameObject("GizmoVisual");
				val2.transform.SetParent(val.transform);
				val2.transform.localPosition = Vector3.zero;
				val2.transform.localRotation = Quaternion.identity;
				ApiLog.Log("Added HandGizmo with dummy child");
			}
		}

		public static Item RegisterItem(GameObject prefab, ItemConfig config)
		{
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: 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)
			if ((Object)(object)prefab == (Object)null)
			{
				throw new ArgumentNullException("prefab");
			}
			ApiLog.Log("Registering item: " + config.displayName + " (Prefab: " + ((Object)prefab).name + ")");
			SetupPrefab(prefab);
			ContentLoader.RegisterPrefabInPhotonPool(prefab);
			Item val = ScriptableObject.CreateInstance<Item>();
			SFX_Instance[] impactSounds = config.impactSounds;
			if (impactSounds == null && config.impactSoundTypes != null)
			{
				impactSounds = ImpactSoundScanner.GetImpactSounds(config.impactSoundTypes);
			}
			if (impactSounds != null && impactSounds.Length != 0)
			{
				SetupPhysicsSound(prefab, impactSounds);
			}
			if ((Object)(object)config.icon != (Object)null)
			{
				val.icon = config.icon;
			}
			else if (!string.IsNullOrEmpty(config.iconName))
			{
				ApiLog.LogWarning("Item '" + config.displayName + "': config.iconName is obsolete. Load a Sprite and set config.icon before calling RegisterItem.");
			}
			val.displayName = config.displayName;
			val.itemObject = prefab;
			string text = (val.persistentID = config.persistentId ?? ("unknown_mod." + val.displayName.ToLower().Replace(" ", "")));
			val.PersistentID = GuidHelper.ToDeterministicGuid(text);
			((Object)val).name = text;
			val.itemType = config.itemType;
			val.Category = config.category;
			val.mass = config.mass;
			val.holdPos = config.holdPos;
			val.holdRotation = config.holdRot;
			val.useAlternativeHoldingPos = config.useAlternativeHoldPos;
			val.useAlternativeHoldingRot = config.useAlternativeHoldRot;
			val.alternativeHoldPos = config.alternativeHoldPos;
			val.alternativeHoldRot = config.alternativeHoldRot;
			val.groundSizeMultiplier = config.groundSizeMultiplier;
			val.groundMassMultiplier = config.groundMassMultiplier;
			val.purchasable = config.purchasable;
			val.price = config.price;
			val.quantity = config.quantity;
			val.spawnable = config.spawnable;
			val.toolSpawnRarity = config.toolSpawnRarity;
			val.toolBudgetCost = config.toolBudgetCost;
			val.budgetCost = config.budgetCost;
			val.rarity = config.rarity;
			val.content = null;
			val.Tooltips = config.tooltips ?? new List<ItemKeyTooltip>();
			if (!CheckDuplicateItem(val))
			{
				AddItemToDatabase(val);
			}
			return val;
		}

		public static Item RegisterArtifact(GameObject prefab, ArtifactConfig config)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)prefab == (Object)null)
			{
				throw new ArgumentNullException("prefab");
			}
			if (config == null)
			{
				throw new ArgumentNullException("config");
			}
			config.itemType = (ItemType)2;
			config.purchasable = false;
			config.price = 0;
			config.spawnable = true;
			EnsureArtifactContentProvider(prefab);
			Item val = RegisterItem(prefab, config);
			val.content = CreateArtifactContent(val, config);
			if (config.registerInRoundSpawns)
			{
				RegisterArtifactSpawn(val);
			}
			ApiLog.Log($"Artifact '{val.displayName}' registered with content ID: {val.content.id}");
			return val;
		}

		public static void SetupIcon(AssetBundle bundle, Item item, string iconName)
		{
			Sprite val = bundle.LoadAsset<Sprite>(iconName);
			if ((Object)(object)val != (Object)null)
			{
				item.icon = val;
			}
		}

		public static void SetupPhysicsSound(GameObject prefab, SFX_Instance[] impactSounds)
		{
			PhysicsSound val = prefab.GetComponent<PhysicsSound>();
			if ((Object)(object)val == (Object)null)
			{
				val = prefab.AddComponent<PhysicsSound>();
			}
			val.impactSounds = impactSounds;
		}

		private static void EnsureArtifactContentProvider(GameObject prefab)
		{
			if (!((Object)(object)prefab.GetComponent<ArtifactContentProvider>() != (Object)null))
			{
				prefab.AddComponent<ArtifactContentProvider>();
				ApiLog.Log("Added ArtifactContentProvider to " + ((Object)prefab).name);
			}
		}

		private static PropContent CreateArtifactContent(Item item, ArtifactConfig config)
		{
			string[] array = RegisterArtifactComments(item, config);
			if (array.Length == 0)
			{
				ApiLog.LogWarning("Artifact '" + item.displayName + "' has no comments configured.");
			}
			PropContent val = ScriptableObject.CreateInstance<PropContent>();
			((Object)val).name = ((Object)item).name + ".content";
			val.isArtifact = true;
			val.contentValue = config.contentValue;
			val.id = config.contentId ?? GetNextContentId();
			val.comments = array;
			return val;
		}

		private static string[] RegisterArtifactComments(Item item, ArtifactConfig config)
		{
			List<string> list = new List<string>();
			if (config.commentKeys != null)
			{
				list.AddRange(config.commentKeys.Where((string key) => !string.IsNullOrWhiteSpace(key)));
			}
			if (config.comments == null || config.comments.Length == 0)
			{
				return list.Distinct().ToArray();
			}
			string arg = (string.IsNullOrWhiteSpace(config.commentKeyPrefix) ? ("Content_" + SanitizeCommentKey(((Object)item).name) + "_Artifact") : config.commentKeyPrefix);
			for (int num = 0; num < config.comments.Length; num++)
			{
				string text = config.comments[num];
				if (!string.IsNullOrWhiteSpace(text))
				{
					string text2 = $"{arg}_{num}";
					CustomCommentRegistry.Register(text2, new CustomComment("en", text));
					list.Add(text2);
				}
			}
			return list.Distinct().ToArray();
		}

		private static string SanitizeCommentKey(string value)
		{
			char[] array = value.Where((char c) => char.IsLetterOrDigit(c) || c == '_').ToArray();
			if (array.Length != 0)
			{
				return new string(array);
			}
			return "Custom";
		}

		private static ushort GetNextContentId()
		{
			ItemDatabase instance = SingletonAsset<ItemDatabase>.Instance;
			FieldInfo objectsField = GetObjectsField(instance);
			List<Item> itemsFromField = GetItemsFromField(objectsField, instance);
			ushort num = 0;
			foreach (Item item in itemsFromField)
			{
				if (!((Object)(object)item?.content == (Object)null))
				{
					num = Math.Max(num, item.content.id);
				}
			}
			return (ushort)(num + 1);
		}

		private static void RegisterArtifactSpawn(Item item)
		{
			if (!DbsContentApiPlugin.customArtifacts.Any((Item artifact) => (Object)(object)artifact != (Object)null && artifact.persistentID == item.persistentID))
			{
				DbsContentApiPlugin.customArtifacts.Add(item);
				ApiLog.Log("Artifact '" + item.displayName + "' added to round artifact spawns.");
			}
		}

		public static SFX_Instance[] GetFallbackPhysicsSound(ItemDatabase db)
		{
			FieldInfo objectsField = GetObjectsField(db);
			List<Item> itemsFromField = GetItemsFromField(objectsField, db);
			return itemsFromField[0].itemObject.GetComponent<PhysicsSound>().impactSounds;
		}

		public static SFX_Instance[] CreateSFXInstanceFromClip(AudioClip customSound)
		{
			ItemDatabase instance = SingletonAsset<ItemDatabase>.Instance;
			FieldInfo objectsField = GetObjectsField(instance);
			List<Item> itemsFromField = GetItemsFromField(objectsField, instance);
			PhysicsSound component = itemsFromField[0].itemObject.GetComponent<PhysicsSound>();
			object obj;
			if (component == null)
			{
				obj = null;
			}
			else
			{
				SFX_Instance[] impactSounds = component.impactSounds;
				obj = ((impactSounds != null) ? impactSounds[0] : null);
			}
			SFX_Instance val = (SFX_Instance)obj;
			if ((Object)(object)val == (Object)null)
			{
				ApiLog.LogError("Could not find template SFX_Instance");
				return GetFallbackPhysicsSound(instance);
			}
			SFX_Instance val2 = Object.Instantiate<SFX_Instance>(val);
			val2.clips = (AudioClip[])(object)new AudioClip[1] { customSound };
			val2.settings.pitch = 1f;
			val2.settings.volume = 1f;
			return (SFX_Instance[])(object)new SFX_Instance[1] { val2 };
		}

		public static SFX_Instance[] CreateImpactSoundFromClips(params AudioClip[] customSounds)
		{
			ItemDatabase instance = SingletonAsset<ItemDatabase>.Instance;
			FieldInfo objectsField = GetObjectsField(instance);
			List<Item> itemsFromField = GetItemsFromField(objectsField, instance);
			PhysicsSound component = itemsFromField[0].itemObject.GetComponent<PhysicsSound>();
			object obj;
			if (component == null)
			{
				obj = null;
			}
			else
			{
				SFX_Instance[] impactSounds = component.impactSounds;
				obj = ((impactSounds != null) ? impactSounds[0] : null);
			}
			SFX_Instance val = (SFX_Instance)obj;
			if ((Object)(object)val == (Object)null)
			{
				ApiLog.LogError("Could not find template SFX_Instance");
				return GetFallbackPhysicsSound(instance);
			}
			SFX_Instance val2 = Object.Instantiate<SFX_Instance>(val);
			val2.clips = customSounds;
			val2.settings.pitch = 1f;
			val2.settings.volume = 1f;
			return (SFX_Instance[])(object)new SFX_Instance[1] { val2 };
		}

		public static FieldInfo GetObjectsField(ItemDatabase db)
		{
			FieldInfo field = ((object)db).GetType().GetField("Objects", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (field == null)
			{
				field = ((object)db).GetType().GetField("objects", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			}
			if (field == null)
			{
				throw new Exception("Could not find Objects field in ItemDatabase");
			}
			return field;
		}

		public static List<Item> GetItemsFromField(FieldInfo objectsField, ItemDatabase db)
		{
			object value = objectsField.GetValue(db);
			if (value is List<Item> result)
			{
				return result;
			}
			if (value is Item[] collection)
			{
				return new List<Item>(collection);
			}
			throw new Exception("Objects field is type " + (value?.GetType()?.Name ?? "null") + ", expected List<Item> or Item[]");
		}

		public static Item? GetItemByPrefabComponent<T>() where T : Component
		{
			ItemDatabase instance = SingletonAsset<ItemDatabase>.Instance;
			FieldInfo objectsField = GetObjectsField(instance);
			List<Item> itemsFromField = GetItemsFromField(objectsField, instance);
			foreach (Item item in itemsFromField)
			{
				if ((Object)(object)item?.itemObject != (Object)null && (Object)(object)item.itemObject.GetComponent<T>() != (Object)null)
				{
					return item;
				}
			}
			return null;
		}

		public static void AddItemToDatabase(Item item)
		{
			ItemDatabase instance = SingletonAsset<ItemDatabase>.Instance;
			FieldInfo objectsField = GetObjectsField(instance);
			List<Item> itemsFromField = GetItemsFromField(objectsField, instance);
			item.id = (byte)((itemsFromField.Count > 0) ? ((byte)(itemsFromField.Max((Item i) => i.id) + 1)) : 0);
			itemsFromField.Add(item);
			objectsField.SetValue(instance, itemsFromField);
			ApiLog.Log($"Item '{item.displayName}' registered with ID: {item.id}");
		}

		public static void SetAllItemsFree()
		{
			ItemDatabase instance = SingletonAsset<ItemDatabase>.Instance;
			FieldInfo objectsField = GetObjectsField(instance);
			List<Item> itemsFromField = GetItemsFromField(objectsField, instance);
			foreach (Item item in itemsFromField)
			{
				if ((Object)(object)item != (Object)null)
				{
					item.price = 0;
				}
			}
			objectsField.SetValue(instance, itemsFromField);
		}

		public static bool CheckDuplicateItem(Item item)
		{
			ItemDatabase instance = SingletonAsset<ItemDatabase>.Instance;
			FieldInfo objectsField = GetObjectsField(instance);
			List<Item> itemsFromField = GetItemsFromField(objectsField, instance);
			if (itemsFromField.Count == 0)
			{
				return false;
			}
			for (int i = 0; i < itemsFromField.Count; i++)
			{
				if (itemsFromField[i].displayName == item.displayName)
				{
					return true;
				}
			}
			return false;
		}

		public static Item? GetItemByID(byte id)
		{
			ItemDatabase instance = SingletonAsset<ItemDatabase>.Instance;
			FieldInfo objectsField = GetObjectsField(instance);
			List<Item> itemsFromField = GetItemsFromField(objectsField, instance);
			return ((IEnumerable<Item>)itemsFromField).FirstOrDefault((Func<Item, bool>)((Item i) => (Object)(object)i != (Object)null && i.id == id));
		}
	}
	public class MapPipelineFlags
	{
		public bool skipVanillaCleanup;

		public bool skipRetexture;

		public bool skipPatrolSetup;

		public bool skipMonsterRemoval;

		public bool skipMultipliers;

		public bool skipAmbience;

		public bool skipDiveBellTeleport;

		public bool skipFinalize;
	}
	public class MapConfig
	{
		public MapPipelineFlags pipeline = new MapPipelineFlags();

		public float patrolConnectionRadius = 64f;

		public int patrolConnectionLayerMask = 1024;

		public bool retextureScene = true;

		public Color retextureColor = Color.gray;

		public bool setupAmbience = true;

		public float ambienceVolumeMultiplier = 6f;

		public bool setupPatrolPoints = true;

		public bool patrolGroupFromName = true;

		public string patrolNameSeparator = "_";

		public PatrolGroup? defaultPatrolGroup = (PatrolGroup)4;

		public bool assignUnspecifiedToAllGroups;

		public bool respectScenePatrolPoints = true;

		public float defaultPatrolSpawnWeight = 1f;

		public bool patrolGroupScopedConnections = true;

		public bool applyMonsterRemoval = true;

		public bool setupMultipliers = true;

		public string diveBellSpawnMarker = "DiveBellSpawn";

		public string patrolPointMarker = "PatrolPoint";

		public string roundRemoveHandlerName = "RoundRemoveHandler";

		public string roundMultiplierHandlerName = "RoundMultiplierHandler";

		public string ambienceHolderName = "AmbienceHolder";

		public List<string> extraKeepObjects = new List<string>();
	}
	public class MapLifecycleHooks
	{
		public Action<MapLoadContext>? onBeforeCleanup;

		public Action<MapLoadContext>? onAfterSceneLoaded;

		public Action<MapLoadContext>? onAfterSetup;
	}
	public class MapLoadContext
	{
		public CustomMap Map { get; }

		public MapConfig Config => Map.Config;

		public CustomMapLoader Loader { get; }

		public Scene ActiveScene { get; internal set; }

		public Scene? LoadedScene { get; internal set; }

		public List<GameObject> DiveBellSpawns { get; } = new List<GameObject>();

		public List<PatrolPoint> PatrolPoints { get; } = new List<PatrolPoint>();

		internal MapLoadContext(CustomMap map, CustomMapLoader loader)
		{
			Map = map;
			Loader = loader;
		}
	}
	public class CustomMap
	{
		public AssetBundle Bundle { get; }

		public string SceneName { get; }

		public string DisplayName { get; }

		public string MapId { get; }

		public MapConfig Config { get; }

		public MapLifecycleHooks Hooks { get; }

		public CustomMap(AssetBundle bundle, string sceneName, string displayName, string mapId, MapConfig? config = null, MapLifecycleHooks? hooks = null)
		{
			Bundle = bundle;
			SceneName = sceneName;
			DisplayName = displayName;
			MapId = mapId;
			Config = config ?? new MapConfig();
			Hooks = hooks ?? new MapLifecycleHooks();
		}
	}
	public static class Maps
	{
		public static CustomMap RegisterMap(AssetBundle bundle, string sceneName, string displayName, MapConfig? config = null, string? mapId = null, MapLifecycleHooks? hooks = null)
		{
			CustomMap customMap = RegisterMapCore(bundle, sceneName, displayName, config, mapId, hooks);
			if (customMap == null)
			{
				throw new InvalidOperationException("[Maps] Failed to register map '" + displayName + "'.");
			}
			return customMap;
		}

		public static CustomMap? TryRegisterMap(AssetBundle bundle, string sceneName, string displayName, MapConfig? config = null, string? mapId = null, MapLifecycleHooks? hooks = null)
		{
			return RegisterMapCore(bundle, sceneName, displayName, config, mapId, hooks);
		}

		private static CustomMap? RegisterMapCore(AssetBundle bundle, string sceneName, string displayName, MapConfig? config, string? mapId, MapLifecycleHooks? hooks)
		{
			string mapId2 = (string.IsNullOrWhiteSpace(mapId) ? SanitizeMapId(displayName) : mapId.Trim());
			CustomMap customMap = new CustomMap(bundle, sceneName, displayName, mapId2, config, hooks);
			if (!DbsContentApiPlugin.RegisterCustomMap(customMap))
			{
				return null;
			}
			return customMap;
		}

		public static bool TryGetMap(string mapId, out CustomMap? map)
		{
			return DbsContentApiPlugin.TryGetCustomMap(mapId, out map);
		}

		public static bool TryGetMapByIndex(int index, out CustomMap? map)
		{
			return DbsContentApiPlugin.TryGetCustomMapByIndex(index, out map);
		}

		public static IReadOnlyList<CustomMap> GetRegisteredMaps()
		{
			return DbsContentApiPlugin.customMaps;
		}

		public static void ForceNextMap(string mapId)
		{
			DbsContentApiPlugin.forcedNextMapId = mapId;
			ApiLog.Log("[Maps] Next map selection forced to: " + mapId);
		}

		public static void ClearForcedMap()
		{
			DbsContentApiPlugin.forcedNextMapId = null;
		}

		public static void SetSelectedMapId(string? mapId)
		{
			DbsContentApiPlugin.selectedCustomMapId = mapId;
		}

		public static int GetLevelIndexForMap(CustomMap map)
		{
			int num = DbsContentApiPlugin.customMaps.IndexOf(map);
			if (num >= 0)
			{
				return 3 + num;
			}
			return -1;
		}

		public static string? FindScenePath(AssetBundle bundle, string hint)
		{
			return bundle.GetAllScenePaths().FirstOrDefault((string p) => p.Contains(hint, StringComparison.OrdinalIgnoreCase));
		}

		public static string SanitizeMapId(string displayName)
		{
			if (string.IsNullOrWhiteSpace(displayName))
			{
				return "map.unnamed";
			}
			char[] value = (from c in displayName.Trim().ToLowerInvariant()
				select (!char.IsLetterOrDigit(c)) ? '_' : c).ToArray();
			string text = new string(value).Trim('_');
			while (text.Contains("__", StringComparison.Ordinal))
			{
				text = text.Replace("__", "_", StringComparison.Ordinal);
			}
			if (!string.IsNullOrEmpty(text))
			{
				return text;
			}
			return "map.unnamed";
		}

		internal static CustomMap? ResolveMapForCurrentRound()
		{
			if (!string.IsNullOrEmpty(DbsContentApiPlugin.selectedCustomMapId) && TryGetMap(DbsContentApiPlugin.selectedCustomMapId, out CustomMap map) && map != null)
			{
				return map;
			}
			int index = SurfaceNetworkHandler.RoomStats.LevelToPlay - 3;
			if (!TryGetMapByIndex(index, out CustomMap map2))
			{
				return null;
			}
			return map2;
		}

		internal static CustomMap? PickMapForNextRound(RoomStatsHolder roomStats)
		{
			if (DbsContentApiPlugin.customMaps.Count == 0)
			{
				return null;
			}
			string forcedNextMapId = DbsContentApiPlugin.forcedNextMapId;
			DbsContentApiPlugin.forcedNextMapId = null;
			if (!string.IsNullOrEmpty(forcedNextMapId))
			{
				if (TryGetMap(forcedNextMapId, out CustomMap map) && map != null)
				{
					return map;
				}
				ApiLog.LogError("[Maps] Forced map id '" + forcedNextMapId + "' not found.");
			}
			int num = 3 + DbsContentApiPlugin.customMaps.Count;
			int num2 = (DbsContentApiPlugin.moddedMapsOnly ? 3 : 0);
			int num3 = Random.Range(num2, num);
			for (int i = 0; i < 100; i++)
			{
				if (!DbsContentApiPlugin.moddedMapsOnly && num3 < 3)
				{
					return null;
				}
				int num4 = num3 - 3;
				if (num4 >= 0 && num4 < DbsContentApiPlugin.customMaps.Count)
				{
					CustomMap customMap = DbsContentApiPlugin.customMaps[num4];
					if (GetLevelIndexForMap(customMap) != roomStats.LevelToPlay || DbsContentApiPlugin.customMaps.Count == 1)
					{
						return customMap;
					}
				}
				num3 = Random.Range(num2, num);
			}
			return DbsContentApiPlugin.customMaps[0];
		}
	}
	public class CustomMapLoader : MonoBehaviour
	{
		private struct PatrolPointEntry
		{
			public PatrolPoint Point;

			public HashSet<PatrolGroup> Groups;
		}

		private readonly List<PatrolPointEntry> _patrolEntries = new List<PatrolPointEntry>();

		public static float multiplierMonster = 1f;

		public static float multiplierTool = 1f;

		public static float multiplierArtifact = 1f;

		public CustomMap? Map { get; set; }

		private IEnumerator Start()
		{
			if (Map == null)
			{
				ApiLog.LogError("CustomMapLoader: Map is null!");
				yield break;
			}
			MapConfig config = Map.Config;
			MapPipelineFlags pipeline = config.pipeline;
			MapLoadContext ctx = new MapLoadContext(Map, this);
			multiplierMonster = 1f;
			multiplierTool = 1f;
			multiplierArtifact = 1f;
			if (SurfaceNetworkHandler.RoomStats.LevelToPlay < 3)
			{
				ApiLog.Log($"[Maps] LevelToPlay ({SurfaceNetworkHandler.RoomStats.LevelToPlay}) is vanilla. Enabling occlusion culling and exiting loader.");
				Camera.main.useOcclusionCulling = true;
				yield break;
			}
			ApiLog.Log("[Maps] Loading custom map: " + Map.DisplayName + " (Id: " + Map.MapId + ", Scene: " + Map.SceneName + ")");
			Camera.main.useOcclusionCulling = false;
			_patrolEntries.Clear();
			ctx.ActiveScene = SceneManager.GetActiveScene();
			DivingBell tmp = Object.FindObjectOfType<DivingBell>();
			if ((Object)(object)tmp == (Object)null)
			{
				ApiLog.LogError("[Maps] DivingBell not found in scene!");
				yield break;
			}
			Material bellMaterial = GetDivingBellMaterial(tmp);
			if ((Object)(object)bellMaterial == (Object)null)
			{
				yield break;
			}
			tmp.locked = true;
			Map.Hooks.onBeforeCleanup?.Invoke(ctx);
			if (!pipeline.skipVanillaCleanup)
			{
				RunVanillaCleanup(config);
			}
			ApiLog.Log("[Maps] Asynchronously loading scene: " + Map.SceneName);
			AsyncOperation val = SceneManager.LoadSceneAsync(Map.SceneName, (LoadSceneMode)1);
			if (val == null)
			{
				ApiLog.LogError("[Maps] Failed to start loading scene: " + Map.SceneName);
				yield break;
			}
			yield return val;
			for (int i = 0; i < SceneManager.sceneCount; i++)
			{
				Scene sceneAt = SceneManager.GetSceneAt(i);
				if (((Scene)(ref sceneAt)).path == Map.SceneName || ((Scene)(ref sceneAt)).name == Path.GetFileNameWithoutExtension(Map.SceneName))
				{
					ctx.LoadedScene = sceneAt;
					break;
				}
			}
			ApiLog.Log("[Maps] Scene loaded: " + Map.SceneName);
			Map.Hooks.onAfterSceneLoaded?.Invoke(ctx);
			if (!pipeline.skipRetexture && config.retextureScene)
			{
				RetextureScene(config, bellMaterial);
			}
			CollectMarkers(config, ctx);
			if (!pipeline.skipPatrolSetup && config.setupPatrolPoints)
			{
				SetupPatrolPoints(config, ctx);
			}
			if (!pipeline.skipMonsterRemoval && config.applyMonsterRemoval)
			{
				ApplyMonsterRemoval(config);
			}
			if (!pipeline.skipMultipliers && config.setupMultipliers)
			{
				LoadMultipliers(config);
			}
			if (!pipeline.skipAmbience && config.setupAmbience)
			{
				SetupAmbience(config);
			}
			Map.Hooks.onAfterSetup?.Invoke(ctx);
			if (!pipeline.skipFinalize)
			{
				bool shouldRebootPlayer = false;
				Vector3 playerSpawnPosition = Vector3.zero;
				Quaternion playerSpawnRotation = Quaternion.identity;
				if (!pipeline.skipDiveBellTeleport)
				{
					shouldRebootPlayer = TryTeleportToSpawn(tmp, ctx, out playerSpawnPosition, out playerSpawnRotation);
				}
				ApiLog.Log("[Maps] Waiting for all players to join...");
				while (PhotonNetwork.PlayerList.Length != PlayerHandler.instance.players.Count)
				{
					yield return null;
				}
				yield return null;
				ApiLog.Log("[Maps] Map setup complete. Level is ready.");
				Level.currentLevel.levelIsReady = true;
				tmp.locked = false;
				if (shouldRebootPlayer)
				{
					RebootLocalPlayerAfterMapLoad(playerSpawnPosition, playerSpawnRotation);
				}
				MethodInfo method = typeof(Level).GetMethod("SetupFinished", BindingFlags.Instanc

3680671533/UnlistedEntities.dll

Decompiled 11 hours 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 BepInEx;
using DbsContentApi;
using DbsContentApi.Patches;
using ExitGames.Client.Photon;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using TMPro;
using Unity.Mathematics;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using UnityEngine.UI.ProceduralImage;
using UnlistedEntities;
using UnlistedEntities.CustomContent;
using UnlistedEntities.CustomContent.ContentEvents;
using Zorro.Core;
using Zorro.Core.Serizalization;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("UnlistedEntities")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("3.0.0.0")]
[assembly: AssemblyInformationalVersion("3.0.0+7460c8f997309fcf25a61466371a4486aefa3176")]
[assembly: AssemblyProduct("Unlisted Entities")]
[assembly: AssemblyTitle("UnlistedEntities")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("3.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.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]
	[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]
	[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;
		}
	}
}
public class BurningSpasmBehaviour : MonoBehaviour
{
	private sealed class SpasmPart
	{
		public Rigidbody rig;

		public Quaternion targetRotation;

		public Vector3 targetForce;

		public float torqueScale = 1f;

		public float forceScale = 1f;
	}

	private Player? player;

	private readonly List<SpasmPart> spasmParts = new List<SpasmPart>();

	private float nextSpasmTime;

	public float spasmIntervalMin = 0.15f;

	public float spasmIntervalMax = 0.25f;

	public float maxTargetAngle = 120f;

	public float torqueStrength = 140f;

	public float angularDamping = 4f;

	public float limbForce = 36f;

	private void Start()
	{
		player = ((Component)this).GetComponentInParent<Player>();
		if ((Object)(object)player == (Object)null || (Object)(object)player.refs.ragdoll == (Object)null)
		{
			Object.Destroy((Object)(object)this);
			return;
		}
		player.refs.ragdoll.ToggleSimplifiedRagdoll(false);
		CacheSpasmParts();
		GenerateNewTargets();
	}

	private void FixedUpdate()
	{
		if (!((Object)(object)player == (Object)null) && !((Object)(object)player.refs.ragdoll == (Object)null))
		{
			player.refs.ragdoll.ToggleSimplifiedRagdoll(false);
			player.refs.ragdoll.Fall(0.35f);
			if (Time.time >= nextSpasmTime)
			{
				nextSpasmTime = Time.time + Random.Range(spasmIntervalMin, spasmIntervalMax);
				GenerateNewTargets();
			}
			ApplyPhysicsSpasm();
		}
	}

	private void CacheSpasmParts()
	{
		//IL_002b: 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_0031: 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_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: 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_00ad: Unknown result type (might be due to invalid IL or missing references)
		spasmParts.Clear();
		foreach (BodypartType value in Enum.GetValues(typeof(BodypartType)))
		{
			if (ShouldSpasm(value))
			{
				Bodypart bodypart = player.refs.ragdoll.GetBodypart(value);
				if (!((Object)(object)bodypart == (Object)null) && !((Object)(object)bodypart.rig == (Object)null))
				{
					spasmParts.Add(new SpasmPart
					{
						rig = bodypart.rig,
						targetRotation = bodypart.rig.rotation,
						torqueScale = (IsCorePart(value) ? 0.35f : 1f),
						forceScale = (IsCorePart(value) ? 0.15f : 1f)
					});
				}
			}
		}
	}

	private unsafe static bool ShouldSpasm(BodypartType partType)
	{
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Invalid comparison between Unknown and I4
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_0092: Invalid comparison between Unknown and I4
		string text = ((object)(*(BodypartType*)(&partType))/*cast due to .constrained prefix*/).ToString();
		if (!text.StartsWith("Arm_", StringComparison.Ordinal) && !text.StartsWith("Elbow_", StringComparison.Ordinal) && !text.StartsWith("Hand_", StringComparison.Ordinal) && !text.StartsWith("Shoulder_", StringComparison.Ordinal) && !text.StartsWith("Leg_", StringComparison.Ordinal) && !text.StartsWith("Knee_", StringComparison.Ordinal) && !text.StartsWith("Foot_", StringComparison.Ordinal) && !text.StartsWith("Toe_", StringComparison.Ordinal) && !text.StartsWith("Finger_", StringComparison.Ordinal) && (int)partType != 2)
		{
			return (int)partType == 3;
		}
		return true;
	}

	private static bool IsCorePart(BodypartType partType)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0002: Invalid comparison between Unknown and I4
		//IL_0004: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Invalid comparison between Unknown and I4
		if ((int)partType != 2)
		{
			return (int)partType == 3;
		}
		return true;
	}

	private void GenerateNewTargets()
	{
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		foreach (SpasmPart spasmPart in spasmParts)
		{
			spasmPart.targetRotation = spasmPart.rig.rotation * Quaternion.Euler(Random.Range(0f - maxTargetAngle, maxTargetAngle), Random.Range(0f - maxTargetAngle, maxTargetAngle), Random.Range(0f - maxTargetAngle, maxTargetAngle));
			spasmPart.targetForce = Random.onUnitSphere * limbForce * spasmPart.forceScale;
		}
	}

	private void ApplyPhysicsSpasm()
	{
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: 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)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: 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_00b2: 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_00bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
		float num = default(float);
		Vector3 val2 = default(Vector3);
		foreach (SpasmPart spasmPart in spasmParts)
		{
			if (!spasmPart.rig.isKinematic)
			{
				Quaternion val = spasmPart.targetRotation * Quaternion.Inverse(spasmPart.rig.rotation);
				((Quaternion)(ref val)).ToAngleAxis(ref num, ref val2);
				if (num > 180f)
				{
					num -= 360f;
				}
				if (!float.IsNaN(val2.x) && ((Vector3)(ref val2)).sqrMagnitude > 0.0001f)
				{
					Vector3 val3 = ((Vector3)(ref val2)).normalized * (num * (MathF.PI / 180f) * torqueStrength * spasmPart.torqueScale);
					val3 -= spasmPart.rig.angularVelocity * angularDamping;
					spasmPart.rig.AddTorque(val3, (ForceMode)5);
				}
				spasmPart.rig.AddForce(spasmPart.targetForce, (ForceMode)5);
			}
		}
	}
}
public class CustomAnimationKeyFrame
{
	public float time;

	public Quaternion rotationValue;

	public string bonePath;
}
public enum InterpolationType
{
	Lerp,
	Slerp
}
public class AnimationCallback
{
	public float time;

	public Action callback;

	public bool hasBeenCalled;
}
public class CustomAnimation
{
	public List<CustomAnimationKeyFrame> keyFrames;

	public Dictionary<string, List<CustomAnimationKeyFrame>> boneKeyFrames;

	public float duration;

	public List<AnimationCallback> animationCallbacks;

	public float speedMultiplier = 1f;

	public InterpolationType interpolationType;

	public CustomAnimation(List<CustomAnimationKeyFrame> keyFrames, InterpolationType interpolationType)
	{
		this.keyFrames = keyFrames;
		this.interpolationType = interpolationType;
		boneKeyFrames = new Dictionary<string, List<CustomAnimationKeyFrame>>();
		animationCallbacks = new List<AnimationCallback>();
		foreach (CustomAnimationKeyFrame keyFrame in keyFrames)
		{
			if (!boneKeyFrames.ContainsKey(keyFrame.bonePath))
			{
				boneKeyFrames[keyFrame.bonePath] = new List<CustomAnimationKeyFrame>();
			}
			boneKeyFrames[keyFrame.bonePath].Add(keyFrame);
		}
	}

	public void RegisterCallbackOnTime(float time, Action callback)
	{
		animationCallbacks.Add(new AnimationCallback
		{
			time = time,
			callback = callback
		});
	}

	public void AddInitialValueKeyframes(GameObject animationRig)
	{
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		foreach (string key in boneKeyFrames.Keys)
		{
			CustomAnimationKeyFrame customAnimationKeyFrame = new CustomAnimationKeyFrame();
			customAnimationKeyFrame.time = 0f;
			customAnimationKeyFrame.rotationValue = animationRig.transform.Find(key).localRotation;
			customAnimationKeyFrame.bonePath = key;
			boneKeyFrames[key].Add(customAnimationKeyFrame);
		}
	}

	public void AddResetKeyframesAtEnd(GameObject animationRig, float animationEndTime)
	{
		//IL_0035: 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)
		foreach (string key in boneKeyFrames.Keys)
		{
			CustomAnimationKeyFrame customAnimationKeyFrame = new CustomAnimationKeyFrame();
			customAnimationKeyFrame.time = animationEndTime;
			customAnimationKeyFrame.rotationValue = animationRig.transform.Find(key).localRotation;
			customAnimationKeyFrame.bonePath = key;
			boneKeyFrames[key].Add(customAnimationKeyFrame);
		}
	}

	public void Finalize()
	{
		SortKeyFrames();
		float num = 0f;
		foreach (string key in boneKeyFrames.Keys)
		{
			foreach (CustomAnimationKeyFrame item in boneKeyFrames[key])
			{
				if (item.time > num)
				{
					num = item.time;
				}
			}
		}
		duration = num;
	}

	public void LogKeyFrames()
	{
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		foreach (string key in boneKeyFrames.Keys)
		{
			foreach (CustomAnimationKeyFrame item in boneKeyFrames[key])
			{
				Logger.Log($"CustomAnimation: {item.time} {item.rotationValue} {item.bonePath}");
			}
		}
	}

	public void SortKeyFrames()
	{
		foreach (string key in boneKeyFrames.Keys)
		{
			boneKeyFrames[key].Sort((CustomAnimationKeyFrame a, CustomAnimationKeyFrame b) => a.time.CompareTo(b.time));
		}
	}

	public void SetValuesForFrame(GameObject animationRig, float timeSinceStart)
	{
		//IL_013d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0191: Unknown result type (might be due to invalid IL or missing references)
		//IL_0198: Unknown result type (might be due to invalid IL or missing references)
		//IL_019f: Unknown result type (might be due to invalid IL or missing references)
		//IL_017a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0181: Unknown result type (might be due to invalid IL or missing references)
		//IL_0188: Unknown result type (might be due to invalid IL or missing references)
		float num = timeSinceStart * speedMultiplier;
		foreach (AnimationCallback animationCallback in animationCallbacks)
		{
			if (num >= animationCallback.time && !animationCallback.hasBeenCalled)
			{
				animationCallback.callback?.Invoke();
				animationCallback.hasBeenCalled = true;
			}
		}
		foreach (string key in boneKeyFrames.Keys)
		{
			List<CustomAnimationKeyFrame> list = boneKeyFrames[key];
			if (list.Count == 0)
			{
				continue;
			}
			CustomAnimationKeyFrame customAnimationKeyFrame = list[0];
			CustomAnimationKeyFrame customAnimationKeyFrame2 = list[list.Count - 1];
			for (int i = 0; i < list.Count - 1; i++)
			{
				if (num >= list[i].time && num <= list[i + 1].time)
				{
					customAnimationKeyFrame = list[i];
					customAnimationKeyFrame2 = list[i + 1];
					break;
				}
			}
			Transform val = animationRig.transform.Find(key);
			if (!((Object)(object)val == (Object)null))
			{
				if (customAnimationKeyFrame == customAnimationKeyFrame2 || num >= customAnimationKeyFrame2.time)
				{
					val.localRotation = customAnimationKeyFrame2.rotationValue;
					continue;
				}
				float num2 = customAnimationKeyFrame2.time - customAnimationKeyFrame.time;
				float num3 = Mathf.Clamp01((num - customAnimationKeyFrame.time) / num2);
				val.localRotation = ((interpolationType == InterpolationType.Slerp) ? Quaternion.Slerp(customAnimationKeyFrame.rotationValue, customAnimationKeyFrame2.rotationValue, num3) : Quaternion.Lerp(customAnimationKeyFrame.rotationValue, customAnimationKeyFrame2.rotationValue, num3));
			}
		}
	}

	private Quaternion GetInterpolatedRotation(Quaternion a, Quaternion b, float t)
	{
		//IL_0019: 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_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: 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_0024: 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_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_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: 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)
		return (Quaternion)(interpolationType switch
		{
			InterpolationType.Slerp => Quaternion.Slerp(a, b, t), 
			InterpolationType.Lerp => Quaternion.Lerp(a, b, t), 
			_ => Quaternion.Lerp(a, b, t), 
		});
	}
}
public class CustomPlayerAnimator : MonoBehaviour
{
	private GameObject animationRigRoot;

	private CustomAnimation currentCustomAnimation;

	private float animationStartTime;

	public void Awake()
	{
		animationRigRoot = ((Component)this).gameObject;
	}

	public void TryActivateThrowAnimation(Action callbackOnThrowFrame)
	{
		//IL_0049: 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_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_012f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0134: Unknown result type (might be due to invalid IL or missing references)
		//IL_016b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0170: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01de: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
		if (currentCustomAnimation == null)
		{
			List<CustomAnimationKeyFrame> list = new List<CustomAnimationKeyFrame>();
			string bonePath = "Rig/Armature/Hip/Torso";
			string bonePath2 = "Rig/Armature/Hip/Torso/Arm_R";
			string bonePath3 = "Rig/Armature/Hip/Torso/Arm_R/Elbow_R";
			list.Add(new CustomAnimationKeyFrame
			{
				time = 10f,
				bonePath = bonePath,
				rotationValue = Quaternion.Euler(0f, 70f, 0f)
			});
			list.Add(new CustomAnimationKeyFrame
			{
				time = 23f,
				bonePath = bonePath,
				rotationValue = Quaternion.Euler(0f, -70f, 0f)
			});
			list.Add(new CustomAnimationKeyFrame
			{
				time = 5f,
				bonePath = bonePath2,
				rotationValue = new Quaternion(0.07831256f, 0.13297257f, -0.9330111f, 0.32507813f)
			});
			list.Add(new CustomAnimationKeyFrame
			{
				time = 17f,
				bonePath = bonePath2,
				rotationValue = Quaternion.Euler(-14f, 64f, -32f)
			});
			list.Add(new CustomAnimationKeyFrame
			{
				time = 25f,
				bonePath = bonePath2,
				rotationValue = new Quaternion(0.4599232f, 0.19515157f, -0.13305375f, 0.8559692f)
			});
			list.Add(new CustomAnimationKeyFrame
			{
				time = 11f,
				bonePath = bonePath3,
				rotationValue = new Quaternion(0.40379998f, -0.48517668f, 0.3436905f, 0.6952884f)
			});
			list.Add(new CustomAnimationKeyFrame
			{
				time = 17f,
				bonePath = bonePath3,
				rotationValue = Quaternion.Euler(36f, -42f, 22f)
			});
			list.Add(new CustomAnimationKeyFrame
			{
				time = 24f,
				bonePath = bonePath3,
				rotationValue = new Quaternion(0.09231234f, -0.3148702f, 0.22914469f, 0.91642123f)
			});
			currentCustomAnimation = new CustomAnimation(list, InterpolationType.Lerp);
			currentCustomAnimation.RegisterCallbackOnTime(25f, callbackOnThrowFrame);
			currentCustomAnimation.LogKeyFrames();
			currentCustomAnimation.speedMultiplier = 35f;
			currentCustomAnimation.AddInitialValueKeyframes(animationRigRoot);
			currentCustomAnimation.AddResetKeyframesAtEnd(animationRigRoot, 28f);
			currentCustomAnimation.Finalize();
			animationStartTime = Time.time;
			Logger.Log("CustomPlayerAnimator: Activated throw animation");
			currentCustomAnimation.LogKeyFrames();
			PhotonView componentInParent = ((Component)this).GetComponentInParent<PhotonView>();
			if ((Object)(object)componentInParent != (Object)null && componentInParent.IsMine)
			{
				componentInParent.RPC("RPCA_PlayThrowAnimation", (RpcTarget)1, Array.Empty<object>());
			}
		}
	}

	private void LateUpdate()
	{
		if (currentCustomAnimation != null)
		{
			float num = Time.time - animationStartTime;
			float num2 = currentCustomAnimation.duration / currentCustomAnimation.speedMultiplier;
			if (num > num2)
			{
				Logger.Log("CustomAnimation finished");
				currentCustomAnimation = null;
			}
			else
			{
				currentCustomAnimation.SetValuesForFrame(animationRigRoot, num);
			}
		}
	}
}
[HarmonyPatch]
public class CustomPlayerAnimatorPatches
{
	[HarmonyPatch(typeof(Player), "Start")]
	[HarmonyPostfix]
	private static void StartPostfixPatch(Player __instance, ref IEnumerator __result)
	{
		if (!__instance.ai)
		{
			__result = WrapEnumerator(__instance, __result);
		}
	}

	private static IEnumerator WrapEnumerator(Player __instance, IEnumerator original)
	{
		while (original.MoveNext())
		{
			yield return original.Current;
		}
		GameObject gameObject = ((Component)((Component)__instance).transform.Find("AnimationRig")).gameObject;
		if ((Object)(object)gameObject.GetComponent<CustomPlayerAnimator>() == (Object)null)
		{
			gameObject.AddComponent<CustomPlayerAnimator>();
		}
	}
}
public class ElectricGrenadeExplosionAOE : MonoBehaviour
{
	public float damage = 20f;

	public float force = 4f;

	public float fall = 6f;

	public float radius = 8f;

	public float innerRadius = 4f;

	private void Start()
	{
		//IL_0016: 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_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_011e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0129: Unknown result type (might be due to invalid IL or missing references)
		//IL_012e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0133: 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_013e: 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)
		//IL_0150: Unknown result type (might be due to invalid IL or missing references)
		//IL_0155: Unknown result type (might be due to invalid IL or missing references)
		//IL_018e: Unknown result type (might be due to invalid IL or missing references)
		//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_025a: Unknown result type (might be due to invalid IL or missing references)
		//IL_026e: Unknown result type (might be due to invalid IL or missing references)
		Logger.Log("ElectricGrenadeExplosionAOE: start");
		List<Player> list = new List<Player>();
		Collider[] array = Physics.OverlapSphere(((Component)this).transform.position, radius);
		Collider[] array2 = array;
		PlayerInventory val5 = default(PlayerInventory);
		BatteryEntry val7 = default(BatteryEntry);
		foreach (Collider val in array2)
		{
			if (!Object.op_Implicit((Object)(object)val.attachedRigidbody))
			{
				continue;
			}
			Player componentInParent = ((Component)val).GetComponentInParent<Player>();
			if (!Object.op_Implicit((Object)(object)componentInParent) || list.Contains(componentInParent))
			{
				continue;
			}
			if ((Object)(object)componentInParent.refs?.view == (Object)null)
			{
				Logger.LogError("ElectricGrenadeExplosionAOE: overlapped Player has null refs or PhotonView; skipping damage and electric grenade content for this overlap.");
				continue;
			}
			Logger.Log("ElectricGrenadeExplosionAOE: player found");
			list.Add(componentInParent);
			float num = Vector3.Distance(((Component)this).transform.position, ((Component)val).transform.position);
			float num2 = Mathf.InverseLerp(radius, innerRadius, num);
			float num3 = (componentInParent.ai ? 1.6f : 1f);
			float num4 = (componentInParent.ai ? 1.6f : 1f);
			float num5 = (componentInParent.ai ? 0f : 1f);
			Vector3 val2 = componentInParent.Center() - ((Component)this).transform.position;
			Vector3 val3 = ((Vector3)(ref val2)).normalized * num2 * force * num3;
			if (componentInParent.refs.view.IsMine || (PhotonNetwork.IsMasterClient && componentInParent.ai))
			{
				componentInParent.CallTakeDamageAndAddForceAndFall(damage * num2 * num5, val3, fall * num2 * num4);
				if ((Object)(object)DbsContentApiPlugin.TemporaryContentTriggerPrefab == (Object)null)
				{
					Logger.LogError("ElectricGrenadeExplosionAOE: TemporaryContentTriggerPrefab is null; electric grenade content provider not spawned.");
				}
				else
				{
					GameObject val4 = ObjectHelper.CreateTemporaryTriggerObject(50, DbsContentApiPlugin.TemporaryContentTriggerPrefab);
					if ((Object)(object)val4 == (Object)null)
					{
						Logger.LogError("ElectricGrenadeExplosionAOE: CreateTemporaryTriggerObject returned null.");
					}
					else
					{
						val4.transform.position = ((Component)this).transform.position;
						if (componentInParent.ai)
						{
							ElectricGrenadeMonsterContentProvider electricGrenadeMonsterContentProvider = val4.AddComponent<ElectricGrenadeMonsterContentProvider>();
						}
						else if (componentInParent.refs.view.Owner != null)
						{
							ElectricGrenadeAllyContentProvider electricGrenadeAllyContentProvider = val4.AddComponent<ElectricGrenadeAllyContentProvider>();
						}
						else
						{
							Logger.LogError("ElectricGrenadeExplosionAOE: hit human Player has no PhotonView.Owner; ElectricGrenadeAllyContentProvider not configured.");
							Object.Destroy((Object)(object)val4);
						}
					}
				}
			}
			if (!componentInParent.TryGetInventory(ref val5))
			{
				continue;
			}
			InventorySlot[] slots = val5.slots;
			foreach (InventorySlot val6 in slots)
			{
				if ((Object)(object)val6.ItemInSlot.item != (Object)null && val6.ItemInSlot.data.TryGetEntry<BatteryEntry>(ref val7) && val7.m_charge < val7.m_maxCharge)
				{
					val7.AddCharge(0.4f * val7.m_maxCharge);
				}
			}
		}
	}
}
public class ElectricGrenadeItemBehaviour : ThrowableExplosiveBehaviour
{
	private Animator? grenadeAnimator;

	private bool lastPrimedVisualState;

	private string primedStateName = "electric_grenade_prime";

	public override void ConfigItem(ItemInstanceData data, PhotonView playerView)
	{
		base.ConfigItem(data, playerView);
		CacheAnimator();
		SyncPrimedVisuals();
	}

	private void CacheAnimator()
	{
		Transform val = ((Component)this).gameObject.transform.Find("Item/electric-grenade");
		if ((Object)(object)val != (Object)null)
		{
			grenadeAnimator = ((Component)val).GetComponent<Animator>();
		}
	}

	protected override void Update()
	{
		if (primedEntry != null && fuseEntry != null && stashAbleEntry != null)
		{
			bool flag = primedEntry.on && !exploded;
			if ((Object)(object)grenadeAnimator == (Object)null)
			{
				CacheAnimator();
			}
			if ((Object)(object)grenadeAnimator != (Object)null && flag != lastPrimedVisualState)
			{
				SyncPrimedVisuals();
			}
			base.Update();
		}
	}

	protected override void OnPrimaryClick(int slotID)
	{
		if (primedEntry != null && !primedEntry.on)
		{
			primedEntry.on = true;
			if (stashAbleEntry != null)
			{
				stashAbleEntry.isStashAble = false;
			}
			if (fuseEntry != null)
			{
				fuseEntry.m_lifeTimeLeft = fuseTime;
				fuseEntry.m_maxLifeTime = fuseTime;
			}
			((ItemDataEntry)primedEntry).SetDirty();
			if (stashAbleEntry != null)
			{
				((ItemDataEntry)stashAbleEntry).SetDirty();
			}
			SyncPrimedVisuals(playTransition: true);
		}
		base.OnPrimaryClick(slotID);
	}

	private void SyncPrimedVisuals(bool playTransition = false)
	{
		if ((Object)(object)grenadeAnimator == (Object)null)
		{
			CacheAnimator();
		}
		if ((Object)(object)grenadeAnimator == (Object)null || primedEntry == null)
		{
			return;
		}
		bool flag = primedEntry.on && !exploded;
		if (flag == lastPrimedVisualState)
		{
			return;
		}
		if (flag)
		{
			if (playTransition)
			{
				grenadeAnimator.SetTrigger("Primed");
			}
			else
			{
				grenadeAnimator.Play(primedStateName, 0, 1f);
			}
		}
		else
		{
			grenadeAnimator.SetBool("Primed", false);
		}
		lastPrimedVisualState = flag;
	}
}
public class GrenadeItemBehaviour : ThrowableExplosiveBehaviour
{
	protected override void OnExplode()
	{
		TrySpawnExplosionContentProvider<GrenadeExplosionContentProvider>();
	}
}
public class MonsterAffectingAOE : MonoBehaviour
{
	public bool doOnStart = true;

	public float damage = 150f;

	public float force;

	public float fall = 2f;

	public float radius = 8f;

	public float innerRadius = 4f;

	public Action<Player, Vector3>? onMonsterHit;

	private void Start()
	{
		if (doOnStart)
		{
			DoAOE();
		}
	}

	private unsafe void DoAOE()
	{
		//IL_0016: 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_008d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_017f: Unknown result type (might be due to invalid IL or missing references)
		//IL_018a: Unknown result type (might be due to invalid IL or missing references)
		//IL_018f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0194: Unknown result type (might be due to invalid IL or missing references)
		//IL_0198: Unknown result type (might be due to invalid IL or missing references)
		//IL_019f: Unknown result type (might be due to invalid IL or missing references)
		//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_01af: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
		Logger.Log("MonsterAffectingAOE: DoAOE");
		List<Player> list = new List<Player>();
		Collider[] array = Physics.OverlapSphere(((Component)this).transform.position, radius);
		Collider[] array2 = array;
		foreach (Collider val in array2)
		{
			if (!Object.op_Implicit((Object)(object)val.attachedRigidbody))
			{
				continue;
			}
			Player componentInParent = ((Component)val).GetComponentInParent<Player>();
			if (!list.Contains(componentInParent) && (Object)(object)componentInParent != (Object)null)
			{
				Logger.Log("MonsterAffectingAOE: player found");
				list.Add(componentInParent);
				float num = Vector3.Distance(((Component)this).transform.position, ((Component)val).transform.position);
				Vector3 val2 = ((Component)this).transform.position;
				Logger.Log("MonsterAffectingAOE: base position: " + ((object)(*(Vector3*)(&val2))/*cast due to .constrained prefix*/).ToString());
				val2 = ((Component)val).transform.position;
				Logger.Log("MonsterAffectingAOE: collider position: " + ((object)(*(Vector3*)(&val2))/*cast due to .constrained prefix*/).ToString());
				Logger.Log("MonsterAffectingAOE: radius: " + radius + " innerRadius: " + innerRadius + " value: " + num);
				float num2 = Mathf.InverseLerp(radius, innerRadius, num);
				float num3 = (componentInParent.ai ? 0f : 1f);
				float num4 = (componentInParent.ai ? 1.6f : 1f);
				val2 = componentInParent.Center() - ((Component)this).transform.position;
				Vector3 val3 = ((Vector3)(ref val2)).normalized * num2 * force;
				Logger.Log("MonsterAffectingAOE: aiDmgMultiplier: " + num3);
				Logger.Log("MonsterAffectingAOE: aiFallMultiplier: " + num4);
				float num5 = damage * num2 * num3;
				float num6 = fall * num2 * num4;
				Logger.Log("MonsterAffectingAOE: damage: " + damage + " num: " + num2 + " aiDmgMultiplier: " + num3);
				Logger.Log("MonsterAffectingAOE: fall: " + fall + " num: " + num2 + " aiFallMultiplier: " + num4);
				Logger.Log("MonsterAffectingAOE: finalDamage: " + num5);
				Logger.Log("MonsterAffectingAOE: finalFall: " + num6);
				componentInParent.CallTakeDamageAndAddForceAndFall(num5, val3, num6);
				if (componentInParent.ai && PhotonNetwork.IsMasterClient)
				{
					onMonsterHit?.Invoke(componentInParent, ((Component)this).transform.position);
				}
			}
		}
	}
}
public class PopitItemBehaviour : ThrowableExplosiveBehaviour
{
	protected override void OnExplode()
	{
		TrySpawnExplosionContentProvider<PopitExplosionContentProvider>();
	}
}
public enum StatTypeEnum
{
	Oxygen,
	Health
}
public class RegenStatItemBehaviour : ItemInstanceBehaviour
{
	private Player? player;

	public int regenPercentageAmount;

	public StatTypeEnum statType;

	private static float maxHealth = 100f;

	public SFX_Instance oxygenRegenerationSfx;

	public override void ConfigItem(ItemInstanceData data, PhotonView playerView)
	{
		player = ((Component)this).GetComponentInParent<Player>();
		base.itemInstance.RegisterRPC((ItemRPC)0, (Action<BinaryDeserializer>)RPCA_Regen);
	}

	private void RPCA_Regen(BinaryDeserializer deserializer)
	{
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		int num = deserializer.ReadInt();
		StatTypeEnum statTypeEnum = (StatTypeEnum)deserializer.ReadInt();
		float num2 = deserializer.ReadFloat();
		Logger.Log($"[RPC] Regen: {statTypeEnum} {num2}");
		Player val = PlayerHandler.instance.TryGetPlayerFromViewID(num);
		if (!((Object)(object)val != (Object)null))
		{
			return;
		}
		switch (statTypeEnum)
		{
		case StatTypeEnum.Oxygen:
			val.data.remainingOxygen = Mathf.Min(val.data.remainingOxygen + num2, val.data.maxOxygen);
			if ((Object)(object)val == (Object)(object)Player.localPlayer)
			{
				UI_FeedbackExtension component = ((Component)UI_Feedback.instance).GetComponent<UI_FeedbackExtension>();
				if ((Object)(object)component != (Object)null)
				{
					component.RegenOxygenFeedback();
					Logger.Log("PLAYING OXYGEN REGEN SFX");
					oxygenRegenerationSfx.Play(((Component)this).transform.position, false, 1f, (Transform)null);
				}
			}
			break;
		case StatTypeEnum.Health:
			val.data.health = Mathf.Min(val.data.health + num2, maxHealth);
			if ((Object)(object)val == (Object)(object)Player.localPlayer)
			{
				UI_Feedback.instance.HealFeedback();
			}
			break;
		}
	}

	private void Update()
	{
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Expected O, but got Unknown
		//IL_0150: 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)
		PlayerInventory val = default(PlayerInventory);
		InventorySlot val2 = default(InventorySlot);
		if (base.isHeldByMe && !Player.localPlayer.HasLockedInput() && Player.localPlayer.input.clickWasPressed && Player.localPlayer.TryGetInventory(ref val) && val.TryGetSlot(Player.localPlayer.data.selectedItemSlot, ref val2))
		{
			BinarySerializer val3 = new BinarySerializer();
			val3.WriteInt(Player.localPlayer.refs.view.ViewID);
			if (statType == StatTypeEnum.Oxygen)
			{
				val3.WriteInt(0);
				float num = player.data.maxOxygen * ((float)regenPercentageAmount / 100f);
				val3.WriteFloat(num);
				Logger.Log($"[Update] Regen: Oxygen {num}");
			}
			else if (statType == StatTypeEnum.Health)
			{
				val3.WriteInt(1);
				float num2 = maxHealth * ((float)regenPercentageAmount / 100f);
				val3.WriteFloat(num2);
				Logger.Log($"[Update] Regen: Health {num2}");
			}
			base.itemInstance.CallRPC((ItemRPC)0, val3);
			Player.localPlayer.refs.emotes.DoBookEquipEffect(Player.localPlayer.refs.view.ViewID, base.itemInstance.item.id, ((Component)this).transform.position, ((Component)this).transform.rotation);
			val2.Clear();
		}
	}
}
public class SemtexItemBehaviour : ThrowableExplosiveBehaviour
{
	private Vector3 relativePos;

	private Quaternion relativeRot;

	private Transform? hitTransform;

	private Rigidbody? rb;

	public SFX_Instance onStickSfx;

	private void Start()
	{
		rb = ((Component)this).GetComponent<Rigidbody>();
	}

	private new void OnCollisionEnter(Collision collision)
	{
		if (!((ItemInstanceBehaviour)this).isHeld && !((Object)(object)hitTransform != (Object)null) && !((Object)(object)collision.gameObject.GetComponentInParent<ItemInstance>() != (Object)null))
		{
			Stick(collision);
		}
	}

	private void Stick(Collision collision)
	{
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//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_0085: Unknown result type (might be due to invalid IL or missing references)
		//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_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_0123: Unknown result type (might be due to invalid IL or missing references)
		hitTransform = collision.transform;
		rb = ((Component)this).GetComponent<Rigidbody>();
		if ((Object)(object)rb != (Object)null)
		{
			rb.isKinematic = true;
			rb.velocity = Vector3.zero;
			rb.angularVelocity = Vector3.zero;
		}
		relativePos = hitTransform.InverseTransformPoint(((Component)this).transform.position);
		relativeRot = Quaternion.Inverse(hitTransform.rotation) * ((Component)this).transform.rotation;
		if ((Object)(object)onStickSfx != (Object)null)
		{
			onStickSfx.Play(((Component)this).transform.position, false, 1f, (Transform)null);
		}
		if (!((ItemInstanceBehaviour)this).isSimulatedByMe)
		{
			return;
		}
		Player componentInParent = ((Component)hitTransform).GetComponentInParent<Player>();
		if ((Object)(object)componentInParent == (Object)null)
		{
			return;
		}
		if ((Object)(object)DbsContentApiPlugin.TemporaryContentTriggerPrefab == (Object)null)
		{
			Logger.LogError("SemtexItemBehaviour.Stick: TemporaryContentTriggerPrefab is null; cannot spawn Semtex stick content provider.");
			return;
		}
		GameObject val = ObjectHelper.CreateTemporaryTriggerObject(50, DbsContentApiPlugin.TemporaryContentTriggerPrefab);
		if ((Object)(object)val == (Object)null)
		{
			Logger.LogError("SemtexItemBehaviour.Stick: CreateTemporaryTriggerObject returned null.");
			return;
		}
		val.transform.position = ((Component)this).transform.position;
		if (componentInParent.ai)
		{
			SemtexStickMonsterContentProvider semtexStickMonsterContentProvider = val.AddComponent<SemtexStickMonsterContentProvider>();
			return;
		}
		PhotonView view = componentInParent.refs.view;
		if (((view != null) ? view.Owner : null) != null)
		{
			SemtexStickAllyContentProvider semtexStickAllyContentProvider = val.AddComponent<SemtexStickAllyContentProvider>();
			return;
		}
		Logger.LogError("SemtexItemBehaviour.Stick: stuck to human Player but PhotonView.Owner is missing; ally stick content provider not configured.");
		Object.Destroy((Object)(object)val);
	}

	protected override void OnExplode()
	{
		TrySpawnExplosionContentProvider<SemtexExplosionContentProvider>();
	}

	protected override void Update()
	{
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0072: 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)
		base.Update();
		if (!((Object)(object)hitTransform != (Object)null))
		{
			return;
		}
		if ((Object)(object)hitTransform == (Object)null)
		{
			hitTransform = null;
			if ((Object)(object)rb != (Object)null)
			{
				rb.isKinematic = false;
			}
		}
		else
		{
			((Component)this).transform.position = hitTransform.TransformPoint(relativePos);
			((Component)this).transform.rotation = hitTransform.rotation * relativeRot;
		}
	}
}
public class SilverFulminateItemBehaviour : ThrowableExplosiveBehaviour
{
	protected override void OnExplode()
	{
		TrySpawnExplosionContentProvider<SilverFulminateExplosionContentProvider>();
	}
}
public class TemporaryInvisibilityItemBehaviour : ItemInstanceBehaviour
{
	private Player? player;

	public SFX_Instance invisibilitySpraySfx;

	public static float duration = 8f;

	public override void ConfigItem(ItemInstanceData data, PhotonView playerView)
	{
		player = ((Component)this).GetComponentInParent<Player>();
	}

	private void Update()
	{
		//IL_0133: Unknown result type (might be due to invalid IL or missing references)
		//IL_013e: 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)
		PlayerInventory val = default(PlayerInventory);
		InventorySlot val2 = default(InventorySlot);
		if (!base.isHeldByMe || Player.localPlayer.HasLockedInput() || !Player.localPlayer.input.clickWasPressed || !Player.localPlayer.TryGetInventory(ref val) || !val.TryGetSlot(Player.localPlayer.data.selectedItemSlot, ref val2))
		{
			return;
		}
		PlayerRPCBridge component = ((Component)Player.localPlayer).gameObject.GetComponent<PlayerRPCBridge>();
		if ((Object)(object)component == (Object)null)
		{
			Logger.LogError("TemporaryInvisibilityItemBehaviour: Could not find PlayerRPCBridge on " + ((Object)((Component)Player.localPlayer).gameObject).name + ".");
			return;
		}
		if (component.isInvisibilityActive)
		{
			Logger.LogError("TemporaryInvisibilityItemBehaviour: Invisibility is already active on " + ((Object)((Component)Player.localPlayer).gameObject).name + ".");
		}
		component.view.RPC("RPCA_Make_Invisible", (RpcTarget)0, new object[2]
		{
			component.view.ViewID,
			duration
		});
		Player.localPlayer.refs.emotes.DoBookEquipEffect(Player.localPlayer.refs.view.ViewID, base.itemInstance.item.id, ((Component)this).transform.position, ((Component)this).transform.rotation);
		Transform val3 = ((Component)Player.localPlayer).transform.Find("RigCreator/Rig/Armature/Hip");
		if ((Object)(object)val3 != (Object)null)
		{
			int num = Mathf.RoundToInt(60f * duration);
			GameObject val4 = ObjectHelper.CreateAttachedTriggerObject(DbsContentApiPlugin.TemporaryContentTriggerPrefab, val3, num);
			InvisiblePlayerContentProvider invisiblePlayerContentProvider = val4.AddComponent<InvisiblePlayerContentProvider>();
			invisiblePlayerContentProvider.playerName = Player.localPlayer.refs.view.Owner.NickName;
			invisiblePlayerContentProvider.actorNumber = Player.localPlayer.refs.view.Owner.ActorNumber;
		}
		if ((Object)(object)player == (Object)(object)Player.localPlayer)
		{
			invisibilitySpraySfx.Play(((Component)this).transform.position, false, 1f, (Transform)null);
		}
		val2.Clear();
	}
}
public class TemporaryPlayerBoostItemBehaviour : ItemInstanceBehaviour
{
	private Player? player;

	public static float duration = 8f;

	public static float moveSpeedMultiplier = 1.5f;

	public static float staminaInstantRegen = 2f;

	public static float staminaRegRateMultiplier = 1.2f;

	public SFX_Instance playerCrunchSFX;

	public override void ConfigItem(ItemInstanceData data, PhotonView playerView)
	{
		player = ((Component)this).GetComponentInParent<Player>();
	}

	private void Update()
	{
		//IL_0181: Unknown result type (might be due to invalid IL or missing references)
		//IL_018c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
		PlayerInventory val = default(PlayerInventory);
		InventorySlot val2 = default(InventorySlot);
		if (!base.isHeldByMe || Player.localPlayer.HasLockedInput() || !Player.localPlayer.input.clickWasPressed || !Player.localPlayer.TryGetInventory(ref val) || !val.TryGetSlot(Player.localPlayer.data.selectedItemSlot, ref val2))
		{
			return;
		}
		PlayerRPCBridge component = ((Component)Player.localPlayer).gameObject.GetComponent<PlayerRPCBridge>();
		if ((Object)(object)component == (Object)null)
		{
			Logger.LogError("TemporaryPlayerBoostItemBehaviour: Could not find PlayerRPCBridge on " + ((Object)((Component)Player.localPlayer).gameObject).name + ".");
		}
		else
		{
			if (component.isBoostActive)
			{
				return;
			}
			if ((Object)(object)player == (Object)(object)Player.localPlayer)
			{
				playerCrunchSFX.Play(((Component)this).transform.position, false, 1f, (Transform)null);
				UI_FeedbackExtension component2 = ((Component)UI_Feedback.instance).GetComponent<UI_FeedbackExtension>();
				if ((Object)(object)component2 != (Object)null)
				{
					component2.PlayerStaminaBoostFeedback();
				}
			}
			component.view.RPC("RPCA_Make_Boosted", (RpcTarget)0, new object[5]
			{
				component.view.ViewID,
				duration,
				moveSpeedMultiplier,
				staminaInstantRegen,
				staminaRegRateMultiplier
			});
			Player.localPlayer.refs.emotes.DoBookEquipEffect(Player.localPlayer.refs.view.ViewID, base.itemInstance.item.id, ((Component)this).transform.position, ((Component)this).transform.rotation);
			val2.Clear();
		}
	}
}
public class ThrowableExplosiveBehaviour : ItemInstanceBehaviour
{
	protected Player? player;

	public GameObject? explosionPrefab;

	protected OnOffEntry? primedEntry;

	protected LifeTimeEntry? fuseEntry;

	protected StashAbleEntry? stashAbleEntry;

	protected AudioLoop? tickingSoundAudioLoop;

	[Header("Base Grenade Settings")]
	[SerializeField]
	protected float fuseTime = 5f;

	[SerializeField]
	protected float timeNotHeldBeforeImpactExplode = 0.1f;

	public bool explodesOnImpact;

	[Header("Audio Settings")]
	public bool hasTickingSound;

	public AudioClip? tickingSoundClip;

	public float baseTickingPitch = 0.3f;

	public float tickingPitchMultiplier = 0.9f;

	public float maxTickingPitch = 5f;

	public float minTickingPitch = 1f;

	public float tickingVolume = 0.2f;

	protected float timeNotHeld;

	protected bool exploded;

	public override void ConfigItem(ItemInstanceData data, PhotonView playerView)
	{
		//IL_001b: 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_002c: Expected O, but got Unknown
		//IL_0047: 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_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Expected O, but got Unknown
		//IL_0084: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_0095: Expected O, but got Unknown
		player = ((Component)this).GetComponentInParent<Player>();
		if (!data.TryGetEntry<OnOffEntry>(ref primedEntry))
		{
			primedEntry = new OnOffEntry
			{
				on = false
			};
			data.AddDataEntry((ItemDataEntry)(object)primedEntry);
		}
		if (!data.TryGetEntry<LifeTimeEntry>(ref fuseEntry))
		{
			fuseEntry = new LifeTimeEntry
			{
				m_lifeTimeLeft = fuseTime,
				m_maxLifeTime = fuseTime
			};
			data.AddDataEntry((ItemDataEntry)(object)fuseEntry);
		}
		if (!data.TryGetEntry<StashAbleEntry>(ref stashAbleEntry))
		{
			stashAbleEntry = new StashAbleEntry
			{
				isStashAble = true
			};
			data.AddDataEntry((ItemDataEntry)(object)stashAbleEntry);
		}
		if (hasTickingSound)
		{
			EnsureTickingSound();
		}
	}

	protected virtual void EnsureTickingSound()
	{
		if ((Object)(object)tickingSoundAudioLoop != (Object)null)
		{
			return;
		}
		Item itemByPrefabComponent = Items.GetItemByPrefabComponent<ItemGooBall>();
		if ((Object)(object)itemByPrefabComponent?.itemObject == (Object)null)
		{
			return;
		}
		ItemGooBall component = itemByPrefabComponent.itemObject.GetComponent<ItemGooBall>();
		if (!((Object)(object)component?.tickingSound == (Object)null))
		{
			AudioLoop tickingSound = component.tickingSound;
			tickingSoundAudioLoop = ((Component)this).gameObject.GetComponent<AudioLoop>();
			if ((Object)(object)tickingSoundAudioLoop == (Object)null)
			{
				tickingSoundAudioLoop = ((Component)this).gameObject.AddComponent<AudioLoop>();
			}
			((Behaviour)tickingSoundAudioLoop).enabled = false;
			tickingSoundAudioLoop.clip = (AudioClip)(((Object)(object)tickingSoundClip != (Object)null) ? ((object)tickingSoundClip) : ((object)tickingSound.clip));
			tickingSoundAudioLoop.mixerGroup = tickingSound.mixerGroup;
			tickingSoundAudioLoop.volume = tickingSound.volume;
			tickingSoundAudioLoop.pitch = tickingSound.pitch;
			tickingSoundAudioLoop.minDistance = tickingSound.minDistance;
			tickingSoundAudioLoop.maxDistance = tickingSound.maxDistance;
			tickingSoundAudioLoop.obstrability = tickingSound.obstrability;
			tickingSoundAudioLoop.blend = tickingSound.blend;
			tickingSoundAudioLoop.volume = tickingVolume;
		}
	}

	protected virtual void Update()
	{
		bool flag = primedEntry.on && !exploded;
		UpdateTickingSound(flag);
		if (!base.isHeld)
		{
			timeNotHeld += Time.deltaTime;
		}
		else
		{
			timeNotHeld = 0f;
		}
		HandleInput();
		if (flag)
		{
			LifeTimeEntry? obj = fuseEntry;
			obj.m_lifeTimeLeft -= Time.deltaTime;
		}
		if (PhotonNetwork.IsMasterClient && flag && fuseEntry.m_lifeTimeLeft <= 0f && !base.isHeld)
		{
			SpawnExplosion();
		}
	}

	protected virtual void OnCollisionEnter(Collision other)
	{
		CheckCollision(other);
	}

	protected virtual void OnCollisionStay(Collision other)
	{
		CheckCollision(other);
	}

	protected virtual void CheckCollision(Collision other)
	{
		if (PhotonNetwork.IsMasterClient && explodesOnImpact && primedEntry != null && primedEntry.on && !exploded && timeNotHeld > timeNotHeldBeforeImpactExplode)
		{
			SpawnExplosion();
		}
	}

	protected virtual void UpdateTickingSound(bool primed)
	{
		if ((Object)(object)tickingSoundAudioLoop != (Object)null && hasTickingSound)
		{
			if (primed != ((Behaviour)tickingSoundAudioLoop).enabled)
			{
				((Behaviour)tickingSoundAudioLoop).enabled = primed;
			}
			if (primed && fuseEntry != null)
			{
				float num = fuseTime * tickingPitchMultiplier / Mathf.Max(0.01f, fuseEntry.m_lifeTimeLeft) + baseTickingPitch;
				tickingSoundAudioLoop.pitch = Mathf.Clamp(num, minTickingPitch, maxTickingPitch);
			}
		}
	}

	protected virtual void HandleInput()
	{
		PlayerInventory val = default(PlayerInventory);
		InventorySlot val2 = default(InventorySlot);
		if (base.isHeldByMe && !Player.localPlayer.HasLockedInput() && Player.localPlayer.input.clickWasPressed && Player.localPlayer.TryGetInventory(ref val) && val.TryGetSlot(Player.localPlayer.data.selectedItemSlot, ref val2))
		{
			OnPrimaryClick(val2.SlotID);
		}
	}

	protected virtual void OnPrimaryClick(int slotID)
	{
		Logger.Log("GrenadeItemBehaviour: Grenade thrown by " + ((Object)((Component)Player.localPlayer).gameObject).name + ".");
		Action callbackOnThrowFrame = delegate
		{
			if ((Object)(object)player != (Object)null && player.refs != null && (Object)(object)player.refs.items != (Object)null && player.data != null && primedEntry != null && stashAbleEntry != null && fuseEntry != null)
			{
				if (!primedEntry.on)
				{
					primedEntry.on = true;
					fuseEntry.m_lifeTimeLeft = fuseTime;
					fuseEntry.m_maxLifeTime = fuseTime;
					Logger.Log("GrenadeItemBehaviour: Grenade primed.");
				}
				else
				{
					Logger.Log("GrenadeItemBehaviour: Grenade re-thrown (already primed).");
				}
				stashAbleEntry.isStashAble = false;
				((ItemDataEntry)stashAbleEntry).SetDirty();
				((ItemDataEntry)primedEntry).SetDirty();
				player.data.throwCharge = 1f;
				player.refs.items.DropItem(slotID, false);
			}
		};
		Transform val = ((Component)player).gameObject.transform.Find("AnimationRig");
		CustomPlayerAnimator customPlayerAnimator = default(CustomPlayerAnimator);
		if ((Object)(object)val != (Object)null && ((Component)val).TryGetComponent<CustomPlayerAnimator>(ref customPlayerAnimator))
		{
			customPlayerAnimator.TryActivateThrowAnimation(callbackOnThrowFrame);
		}
	}

	protected virtual void SpawnExplosion()
	{
		//IL_0028: 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)
		if (exploded)
		{
			return;
		}
		exploded = true;
		if (PhotonNetwork.IsMasterClient)
		{
			PhotonNetwork.Instantiate(((Object)explosionPrefab).name, ((Component)this).transform.position, ((Component)this).transform.rotation, (byte)0, (object[])null);
			OnExplode();
			PhotonNetwork.Destroy(((Component)((Component)this).GetComponentInParent<PhotonView>()).gameObject);
		}
		((Component)this).gameObject.SetActive(false);
		Player componentInParent = ((Component)this).GetComponentInParent<Player>();
		if ((Object)(object)componentInParent != (Object)null)
		{
			PlayerInventory val = default(PlayerInventory);
			InventorySlot val2 = default(InventorySlot);
			if (!componentInParent.TryGetInventory(ref val))
			{
				Debug.LogError((object)"No inventory found");
			}
			else if (!val.TryGetSlot(componentInParent.data.selectedItemSlot, ref val2))
			{
				Debug.LogError((object)$"Slot not found with index: {componentInParent.data.selectedItemSlot}");
			}
			else
			{
				val2.ClearLocal();
			}
		}
		else
		{
			MonoFunctions.instance.PhotonDestroy(((Component)((Component)this).transform.root).gameObject, 2f);
		}
	}

	protected bool TrySpawnExplosionContentProvider<T>() where T : Component
	{
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)DbsContentApiPlugin.TemporaryContentTriggerPrefab == (Object)null)
		{
			Logger.LogError("ThrowableExplosiveBehaviour.TrySpawnExplosionContentProvider: TemporaryContentTriggerPrefab is null.");
			return false;
		}
		GameObject val = ObjectHelper.CreateTemporaryTriggerObject(50, DbsContentApiPlugin.TemporaryContentTriggerPrefab);
		if ((Object)(object)val == (Object)null)
		{
			Logger.LogError("ThrowableExplosiveBehaviour.TrySpawnExplosionContentProvider: CreateTemporaryTriggerObject returned null.");
			return false;
		}
		val.transform.position = ((Component)this).transform.position;
		T val2 = val.AddComponent<T>();
		if ((Object)(object)val2 == (Object)null)
		{
			Logger.LogError("ThrowableExplosiveBehaviour.TrySpawnExplosionContentProvider: AddComponent<" + typeof(T).Name + "> failed.");
			return false;
		}
		return true;
	}

	protected virtual void OnExplode()
	{
	}
}
public class AngelWingsEquipableItemBehaviour : EquipableItemBehaviour
{
}
[HarmonyPatch(typeof(Player))]
public class AngelWingsEquipableItemBehaviourPatches
{
	[HarmonyPatch("CallTakeDamageAndAddForceAndFall")]
	[HarmonyPrefix]
	public static bool PrefixCallTakeDamageAndAddForceAndFall(Player __instance, float damage, Vector3 force, float fall)
	{
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		if (damage == 0f && force == Vector3.zero && fall == 2f && __instance.IsLocal && EquipableInventory.PlayerHasEquipableCached(__instance, CustomItems.AngelWingsItem.id))
		{
			return false;
		}
		return true;
	}
}
[HarmonyPatch(typeof(PlayerController), "FixedUpdate")]
public static class AngelWingsVelocityPatch
{
	[HarmonyPostfix]
	public static void Postfix(PlayerController __instance)
	{
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		Player component = ((Component)__instance).GetComponent<Player>();
		if ((Object)(object)component == (Object)null || !EquipableInventory.PlayerHasEquipableCached(component, CustomItems.AngelWingsItem.id) || component.data.isGrounded)
		{
			return;
		}
		PlayerRagdoll ragdoll = component.refs.ragdoll;
		if ((Object)(object)ragdoll == (Object)null)
		{
			return;
		}
		Bodypart bodypart = ragdoll.GetBodypart((BodypartType)2);
		if (!((Object)(object)bodypart == (Object)null))
		{
			Vector3 velocity = bodypart.rig.velocity;
			if (velocity.y < 0f - AngelWingsVisualAnimationHandler.MAX_DOWNWARDS_VELOCITY)
			{
				velocity.y = 0f - AngelWingsVisualAnimationHandler.MAX_DOWNWARDS_VELOCITY;
				bodypart.rig.velocity = velocity;
			}
		}
	}
}
public class AngelWingsVisualAnimationHandler : MonoBehaviour
{
	private Animator animator;

	private Player player;

	private Bodypart hip;

	private bool flying;

	public static float MAX_DOWNWARDS_VELOCITY = 1.7f;

	private void Start()
	{
		animator = ((Component)this).GetComponent<Animator>();
		player = ((Component)this).GetComponentInParent<Player>();
		hip = player.refs.ragdoll.GetBodypart((BodypartType)2);
	}

	private void LateUpdate()
	{
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		if (player.data.isGrounded)
		{
			if (flying)
			{
				SetFlying(flying: false);
			}
		}
		else if (((Component)this).gameObject.activeSelf && (Object)(object)hip != (Object)null)
		{
			Vector3 velocity = hip.rig.velocity;
			if (velocity.y < (0f - MAX_DOWNWARDS_VELOCITY) * 0.8f && !flying && !player.data.isGrounded)
			{
				SetFlying(flying: true);
			}
			if (velocity.y > (0f - MAX_DOWNWARDS_VELOCITY) * 0.65f && flying)
			{
				SetFlying(flying: false);
			}
		}
	}

	public void SetFlying(bool flying)
	{
		Logger.Log($"-------------- Setting flying to {flying}");
		this.flying = flying;
		animator.SetBool("Flying", flying);
	}
}
public class BootsEquipableItemBehaviour : EquipableItemBehaviour
{
}
[HarmonyPatch(typeof(PlayerController))]
public class JumpPatch
{
	[HarmonyPatch("RPCA_Jump")]
	[HarmonyPrefix]
	private static void PrefixPatchJumpImpulse(PlayerController __instance)
	{
		Player component = ((Component)__instance).GetComponent<Player>();
		if (EquipableInventory.PlayerHasEquipableCached(component, CustomItems.JumpingBootsItem.id))
		{
			((MonoBehaviour)__instance).StartCoroutine(BoostJumpTemporarily(__instance));
		}
	}

	private static IEnumerator BoostJumpTemporarily(PlayerController controller)
	{
		float originalJumpImpulse = controller.jumpImpulse;
		float originalJumpForceOverTime = controller.jumpForceOverTime;
		float originalJumpForceDuration = controller.jumpForceDuration;
		controller.jumpImpulse = 15f;
		controller.jumpForceOverTime = 0.7f;
		controller.jumpForceDuration = 1f;
		yield return (object)new WaitForSeconds(1f);
		controller.jumpImpulse = originalJumpImpulse;
		controller.jumpForceOverTime = originalJumpForceOverTime;
		controller.jumpForceDuration = originalJumpForceDuration;
	}
}
public class CursedDollEquipableItemBehaviour : EquipableItemBehaviour
{
}
public class DollEquipableBehaviour : EquipableItemBehaviour
{
	public const string ROOM_PROP_KEY = "DollCount";

	public const float MULTIPLIER_PER_DOLL = 1.5f;

	public static float GetTotalMultiplier()
	{
		if (!PhotonNetwork.InRoom)
		{
			return 1f;
		}
		if (((Dictionary<object, object>)(object)((RoomInfo)PhotonNetwork.CurrentRoom).CustomProperties).TryGetValue((object)"DollCount", out object value))
		{
			int num = (int)value;
			if (num != 0)
			{
				return Mathf.Pow(1.5f, (float)num);
			}
			return 1f;
		}
		return 1f;
	}

	private static void SetDollCount(int delta)
	{
		//IL_0033: 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)
		//IL_0049: Expected O, but got Unknown
		//IL_004a: Expected O, but got Unknown
		if (PhotonNetwork.InRoom)
		{
			int num = 0;
			if (((Dictionary<object, object>)(object)((RoomInfo)PhotonNetwork.CurrentRoom).CustomProperties).TryGetValue((object)"DollCount", out object value))
			{
				num = (int)value;
			}
			int num2 = Mathf.Max(0, num + delta);
			Hashtable val = new Hashtable();
			((Dictionary<object, object>)val).Add((object)"DollCount", (object)num2);
			Hashtable val2 = val;
			PhotonNetwork.CurrentRoom.SetCustomProperties(val2, (Hashtable)null, (WebFlags)null);
			Logger.Log($"Doll count updated to {num2} (multiplier: {Mathf.Pow(1.5f, (float)num2):F2}x)");
		}
	}

	protected override void OnEquipped(int slotIndex)
	{
		base.OnEquipped(slotIndex);
		SetDollCount(1);
	}

	protected override void OnUnequipped(int slotIndex)
	{
		base.OnUnequipped(slotIndex);
		SetDollCount(-1);
	}
}
[HarmonyPatch(typeof(RoundSpawner))]
public static class RoundSpawnerPatch
{
	[HarmonyPatch("Start")]
	[HarmonyPrefix]
	public static void StartPrefix(RoundSpawner __instance)
	{
		float totalMultiplier = DollEquipableBehaviour.GetTotalMultiplier();
		if (totalMultiplier != 1f)
		{
			__instance.testBudget = Mathf.RoundToInt((float)__instance.testBudget * totalMultiplier);
			__instance.testBiggestPurchase = Mathf.RoundToInt((float)__instance.testBiggestPurchase * totalMultiplier);
			Logger.Log($"Test budget boosted to {__instance.testBudget} (x{totalMultiplier:F2})");
		}
	}

	[HarmonyPatch("GetMonstersToSpawn")]
	[HarmonyPrefix]
	public static void GetMonstersToSpawnPrefix(ref int budget, ref int biggestPurchase)
	{
		float totalMultiplier = DollEquipableBehaviour.GetTotalMultiplier();
		if (totalMultiplier != 1f)
		{
			budget = Mathf.RoundToInt((float)budget * totalMultiplier);
			biggestPurchase = Mathf.RoundToInt((float)biggestPurchase * totalMultiplier);
			Logger.Log($"Budget boosted — budget: {budget}, biggestPurchase: {biggestPurchase} (x{totalMultiplier:F2})");
		}
	}
}
public class EquipableInventory : MonoBehaviourPun
{
	public byte[] equipableIDs = new byte[2];

	private Dictionary<int, List<GameObject>> spawnedVisuals = new Dictionary<int, List<GameObject>>();

	private Player? cachedPlayer;

	private void Awake()
	{
		for (int i = 0; i < equipableIDs.Length; i++)
		{
			equipableIDs[i] = byte.MaxValue;
			spawnedVisuals[i] = new List<GameObject>();
		}
	}

	private Player? GetPlayer()
	{
		if ((Object)(object)cachedPlayer != (Object)null)
		{
			return cachedPlayer;
		}
		if ((Object)(object)PlayerHandler.instance == (Object)null || PlayerHandler.instance.players == null)
		{
			return null;
		}
		foreach (Player player in PlayerHandler.instance.players)
		{
			if ((Object)(object)player != (Object)null && (Object)(object)player.refs.view != (Object)null && player.refs.view.Owner == ((MonoBehaviourPun)this).photonView.Owner)
			{
				cachedPlayer = player;
				return player;
			}
		}
		return null;
	}

	private void LateUpdate()
	{
		bool flag = false;
		for (int i = 0; i < equipableIDs.Length; i++)
		{
			List<GameObject> value2;
			if (equipableIDs[i] != byte.MaxValue)
			{
				if (!spawnedVisuals.TryGetValue(i, out List<GameObject> value) || value.Count == 0 || value.Exists((GameObject v) => (Object)(object)v == (Object)null))
				{
					flag = true;
					break;
				}
			}
			else if (spawnedVisuals.TryGetValue(i, out value2) && value2.Count > 0)
			{
				flag = true;
				break;
			}
		}
		if (flag)
		{
			cachedPlayer = null;
			UpdateVisuals();
		}
	}

	private void UpdateVisuals()
	{
		Player player = GetPlayer();
		if ((Object)(object)player == (Object)null)
		{
			foreach (KeyValuePair<int, List<GameObject>> spawnedVisual in spawnedVisuals)
			{
				foreach (GameObject item in spawnedVisual.Value)
				{
					if ((Object)(object)item != (Object)null)
					{
						Object.Destroy((Object)(object)item);
					}
				}
				spawnedVisual.Value.Clear();
			}
			return;
		}
		for (int i = 0; i < equipableIDs.Length; i++)
		{
			byte b = equipableIDs[i];
			if (spawnedVisuals.TryGetValue(i, out List<GameObject> value) && (b == byte.MaxValue || value.Exists((GameObject v) => (Object)(object)v == (Object)null)))
			{
				foreach (GameObject item2 in value)
				{
					if ((Object)(object)item2 != (Object)null)
					{
						Object.Destroy((Object)(object)item2);
					}
				}
				value.Clear();
			}
			if (b != byte.MaxValue && (!spawnedVisuals.ContainsKey(i) || spawnedVisuals[i].Count == 0))
			{
				if (!spawnedVisuals.ContainsKey(i))
				{
					spawnedVisuals[i] = new List<GameObject>();
				}
				if ((Object)(object)CustomItems.JumpingBootsItem != (Object)null && b == CustomItems.JumpingBootsItem.id)
				{
					SpawnFroggyBoot(i, player);
				}
				else if ((Object)(object)CustomItems.CursedDoll != (Object)null && b == CustomItems.CursedDoll.id)
				{
					SpawnCursedDoll(i, player);
				}
				else if ((Object)(object)CustomItems.AngelWingsItem != (Object)null && b == CustomItems.AngelWingsItem.id)
				{
					SpawnAngelWings(i, player);
				}
				else if ((Object)(object)CustomItems.GlowingVest != (Object)null && b == CustomItems.GlowingVest.id)
				{
					SpawnGlowingVest(i, player);
				}
			}
		}
	}

	private GameObject SpawnAngelWings(int slot, Player player)
	{
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)CustomItems.AngelWingsPrefab == (Object)null)
		{
			return null;
		}
		Transform val = ((!((Object)(object)player == (Object)(object)Player.localPlayer)) ? player.refs.rigRoot.transform.Find("Rig/Armature/Torso") : player.refs.rigRoot.transform.Find("Rig/Armature/Hip/Torso"));
		if ((Object)(object)val != (Object)null)
		{
			GameObject val2 = Object.Instantiate<GameObject>(CustomItems.AngelWingsPrefab, val);
			val2.transform.localPosition = new Vector3(0f, 0.65f, -1.64f);
			val2.transform.localRotation = Quaternion.Euler(0f, 0f, 0f);
			val2.transform.localScale = new Vector3(2.73f, 2.73f, 2.73f);
			spawnedVisuals[slot].Add(val2);
			ObjectHelper.FixShadersForCurrentScene(val2);
			Transform val3 = ((Component)player).transform.Find("RigCreator/Rig/Armature/Hip");
			if ((Object)(object)val3 != (Object)null)
			{
				GameObject val4 = ObjectHelper.CreateAttachedTriggerObject(DbsContentApiPlugin.TemporaryContentTriggerPrefab, val3, -1);
				AngelWingsContentProvider angelWingsContentProvider = val4.AddComponent<AngelWingsContentProvider>();
				angelWingsContentProvider.playerName = player.refs.view.Owner.NickName;
				angelWingsContentProvider.actorNumber = player.refs.view.Owner.ActorNumber;
				spawnedVisuals[slot].Add(val4);
			}
			return val2;
		}
		return null;
	}

	private void SpawnCursedDoll(int slot, Player player)
	{
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00be: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)CustomItems.CursedNecklaceVisualPrefab == (Object)null)
		{
			return;
		}
		Transform val = ((!((Object)(object)player == (Object)(object)Player.localPlayer)) ? player.refs.rigRoot.transform.Find("Rig/Armature/Torso") : player.refs.rigRoot.transform.Find("Rig/Armature/Hip/Torso"));
		if ((Object)(object)val != (Object)null)
		{
			GameObject val2 = Object.Instantiate<GameObject>(CustomItems.CursedNecklaceVisualPrefab, val);
			val2.transform.localPosition = new Vector3(1.94f, 1.8f, 2.47f);
			val2.transform.localRotation = Quaternion.Euler(-83.044f, 0f, 0f);
			val2.transform.localScale = new Vector3(2.98f, 2.98f, 2.98f);
			spawnedVisuals[slot].Add(val2);
			ObjectHelper.FixShadersForCurrentScene(val2);
			Transform val3 = ((Component)player).transform.Find("RigCreator/Rig/Armature/Hip");
			if ((Object)(object)val3 != (Object)null)
			{
				GameObject val4 = ObjectHelper.CreateAttachedTriggerObject(DbsContentApiPlugin.TemporaryContentTriggerPrefab, val3, -1);
				CursedDollContentProvider cursedDollContentProvider = val4.AddComponent<CursedDollContentProvider>();
				spawnedVisuals[slot].Add(val4);
			}
		}
		else
		{
			Logger.LogError("[EquipableInventory] Could not find Torso bone for necklace attachment.");
		}
	}

	public static Transform[] getPlayerRigTransformsAsExpectedByDbExportedFbx(Player player)
	{
		if ((Object)(object)player == (Object)(object)Player.localPlayer)
		{
			List<Transform> list = new List<Transform>
			{
				((Component)player).transform.Find("RigCreator/Rig/Armature/Hip"),
				((Component)player).transform.Find("RigCreator/Rig/Armature/Hip/Extra_1"),
				((Component)player).transform.Find("RigCreator/Rig/Armature/Hip/Leg_L"),
				((Component)player).transform.Find("RigCreator/Rig/Armature/Hip/Leg_L/Knee_L"),
				((Component)player).transform.Find("RigCreator/Rig/Armature/Hip/Leg_L/Knee_L/Foot_L"),
				((Component)player).transform.Find("RigCreator/Rig/Armature/Hip/Leg_R"),
				((Component)player).transform.Find("RigCreator/Rig/Armature/Hip/Leg_R/Knee_R"),
				((Component)player).transform.Find("RigCreator/Rig/Armature/Hip/Leg_R/Knee_R/Foot_R"),
				((Component)player).transform.Find("RigCreator/Rig/Armature/Hip/Torso"),
				((Component)player).transform.Find("RigCreator/Rig/Armature/Hip/Torso/Arm_L"),
				((Component)player).transform.Find("RigCreator/Rig/Armature/Hip/Torso/Arm_L/Elbow_L"),
				((Component)player).transform.Find("RigCreator/Rig/Armature/Hip/Torso/Arm_L/Elbow_L/Hand_L"),
				((Component)player).transform.Find("RigCreator/Rig/Armature/Hip/Torso/Arm_L/Elbow_L/Hand_L/Finger_Index_1_L"),
				((Component)player).transform.Find("RigCreator/Rig/Armature/Hip/Torso/Arm_L/Elbow_L/Hand_L/Finger_Index_1_L/Finger_Index_2_L"),
				((Component)player).transform.Find("RigCreator/Rig/Armature/Hip/Torso/Arm_L/Elbow_L/Hand_L/Finger_Index_1_L/Finger_Index_2_L/Finger_Index_3_L"),
				((Component)player).transform.Find("RigCreator/Rig/Armature/Hip/Torso/Arm_L/Elbow_L/Hand_L/Finger_Middle_1_L"),
				((Component)player).transform.Find("RigCreator/Rig/Armature/Hip/Torso/Arm_L/Elbow_L/Hand_L/Finger_Middle_1_L/Finger_Middle_2_L"),
				((Component)player).transform.Find("RigCreator/Rig/Armature/Hip/Torso/Arm_L/Elbow_L/Hand_L/Finger_Middle_1_L/Finger_Middle_2_L/Finger_Middle_3_L"),
				((Component)player).transform.Find("RigCreator/Rig/Armature/Hip/Torso/Arm_L/Elbow_L/Hand_L/Finger_Pinky_1_L"),
				((Component)player).transform.Find("RigCreator/Rig/Armature/Hip/Torso/Arm_L/Elbow_L/Hand_L/Finger_Pinky_1_L/Finger_Pinky_2_L"),
				((Component)player).transform.Find("RigCreator/Rig/Armature/Hip/Torso/Arm_L/Elbow_L/Hand_L/Finger_Pinky_1_L/Finger_Pinky_2_L/Finger_Pinky_3_L"),
				((Component)player).transform.Find("RigCreator/Rig/Armature/Hip/Torso/Arm_L/Elbow_L/Hand_L/Finger_Ring_1_L"),
				((Component)player).transform.Find("RigCreator/Rig/Armature/Hip/Torso/Arm_L/Elbow_L/Hand_L/Finger_Ring_1_L/Finger_Ring_2_L"),
				((Component)player).transform.Find("RigCreator/Rig/Armature/Hip/Torso/Arm_L/Elbow_L/Hand_L/Finger_Ring_1_L/Finger_Ring_2_L/Finger_Ring_3_L"),
				((Component)player).transform.Find("RigCreator/Rig/Armature/Hip/Torso/Arm_L/Elbow_L/Hand_L/Thumb_L_1"),
				((Component)player).transform.Find("RigCreator/Rig/Armature/Hip/Torso/Arm_L/Elbow_L/Hand_L/Thumb_L_1/Thumb_L_2"),
				((Component)player).transform.Find("RigCreator/Rig/Armature/Hip/Torso/Arm_L/Elbow_L/Hand_L/Thumb_L_1/Thumb_L_2/Thumb_L_3"),
				((Component)player).transform.Find("RigCreator/Rig/Armature/Hip/Torso/Arm_R"),
				((Component)player).transform.Find("RigCreator/Rig/Armature/Hip/Torso/Arm_R/Elbow_R"),
				((Component)player).transform.Find("RigCreator/Rig/Armature/Hip/Torso/Arm_R/Elbow_R/Hand_R"),
				((Component)player).transform.Find("RigCreator/Rig/Armature/Hip/Torso/Arm_R/Elbow_R/Hand_R/Finger_Index_1_R"),
				((Component)player).transform.Find("RigCreator/Rig/Armature/Hip/Torso/Arm_R/Elbow_R/Hand_R/Finger_Index_1_R/Finger_Index_2_R"),
				((Component)player).transform.Find("RigCreator/Rig/Armature/Hip/Torso/Arm_R/Elbow_R/Hand_R/Finger_Index_1_R/Finger_Index_2_R/Finger_Index_3_R"),
				((Component)player).transform.Find("RigCreator/Rig/Armature/Hip/Torso/Arm_R/Elbow_R/Hand_R/Finger_Middle_1_R"),
				((Component)player).transform.Find("RigCreator/Rig/Armature/Hip/Torso/Arm_R/Elbow_R/Hand_R/Finger_Middle_1_R/Finger_Middle_2_R"),
				((Component)player).transform.Find("RigCreator/Rig/Armature/Hip/Torso/Arm_R/Elbow_R/Hand_R/Finger_Middle_1_R/Finger_Middle_2_R/Finger_Middle_3_R"),
				((Component)player).transform.Find("RigCreator/Rig/Armature/Hip/Torso/Arm_R/Elbow_R/Hand_R/Finger_Pinky_1_R"),
				((Component)player).transform.Find("RigCreator/Rig/Armature/Hip/Torso/Arm_R/Elbow_R/Hand_R/Finger_Pinky_1_R/Finger_Pinky_2_R"),
				((Component)player).transform.Find("RigCreator/Rig/Armature/Hip/Torso/Arm_R/Elbow_R/Hand_R/Finger_Pinky_1_R/Finger_Pinky_2_R/Finger_Pinky_3_R"),
				((Component)player).transform.Find("RigCreator/Rig/Armature/Hip/Torso/Arm_R/Elbow_R/Hand_R/Finger_Ring_1_R"),
				((Component)player).transform.Find("RigCreator/Rig/Armature/Hip/Torso/Arm_R/Elbow_R/Hand_R/Finger_Ring_1_R/Finger_Ring_2_R"),
				((Component)player).transform.Find("RigCreator/Rig/Armature/Hip/Torso/Arm_R/Elbow_R/Hand_R/Finger_Ring_1_R/Finger_Ring_2_R/Finger_Ring_3_R"),
				((Component)player).transform.Find("RigCreator/Rig/Armature/Hip/Torso/Arm_R/Elbow_R/Hand_R/Thumb_1_R"),
				((Component)player).transform.Find("RigCreator/Rig/Armature/Hip/Torso/Arm_R/Elbow_R/Hand_R/Thumb_1_R/Thumb_2_R"),
				((Component)player).transform.Find("RigCreator/Rig/Armature/Hip/Torso/Arm_R/Elbow_R/Hand_R/Thumb_1_R/Thumb_2_R/Thumb_3_R"),
				((Component)player).transform.Find("RigCreator/Rig/Armature/Hip/Torso/Head")
			};
			return list.ToArray();
		}
		List<Transform> list2 = new List<Transform>
		{
			((Component)player).transform.Find("RigCreator/Rig/Armature/Hip"),
			((Component)player).transform.Find("RigCreator/Rig/Armature/Extra_1"),
			((Component)player).transform.Find("RigCreator/Rig/Armature/Leg_L"),
			((Component)player).transform.Find("RigCreator/Rig/Armature/Knee_L"),
			((Component)player).transform.Find("RigCreator/Rig/Armature/Foot_L"),
			((Component)player).transform.Find("RigCreator/Rig/Armature/Leg_R"),
			((Component)player).transform.Find("RigCreator/Rig/Armature/Knee_R"),
			((Component)player).transform.Find("RigCreator/Rig/Armature/Foot_R"),
			((Component)player).transform.Find("RigCreator/Rig/Armature/Torso"),
			((Component)player).transform.Find("RigCreator/Rig/Armature/Arm_L"),
			((Component)player).transform.Find("RigCreator/Rig/Armature/Elbow_L"),
			((Component)player).transform.Find("RigCreator/Rig/Armature/Hand_L"),
			((Component)player).transform.Find("RigCreator/Rig/Armature/Hand_L/Finger_Index_1_L"),
			((Component)player).transform.Find("RigCreator/Rig/Armature/Hand_L/Finger_Index_1_L/Finger_Index_2_L"),
			((Component)player).transform.Find("RigCreator/Rig/Armature/Hand_L/Finger_Index_1_L/Finger_Index_2_L/Finger_Index_3_L"),
			((Component)player).transform.Find("RigCreator/Rig/Armature/Hand_L/Finger_Middle_1_L"),
			((Component)player).transform.Find("RigCreator/Rig/Armature/Hand_L/Finger_Middle_1_L/Finger_Middle_2_L"),
			((Component)player).transform.Find("RigCreator/Rig/Armature/Hand_L/Finger_Middle_1_L/Finger_Middle_2_L/Finger_Middle_3_L"),
			((Component)player).transform.Find("RigCreator/Rig/Armature/Hand_L/Finger_Pinky_1_L"),
			((Component)player).transform.Find("RigCreator/Rig/Armature/Hand_L/Finger_Pinky_1_L/Finger_Pinky_2_L"),
			((Component)player).transform.Find("RigCreator/Rig/Armature/Hand_L/Finger_Pinky_1_L/Finger_Pinky_2_L/Finger_Pinky_3_L"),
			((Component)player).transform.Find("RigCreator/Rig/Armature/Hand_L/Finger_Ring_1_L"),
			((Component)player).transform.Find("RigCreator/Rig/Armature/Hand_L/Finger_Ring_1_L/Finger_Ring_2_L"),
			((Component)player).transform.Find("RigCreator/Rig/Armature/Hand_L/Finger_Ring_1_L/Finger_Ring_2_L/Finger_Ring_3_L"),
			((Component)player).transform.Find("RigCreator/Rig/Armature/Hand_L/Thumb_L_1"),
			((Component)player).transform.Find("RigCreator/Rig/Armature/Hand_L/Thumb_L_1/Thumb_L_2"),
			((Component)player).transform.Find("RigCreator/Rig/Armature/Hand_L/Thumb_L_1/Thumb_L_2/Thumb_L_3"),
			((Component)player).transform.Find("RigCreator/Rig/Armature/Arm_R"),
			((Component)player).transform.Find("RigCreator/Rig/Armature/Elbow_R"),
			((Component)player).transform.Find("RigCreator/Rig/Armature/Hand_R"),
			((Component)player).transform.Find("RigCreator/Rig/Armature/Hand_R/Finger_Index_1_R"),
			((Component)player).transform.Find("RigCreator/Rig/Armature/Hand_R/Finger_Index_1_R/Finger_Index_2_R"),
			((Component)player).transform.Find("RigCreator/Rig/Armature/Hand_R/Finger_Index_1_R/Finger_Index_2_R/Finger_Index_3_R"),
			((Component)player).transform.Find("RigCreator/Rig/Armature/Hand_R/Finger_Middle_1_R"),
			((Component)player).transform.Find("RigCreator/Rig/Armature/Hand_R/Finger_Middle_1_R/Finger_Middle_2_R"),
			((Component)player).transform.Find("RigCreator/Rig/Armature/Hand_R/Finger_Middle_1_R/Finger_Middle_2_R/Finger_Middle_3_R"),
			((Component)player).transform.Find("RigCreator/Rig/Armature/Hand_R/Finger_Pinky_1_R"),
			((Component)player).transform.Find("RigCreator/Rig/Armature/Hand_R/Finger_Pinky_1_R/Finger_Pinky_2_R"),
			((Component)player).transform.Find("RigCreator/Rig/Armature/Hand_R/Finger_Pinky_1_R/Finger_Pinky_2_R/Finger_Pinky_3_R"),
			((Component)player).transform.Find("RigCreator/Rig/Armature/Hand_R/Finger_Ring_1_R"),
			((Component)player).transform.Find("RigCreator/Rig/Armature/Hand_R/Finger_Ring_1_R/Finger_Ring_2_R"),
			((Component)player).transform.Find("RigCreator/Rig/Armature/Hand_R/Finger_Ring_1_R/Finger_Ring_2_R/Finger_Ring_3_R"),
			((Component)player).transform.Find("RigCreator/Rig/Armature/Hand_R/Thumb_1_R"),
			((Component)player).transform.Find("RigCreator/Rig/Armature/Hand_R/Thumb_1_R/Thumb_2_R"),
			((Component)player).transform.Find("RigCreator/Rig/Armature/Hand_R/Thumb_1_R/Thumb_2_R/Thumb_3_R"),
			((Component)player).transform.Find("RigCreator/Rig/Armature/Head")
		};
		return list2.ToArray();
	}

	private static bool HasAnyNullTransforms(Transform[] transforms)
	{
		if (transforms == null)
		{
			return true;
		}
		for (int i = 0; i < transforms.Length; i++)
		{
			if ((Object)(object)transforms[i] == (Object)null)
			{
				return true;
			}
		}
		return false;
	}

	private void SpawnGlowingVest(int slot, Player player)
	{
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00db: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_023a: Unknown result type (might be due to invalid IL or missing references)
		//IL_025a: Unknown result type (might be due to invalid IL or missing references)
		//IL_029f: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_0304: Unknown result type (might be due to invalid IL or missing references)
		//IL_0324: Unknown result type (might be due to invalid IL or missing references)
		Transform obj = ((Component)player).gameObject.transform.Find("CharacterModel/BodyRenderer");
		SkinnedMeshRenderer val = ((obj != null) ? ((Component)obj).GetComponent<SkinnedMeshRenderer>() : null);
		GameObject glowingVestPrefab = CustomItems.GlowingVestPrefab;
		GameObject smallLightBeamPrefab = CustomItems.SmallLightBeamPrefab;
		if ((Object)(object)val == (Object)null)
		{
			Logger.LogError("[EquipableInventory] playerBodyRenderer missing for SpawnGlowingVest.");
			return;
		}
		if ((Object)(object)smallLightBeamPrefab == (Object)null)
		{
			Logger.LogError("[EquipableInventory] lightPrefab missing for SpawnGlowingVest.");
			return;
		}
		if ((Object)(object)glowingVestPrefab == (Object)null)
		{
			Logger.LogError("[EquipableInventory] prefab missing for SpawnGlowingVest.");
			return;
		}
		Transform[] playerRigTransformsAsExpectedByDbExportedFbx = getPlayerRigTransformsAsExpectedByDbExportedFbx(player);
		if (HasAnyNullTransforms(playerRigTransformsAsExpectedByDbExportedFbx))
		{
			Logger.LogError("[EquipableInventory] Rig not ready yet; do not register a visual so we retry next frame.");
			return;
		}
		Transform val2 = ((Component)player).gameObject.transform.Find("CharacterModel");
		GameObject val3 = Object.Instantiate<GameObject>(glowingVestPrefab, val2);
		val3.transform.localPosition = new Vector3(0f, 8f, 0.07f);
		val3.transform.localRotation = Quaternion.Euler(0f, 0f, 0f);
		val3.transform.localScale = new Vector3(4.47f, 4.47f, 4.47f);
		SkinnedMeshRenderer componentInChildren = val3.GetComponentInChildren<SkinnedMeshRenderer>(true);
		componentInChildren.bones = playerRigTransformsAsExpectedByDbExportedFbx;
		componentInChildren.rootBone = val.rootBone;
		ObjectHelper.FixShadersForCurrentScene(val3);
		Transform val4 = player.refs.rigRoot.transform.Find("Rig/Armature/Hip");
		Transform val5 = ((!((Object)(object)player == (Object)(object)Player.localPlayer)) ? player.refs.rigRoot.transform.Find("Rig/Armature/Torso") : player.refs.rigRoot.transform.Find("Rig/Armature/Hip/Torso"));
		if ((Object)(object)val4 == (Object)null || (Object)(object)val5 == (Object)null)
		{
			Logger.LogError("[EquipableInventory] Could not find CharacterModel/Armature/Hip or CharacterModel/Armature/Hip/Torso.");
			return;
		}
		GameObject val6 = Object.Instantiate<GameObject>(smallLightBeamPrefab, val4);
		val6.SetActive(true);
		val6.transform.localPosition = new Vector3(0.869f, 1.582f, 1.507f);
		val6.transform.localRotation = Quaternion.Euler(10f, 20f, 0f);
		spawnedVisuals[slot].Add(val6);
		GameObject val7 = Object.Instantiate<GameObject>(smallLightBeamPrefab, val4);
		val7.SetActive(true);
		val7.transform.localPosition = new Vector3(-0.784f, 1.561f, 1.55f);
		val7.transform.localRotation = Quaternion.Euler(10f, -20f, 0f);
		spawnedVisuals[slot].Add(val7);
		GameObject val8 = Object.Instantiate<GameObject>(smallLightBeamPrefab, val5);
		val8.SetActive(true);
		val8.transform.localPosition = new Vector3(0.659f, 0.259f, 1.64f);
		val8.transform.localRotation = Quaternion.Euler(-10f, 20f, 0f);
		spawnedVisuals[slot].Add(val8);
		GameObject val9 = Object.Instantiate<GameObject>(smallLightBeamPrefab, val5);
		val9.SetActive(true);
		val9.transform.localPosition = new Vector3(-0.796f, 0.259f, 1.616f);
		val9.transform.localRotation = Quaternion.Euler(-10f, -20f, 0f);
		spawnedVisuals[slot].Add(val9);
		Transform val10 = ((Component)player).transform.Find("RigCreator/Rig/Armature/Hip");
		if ((Object)(object)val10 != (Object)null)
		{
			GameObject val11 = ObjectHelper.CreateAttachedTriggerObject(DbsContentApiPlugin.TemporaryContentTriggerPrefab, val10, -1);
			GlowingVestContentProvider glowingVestContentProvider = val11.AddComponent<GlowingVestContentProvider>();
			glowingVestContentProvider.playerName = player.refs.view.Owner.NickName;
			glowingVestContentProvider.actorNumber = player.refs.view.Owner.ActorNumber;
			spawnedVisuals[slot].Add(val11);
		}
		spawnedVisuals[slot].Add(val3);
	}

	private void VerifyBones(Transform[] originalCustomItemBones, Transform[] rearrangedCustomItemBones, Transform[] playerBones)
	{
		bool flag = false;
		if (rearrangedCustomItemBones.Length != playerBones.Length)
		{
			Logger.LogError("[EquipableInventory] Custom item bones length does not match player bones length.");
			Logger.LogError("[EquipableInventory] Custom item bones length: " + rearrangedCustomItemBones.Length + " Player bones length: " + playerBones.Length);
			flag = true;
		}
		for (int i = 0; i < originalCustomItemBones.Length; i++)
		{
			Logger.Log("[EquipableInventory] Custom item bone " + i + " name: " + ((Object)originalCustomItemBones[i]).name);
		}
		for (int j = 0; j < playerBones.Length; j++)
		{
			Logger.Log("[EquipableInventory] Player bone " + j + " name: " + ((Object)playerBones[j]).name);
		}
		if (flag)
		{
			Logger.LogError("[EquipableInventory] Custom item bones do not match player bones.");
		}
	}

	private void SpawnFroggyBoot(int slot, Player player)
	{
		//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0102: Unknown result type (might be due to invalid IL or missing references)
		//IL_015f: Unknown result type (might be due to invalid IL or missing references)
		//IL_017f: Unknown result type (might be due to invalid IL or missing references)
		//IL_019f: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)CustomItems.FroggyBootRightPrefab == (Object)null) && !((Object)(object)CustomItems.FroggyBootLeftPrefab == (Object)null))
		{
			Transform val;
			Transform val2;
			if ((Object)(object)player == (Object)(object)Player.localPlayer)
			{
				val = player.refs.rigRoot.transform.Find("Rig/Armature/Hip/Leg_R/Knee_R/Foot_R");
				val2 = player.refs.rigRoot.transform.Find("Rig/Armature/Hip/Leg_L/Knee_L/Foot_L");
			}
			else
			{
				val = player.refs.rigRoot.transform.Find("Rig/Armature/Foot_R");
				val2 = player.refs.rigRoot.transform.Find("Rig/Armature/Foot_L");
			}
			if ((Object)(object)val != (Object)null)
			{
				GameObject val3 = Object.Instantiate<GameObject>(CustomItems.FroggyBootRightPrefab, val);
				val3.transform.localPosition = new Vector3(0.5087553f, 0.7142437f, 0.01682295f);
				val3.transform.localRotation = Quaternion.Euler(-90f, 0f, -90f);
				val3.transform.localScale = new Vector3(2.398091f, 2.398091f, 2.398091f);
				spawnedVisuals[slot].Add(val3);
				ObjectHelper.FixShadersForCurrentScene(val3);
			}
			else
			{
				Logger.LogError("[EquipableInventory] Could not find Foot_R bone for Froggy Boot attachment.");
			}
			if ((Object)(object)val2 != (Object)null)
			{
				GameObject val4 = Object.Instantiate<GameObject>(CustomItems.FroggyBootLeftPrefab, val2);
				val4.transform.localPosition = new Vector3(0.5087553f, 0.7142437f, -0.07f);
				val4.transform.localRotation = Quaternion.Euler(-90f, 0f, -90f);
				val4.transform.localScale = new Vector3(2.398091f, 2.398091f, 2.398091f);
				spawnedVisuals[slot].Add(val4);
				ObjectHelper.FixShadersForCurrentScene(val4);
			}
			else
			{
				Logger.LogError("[EquipableInventory] Could not find Foot_R bone for Froggy Boot attachment.");
			}
			Transform val5 = ((Component)player).transform.Find("RigCreator/Rig/Armature/Hip");
			if ((Object)(object)val5 != (Object)null)
			{
				GameObject val6 = ObjectHelper.CreateAttachedTriggerObject(DbsContentApiPlugin.TemporaryContentTriggerPrefab, val5, -1);
				FroggyBootsContentProvider froggyBootsContentProvider = val6.AddComponent<FroggyBootsContentProvider>();
				froggyBootsContentProvider.playerName = player.refs.view.Owner.NickName;
				froggyBootsContentProvider.actorNumber = player.refs.view.Owner.ActorNumber;
				spawnedVisuals[slot].Add(val6);
			}
		}
	}

	public void SetEquipable(int slot, byte itemID)
	{
		if (((MonoBehaviourPun)this).photonView.IsMine)
		{
			((MonoBehaviourPun)this).photonView.RPC("RPC_SyncEquipable", (RpcTarget)3, new object[2] { slot, itemID });
		}
	}

	[PunRPC]
	public void RPC_SyncEquipable(int slot, byte itemID)
	{
		if (slot >= 0 && slot < equipableIDs.Length)
		{
			equipableIDs[slot] = itemID;
			UpdateVisuals();
			Player player = GetPlayer();
			if ((Object)(object)player != (Object)null)
			{
				ExtendedPlayerData cache = PlayerCache.GetCache(player);
				cache.UpdateData();
			}
		}
	}

	public IEnumerator ClearAndDropOnDeathCoroutine()
	{
		Logger.Log("[EquipableInventory] Starting ClearAndDropOnDeathCoroutine for player.");
		yield return (object)new WaitForSeconds(3f);
		if (((MonoBehaviourPun)this).photonView.IsMine)
		{
			Player player = GetPlayer();
			if ((Object)(object)player == (Object)null)
			{
				Logger.LogError("[EquipableInventory] Could not find player in ClearAndDropOnDeathCoroutine.");
				yield break;
			}
			for (int i = 0; i < equipableIDs.Length; i++)
			{
				byte b = equipableIDs[i];
				if (b != byte.MaxValue)
				{
					Item itemByID = Items.GetItemByID(b);
					if ((Object)(object)itemByID != (Object)null)
					{
						player.RequestCreatePickup(itemByID, new ItemInstanceData(Guid.NewGuid()), player.Center(), Quaternion.identity);
						Logger.Log("[EquipableInventory] Dropping equipable item on death: " + ((Object)itemByID).name);
					}
					else
					{
						Logger.LogError("[EquipableInventory] Could not find Item component on equipable item.");
					}
					SetEquipable(i, byte.MaxValue);
					UpdateVisuals();
				}
				else
				{
					Logger.Log("[EquipableInventory] No equipable item found in slot " + i);
				}
			}
		}
		else
		{
			Logger.LogError("[EquipableInventory] View is not mine.");
		}
	}

	public void ClearOnDeath()
	{
		if (((MonoBehaviourPun)this).photonView.IsMine)
		{
			for (int i = 0; i < 2; i++)
			{
				SetEquipable(i, byte.MaxValue);
			}
		}
	}

	private void OnDestroy()
	{
		foreach (KeyValuePair<int, List<GameObject>> spawnedVisual in spawnedVisuals)
		{
			foreach (GameObject item in spawnedVisual.Value)
			{
				if ((Object)(object)item != (Object)null)
				{
					Object.Destroy((Object)(object)item);
				}
			}
		}
		spawnedVisuals.Clear();
	}

	public int GetFirstAvailableSlot()
	{
		for (int i = 0; i < equipableIDs.Length; i++)
		{
			if (equipableIDs[i] == byte.MaxValue)
			{
				return i;
			}
		}
		return -1;
	}

	public bool HasEquipable(byte itemID)
	{
		for (int i = 0; i < equipableIDs.Length; i++)
		{
			if (equipableIDs[i] == itemID)
			{
				return true;
			}
		}
		return false;
	}

	public int GetSlotForItem(byte itemID)
	{
		for (int i = 0; i < equipableIDs.Length; i++)
		{
			if (equipableIDs[i] == itemID)
			{
				return i;
			}
		}
		return -1;
	}

	public static bool PlayerHasEquipable(Player player, byte itemID)
	{
		PlayerInventory val = default(PlayerInventory);
		if (!player.TryGetInventory(ref val))
		{
			Logger.LogError("[EquipableInventory] Could not find Inventory component on player.");
			return false;
		}
		EquipableInventory component = ((Component)val).gameObject.GetComponent<EquipableInventory>();
		if ((Object)(object)component == (Object)null)
		{
			Logger.LogError("[EquipableInventory] Could not find EquipableInventory component on player.");
			return false;
		}
		return component.HasEquipable(itemID);
	}

	public static bool PlayerHasEquipableCached(Player player, byte itemID)
	{
		ExtendedPlayerData cache = PlayerCache.GetCache(player);
		if (cache == null)
		{
			Logger.LogError("[EquipableInventory] Could not find ExtendedData component on player.");
			return false;
		}
		return cache.PlayerHasEquipable(itemID);
	}
}
[HarmonyPatch]
public class EquipableInventoryPatches
{
	[HarmonyPatch(typeof(GlobalPlayerData), "Awake")]
	[HarmonyPostfix]
	private static void AddEquipableComp(GlobalPlayerData __instance)
	{
		if ((Object)(object)((Component)__instance).gameObject.GetComponent<EquipableInventory>() == (Object)null)
		{
			((Component)__instance).gameObject.AddComponent<EquipableInventory>();
		}
	}

	[HarmonyPatch(typeof(Player), "DelayDropItems")]
	[HarmonyPrefix]
	private static void OnPlayerDelayDropItems(Player __instance)
	{
		GlobalPlayerData val = default(GlobalPlayerData);
		if (GlobalPlayerData.TryGetPlayerData(__instance.refs.view.Owner, ref val))
		{
			EquipableInventory component = ((Component)val).GetComponent<EquipableInventory>();
			if ((Object)(object)component != (Object)null)
			{
				Logger.Log("[EquipableInventory] Starting ClearAndDropOnDeathCoroutine for player.");
				((MonoBehaviour)component).StartCoroutine(component.ClearAndDropOnDeathCoroutine());
			}
			else
			{
				Logger.LogError("[EquipableInventory] Could not find EquipableInventory component on player.");
			}
		}
		else
		{
			Logger.LogError("[EquipableInventory] Could not find PlayerData component on player.");
		}
	}

	[HarmonyPatch(typeof(Player), "Die")]
	[HarmonyPostfix]
	private static void OnPlayerDie(Player __instance)
	{
	}
}
public class GlowingVestEquipableItemBehaviour : EquipableItemBehaviour
{
}
public class BatBehaviour : ItemInstanceBehaviour
{
	private Player? player;

	private bool isSwinging;

	private Coroutine? currentSwingCoroutine;

	private HashSet<Player> hitPlayersThisSwing = new HashSet<Player>();

	public float swingForce = 3f;

	public float swingDuration = 0.6f;

	public float cooldownTime = 1.6f;

	public SFX_Instance batHitSFX;

	public bool isBreakable;

	public bool hasLimitedUses;

	public int maxUses = 10;

	private IntEntry? usesEntry;

	public override void ConfigItem(ItemInstanceData data, PhotonView playerView)
	{
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Expected O, but got Unknown
		player = ((Component)this).GetComponentInParent<Player>();
		base.itemInstance.RegisterRPC((ItemRPC)0, (Action<BinaryDeserializer>)RPC_Hit);
		base.itemInstance.RegisterRPC((ItemRPC)1, (Action<BinaryDeserializer>)RPC_StartSwing);
		if (hasLimitedUses)
		{
			if (!data.TryGetEntry<IntEntry>(ref usesEntry))
			{
				usesEntry = new IntEntry
				{
					i = maxUses
				};
				data.AddDataEntry((ItemDataEntry)(object)usesEntry);
			}
		}
		else
		{
			usesEntry = null;
		}
		hitPlayersThisSwing.Clear();
		if (currentSwingCoroutine != null)
		{
			((MonoBehaviour)this).StopCoroutine(currentSwingCoroutine);
			currentSwingCoroutine = null;
		}
		isSwinging = false;
	}

	private void RPC_StartSwing(BinaryDeserializer deserializer)
	{
		//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
		float num = deserializer.ReadFloat();
		float num2 = deserializer.ReadFloat();
		float num3 = deserializer.ReadFloat();
		float num4 = deserializer.ReadFloat();
		float num5 = deserializer.ReadFloat();
		float num6 = deserializer.ReadFloat();
		Vector3 forceDirection = default(Vector3);
		((Vector3)(ref forceDirection))..ctor(num, num2, num3);
		Vector3 lookDirection = default(Vector3);
		((Vector3)(ref lookDirection))..ctor(num4, num5, num6);
		Player componentInParent = ((Component)this).GetComponentInParent<Player>();
		if ((Object)(object)componentInParent == (Object)null || (Object)(object)componentInParent.refs?.ragdoll == (Object)null)
		{
			return;
		}
		Bodypart bodypart = componentInParent.refs.ragdoll.GetBodypart((BodypartType)10);
		Bodypart bodypart2 = componentInParent.refs.ragdoll.GetBodypart((BodypartType)9);
		Bodypart bodypart3 = componentInParent.refs.ragdoll.GetBodypart((BodypartType)8);
		if ((Object)(object)bodypart != (Object)null && (Object)(object)bodypart2 != (Object)null && (Object)(object)bodypart3 != (Object)null)
		{
			hitPlayersThisSwing.Clear();
			isSwinging = true;
			if (currentSwingCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(currentSwingCoroutine);
			}
			currentSwingCoroutine = ((MonoBehaviour)this).StartCoroutine(PerformSwingReplicated(componentInParent, bodypart, bodypart2, bodypart3, forceDirection, lookDirection));
		}
	}

	private void RPC_Hit(BinaryDeserializer deserializer)
	{
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
		int num = deserializer.ReadInt();
		float num2 = deserializer.ReadFloat();
		float num3 = deserializer.ReadFloat();
		float num4 = deserializer.ReadFloat();
		bool flag = deserializer.ReadBool();
		Vector3 val = default(Vector3);
		((Vector3)(ref val))..ctor(num2, num3, num4);
		PhotonView photonView = PhotonNetwork.GetPhotonView(num);
		if (!((Object)(object)photonView == (Object)null))
		{
			Player component = ((Component)photonView).GetComponent<Player>();
			Player componentInParent = ((Component)this).GetComponentInParent<Player>();
			if ((Object)(object)component?.refs?.ragdoll != (Object)null)
			{
				component.refs.ragdoll.TaseShock(3f);
				component.refs.ragdoll.AddForce(val * 20f, (ForceMode)2);
			}
			if (Object.op_Implicit((Object)(object)batHitSFX))
			{
				batHitSFX.Play(((Component)this).transform.position, false, 1f, (Transform)null);
			}
			if (isBreakable || flag)
			{
				BreakBat(componentInParent);
			}
		}
	}

	private void BreakBat(Player? holder)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		CreateBreakEffect(((Component)this).transform.position);
		if (base.isSimulatedByMe && (Object)(object)holder != (Object)null)
		{
			((MonoBehaviour)this).StartCoroutine(DestroyBatAfterHit(holder));
		}
	}

	private IEnumerator DestroyBatAfterHit(Player holder)
	{
		GlobalPlayerData val = default(GlobalPlayerData);
		if (GlobalPlayerData.TryGetPlayerData(holder.refs.view.Owner, ref val))
		{
			PlayerInventory inventory = val.inventory;
			InventorySlot val2 = default(InventorySlot);
			if ((Object)(object)inventory != (Object)null && holder.data.selectedItemSlot >= 0 && inventory.TryGetSlot(holder.data.selectedItemSlot, ref val2))
			{
				val2.Clear();
			}
		}
		yield return null;
		yield return null;
		if ((Object)(object)this != (Object)null && (Object)(object)((Component)this).gameObject != (Object)null)
		{
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}
	}

	private void Update()
	{
		if (!((Object)(object)player == (Object)null) && base.isHeldByMe && !player.HasLockedInput() && player.input.clickWasPressed && !isSwinging)
		{
			TriggerSwing();
		}
	}

	private void TriggerSwing()
	{
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: 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_0094: Unknown result type (might be due to invalid IL or missing references)
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_009b: Expected O, but got Unknown
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: 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_00c0: 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_00d8: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)player == (Object)null) && !((Object)(object)player.refs?.ragdoll == (Object)null) && !((Object)(object)player.refs?.headPos == (Object)null))
		{
			Vector3 forward = player.refs.headPos.forward;
			Vector3 val = player.refs.headPos.forward + Vector3.down * 0.95f;
			Vector3 normalized = ((Vector3)(ref val)).normalized;
			BinarySerializer val2 = new BinarySerializer();
			val2.WriteFloat(normalized.x);
			val2.WriteFloat(normalized.y);
			val2.WriteFloat(normalized.z);
			val2.WriteFloat(forward.x);
			val2.WriteFloat(forward.y);
			val2.WriteFloat(forward.z);
			base.itemInstance.CallRPC((ItemRPC)1, val2);
		}
	}

	private IEnumerator PerformSwingReplicated(Player holder, Bodypart hand, Bodypart elbow, Bodypart arm, Vector3 forceDirection, Vector3 lookDirection)
	{
		//IL_002b: 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)
		if ((Object)(object)holder == (Object)null || (Object)(object)hand ==