Decompiled source of DBs Content API v1.0.1

DbsContentApi.dll

Decompiled a day ago
using System;
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.Permissions;
using BepInEx;
using BepInEx.Logging;
using DbsContentApi.Modules;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using TMPro;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Events;
using Zorro.Core;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("DbsContentApi")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.0.0.0")]
[assembly: AssemblyInformationalVersion("0.0.0+d52117fdf22d10934c339ae253cc08fad5faa452")]
[assembly: AssemblyProduct("DbsContentApi")]
[assembly: AssemblyTitle("DbsContentApi")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace DbsContentApi
{
	[ContentWarningPlugin("db.contentapi", "1.0.1", false)]
	[BepInPlugin("db.contentapi", "DB's Content API", "1.0.1")]
	public class DbsContentApiPlugin : BaseUnityPlugin
	{
		public static List<GameObject> customMonsters = new List<GameObject>();

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

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

		public static bool moddedMobsOnly = false;

		public static bool allItemsFree = false;

		internal static Harmony? Harmony { get; set; }

		public static DbsContentApiPlugin Instance { get; private set; } = null;


		private void Awake()
		{
			Logger.Log("DbsContentApi API Initializing... [POST UPDATE]");
			Instance = this;
			Patch();
			GameMaterials.InitMaterials();
			Logger.Init(((BaseUnityPlugin)this).Logger);
			Logger.Log("DbsContentApi API Loaded successfully!");
		}

		internal static void Patch()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony = new Harmony("db.contentapi");
			}
			Logger.Log("Patching...");
			Harmony.PatchAll();
			Logger.Log("Finished patching!");
		}

		internal static void Unpatch()
		{
			Logger.Log("Unpatching...");
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			Logger.Log("Finished unpatching!");
		}

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

		public static void SetAllItemsFree(bool value)
		{
			allItemsFree = value;
		}
	}
	public class MyPluginInfo
	{
		public const string PLUGIN_GUID = "db.contentapi";

		public const string PLUGIN_NAME = "DB's Content API";

		public const string PLUGIN_VERSION = "1.0.1";

		public const bool VANILLA_COMPATIBLE = false;
	}
}
namespace DbsContentApi.Patches
{
	[HarmonyPatch(typeof(ShopViewScreen))]
	public static class ItemCategoriesPatch
	{
		[HarmonyPatch("DrawCategories")]
		[HarmonyPrefix]
		private static bool DrawCategoriesPatch(ShopViewScreen __instance)
		{
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			Logger.Log("ItemCategoriesPatch: Registering custom categories.");
			__instance.ResetScreenIndex();
			__instance.DestroyCategoryGrid();
			ShopItemCategory[] first = (ShopItemCategory[])Enum.GetValues(typeof(ShopItemCategory));
			first = first.Concat(Items.customCategories.Select((CustomShopItemCategory c) => (ShopItemCategory)c.index)).ToArray();
			ShopItemCategory[] array = first;
			foreach (ShopItemCategory val in array)
			{
				if ((int)val != 0 && !__instance.excludeCategories.Contains(val))
				{
					__instance.SpawnCategoryCell(val);
				}
			}
			return false;
		}

		[HarmonyPatch("UpdateViewScreen")]
		[HarmonyPostfix]
		private static void UpdateViewScreenPostfix(ShopViewScreen __instance)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Invalid comparison between Unknown and I4
			foreach (CustomShopItemCategory customCategory in Items.customCategories)
			{
				if ((int)__instance.CurrentCategoryIndex == customCategory.index)
				{
					((TMP_Text)__instance.m_CurrentCategoryNameText).text = customCategory.name;
				}
			}
		}
	}
	[HarmonyPatch(typeof(ShopInteractibleCategory))]
	public static class ShopInteractibleCategoryPatch
	{
		[HarmonyPatch("Setup")]
		[HarmonyPrefix]
		private static bool SetupPrefix(ShopInteractibleCategory __instance, ShopHandler handler, ShopItemCategory category)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Invalid comparison between Unknown and I4
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			foreach (CustomShopItemCategory customCategory in Items.customCategories)
			{
				if ((int)category == customCategory.index)
				{
					ShopInteractibleCategory.m_ShopHandler = handler;
					__instance.m_Category = category;
					((Interactable)__instance).hoverText = customCategory.name;
					((TMP_Text)__instance.m_CategoryText).text = customCategory.name;
					return false;
				}
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(ShopViewScreen))]
	public static class ShopViewScreenPatch
	{
		public static bool isRegistered;

		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		private static void AwakePatch(ShopViewScreen __instance)
		{
			if (!isRegistered)
			{
				isRegistered = true;
				Logger.Log("RegisterItemsPatch: Registering custom items.");
				DbsContentApiPlugin.customItemsRegistrationCallbacks.ForEach(delegate(Action callback)
				{
					callback();
				});
				if (DbsContentApiPlugin.allItemsFree)
				{
					Logger.Log("RegisterItemsPatch: Setting all items free.");
					Items.SetAllItemsFree();
				}
			}
		}
	}
	[HarmonyPatch(typeof(RoundSpawner))]
	public static class RoundSpawnerPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPrefix]
		public static void StartPrefix(RoundSpawner __instance)
		{
			Logger.Log("RoundSpawnerPatch: Registering custom monsters in Photon pool.");
			Logger.Log("RoundSpawnerPatch: Modded mobs only: " + DbsContentApiPlugin.moddedMobsOnly);
			Logger.Log("RoundSpawnerPatch: Custom monsters: " + DbsContentApiPlugin.customMonsters.Count);
			foreach (GameObject customMonster in DbsContentApiPlugin.customMonsters)
			{
				Logger.Log("RoundSpawnerPatch: Registering custom monster: " + ((Object)customMonster).name);
				ContentLoader.RegisterPrefabInPhotonPool(customMonster);
			}
			if (PhotonNetwork.IsMasterClient)
			{
				Traverse val = Traverse.Create((object)__instance);
				Traverse<GameObject[]> val2 = val.Field<GameObject[]>("possibleSpawns");
				if (DbsContentApiPlugin.moddedMobsOnly)
				{
					val2.Value = DbsContentApiPlugin.customMonsters.ToArray();
					Logger.Log("RoundSpawnerPatch: Modded mobs only: " + val2.Value.Length);
				}
				else
				{
					val2.Value = val2.Value.Concat(DbsContentApiPlugin.customMonsters).ToArray();
				}
			}
		}
	}
}
namespace DbsContentApi.Modules
{
	public class ContentEvents
	{
		public static void RegisterEvent(ContentEvent contentEvent)
		{
			Logger.Log("Registering content event for " + contentEvent.GetName());
			DbsContentApiPlugin.customContentEvents.Add(contentEvent);
		}

		public static ushort GetEventID(string contentEventName)
		{
			string contentEventName2 = contentEventName;
			List<ContentEvent> customContentEvents = DbsContentApiPlugin.customContentEvents;
			Logger.Log(customContentEvents.Count.ToString());
			int num = customContentEvents.FindIndex((ContentEvent match) => ((object)match).GetType().Name == contentEventName2);
			if (num == -1)
			{
				for (int i = 0; i < customContentEvents.Count; i++)
				{
					Logger.Log($"{((object)customContentEvents[i]).GetType().Name}, {contentEventName2}, {((object)customContentEvents[i]).GetType().Name == contentEventName2}");
				}
				Logger.Log("GetEventID for " + contentEventName2 + " returned -1");
			}
			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;
			Logger.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(PluginInfo pluginInfo, string bundleName)
		{
			string text = Path.Combine(Path.GetDirectoryName(pluginInfo.Location), bundleName);
			AssetBundle val = AssetBundle.LoadFromFile(text);
			if ((Object)(object)val == (Object)null)
			{
				throw new Exception("Failed to load AssetBundle: " + bundleName + " at path: " + text);
			}
			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 enum GameMaterialType
	{
		M_World,
		M_World_Local,
		Lit,
		M_Player,
		M_Player_1,
		M_Monster,
		M_Monster_Red,
		M_Monster_Black,
		M_Monster_Harpoon,
		M_Ghost,
		M_Ghost_Teeth,
		M_Slurp,
		M_Snatcho,
		M_Witch,
		M_Propeller,
		M_Eye,
		M_MonsterEye,
		M_MonsterSkinnyEye,
		M_PlayerVisor,
		M_VFX_Fire,
		M_VFX_BombFuze,
		M_VFX_Tentacle,
		M_VFX_ShockStick,
		M_DistrorionParticle,
		M_DefaultParticle,
		ParticlesUnlit,
		M_Splash,
		M_Gas,
		M_Goop,
		M_Laser,
		M_FlashBeam,
		M_FlashBeamRed,
		M_Light_Bright,
		M_BatteryLight_Off,
		M_Flashlight_Bright,
		M_Flashlight_1_1,
		M_Flashlight_1_2,
		M_Flashlight_Off,
		M_OxygenDisplay,
		LiberationSans_SDF,
		Rajdhani_Regular_SDF,
		AkzidenzGroteskPro_Bold_SDF,
		AkzidenzGroteskPro_Light_SDF,
		M_Cursor,
		M_Screen,
		M_VideoDisplayScreen,
		M_Cinema_1,
		M_Cinema_2,
		M_GreenScreen_1,
		M_GreenScreen_2,
		M_GreenScreen_3,
		M_Balaclava,
		M_Beanie_1,
		M_Bucket_1,
		M_Cap_1,
		M_Chef_1,
		M_Child_1,
		M_Child_2,
		M_Child_3,
		M_Child_4,
		M_Child_5,
		M_Clown_1,
		M_Clown_2,
		M_Cowboy,
		M_Crown,
		M_Ears_1,
		M_Ears_2,
		M_Ears_3,
		M_Floppy_1,
		M_Foodora,
		M_Hair_1,
		M_Halo,
		M_Horn,
		M_Hotdog_1,
		M_Hotdog_2,
		M_Hotdog_3,
		M_Hotdog_4,
		M_Jester_1,
		M_Jester_2,
		M_Jester_3,
		M_Jester_4,
		M_Knifo,
		M_Milk1,
		M_Milk2,
		M_News1,
		M_News2,
		M_Party_1,
		M_Party_2,
		M_Pirate_1,
		M_Pirate_2,
		M_Pirate_3,
		M_PlayerHatColor,
		M_Rugby_1,
		M_Rugby_2,
		M_Rugby_3,
		M_Shroom_1,
		M_Shroom_2,
		M_Top,
		M_Ushanka_1,
		M_Ushanka_2,
		M_Bowler,
		M_Metal,
		M_Book_1,
		M_Book_2,
		M_Interior_7,
		M_Crane,
		M_Pool_4,
		M_Pool_6,
		M_Pool_7,
		M_Pool_8,
		M_BrightRed,
		M_BrightRed_Chill,
		M_DarkBlack,
		M_HatShop_1,
		M_HatShop_2,
		M_HatShop_3,
		M_HatShop_4,
		M_HatShop_5,
		M_HatShop_6,
		M_HatShop_7,
		M_HatShop_8,
		M_ShopGlass,
		M_House_Glas,
		M_Copyright,
		M_Copyright_1,
		M_Rug_1,
		M_Rug_3,
		M_Rug_4,
		M_Rug_5,
		M_Rug_6,
		M_SkyNice,
		M_Podcast_2,
		M_Podcast_4,
		M_Projector_1,
		M_Projector_2,
		M_Projector_3,
		M_Projector_4,
		M_Projector_5,
		M_ShockStick_1,
		M_ShockStick_2,
		M_StreamerCamera,
		Material_004,
		Material_005,
		Material_010,
		Material_011,
		Material_012,
		M_Debug
	}
	public class GameMaterials
	{
		public static Dictionary<GameMaterialType, Material> Materials = new Dictionary<GameMaterialType, Material>();

		private static readonly Dictionary<string, Dictionary<string, GameMaterialType>> PrefabExtractionMap = new Dictionary<string, Dictionary<string, GameMaterialType>>
		{
			{
				"Hatshop",
				new Dictionary<string, GameMaterialType>
				{
					{
						"M_HatShop 1",
						GameMaterialType.M_HatShop_1
					},
					{
						"M_HatShop 2",
						GameMaterialType.M_HatShop_2
					},
					{
						"M_HatShop 3",
						GameMaterialType.M_HatShop_3
					},
					{
						"M_HatShop 4",
						GameMaterialType.M_HatShop_4
					},
					{
						"M_HatShop 5",
						GameMaterialType.M_HatShop_5
					},
					{
						"M_HatShop 6",
						GameMaterialType.M_HatShop_6
					},
					{
						"M_HatShop 7",
						GameMaterialType.M_HatShop_7
					},
					{
						"M_HatShop 8",
						GameMaterialType.M_HatShop_8
					},
					{
						"M_ShopGlass",
						GameMaterialType.M_ShopGlass
					},
					{
						"M_House Glas",
						GameMaterialType.M_House_Glas
					},
					{
						"M_Balaclava",
						GameMaterialType.M_Balaclava
					},
					{
						"M_Beanie 1",
						GameMaterialType.M_Beanie_1
					},
					{
						"M_Bucket 1",
						GameMaterialType.M_Bucket_1
					},
					{
						"M_Chef 1",
						GameMaterialType.M_Chef_1
					},
					{
						"M_Floppy 1",
						GameMaterialType.M_Floppy_1
					},
					{
						"M_PlayerHatColor",
						GameMaterialType.M_PlayerHatColor
					},
					{
						"M_Foodora",
						GameMaterialType.M_Foodora
					},
					{
						"M_Hair 1",
						GameMaterialType.M_Hair_1
					},
					{
						"M_Party 1",
						GameMaterialType.M_Party_1
					},
					{
						"M_Party 2",
						GameMaterialType.M_Party_2
					},
					{
						"M_Shroom 1",
						GameMaterialType.M_Shroom_1
					},
					{
						"M_Shroom 2",
						GameMaterialType.M_Shroom_2
					},
					{
						"M_Ushanka 1",
						GameMaterialType.M_Ushanka_1
					},
					{
						"M_Ushanka 2",
						GameMaterialType.M_Ushanka_2
					},
					{
						"M_Witch",
						GameMaterialType.M_Witch
					},
					{
						"M_Bowler",
						GameMaterialType.M_Bowler
					},
					{
						"M_Cowboy",
						GameMaterialType.M_Cowboy
					},
					{
						"M_Crown",
						GameMaterialType.M_Crown
					},
					{
						"M_Knifo",
						GameMaterialType.M_Knifo
					},
					{
						"M_Milk1",
						GameMaterialType.M_Milk1
					},
					{
						"M_Milk2",
						GameMaterialType.M_Milk2
					},
					{
						"M_News1",
						GameMaterialType.M_News1
					},
					{
						"M_News2",
						GameMaterialType.M_News2
					},
					{
						"M_Top",
						GameMaterialType.M_Top
					},
					{
						"M_Halo",
						GameMaterialType.M_Halo
					},
					{
						"M_Horn",
						GameMaterialType.M_Horn
					},
					{
						"M_Laser",
						GameMaterialType.M_Laser
					},
					{
						"M_Ears 1",
						GameMaterialType.M_Ears_1
					},
					{
						"M_Ears 2",
						GameMaterialType.M_Ears_2
					},
					{
						"M_Ears 3",
						GameMaterialType.M_Ears_3
					},
					{
						"M_Rug 1",
						GameMaterialType.M_Rug_1
					},
					{
						"M_Rug 3",
						GameMaterialType.M_Rug_3
					},
					{
						"M_Rug 4",
						GameMaterialType.M_Rug_4
					},
					{
						"M_Rug 5",
						GameMaterialType.M_Rug_5
					},
					{
						"M_Rug 6",
						GameMaterialType.M_Rug_6
					},
					{
						"AkzidenzGroteskPro-Bold SDF Material",
						GameMaterialType.AkzidenzGroteskPro_Bold_SDF
					},
					{
						"AkzidenzGroteskPro-Light SDF Material",
						GameMaterialType.AkzidenzGroteskPro_Light_SDF
					},
					{
						"M_Child 1",
						GameMaterialType.M_Child_1
					},
					{
						"M_Child 2",
						GameMaterialType.M_Child_2
					},
					{
						"M_Child 3",
						GameMaterialType.M_Child_3
					},
					{
						"M_Child 4",
						GameMaterialType.M_Child_4
					},
					{
						"M_Child 5",
						GameMaterialType.M_Child_5
					},
					{
						"M_Pirate 1",
						GameMaterialType.M_Pirate_1
					},
					{
						"M_Pirate 2",
						GameMaterialType.M_Pirate_2
					},
					{
						"M_Pirate 3",
						GameMaterialType.M_Pirate_3
					},
					{
						"M_Jester 1",
						GameMaterialType.M_Jester_1
					},
					{
						"M_Jester 2",
						GameMaterialType.M_Jester_2
					},
					{
						"M_Jester 3",
						GameMaterialType.M_Jester_3
					},
					{
						"M_Jester 4",
						GameMaterialType.M_Jester_4
					},
					{
						"M_Clown 1",
						GameMaterialType.M_Clown_1
					},
					{
						"M_Clown 2",
						GameMaterialType.M_Clown_2
					},
					{
						"M_Hotdog 1",
						GameMaterialType.M_Hotdog_1
					},
					{
						"M_Hotdog 2",
						GameMaterialType.M_Hotdog_2
					},
					{
						"M_Hotdog 3",
						GameMaterialType.M_Hotdog_3
					},
					{
						"M_Hotdog 4",
						GameMaterialType.M_Hotdog_4
					},
					{
						"M_Rugby 1",
						GameMaterialType.M_Rugby_1
					},
					{
						"M_Rugby 2",
						GameMaterialType.M_Rugby_2
					},
					{
						"M_Rugby 3",
						GameMaterialType.M_Rugby_3
					},
					{
						"M_Copyright",
						GameMaterialType.M_Copyright
					},
					{
						"M_Copyright 1",
						GameMaterialType.M_Copyright_1
					},
					{
						"M_Cap 1",
						GameMaterialType.M_Cap_1
					},
					{
						"Material.004",
						GameMaterialType.Material_004
					},
					{
						"Material.011",
						GameMaterialType.Material_011
					},
					{
						"Material.012",
						GameMaterialType.Material_012
					}
				}
			},
			{
				"AnglerMimic",
				new Dictionary<string, GameMaterialType>
				{
					{
						"M_Player",
						GameMaterialType.M_Player
					},
					{
						"M_Player 1",
						GameMaterialType.M_Player_1
					},
					{
						"M_PlayerVisor",
						GameMaterialType.M_PlayerVisor
					},
					{
						"M_FlashBeam",
						GameMaterialType.M_FlashBeam
					},
					{
						"M_Metal",
						GameMaterialType.M_Metal
					},
					{
						"M_Eye",
						GameMaterialType.M_Eye
					},
					{
						"LiberationSans SDF Material",
						GameMaterialType.LiberationSans_SDF
					}
				}
			},
			{
				"Projector",
				new Dictionary<string, GameMaterialType>
				{
					{
						"M_Projector 1",
						GameMaterialType.M_Projector_1
					},
					{
						"M_Projector 2",
						GameMaterialType.M_Projector_2
					},
					{
						"M_Projector 3",
						GameMaterialType.M_Projector_3
					},
					{
						"M_Projector 4",
						GameMaterialType.M_Projector_4
					},
					{
						"M_Projector 5",
						GameMaterialType.M_Projector_5
					},
					{
						"M_GreenScreen 1",
						GameMaterialType.M_GreenScreen_1
					},
					{
						"M_GreenScreen 2",
						GameMaterialType.M_GreenScreen_2
					},
					{
						"M_GreenScreen 3",
						GameMaterialType.M_GreenScreen_3
					}
				}
			},
			{
				"CinemaScreen",
				new Dictionary<string, GameMaterialType>
				{
					{
						"M_Cinema 1",
						GameMaterialType.M_Cinema_1
					},
					{
						"M_Cinema 2",
						GameMaterialType.M_Cinema_2
					},
					{
						"M_Crane",
						GameMaterialType.M_Crane
					},
					{
						"M_Screen",
						GameMaterialType.M_Screen
					},
					{
						"M_VideoDisplayScreen",
						GameMaterialType.M_VideoDisplayScreen
					},
					{
						"M_Cursor",
						GameMaterialType.M_Cursor
					}
				}
			},
			{
				"Streamer",
				new Dictionary<string, GameMaterialType>
				{
					{
						"M_ShockStick 1",
						GameMaterialType.M_ShockStick_1
					},
					{
						"M_ShockStick 2",
						GameMaterialType.M_ShockStick_2
					},
					{
						"M_VFX_ShockStick",
						GameMaterialType.M_VFX_ShockStick
					},
					{
						"M_StreamerCamera",
						GameMaterialType.M_StreamerCamera
					},
					{
						"M_Light_Bright",
						GameMaterialType.M_Light_Bright
					},
					{
						"Material.010",
						GameMaterialType.Material_010
					}
				}
			},
			{
				"AnglerMimic2",
				new Dictionary<string, GameMaterialType>
				{
					{
						"M_Flashlight 1 1",
						GameMaterialType.M_Flashlight_1_1
					},
					{
						"M_Flashlight 1 2",
						GameMaterialType.M_Flashlight_1_2
					},
					{
						"M_Flashlight Off",
						GameMaterialType.M_Flashlight_Off
					},
					{
						"M_Flashlight Bright",
						GameMaterialType.M_Flashlight_Bright
					},
					{
						"M_BatteryLight_Off",
						GameMaterialType.M_BatteryLight_Off
					}
				}
			},
			{
				"Fire",
				new Dictionary<string, GameMaterialType>
				{
					{
						"M_Monster",
						GameMaterialType.M_Monster
					},
					{
						"M_VFX_Fire",
						GameMaterialType.M_VFX_Fire
					},
					{
						"M_Debug",
						GameMaterialType.M_Debug
					}
				}
			},
			{
				"Harpooner",
				new Dictionary<string, GameMaterialType>
				{
					{
						"M_Monster_Harpoon",
						GameMaterialType.M_Monster_Harpoon
					},
					{
						"M_DarkBlack",
						GameMaterialType.M_DarkBlack
					},
					{
						"Material.005",
						GameMaterialType.Material_005
					}
				}
			},
			{
				"Ghost",
				new Dictionary<string, GameMaterialType>
				{
					{
						"M_Ghost",
						GameMaterialType.M_Ghost
					},
					{
						"M_Ghost_Teeth",
						GameMaterialType.M_Ghost_Teeth
					}
				}
			},
			{
				"Flicker",
				new Dictionary<string, GameMaterialType>
				{
					{
						"M_VFX_Tentacle",
						GameMaterialType.M_VFX_Tentacle
					},
					{
						"M_MonsterSkinnyEye",
						GameMaterialType.M_MonsterSkinnyEye
					}
				}
			},
			{
				"EyeGuy",
				new Dictionary<string, GameMaterialType> { 
				{
					"M_MonsterEye",
					GameMaterialType.M_MonsterEye
				} }
			},
			{
				"Snatcho",
				new Dictionary<string, GameMaterialType> { 
				{
					"M_Snatcho",
					GameMaterialType.M_Snatcho
				} }
			},
			{
				"Slurper",
				new Dictionary<string, GameMaterialType>
				{
					{
						"M_Slurp",
						GameMaterialType.M_Slurp
					},
					{
						"M_World_Local",
						GameMaterialType.M_World_Local
					}
				}
			},
			{
				"Spider",
				new Dictionary<string, GameMaterialType> { 
				{
					"M_Monster_BlackLocal",
					GameMaterialType.M_Monster_Black
				} }
			},
			{
				"ButtonRobot",
				new Dictionary<string, GameMaterialType> { 
				{
					"M_Monster_Red",
					GameMaterialType.M_Monster_Red
				} }
			},
			{
				"BlackHoleBot",
				new Dictionary<string, GameMaterialType>
				{
					{
						"M_Propeller",
						GameMaterialType.M_Propeller
					},
					{
						"Rajdhani-Regular SDF Material",
						GameMaterialType.Rajdhani_Regular_SDF
					}
				}
			},
			{
				"Dog",
				new Dictionary<string, GameMaterialType>
				{
					{
						"M_BrightRed",
						GameMaterialType.M_BrightRed
					},
					{
						"M_BrightRed_Chill",
						GameMaterialType.M_BrightRed_Chill
					},
					{
						"M_FlashBeamRed",
						GameMaterialType.M_FlashBeamRed
					}
				}
			},
			{
				"Angler",
				new Dictionary<string, GameMaterialType>
				{
					{
						"M_World",
						GameMaterialType.M_World
					},
					{
						"Lit",
						GameMaterialType.Lit
					},
					{
						"M_DistrorionParticle",
						GameMaterialType.M_DistrorionParticle
					}
				}
			},
			{
				"PoolBall",
				new Dictionary<string, GameMaterialType>
				{
					{
						"M_Pool 6",
						GameMaterialType.M_Pool_6
					},
					{
						"M_Pool 7",
						GameMaterialType.M_Pool_7
					},
					{
						"M_Pool 8",
						GameMaterialType.M_Pool_8
					}
				}
			},
			{
				"DeckChair",
				new Dictionary<string, GameMaterialType> { 
				{
					"M_Pool 4",
					GameMaterialType.M_Pool_4
				} }
			},
			{
				"PodcastChair",
				new Dictionary<string, GameMaterialType>
				{
					{
						"M_Podcast 2",
						GameMaterialType.M_Podcast_2
					},
					{
						"M_Podcast 4",
						GameMaterialType.M_Podcast_4
					}
				}
			},
			{
				"BoookDissolve",
				new Dictionary<string, GameMaterialType>
				{
					{
						"M_Book 1",
						GameMaterialType.M_Book_1
					},
					{
						"M_Book 2",
						GameMaterialType.M_Book_2
					}
				}
			},
			{
				"Chair_Inside",
				new Dictionary<string, GameMaterialType> { 
				{
					"M_Interior 7",
					GameMaterialType.M_Interior_7
				} }
			},
			{
				"Jello",
				new Dictionary<string, GameMaterialType> { 
				{
					"M_SkyNice",
					GameMaterialType.M_SkyNice
				} }
			},
			{
				"BarnacleBall",
				new Dictionary<string, GameMaterialType> { 
				{
					"M_Gas",
					GameMaterialType.M_Gas
				} }
			},
			{
				"Bombs",
				new Dictionary<string, GameMaterialType> { 
				{
					"M_VFX_BombFuze",
					GameMaterialType.M_VFX_BombFuze
				} }
			},
			{
				"Infiltrator2",
				new Dictionary<string, GameMaterialType> { 
				{
					"M_OxygenDisplay",
					GameMaterialType.M_OxygenDisplay
				} }
			},
			{
				"ExplodedGoop",
				new Dictionary<string, GameMaterialType> { 
				{
					"M_Goop",
					GameMaterialType.M_Goop
				} }
			},
			{
				"UnlockExplosion",
				new Dictionary<string, GameMaterialType> { 
				{
					"M_Splash",
					GameMaterialType.M_Splash
				} }
			},
			{
				"PartyPopperConfetti",
				new Dictionary<string, GameMaterialType>
				{
					{
						"ParticlesUnlit",
						GameMaterialType.ParticlesUnlit
					},
					{
						"M_DefaultParticle",
						GameMaterialType.M_DefaultParticle
					}
				}
			}
		};

		public static void InitMaterials()
		{
			foreach (KeyValuePair<string, Dictionary<string, GameMaterialType>> item in PrefabExtractionMap)
			{
				string key = item.Key;
				Dictionary<string, GameMaterialType> value = item.Value;
				bool flag = true;
				foreach (GameMaterialType value3 in value.Values)
				{
					if (!Materials.ContainsKey(value3))
					{
						flag = false;
						break;
					}
				}
				if (flag)
				{
					continue;
				}
				GameObject val = Resources.Load<GameObject>(key);
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				Renderer[] componentsInChildren = val.GetComponentsInChildren<Renderer>(true);
				Renderer[] array = componentsInChildren;
				foreach (Renderer val2 in array)
				{
					Material[] sharedMaterials = val2.sharedMaterials;
					foreach (Material val3 in sharedMaterials)
					{
						if (!((Object)(object)val3 == (Object)null) && value.TryGetValue(((Object)val3).name, out var value2) && !Materials.ContainsKey(value2))
						{
							Materials.Add(value2, val3);
						}
					}
				}
			}
		}

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

		public static void ApplyMaterial(GameObject target, GameMaterialType type, bool deepApply = true)
		{
			if (!Materials.TryGetValue(type, out Material value) || !((Object)(object)value != (Object)null))
			{
				return;
			}
			if (deepApply)
			{
				Renderer[] componentsInChildren = target.GetComponentsInChildren<Renderer>(true);
				foreach (Renderer val in componentsInChildren)
				{
					val.material = value;
				}
			}
			else
			{
				Renderer component = target.GetComponent<Renderer>();
				if ((Object)(object)component != (Object)null)
				{
					component.material = value;
				}
			}
		}
	}
	public class CustomShopItemCategory
	{
		public byte index;

		public string name;
	}
	public static class Items
	{
		public static List<CustomShopItemCategory> customCategories = new List<CustomShopItemCategory>();

		public static GameObject LoadPrefab(AssetBundle bundle, string prefabName)
		{
			if ((Object)(object)bundle == (Object)null)
			{
				throw new Exception("AssetBundle is null");
			}
			GameObject val = bundle.LoadAsset<GameObject>(prefabName);
			if ((Object)(object)val == (Object)null)
			{
				throw new Exception(prefabName + " not found in AssetBundle");
			}
			return val;
		}

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

		public static void SetupPrefab(GameObject prefab, string prefabName, GameMaterialType mat)
		{
			GameMaterials.ApplyMaterial(prefab, mat);
			EnsureComponents(prefab, prefabName);
		}

		private static void EnsureComponents(GameObject prefab, string prefabName)
		{
			if ((Object)(object)prefab.GetComponent<ItemInstance>() == (Object)null)
			{
				prefab.AddComponent<ItemInstance>();
				Debug.Log((object)"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;
				Debug.Log((object)"Added HandGizmo with dummy child");
			}
		}

		public static void RegisterPrefabInPool(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 static Item CreateItem(AssetBundle bundle, string prefabName, GameObject prefab, int price, ShopItemCategory category, string iconName, string soundEffectName, Vector3 holdPos, string displayName)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			ItemDatabase instance = SingletonAsset<ItemDatabase>.Instance;
			Item val = ScriptableObject.CreateInstance<Item>();
			SetupPhysicsSound(bundle, prefab, instance, soundEffectName);
			SetupIcon(bundle, prefab, val, iconName);
			SetupItemBasics(val, prefabName, prefab, price, category, holdPos, displayName);
			return val;
		}

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

		public static void SetupPhysicsSound(AssetBundle bundle, GameObject prefab, ItemDatabase db, string soundEffectName)
		{
			PhysicsSound val = prefab.AddComponent<PhysicsSound>();
			AudioClip val2 = bundle.LoadAsset<AudioClip>(soundEffectName);
			if ((Object)(object)val2 == (Object)null)
			{
				Debug.LogWarning((object)"Custom impact sound not found, using fallback");
				val.impactSounds = GetFallbackPhysicsSound(db);
			}
			else
			{
				val.impactSounds = CreateCustomImpactSound(val2, db);
				Debug.Log((object)"Custom impact sound loaded successfully!");
			}
		}

		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[] CreateCustomImpactSound(AudioClip customSound, ItemDatabase db)
		{
			FieldInfo objectsField = GetObjectsField(db);
			List<Item> itemsFromField = GetItemsFromField(objectsField, db);
			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)
			{
				Debug.LogError((object)"Could not find template SFX_Instance");
				return GetFallbackPhysicsSound(db);
			}
			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 void SetupItemBasics(Item item, string prefabName, GameObject prefab, int price, ShopItemCategory category, Vector3 holdPos, string displayName)
		{
			//IL_0047: 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_004f: 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_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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			item.displayName = displayName;
			item.itemObject = prefab;
			item.persistentID = "unlistedentities." + item.displayName.ToLower();
			((Object)item).name = "unlistedentities." + item.displayName.ToLower();
			item.itemType = (ItemType)1;
			item.Category = category;
			item.mass = 0.5f;
			item.holdPos = holdPos;
			item.holdRotation = Vector3.zero;
			item.useAlternativeHoldingPos = false;
			item.useAlternativeHoldingRot = false;
			item.groundSizeMultiplier = 1f;
			item.groundMassMultiplier = 1f;
			item.purchasable = true;
			item.price = price;
			item.quantity = 1;
			item.spawnable = true;
			item.toolSpawnRarity = (RARITY)100;
			item.toolBudgetCost = 1;
			item.budgetCost = 0;
			item.rarity = 1f;
			item.content = null;
			item.Tooltips = new List<ItemKeyTooltip>();
		}

		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 CopyIconFromTemplate(List<Item> currentItems)
		{
			foreach (Item currentItem in currentItems)
			{
				if ((Object)(object)currentItem.icon != (Object)null && currentItem.purchasable)
				{
					Debug.Log((object)("Found template item with icon: " + currentItem.displayName));
					return currentItem;
				}
			}
			Debug.LogWarning((object)"No template item found with icon!");
			return null;
		}

		public static void AddItemToDatabase(Item item)
		{
			ItemDatabase instance = SingletonAsset<ItemDatabase>.Instance;
			FieldInfo objectsField = GetObjectsField(instance);
			List<Item> itemsFromField = GetItemsFromField(objectsField, instance);
			Item val = CopyIconFromTemplate(itemsFromField);
			item.id = (byte)((itemsFromField.Count > 0) ? ((byte)(itemsFromField.Max((Item i) => i.id) + 1)) : 0);
			itemsFromField.Add(item);
			objectsField.SetValue(instance, itemsFromField);
			Debug.Log((object)$"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 void RegisterItem(AssetBundle bundle, string prefabName, string displayName, int price, ShopItemCategory category, string iconName, string soundEffectName, GameMaterialType mat, Vector3? holdPos = null, Action<GameObject, string> customBehaviourSetup = null)
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: 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)
			Debug.Log((object)("Registering item: " + prefabName));
			GameObject val = LoadPrefab(bundle, prefabName);
			SetupPrefab(val, prefabName, mat);
			customBehaviourSetup?.Invoke(val, prefabName);
			RegisterPrefabInPool(val);
			Vector3 holdPos2 = (Vector3)(((??)holdPos) ?? new Vector3(0.3f, -0.3f, 0.7f));
			Item item = CreateItem(bundle, prefabName, val, price, category, iconName, soundEffectName, holdPos2, displayName);
			if (!CheckDuplicateItem(item))
			{
				AddItemToDatabase(item);
			}
		}
	}
	public static class Logger
	{
		private static ManualLogSource? _source;

		public static void Init(ManualLogSource source)
		{
			_source = source;
		}

		public static void Log(string message)
		{
			ManualLogSource? source = _source;
			if (source != null)
			{
				source.LogInfo((object)("[DbsContentApi] " + message));
			}
		}

		public static void LogError(string message)
		{
			ManualLogSource? source = _source;
			if (source != null)
			{
				source.LogError((object)("[DbsContentApi] " + message));
			}
		}

		public static void LogWarning(string message)
		{
			ManualLogSource? source = _source;
			if (source != null)
			{
				source.LogWarning((object)("[DbsContentApi] " + message));
			}
		}
	}
	public class BudgetConfig
	{
		public int budgetCost = 1;

		public float rarity = 0.01f;
	}
	public class ControllerConfig
	{
		public float movementForce = 9f;

		public float standForce = 25f;

		public float gravity = 80f;

		public float maxStamina = 100f;

		public float staminaRegRate = 100f;

		public float staminaReActivationThreshold = 100f;

		public float jumpImpulse = 7f;

		public float jumpForceOverTime = 0.6f;

		public float constantGravity = 1f;
	}
	public class PlayerConfig
	{
		public float targetHeight = 3f;
	}
	public class RigCreatorConfig
	{
		public List<RigCreatorBodypart>? bodyparts;

		public bool useGravity;

		public float massMultiplier = 1f;

		public bool useTargetRotation = true;

		public float targetRotationSpring = 300f;

		public float targetRotationDragFactor = 0.05f;

		public int smartFillLegs;

		public int setDefaultLayer;
	}
	public class RagdollConfig
	{
		public bool addOpposingForce;

		public float force = 60f;

		public float torque = 0.1f;

		public float drag = 0.92f;

		public float angularDrag = 0.9f;
	}
	public class MonsterAnimationValuesConfig
	{
		public bool rightPunch;

		public bool leftPunch;

		public float movementMultiplier = 1f;
	}
	public class PhotonViewConfig
	{
		public ViewSynchronization synchronization = (ViewSynchronization)3;

		public bool observeMonsterSyncer = true;
	}
	public class BotConfig
	{
		public string monsterName = "";

		public List<PatrolGroup> patrolGroups = new List<PatrolGroup>
		{
			(PatrolGroup)4,
			(PatrolGroup)0
		};

		public int attackType;

		public float turnVel;

		public float animMoveSpeedFactor = 1f;

		public bool alertable = true;
	}
	public class NavMeshConfig
	{
		public float speed = 3.5f;

		public float acceleration;

		public float angularSpeed = 120f;

		public float stoppingDistance;

		public float radius = 1f;

		public float height = 4f;

		public int obstacleAvoidanceType = 4;
	}
	public class MobSetupConfig
	{
		public RigCreatorConfig? visualRig;

		public BudgetConfig? budget;

		public ControllerConfig? controller;

		public bool addAnimRefHandler;

		public PlayerConfig? player;

		public RagdollConfig? ragdoll;

		public PhotonViewConfig? photonView;

		public BotConfig? bot;

		public NavMeshConfig? navMesh;

		public MonsterAnimationValuesConfig? monsterAnimationValues;

		public bool addMonsterAnimationHandler;

		public bool addMonsterSyncer;

		public bool addHeadFollower;

		public bool addGroundPos;
	}
	public class Mobs
	{
		public static void SetupCustomMonster(GameObject monster, string monsterName, MobSetupConfig config)
		{
			Logger.Log("Starting setup for custom monster: " + monsterName);
			if (config.budget != null)
			{
				Logger.Log("  Setting up Budget component for " + monsterName);
				SetupBudget(monster, config.budget);
			}
			if (config.player != null)
			{
				Logger.Log("  Setting up Player component for " + monsterName);
				SetupPlayer(monster, config.player);
			}
			if (config.ragdoll != null)
			{
				Logger.Log("  Setting up Ragdoll component for " + monsterName);
				SetupRagdoll(monster, config.ragdoll);
			}
			if (config.addMonsterSyncer)
			{
				Logger.Log("  Setting up MonsterSyncer component for " + monsterName);
				SetupMonsterSyncer(monster);
			}
			if (config.controller != null)
			{
				Logger.Log("  Setting up Controller component for " + monsterName);
				SetupController(monster, config.controller);
			}
			if (config.addAnimRefHandler)
			{
				Logger.Log("  Setting up AnimRefHandler component for " + monsterName);
				SetupAnimRefHandler(monster);
			}
			if (config.photonView != null)
			{
				Logger.Log("  Setting up PhotonView component for " + monsterName);
				SetupPhotonView(monster, config.photonView);
			}
			if (config.bot != null)
			{
				Logger.Log("  Setting up Bot component for " + monsterName);
				SetupBot(monster, config.bot, config.navMesh);
			}
			if (config.visualRig != null)
			{
				Logger.Log("  Setting up Visual and RigCreator for " + monsterName);
				SetupVisualAndRigCreator(monster, monsterName, config.visualRig);
			}
			if (config.addHeadFollower)
			{
				Logger.Log("  Setting up HeadFollower component for " + monsterName);
				SetupHeadFollower(monster);
			}
			if (config.addGroundPos)
			{
				Logger.Log("  Setting up GroundPositionTransform component for " + monsterName);
				SetupGroundPositionTransform(monster);
			}
			if (config.addMonsterAnimationHandler)
			{
				Logger.Log("  Setting up MonsterAnimationHandler component for " + monsterName);
				SetupMonsterAnimationHandler(monster);
			}
			if (config.monsterAnimationValues != null)
			{
				Logger.Log("  Setting up MonsterAnimationValues component for " + monsterName);
				SetupMonsterAnimationValues(monster, config.monsterAnimationValues);
			}
			Logger.Log("Completed setup for custom monster: " + monsterName);
		}

		private static void SetupMonsterAnimationValues(GameObject monster, MonsterAnimationValuesConfig config)
		{
			Transform val = monster.transform.Find("RigCreator");
			if ((Object)(object)val == (Object)null)
			{
				throw new Exception("RigCreator not found for " + ((Object)monster).name);
			}
			MonsterAnimationValues val2 = ((Component)val).gameObject.AddComponent<MonsterAnimationValues>();
			val2.rightPunch = config.rightPunch;
			val2.leftPunch = config.leftPunch;
			val2.movementMultiplier = config.movementMultiplier;
		}

		public static GameObject GetBotChildObject(GameObject customMonsterPrefab)
		{
			GameObject gameObject = ((Component)customMonsterPrefab.transform.Find("Bot_" + ((Object)customMonsterPrefab).name)).gameObject;
			Logger.Log("  Retrieved Bot child object '" + ((Object)gameObject).name + "' for " + ((Object)customMonsterPrefab).name);
			return gameObject;
		}

		public static void RestoreShaders(GameObject prefab)
		{
			Logger.Log("  Restoring shaders for " + ((Object)prefab).name);
			Renderer[] componentsInChildren = prefab.GetComponentsInChildren<Renderer>();
			GameObject val = Resources.Load<GameObject>("Zombe");
			if ((Object)(object)val == (Object)null)
			{
				Logger.LogWarning("  Zombe prefab not found, skipping shader restoration for " + ((Object)prefab).name);
				return;
			}
			Shader shader = val.GetComponentInChildren<Renderer>().sharedMaterial.shader;
			int num = 0;
			Renderer[] array = componentsInChildren;
			foreach (Renderer val2 in array)
			{
				Material[] sharedMaterials = val2.sharedMaterials;
				foreach (Material val3 in sharedMaterials)
				{
					if (((Object)val3.shader).name == "World Optimized")
					{
						val3.shader = shader;
						num++;
					}
				}
			}
			Logger.Log($"  Restored {num} shader(s) for {((Object)prefab).name}");
		}

		private static void SetupBudget(GameObject monster, BudgetConfig config)
		{
			BudgetCost val = monster.AddComponent<BudgetCost>();
			val.budgetCost = config.budgetCost;
			val.rarity = config.rarity;
			Logger.Log($"Budget configured: cost={config.budgetCost}, rarity={config.rarity}");
		}

		private static void SetupController(GameObject monster, ControllerConfig config)
		{
			PlayerController val = monster.AddComponent<PlayerController>();
			val.movementForce = config.movementForce;
			val.standForce = config.standForce;
			val.gravity = config.gravity;
			val.maxStamina = config.maxStamina;
			val.staminaRegRate = config.staminaRegRate;
			val.staminaReActivationThreshold = config.staminaReActivationThreshold;
			val.jumpImpulse = config.jumpImpulse;
			val.jumpForceOverTime = config.jumpForceOverTime;
			val.constantGravity = config.constantGravity;
			Logger.Log($"Controller configured: movementForce={config.movementForce}, maxStamina={config.maxStamina}");
		}

		private static void SetupAnimRefHandler(GameObject monster)
		{
			monster.AddComponent<PlayerAnimRefHandler>();
			Logger.Log("AnimRefHandler component added");
		}

		private static void SetupPlayer(GameObject monster, PlayerConfig config)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected O, but got Unknown
			Player val = monster.AddComponent<Player>();
			val.ai = true;
			val.input = new PlayerInput();
			val.data = new PlayerData();
			val.data.targetHeight = config.targetHeight;
			val.refs = new PlayerRefs();
			Logger.Log($"Player configured: targetHeight={config.targetHeight}, ai={val.ai}");
		}

		private static void SetupRagdoll(GameObject monster, RagdollConfig config)
		{
			PlayerRagdoll val = monster.AddComponent<PlayerRagdoll>();
			val.addOpposingForce = config.addOpposingForce;
			val.force = config.force;
			val.torque = config.torque;
			val.drag = config.drag;
			val.angularDrag = config.angularDrag;
			Logger.Log($"Ragdoll configured: force={config.force}, torque={config.torque}, drag={config.drag}");
		}

		private static void SetupMonsterSyncer(GameObject monster)
		{
			MonsterSyncer val = monster.AddComponent<MonsterSyncer>();
			val.applyData = true;
			Logger.Log($"MonsterSyncer component added (applyData={val.applyData})");
		}

		private static void SetupVisualAndRigCreator(GameObject monster, string monsterName, RigCreatorConfig config)
		{
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Expected O, but got Unknown
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Expected O, but got Unknown
			//IL_0309: Unknown result type (might be due to invalid IL or missing references)
			//IL_0313: Expected O, but got Unknown
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Expected O, but got Unknown
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			GameObject monster2 = monster;
			Transform val = monster2.transform.Find("Visual");
			if ((Object)(object)val == (Object)null)
			{
				throw new Exception("Visual GameObject not found for " + monsterName + ". A 'Visual' child is required.");
			}
			PlayerVisual component = ((Component)val).GetComponent<PlayerVisual>();
			Transform val2 = monster2.transform.Find("RigCreator");
			RigCreator val3 = ((val2 != null) ? ((Component)val2).GetComponent<RigCreator>() : null);
			bool flag = (Object)(object)((val2 != null) ? val2.Find("Rig") : null) != (Object)null;
			Logger.Log("Visual/Rig status: PlayerVisual=" + (((Object)(object)component != (Object)null) ? "exists" : "missing") + ", RigCreator=" + (((Object)(object)val3 != (Object)null) ? "exists" : "missing") + ", Rig=" + (flag ? "created" : "not created"));
			if ((Object)(object)component != (Object)null && (Object)(object)val3 != (Object)null && flag)
			{
				Logger.Log("Scenario 1: Both PlayerVisual and RigCreator are fully configured, nothing to do");
				return;
			}
			if ((Object)(object)val3 != (Object)null && (Object)(object)component == (Object)null)
			{
				Logger.Log("Scenario 2: RigCreator exists but PlayerVisual missing, adding PlayerVisual");
				PlayerVisual val4 = ((Component)val).gameObject.AddComponent<PlayerVisual>();
				if (flag)
				{
					Logger.Log("Rig already created, calling SetTargets on PlayerVisual");
					val4.SetTargets();
					return;
				}
				Logger.Log("Rig not created yet, will call SetTargets after rig creation");
				val3.createRigEvent = (UnityEvent)(((object)val3.createRigEvent) ?? ((object)new UnityEvent()));
				val3.createRigEvent.AddListener((UnityAction)delegate
				{
					VisualSetTargets(monster2);
				});
				Logger.Log("Creating rig for existing RigCreator");
				CustomCreateRig(val3);
				return;
			}
			if ((Object)(object)component == (Object)null)
			{
				Logger.Log("Scenario 4: Neither PlayerVisual nor RigCreator exist, creating both");
				((Component)val).gameObject.AddComponent<PlayerVisual>();
			}
			else
			{
				Logger.Log("Scenario 3: PlayerVisual exists but RigCreator missing, creating RigCreator");
			}
			if (config.bodyparts == null)
			{
				throw new Exception("bodyparts configuration is required when RigCreator doesn't exist on the prefab for " + monsterName);
			}
			Logger.Log($"Creating RigCreator GameObject with {config.bodyparts.Count} bodyparts");
			GameObject val5 = new GameObject("RigCreator");
			val5.transform.SetParent(monster2.transform);
			val5.transform.localPosition = Vector3.zero;
			val5.transform.localRotation = Quaternion.identity;
			RigCreator val6 = val5.AddComponent<RigCreator>();
			val6.source = ((Component)val).gameObject;
			Logger.Log("RigCreator source set to Visual GameObject");
			Logger.Log("Setting up RigCreator resources");
			SetupRigCreatorResources(val6);
			Logger.Log("Applying RigCreator configuration");
			val6.useGravity = config.useGravity;
			val6.massMultiplier = config.massMultiplier;
			val6.useTargetRotation = config.useTargetRotation;
			val6.targetRotationSpring = config.targetRotationSpring;
			val6.targetRotationDragFactor = config.targetRotationDragFactor;
			val6.smartFillLegs = config.smartFillLegs;
			val6.setDefaultLayer = config.setDefaultLayer;
			val6.bodyparts = config.bodyparts;
			val6.createRigEvent = new UnityEvent();
			val6.createRigEvent.AddListener((UnityAction)delegate
			{
				VisualSetTargets(monster2);
			});
			Logger.Log("Creating rig for " + monsterName);
			CustomCreateRig(val6);
			Logger.Log("Rig creation completed for " + monsterName);
		}

		private static void VisualSetTargets(GameObject monster)
		{
			Transform obj = monster.transform.Find("Visual");
			GameObject val = ((obj != null) ? ((Component)obj).gameObject : null);
			if ((Object)(object)val != (Object)null)
			{
				PlayerVisual component = val.GetComponent<PlayerVisual>();
				if ((Object)(object)component != (Object)null)
				{
					component.SetTargets();
					Logger.Log("Visual targets set successfully");
				}
				else
				{
					Logger.LogWarning("PlayerVisual component not found on Visual for " + ((Object)monster).name);
				}
			}
			else
			{
				Logger.LogWarning("Visual GameObject not found for " + ((Object)monster).name);
			}
		}

		private static void SetupPhotonView(GameObject monster, PhotonViewConfig config)
		{
			//IL_0009: 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_0076: 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_0043: Unknown result type (might be due to invalid IL or missing references)
			PhotonView val = monster.AddComponent<PhotonView>();
			val.Synchronization = config.synchronization;
			if (config.observeMonsterSyncer)
			{
				MonsterSyncer component = monster.GetComponent<MonsterSyncer>();
				if ((Object)(object)component != (Object)null)
				{
					val.ObservedComponents = new List<Component> { (Component)(object)component };
					Logger.Log($"PhotonView configured: synchronization={config.synchronization}, observing MonsterSyncer");
				}
				else
				{
					Logger.LogWarning("MonsterSyncer not found for PhotonView observation on " + ((Object)monster).name);
				}
			}
			else
			{
				Logger.Log($"PhotonView configured: synchronization={config.synchronization}");
			}
			val.observableSearch = (ObservableSearch)2;
		}

		private static void SetupHeadFollower(GameObject monster)
		{
			Transform obj = monster.transform.Find("HeadPosition");
			GameObject val = ((obj != null) ? ((Component)obj).gameObject : null);
			if ((Object)(object)val != (Object)null)
			{
				val.AddComponent<HeadFollower>();
				Logger.Log("HeadFollower component added to HeadPosition");
			}
			else
			{
				Logger.LogWarning("HeadPosition not found for " + ((Object)monster).name);
			}
		}

		private static void SetupGroundPositionTransform(GameObject monster)
		{
			Transform obj = monster.transform.Find("PlayerGroundPos");
			GameObject val = ((obj != null) ? ((Component)obj).gameObject : null);
			if ((Object)(object)val != (Object)null)
			{
				val.AddComponent<PlayerGroundPositionTransform>();
				Logger.Log("PlayerGroundPositionTransform component added to PlayerGroundPos");
			}
			else
			{
				Logger.LogWarning("PlayerGroundPos not found for " + ((Object)monster).name);
			}
		}

		private static void SetupMonsterAnimationHandler(GameObject monster)
		{
			monster.AddComponent<MonsterAnimationHandler>();
			Logger.Log("MonsterAnimationHandler component added");
		}

		private static void SetupBot(GameObject monster, BotConfig botConfig, NavMeshConfig? navConfig)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_004d: 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_0085: 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_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Expected O, but got Unknown
			Logger.Log("Creating Bot GameObject 'Bot_" + botConfig.monsterName + "' for " + botConfig.monsterName);
			GameObject val = new GameObject("Bot_" + botConfig.monsterName);
			val.transform.SetParent(monster.transform);
			val.transform.localPosition = Vector3.zero;
			val.transform.localRotation = Quaternion.identity;
			Logger.Log("Adding PhotonView to Bot for " + botConfig.monsterName);
			PhotonView val2 = val.AddComponent<PhotonView>();
			val2.Synchronization = (ViewSynchronization)3;
			val2.observableSearch = (ObservableSearch)2;
			Logger.Log($"Configuring Bot component: patrolGroups={botConfig.patrolGroups.Count}, attackType={botConfig.attackType}, alertable={botConfig.alertable}");
			Bot val3 = val.AddComponent<Bot>();
			val3.patrolGroups = botConfig.patrolGroups;
			val3.attackType = botConfig.attackType;
			val3.turnVel = botConfig.turnVel;
			val3.animMoveSpeedFactor = botConfig.animMoveSpeedFactor;
			val3.alertable = botConfig.alertable;
			Transform obj = monster.transform.Find("Visual");
			object centerTransform;
			if (obj == null)
			{
				centerTransform = null;
			}
			else
			{
				Transform obj2 = obj.Find(botConfig.monsterName);
				if (obj2 == null)
				{
					centerTransform = null;
				}
				else
				{
					Transform obj3 = obj2.Find("Armature");
					centerTransform = ((obj3 != null) ? obj3.Find("Hip") : null);
				}
			}
			Transform val4 = (val3.centerTransform = (Transform)centerTransform);
			val3.groundTransform = monster.transform.Find("PlayerGroundPos");
			val3.syncData = new SyncData
			{
				targetPlayerId = -1
			};
			if ((Object)(object)val4 != (Object)null)
			{
				Logger.Log("Bot centerTransform set to Hip");
			}
			else
			{
				Logger.LogWarning("Hip transform not found for Bot centerTransform on " + botConfig.monsterName);
			}
			if (navConfig != null)
			{
				Logger.Log($"Configuring NavMeshAgent: speed={navConfig.speed}, angularSpeed={navConfig.angularSpeed}, radius={navConfig.radius}, height={navConfig.height}");
				NavMeshAgent val5 = val.AddComponent<NavMeshAgent>();
				val5.speed = navConfig.speed;
				val5.acceleration = navConfig.acceleration;
				val5.angularSpeed = navConfig.angularSpeed;
				val5.stoppingDistance = navConfig.stoppingDistance;
				val5.radius = navConfig.radius;
				val5.height = navConfig.height;
				val5.obstacleAvoidanceType = (ObstacleAvoidanceType)navConfig.obstacleAvoidanceType;
			}
			else
			{
				Logger.Log("No NavMeshConfig provided, skipping NavMeshAgent setup");
			}
			Logger.Log("Adding Bot_Nav_Navmesh and Bot_RagdollCharacter components");
			val.AddComponent<Bot_Nav_Navmesh>();
			val.AddComponent<Bot_RagdollCharacter>();
			Logger.Log("Bot setup completed for " + botConfig.monsterName);
		}

		public static void AddBotZombieComponent(GameObject botObject)
		{
			botObject.AddComponent<Bot_Zombie>();
			Logger.Log("  Added Bot_Zombie component to " + ((Object)botObject).name);
		}

		public static void AddBotToolkitBoyComponent(GameObject botObject, float targetDistance = 2f)
		{
			Bot_ToolkitBoy val = botObject.AddComponent<Bot_ToolkitBoy>();
			val.targetDistance = targetDistance;
			Logger.Log($"  Added Bot_ToolkitBoy component to {((Object)botObject).name} (targetDistance={targetDistance})");
		}

		public static void AddBotKnifoComponent(GameObject botObject, BodypartType mainRigBodyPart)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: 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)
			Bot_Knifo val = botObject.AddComponent<Bot_Knifo>();
			val.targetDistance = 1f;
			val.mainRig = mainRigBodyPart;
			val.jumpForceForward = 15f;
			val.jumpForceUp = 15f;
			GameObject obj = Resources.Load<GameObject>("Knifo");
			object jumpCurve;
			if (obj == null)
			{
				jumpCurve = null;
			}
			else
			{
				Transform obj2 = obj.transform.Find("Bot_Knifo");
				jumpCurve = ((obj2 == null) ? null : ((Component)obj2).GetComponent<Bot_Knifo>()?.jumpCurve);
			}
			val.jumpCurve = (AnimationCurve)jumpCurve;
			Logger.Log($"  Added Bot_Knifo component to {((Object)botObject).name} (mainRig={mainRigBodyPart})");
		}

		public static void AddBotChaserComponent(GameObject botObject)
		{
			Bot_Chaser val = botObject.AddComponent<Bot_Chaser>();
			val.exhastionTime = 20f;
			val.fleeForSeconds = 20f;
			val.hidingExhastionMultiplier = 1f;
			val.timeToLoseTarget = 2f;
			val.targetDistance = 3f;
			val.backUpIfTooClose = true;
			val.useWorldMoveInChase = true;
			val.canRotateWhenStandingStill = true;
			val.chaseTurnRate = 6f;
			val.fleeTurnRate = 6f;
			val.investigateTurnRate = 3f;
			val.patrolTurnRate = 3f;
			val.maxRange = 70f;
			val.maxAngle = 110f;
			val.timeToSeeTarget = 1f;
			Logger.Log($"  Added Bot_Chaser component to {((Object)botObject).name} (maxRange={val.maxRange}, targetDistance={val.targetDistance})");
		}

		public static void AddBotDragComponent(GameObject botObject)
		{
			Bot_Drag val = botObject.AddComponent<Bot_Drag>();
			val.dragForce = 150f;
			val.handForce = 150f;
			val.range = 2f;
			Logger.Log($"  Added Bot_Drag component to {((Object)botObject).name} (dragForce={val.dragForce}, range={val.range})");
		}

		private static void SetupRigCreatorResources(RigCreator rigCreator)
		{
			RigCreator val = null;
			RigCreator[] array = Resources.FindObjectsOfTypeAll<RigCreator>();
			foreach (RigCreator val2 in array)
			{
				if ((Object)(object)val2.boxColldier != (Object)null && (Object)(object)val2.capsuleCol != (Object)null && (Object)(object)val2.slipperyMat != (Object)null)
				{
					val = val2;
					Logger.Log("  Found RigCreator template from existing instance");
					break;
				}
			}
			if ((Object)(object)val == (Object)null)
			{
				Logger.Log("  Searching for Zombe prefab as RigCreator template");
				GameObject val3 = Resources.Load<GameObject>("Zombe");
				if ((Object)(object)val3 != (Object)null)
				{
					val = val3.GetComponentInChildren<RigCreator>(true);
					if ((Object)(object)val != (Object)null)
					{
						Logger.Log("  Found RigCreator template from Zombe prefab");
					}
				}
			}
			if ((Object)(object)val != (Object)null)
			{
				rigCreator.boxColldier = val.boxColldier;
				rigCreator.capsuleCol = val.capsuleCol;
				rigCreator.sphereCol = val.sphereCol;
				rigCreator.slipperyMat = val.slipperyMat;
				Logger.Log("  RigCreator resources copied from template");
			}
			else if ((Object)(object)rigCreator.slipperyMat == (Object)null)
			{
				Logger.Log("  Searching for slippery PhysicMaterial");
				PhysicMaterial[] array2 = Resources.FindObjectsOfTypeAll<PhysicMaterial>();
				foreach (PhysicMaterial val4 in array2)
				{
					if (((Object)val4).name.ToLower().Contains("slippery"))
					{
						rigCreator.slipperyMat = val4;
						Logger.Log("  Found slippery PhysicMaterial: " + ((Object)val4).name);
						break;
					}
				}
			}
			else
			{
				Logger.LogWarning("  No RigCreator template found and no slippery material available");
			}
		}

		private static void CustomCreateRig(RigCreator rigCreator)
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			Logger.Log("  SmartFillLegs()");
			rigCreator.SmartFillLegs();
			Transform val = ((Component)rigCreator).gameObject.transform.Find("Rig");
			if (Object.op_Implicit((Object)(object)val))
			{
				Logger.Log("  Destroying existing Rig GameObject");
				Object.DestroyImmediate((Object)(object)((Component)val).gameObject);
			}
			Logger.Log("  Instantiating rig source");
			GameObject val2 = Object.Instantiate<GameObject>(rigCreator.source, ((Component)rigCreator).gameObject.transform.position, ((Component)rigCreator).gameObject.transform.rotation, ((Component)rigCreator).gameObject.transform);
			val2.SetActive(true);
			((Object)val2).name = "Rig";
			Logger.Log("  Clearing mesh and registering parts");
			rigCreator.ClearMesh(val2);
			rigCreator.RegisterParts();
			Logger.Log("  Configuring rotations");
			rigCreator.ConfigRotations();
			Logger.Log("  Adding rigs");
			rigCreator.AddRigs();
			int num = 0;
			for (int i = 0; i < rigCreator.bodyparts.Count; i++)
			{
				if (Object.op_Implicit((Object)(object)rigCreator.bodyparts[i].rigObject) && rigCreator.bodyparts[i].joint.hasJoint)
				{
					rigCreator.bodyparts[i].rigObject.AddComponent<RigCreatorJoint>().Init(rigCreator, rigCreator.bodyparts[i]);
					rigCreator.bodyparts[i].joint.SpawnJoint(rigCreator.bodyparts[i].rig, ((Component)rigCreator.bodyparts[i].rigObject.transform.parent).GetComponentInParent<Rigidbody>(true), rigCreator.useTargetRotation ? rigCreator.targetRotationSpring : 0f, rigCreator.useTargetRotation ? (rigCreator.targetRotationSpring * rigCreator.targetRotationDragFactor) : 0f);
					num++;
				}
			}
			Logger.Log($"  Created {num} joints for {rigCreator.bodyparts.Count} bodyparts");
			Logger.Log("  Adding collision and scripts");
			rigCreator.AddCollision();
			rigCreator.AddScripts();
			Logger.Log("  Invoking createRigEvent");
			rigCreator.createRigEvent.Invoke();
		}

		public static RigCreatorBodypart CreatePart(BodypartType type, float mass, ColliderType colType, bool hasJoint = true, ColliderMaterial mat = 0)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: 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_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: 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_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Expected O, but got Unknown
			//IL_007a: Expected O, but got Unknown
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: 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_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Expected O, but got Unknown
			RigCreatorBodypart val = new RigCreatorBodypart
			{
				partType = type,
				mass = mass,
				useMovementForceMultiplier = false,
				movementForceMultiplier = 0f,
				joint = new JointConfig
				{
					hasJoint = hasJoint,
					springMultiplier = 1f,
					dragMultiplier = 1f,
					minX = -45f,
					maxX = 45f,
					yAngle = 45f,
					zAngle = 45f
				}
			};
			val.colliders = new List<RigCreatorColliderData>
			{
				new RigCreatorColliderData
				{
					colliderType = colType,
					colliderScale = new Vector3(0.2f, 0.2f, 0.2f),
					colliderPosition = Vector3.zero,
					colliderRotation = Vector3.zero,
					physicsMaterial = mat,
					overrideLayer = 0
				}
			};
			return val;
		}

		public static bool ValidatePlayerPrefab(GameObject prefab, string monsterName)
		{
			GameObject prefab2 = prefab;
			string monsterName2 = monsterName;
			bool ok = true;
			Player component = prefab2.GetComponent<Player>();
			if ((Object)(object)component == (Object)null)
			{
				Logger.LogError("[ValidatePlayerPrefab] " + monsterName2 + ": Missing Player component on root GameObject.");
				return false;
			}
			if (component.input == null)
			{
				Logger.LogError("[ValidatePlayerPrefab] " + monsterName2 + ": Player.input is null. Make sure SetupPlayer was called or assign a PlayerInput instance.");
				ok = false;
			}
			if (component.data == null)
			{
				Logger.LogError("[ValidatePlayerPrefab] " + monsterName2 + ": Player.data is null. Make sure SetupPlayer was called or assign a PlayerData instance.");
				ok = false;
			}
			if (component.refs == null)
			{
				Logger.LogError("[ValidatePlayerPrefab] " + monsterName2 + ": Player.refs is null. Make sure SetupPlayer was called or assign a PlayerRefs instance.");
				ok = false;
			}
			Transform val = prefab2.transform.Find("RigCreator");
			if ((Object)(object)val == (Object)null)
			{
				Logger.LogError("[ValidatePlayerPrefab] " + monsterName2 + ": Child 'RigCreator' not found. Player.Start() accesses it via transform.Find(\"RigCreator\").");
				ok = false;
			}
			else
			{
				RigCreator component2 = ((Component)val).GetComponent<RigCreator>();
				if ((Object)(object)component2 == (Object)null)
				{
					Logger.LogError("[ValidatePlayerPrefab] " + monsterName2 + ": 'RigCreator' found but has no RigCreator component. CustomCreateRig must have been run on this object.");
					ok = false;
				}
				else
				{
					Transform val2 = val.Find("Rig");
					if ((Object)(object)val2 == (Object)null)
					{
						Logger.LogWarning("[ValidatePlayerPrefab] " + monsterName2 + ": RigCreator has no 'Rig' child. Did CustomCreateRig run on this prefab?");
					}
				}
			}
			RequireOnRoot<PlayerRagdoll>();
			RequireOnRoot<PlayerAnimRefHandler>();
			RequireOnRoot<PlayerAnimationHandler>();
			RequireOnRoot<PlayerItems>();
			RequireOnRoot<PlayerInteraction>();
			RequireOnRoot<PhotonView>();
			if ((Object)(object)prefab2.GetComponent<PlayerVisor>() == (Object)null)
			{
				Logger.LogWarning("[ValidatePlayerPrefab] " + monsterName2 + ": PlayerVisor not found. This is optional but differs from the default player prefab.");
			}
			if (!ok)
			{
				Logger.LogError("[ValidatePlayerPrefab] " + monsterName2 + ": Prefab validation FAILED. Player.Start() may throw NullReferenceException. See previous logs for details.");
			}
			else
			{
				Logger.Log("[ValidatePlayerPrefab] " + monsterName2 + ": Prefab validation passed.");
			}
			return ok;
			void RequireOnRoot<T>() where T : notnull, Component
			{
				if ((Object)(object)prefab2.GetComponent<T>() == (Object)null)
				{
					Logger.LogError("[ValidatePlayerPrefab] " + monsterName2 + ": Missing required component " + typeof(T).Name + " on root GameObject.");
					ok = false;
				}
			}
		}
	}
}