Decompiled source of TheFoundingFarters CustomMoons v1.4.56

plugins/AtlasAbyss.dll

Decompiled 2 weeks ago
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using AtlasAbyss.Patches;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;

[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("AtlasAbyss")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("AtlasAbyss")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0+d0f52e14bf546cdcac0b95a0f3af45400e14dd87")]
[assembly: AssemblyProduct("AtlasAbyss")]
[assembly: AssemblyTitle("AtlasAbyss")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace AtlasAbyss
{
	[Serializable]
	public class Config : SyncedInstance<Config>
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static HandleNamedMessageDelegate <0>__OnRequestSync;

			public static HandleNamedMessageDelegate <1>__OnReceiveSync;
		}

		public bool customPriceEnabled;

		public int moonPrice;

		public Config(ConfigFile cfg)
		{
			InitInstance(this);
			customPriceEnabled = cfg.Bind<bool>("General", "CustomPriceEnabled", false, "Enable this if you wish to configure the moons route price below.").Value;
			moonPrice = cfg.Bind<int>("General", "MoonPrice", 300, "The route price of the Atlas Abyss moon.").Value;
		}

		public static void RequestSync()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			if (!SyncedInstance<Config>.IsClient)
			{
				return;
			}
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(SyncedInstance<Config>.IntSize, (Allocator)2, -1);
			try
			{
				SyncedInstance<Config>.MessageManager.SendNamedMessage("AtlasAbyss_OnRequestConfigSync", 0uL, val, (NetworkDelivery)3);
			}
			finally
			{
				((IDisposable)(FastBufferWriter)(ref val)).Dispose();
			}
		}

		public static void OnRequestSync(ulong clientId, FastBufferReader _)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			if (!SyncedInstance<Config>.IsHost)
			{
				return;
			}
			byte[] array = SyncedInstance<Config>.SerializeToBytes(SyncedInstance<Config>.Instance);
			int num = array.Length;
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(num + SyncedInstance<Config>.IntSize, (Allocator)2, -1);
			try
			{
				((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref num, default(ForPrimitives));
				((FastBufferWriter)(ref val)).WriteBytesSafe(array, -1, 0);
				SyncedInstance<Config>.MessageManager.SendNamedMessage("AtlasAbyss_OnReceiveConfigSync", clientId, val, (NetworkDelivery)3);
			}
			catch (Exception arg)
			{
				Plugin.Logger.LogDebug((object)$"Error occurred syncing config with client: {clientId}\n{arg}");
			}
			finally
			{
				((IDisposable)(FastBufferWriter)(ref val)).Dispose();
			}
		}

		public static void OnReceiveSync(ulong _, FastBufferReader reader)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			if (!((FastBufferReader)(ref reader)).TryBeginRead(SyncedInstance<Config>.IntSize))
			{
				Plugin.Logger.LogError((object)"Config sync error: Could not begin reading buffer.");
				return;
			}
			int num = default(int);
			((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num, default(ForPrimitives));
			if (!((FastBufferReader)(ref reader)).TryBeginRead(num))
			{
				Plugin.Logger.LogError((object)"Config sync error: Host could not sync.");
				return;
			}
			byte[] data = new byte[num];
			((FastBufferReader)(ref reader)).ReadBytesSafe(ref data, num, 0);
			SyncedInstance<Config>.SyncInstance(data);
			Plugin.Logger.LogDebug((object)"Successfully synced config with host.");
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")]
		public static void InitializeLocalPlayer()
		{
			//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_0063: Expected O, but got Unknown
			//IL_0021: 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_002c: Expected O, but got Unknown
			if (SyncedInstance<Config>.IsHost)
			{
				CustomMessagingManager messageManager = SyncedInstance<Config>.MessageManager;
				object obj = <>O.<0>__OnRequestSync;
				if (obj == null)
				{
					HandleNamedMessageDelegate val = OnRequestSync;
					<>O.<0>__OnRequestSync = val;
					obj = (object)val;
				}
				messageManager.RegisterNamedMessageHandler("AtlasAbyss_OnRequestConfigSync", (HandleNamedMessageDelegate)obj);
				SyncedInstance<Config>.Synced = true;
				return;
			}
			SyncedInstance<Config>.Synced = false;
			CustomMessagingManager messageManager2 = SyncedInstance<Config>.MessageManager;
			object obj2 = <>O.<1>__OnReceiveSync;
			if (obj2 == null)
			{
				HandleNamedMessageDelegate val2 = OnReceiveSync;
				<>O.<1>__OnReceiveSync = val2;
				obj2 = (object)val2;
			}
			messageManager2.RegisterNamedMessageHandler("AtlasAbyss_OnReceiveConfigSync", (HandleNamedMessageDelegate)obj2);
			RequestSync();
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(GameNetworkManager), "StartDisconnect")]
		public static void PlayerLeave()
		{
			SyncedInstance<Config>.RevertSync();
		}
	}
	[Serializable]
	public class SyncedInstance<T>
	{
		[NonSerialized]
		protected static int IntSize = 4;

		internal static CustomMessagingManager MessageManager => NetworkManager.Singleton.CustomMessagingManager;

		internal static bool IsClient => NetworkManager.Singleton.IsClient;

		internal static bool IsHost => NetworkManager.Singleton.IsHost;

		public static T Default { get; set; }

		public static T Instance { get; set; }

		public static bool Synced { get; internal set; }

		protected void InitInstance(T instance)
		{
			Default = instance;
			Instance = instance;
		}

		internal static void SyncInstance(byte[] data)
		{
			Instance = DeserializeFromBytes(data);
			Synced = true;
		}

		internal static void RevertSync()
		{
			Instance = Default;
			Synced = false;
		}

		public static byte[] SerializeToBytes(T val)
		{
			BinaryFormatter binaryFormatter = new BinaryFormatter();
			using MemoryStream memoryStream = new MemoryStream();
			try
			{
				binaryFormatter.Serialize(memoryStream, val);
				return memoryStream.ToArray();
			}
			catch (Exception arg)
			{
				Plugin.Logger.LogError((object)$"Error serializing instance: {arg}");
				return null;
			}
		}

		public static T DeserializeFromBytes(byte[] data)
		{
			BinaryFormatter binaryFormatter = new BinaryFormatter();
			using MemoryStream serializationStream = new MemoryStream(data);
			try
			{
				return (T)binaryFormatter.Deserialize(serializationStream);
			}
			catch (Exception arg)
			{
				Plugin.Logger.LogError((object)$"Error deserializing instance: {arg}");
				return default(T);
			}
		}
	}
	[BepInPlugin("AtlasAbyss", "AtlasAbyss", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private Harmony _harmony;

		public static ManualLogSource Logger;

		public static Config Config { get; internal set; }

		private void Awake()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			_harmony = new Harmony("AtlasAbyss");
			Config = new Config(((BaseUnityPlugin)this).Config);
			_harmony.PatchAll(typeof(RoutePatches));
			_harmony.PatchAll(typeof(Config));
			Logger.LogDebug((object)"Plugin AtlasAbyss is loaded!");
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "AtlasAbyss";

		public const string PLUGIN_NAME = "AtlasAbyss";

		public const string PLUGIN_VERSION = "1.0.0";
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "AtlasAbyss";

		public const string PLUGIN_NAME = "AtlasAbyss";

		public const string PLUGIN_VERSION = "0.1.0";
	}
}
namespace AtlasAbyss.Patches
{
	[HarmonyPatch(typeof(Terminal))]
	public class RoutePatches
	{
		[HarmonyPatch("LoadNewNode")]
		[HarmonyPrefix]
		private static void LoadNewNodePatchBefore(ref TerminalNode node)
		{
			if (!SyncedInstance<Config>.Instance.customPriceEnabled)
			{
				return;
			}
			Terminal obj = Object.FindObjectOfType<Terminal>();
			Plugin.Logger.LogDebug((object)((Object)node).name);
			CompatibleNoun[] compatibleNouns = obj.terminalNodes.allKeywords.First((TerminalKeyword terminalKeyword) => terminalKeyword.word == "route").compatibleNouns;
			foreach (CompatibleNoun val in compatibleNouns)
			{
				if (!((Object)(object)val.result == (Object)null) && ((Object)val.result).name == "atlas abyssRoute")
				{
					val.result.itemCost = SyncedInstance<Config>.Instance.moonPrice;
				}
			}
		}

		[HarmonyPatch("LoadNewNodeIfAffordable")]
		[HarmonyPrefix]
		private static void LoadNewNodeIfAffordablePatch(ref TerminalNode node)
		{
			if (SyncedInstance<Config>.Instance.customPriceEnabled)
			{
				Plugin.Logger.LogDebug((object)((Object)node).name);
				if (!((Object)(object)node == (Object)null) && !(((Object)node).name != "atlas abyssRouteConfirm"))
				{
					node.itemCost = Math.Abs(SyncedInstance<Config>.Instance.moonPrice);
				}
			}
		}
	}
}

plugins/MentalHospital.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using DunGen;
using DunGen.Graph;
using HarmonyLib;
using LethalLevelLoader;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Rendering.HighDefinition;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("MentalHospital")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MentalHospital")]
[assembly: AssemblyTitle("MentalHospital")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace MentalHospital
{
	[BepInPlugin("MentalHospital", "MentalHospital", "1.0.0")]
	public class MentalHospitalDunGen : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(RoundManager))]
		internal class RoundManagerPatch
		{
			[HarmonyPatch("SpawnScrapInLevel")]
			[HarmonyPrefix]
			private static bool SetItemSpawnPoints(ref RuntimeDungeon ___dungeonGenerator)
			{
				string name = ((Object)DungeonManager.CurrentExtendedDungeonFlow).name;
				if (name != "HospitalExtendedDungeonFlow")
				{
					return true;
				}
				StartOfRound instance = StartOfRound.Instance;
				if ((Object)(object)instance == (Object)null)
				{
					Instance.mls.LogError((object)"Failed to get start of round instance. Scrap spawns may not work correctly.");
					return true;
				}
				Item val = instance.allItemsList.itemsList.Find((Item x) => x.itemName == "Bottles");
				if ((Object)(object)val == (Object)null)
				{
					Instance.mls.LogError((object)"Failed to find bottle bin item for reference snatching; scrap spawn may be significantly lower than expected.");
					return true;
				}
				Item val2 = instance.allItemsList.itemsList.Find((Item x) => x.itemName == "Golden cup");
				int num = 0;
				int num2 = 0;
				int num3 = 0;
				ItemGroup spawnableItems = val.spawnPositionTypes.Find((ItemGroup x) => ((Object)x).name == "GeneralItemClass");
				ItemGroup val3 = val.spawnPositionTypes.Find((ItemGroup x) => ((Object)x).name == "TabletopItems");
				ItemGroup spawnableItems2 = (ItemGroup)(((Object)(object)val2 == (Object)null) ? ((object)val3) : ((object)val2.spawnPositionTypes.Find((ItemGroup x) => ((Object)x).name == "SmallItems")));
				RandomScrapSpawn[] array = Object.FindObjectsOfType<RandomScrapSpawn>();
				RandomScrapSpawn[] array2 = array;
				foreach (RandomScrapSpawn val4 in array2)
				{
					switch (((Object)val4.spawnableItems).name)
					{
					case "GeneralItemClassDUMMY":
						val4.spawnableItems = spawnableItems;
						num++;
						break;
					case "TabletopItemsDUMMY":
						val4.spawnableItems = val3;
						num2++;
						break;
					case "SmallItemsDUMMY":
						val4.spawnableItems = spawnableItems2;
						num3++;
						break;
					}
				}
				Instance.mls.LogInfo((object)$"Totals for scrap replacement: General: {num}, Tabletop: {num2}, Small: {num3}");
				if (num + num2 + num3 < 10)
				{
					Instance.mls.LogWarning((object)"Unusually low scrap spawn count; scrap may be sparse.");
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(SteamValveHazard))]
		[HarmonyPatch("BurstValve")]
		public class BurstValveColorPatch
		{
			private static void Postfix(SteamValveHazard __instance)
			{
				//IL_0076: 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)
				string name = ((Object)DungeonManager.CurrentExtendedDungeonFlow).name;
				if (!(name == "HospitalExtendedDungeonFlow") || !configGreenFog.Value)
				{
					return;
				}
				string text = "749B3B";
				Color albedo = default(Color);
				if (ColorUtility.TryParseHtmlString("#" + text, ref albedo))
				{
					LocalVolumetricFog component = ((Component)__instance.fogAnimator).GetComponent<LocalVolumetricFog>();
					if ((Object)(object)component != (Object)null)
					{
						((Component)__instance.fogAnimator).GetComponent<LocalVolumetricFog>().parameters.albedo = albedo;
					}
					else
					{
						Debug.LogError((object)"LocalVolumetricFog component not found on fogAnimator.");
					}
				}
				else
				{
					Debug.LogError((object)("Invalid hexadecimal color value: " + text));
				}
			}
		}

		[HarmonyPatch(typeof(SteamValveHazard))]
		[HarmonyPatch("Update")]
		public class SteamValveHazard_Update_Patch
		{
			private class SteamValveState
			{
				public float timeInsideFog = 0f;

				public float damageTimer = 0f;

				public bool isInsideFog = false;
			}

			private static readonly FieldInfo valveHasBurstField = AccessTools.Field(typeof(SteamValveHazard), "valveHasBurst");

			private static readonly FieldInfo valveHasBeenRepairedField = AccessTools.Field(typeof(SteamValveHazard), "valveHasBeenRepaired");

			private static Dictionary<int, SteamValveState> valveStates = new Dictionary<int, SteamValveState>();

			[HarmonyPrefix]
			public static bool Prefix(SteamValveHazard __instance)
			{
				//IL_00a2: 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)
				bool flag = (bool)valveHasBurstField.GetValue(__instance);
				int instanceID = ((Object)__instance).GetInstanceID();
				bool flag2 = (bool)valveHasBeenRepairedField.GetValue(__instance);
				string name = ((Object)DungeonManager.CurrentExtendedDungeonFlow).name;
				if (flag && name == "HospitalExtendedDungeonFlow" && !flag2 && configFogDamage.Value)
				{
					if (!valveStates.ContainsKey(instanceID))
					{
						valveStates[instanceID] = new SteamValveState();
					}
					SteamValveState steamValveState = valveStates[instanceID];
					if (Vector3.Distance(((Component)GameNetworkManager.Instance.localPlayerController).transform.position, ((Component)__instance.valveAudio).transform.position) < 10f)
					{
						steamValveState.timeInsideFog += Time.deltaTime;
						if (steamValveState.timeInsideFog >= 5f && !steamValveState.isInsideFog)
						{
							steamValveState.isInsideFog = true;
							steamValveState.damageTimer = 0f;
						}
						if (steamValveState.isInsideFog)
						{
							steamValveState.damageTimer += Time.deltaTime;
							if (steamValveState.damageTimer >= 1f)
							{
								steamValveState.damageTimer = 0f;
								ApplyDamageToPlayer();
							}
						}
					}
					else
					{
						steamValveState.timeInsideFog = 0f;
						steamValveState.damageTimer = 0f;
						steamValveState.isInsideFog = false;
					}
					return true;
				}
				return true;
			}

			private static void ApplyDamageToPlayer()
			{
				//IL_0013: Unknown result type (might be due to invalid IL or missing references)
				//IL_0019: Unknown result type (might be due to invalid IL or missing references)
				GameNetworkManager.Instance.localPlayerController.DamagePlayer(5, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
			}
		}

		private const string modGUID = "DantorMentalHospital";

		private const string modName = "Dantor's Mental Hospital";

		private const string modVersion = "1.2.0";

		private static MentalHospitalDunGen Instance;

		private readonly Harmony harmony = new Harmony("Dantor's Mental Hospital");

		public static ConfigEntry<int> configRarity;

		public static ConfigEntry<string> configMoons;

		public static ConfigEntry<bool> configGuaranteed;

		public static ConfigEntry<float> configMinSize;

		public static ConfigEntry<float> configMaxSize;

		public static ConfigEntry<float> configDynamicValue;

		public static ConfigEntry<bool> configDynamicToggle;

		public static ConfigEntry<bool> configGreenFog;

		public static ConfigEntry<bool> configFogDamage;

		internal ManualLogSource mls;

		public static AssetBundle Assets;

		private void Awake()
		{
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Expected O, but got Unknown
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Expected O, but got Unknown
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Expected O, but got Unknown
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Expected O, but got Unknown
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Expected O, but got Unknown
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Expected O, but got Unknown
			//IL_025d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Expected O, but got Unknown
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Expected O, but got Unknown
			//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: Expected O, but got Unknown
			//IL_033a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0344: Expected O, but got Unknown
			//IL_0352: Unknown result type (might be due to invalid IL or missing references)
			//IL_035c: Expected O, but got Unknown
			//IL_0394: Unknown result type (might be due to invalid IL or missing references)
			//IL_039e: Expected O, but got Unknown
			//IL_03d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e0: Expected O, but got Unknown
			//IL_041b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0422: Unknown result type (might be due to invalid IL or missing references)
			//IL_042c: Expected O, but got Unknown
			//IL_0467: Unknown result type (might be due to invalid IL or missing references)
			//IL_046e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0478: Expected O, but got Unknown
			//IL_0543: Unknown result type (might be due to invalid IL or missing references)
			//IL_054d: Expected O, but got Unknown
			//IL_05d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05dd: Expected O, but got Unknown
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array2 = methods;
				foreach (MethodInfo methodInfo in array2)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
			mls = Logger.CreateLogSource("MentalHospital");
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			Assets = AssetBundle.LoadFromFile(Path.Combine(directoryName, "hospitalbundle"));
			if ((Object)(object)Assets == (Object)null)
			{
				mls.LogError((object)"Failed to load DantorsMentalHospital assets.");
				return;
			}
			DungeonFlow val = Assets.LoadAsset<DungeonFlow>("Assets/Abandoned_Psychiatric_Hospitals/DunGen Data/HospitalFlow.asset");
			if ((Object)(object)val == (Object)null)
			{
				mls.LogError((object)"Failed to load DantorsMentalHospital Dungeon Flow.");
				return;
			}
			configRarity = ((BaseUnityPlugin)this).Config.Bind<int>("General", "HospitalDefaultRarity", 100, new ConfigDescription("How rare it is for the mental hospital to be chosen. Higher values increases the chance of spawning the mental hospital. Vanillas' main dungeons use a value of 300. Google Weighted Random if you don't know how it works, as that's how Lethal Company rarities function.", (AcceptableValueBase)null, Array.Empty<object>()));
			configMoons = ((BaseUnityPlugin)this).Config.Bind<string>("General", "HospitalMoonsList", "Assurance@100,Vow@100,Offense@100,March@100,Rend@100,Dine@100,Titan@100,PsychSanctum@9999", new ConfigDescription("The moon(s) that the hospital can spawn on, in the form of a comma separated list of selectable level names and optionally a weight value by using an '@' and weight value after it (e.g. \"Titan@300,Dine,Rend@10,PsychSanctum@9999\")\nThe name matching is lenient and should pick it up if you use the terminal name or internal mod name. If no rarity is specified, the HospitalRarity parameter is used.\nThe following strings: \"all\", \"vanilla\", \"modded\", \"paid\", \"free\" are dynamic presets which add the dungeon to that specified group (string must only contain one of these, or a manual moon name list).\n", (AcceptableValueBase)null, Array.Empty<object>()));
			configGuaranteed = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "HospitalGuaranteed", false, new ConfigDescription("\nSet it to true to guarantee the interior to spawn on any moon you visit. It works in any case except when if you use list mode", (AcceptableValueBase)null, Array.Empty<object>()));
			configDynamicToggle = ((BaseUnityPlugin)this).Config.Bind<bool>("Size", "DynamicScaleToggle", true, new ConfigDescription("Enables the next 3 options. \nATTENTION: READ CAREFULLY HOW IT WORKS. This adjust the dungeon size accordingly to which moon you visit, it is recommended to let it on true\nDefault: true", (AcceptableValueBase)null, Array.Empty<object>()));
			configDynamicValue = ((BaseUnityPlugin)this).Config.Bind<float>("Size", "DynamicScaleValue", 0.8f, new ConfigDescription("If the DungeonMinSize/DungeonMaxSize is above or below the next two settings, the dungeon size multiplier will aproximate to the value between the moon's specific dungeon size and this value.\nExample 1: If set to 0, the dungeon size will not be higher than DungeonMaxSize.\nExample 2: If set to 0.5, the dungeon size will be between the DungeonMaxSize and the moon's dungeon size multiplier.\nExample 3: If Set To 1, the dungeon size will be the moon's dungeon size multiplier with no restrictions.\nATTENTION: It is recommended to let it at default value or lower, the closer to 1 the bigger the dungeon.\nDefault: 0.8", (AcceptableValueBase)null, Array.Empty<object>()));
			configMinSize = ((BaseUnityPlugin)this).Config.Bind<float>("Size", "DungeonMinSize", 0.5f, new ConfigDescription("Input the minimum's dungeon size multiplier.\nDefault: 0.5", (AcceptableValueBase)null, Array.Empty<object>()));
			configMaxSize = ((BaseUnityPlugin)this).Config.Bind<float>("Size", "DungeonMaxSize", 0.65f, new ConfigDescription("Input the maximum's dungeon size multiplier.\nDefault: 0.65", (AcceptableValueBase)null, Array.Empty<object>()));
			configGreenFog = ((BaseUnityPlugin)this).Config.Bind<bool>("Interior Settings", "GreenFogToggle", true, new ConfigDescription("Sets the Hospital fog from steams valves to green, this is just an aesthetic change", (AcceptableValueBase)null, Array.Empty<object>()));
			configFogDamage = ((BaseUnityPlugin)this).Config.Bind<bool>("Interior Settings", "FogDamageToggle", true, new ConfigDescription("Enables the damage over time if you are inside the fog for too long (It only works in the Mental Hospital)", (AcceptableValueBase)null, Array.Empty<object>()));
			ExtendedDungeonFlow val2 = ScriptableObject.CreateInstance<ExtendedDungeonFlow>();
			val2.contentSourceName = "Dantors Mental Hospital";
			val2.dungeonFlow = val;
			val2.dungeonDefaultRarity = configRarity.Value;
			int num = (configGuaranteed.Value ? 99999 : configRarity.Value);
			switch (configMoons.Value.ToLower())
			{
			case "all":
				val2.dynamicLevelTagsList.Add(new StringWithRarity("Vanilla", num));
				val2.dynamicLevelTagsList.Add(new StringWithRarity("Custom", num));
				mls.LogInfo((object)"Registered DantorsMentalHospital dungeon for all moons.");
				break;
			case "vanilla":
				val2.manualContentSourceNameReferenceList.Add(new StringWithRarity("Lethal Company", num));
				mls.LogInfo((object)"Registered DantorsMentalHospital dungeon for all vanilla moons.");
				break;
			case "modded":
				val2.manualContentSourceNameReferenceList.Add(new StringWithRarity("Custom", num));
				mls.LogInfo((object)"Registered DantorsMentalHospital dungeon for all modded moons.");
				break;
			case "paid":
				val2.dynamicRoutePricesList.Add(new Vector2WithRarity(new Vector2(1f, 9999f), num));
				mls.LogInfo((object)"Registered DantorsMentalHospital dungeon for all paid moons.");
				break;
			case "free":
				val2.dynamicRoutePricesList.Add(new Vector2WithRarity(new Vector2(0f, 0f), num));
				mls.LogInfo((object)"Registered DantorsMentalHospital dungeon for all free moons.");
				break;
			default:
			{
				mls.LogInfo((object)"Registering DantorsMentalHospital dungeon for predefined moon list.");
				string[] array3 = configMoons.Value.Split(',', StringSplitOptions.RemoveEmptyEntries);
				List<StringWithRarity> list = new List<StringWithRarity>();
				for (int k = 0; k < array3.Length; k++)
				{
					string[] array4 = array3[k].Split('@', StringSplitOptions.RemoveEmptyEntries);
					int num2 = array4.Length;
					int result;
					if (num2 > 2)
					{
						mls.LogError((object)("Invalid setup for moon rarity config: " + array3[k] + ". Skipping."));
					}
					else if (num2 == 1)
					{
						mls.LogInfo((object)$"Registering DantorsMentalHospital dungeon for moon {array3[k]} at default rarity {num}");
						list.Add(new StringWithRarity(array3[k], num));
					}
					else if (!int.TryParse(array4[1], out result))
					{
						mls.LogError((object)("Failed to parse rarity value for moon " + array4[0] + ": " + array4[1] + ". Skipping."));
					}
					else
					{
						mls.LogInfo((object)$"Registering DantorsMentalHospital dungeon for moon {array3[k]} at rarity {result}");
						list.Add(new StringWithRarity(array4[0], result));
					}
				}
				val2.manualPlanetNameReferenceList = list;
				break;
			}
			}
			val2.dungeonDisplayName = "Mental Hospital";
			val2.dungeonSizeMin = configMinSize.Value;
			val2.dungeonSizeMax = configMaxSize.Value;
			val2.dungeonSizeLerpPercentage = configDynamicValue.Value;
			val2.enableDynamicDungeonSizeRestriction = configDynamicToggle.Value;
			PatchedContent.RegisterExtendedDungeonFlow(val2);
			harmony.PatchAll(typeof(MentalHospitalDunGen));
			harmony.PatchAll(typeof(RoundManagerPatch));
			harmony.PatchAll(typeof(BurstValveColorPatch));
			harmony.PatchAll(typeof(SteamValveHazard_Update_Patch));
			mls.LogInfo((object)"DantorsMentalHospital DunGen for Lethal Company [Version 1.0.0] successfully loaded.");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin MentalHospital is loaded!");
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "MentalHospital";

		public const string PLUGIN_NAME = "MentalHospital";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}

plugins/ScarletMansion.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using DunGen;
using DunGen.Adapters;
using DunGen.Graph;
using FacilityMeltdown.API;
using GameNetcodeStuff;
using HarmonyLib;
using LethalConfig;
using LethalConfig.ConfigItems;
using LethalConfig.ConfigItems.Options;
using LethalLevelLoader;
using LethalLib.Modules;
using OdinSerializer;
using ReservedItemSlotCore.Data;
using ScarletMansion.DunGenPatch;
using ScarletMansion.DunGenPatch.Doorways;
using ScarletMansion.GamePatch;
using ScarletMansion.GamePatch.Components;
using ScarletMansion.GamePatch.Enemies;
using ScarletMansion.GamePatch.FixValues;
using ScarletMansion.GamePatch.Items;
using ScarletMansion.GamePatch.Managers;
using ScarletMansion.GamePatch.Props;
using ScarletMansion.Lights;
using ScarletMansion.ModPatch;
using ScarletMansion.NetcodePatcher;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Animations.Rigging;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ScarletMansion")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ScarletMansion")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("d7e169df-3f43-44b0-a300-c23b9aa44d48")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
namespace ScarletMansion
{
	public static class Assets
	{
		public class Enemy
		{
			public GameObject enemy;

			public EnemyType enemyType;

			public Func<int> rarityFunc;

			public TerminalNode terminalNode;

			public TerminalKeyword terminalKeyword;

			public Enemy(GameObject enemy, TerminalNode node, TerminalKeyword keyword)
			{
				this.enemy = enemy;
				terminalNode = node;
				terminalKeyword = keyword;
			}

			public SpawnableEnemyWithRarity GetItemEntry(int rarity)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Expected O, but got Unknown
				SpawnableEnemyWithRarity val = new SpawnableEnemyWithRarity();
				val.enemyType = enemyType;
				val.rarity = rarity;
				return val;
			}
		}

		public class GlobalItem
		{
			public Item item;

			private int _itemId;

			public int itemId
			{
				get
				{
					if (_itemId == -1 && Object.op_Implicit((Object)(object)StartOfRound.Instance))
					{
						string text = (Object.op_Implicit((Object)(object)item) ? item.itemName : "NULL");
						_itemId = Utility.GetGlobalItemId(item);
						if (_itemId != -1)
						{
							Plugin.logger.LogWarning((object)$"Cached {_itemId} itemId for item {text}");
							return _itemId;
						}
						Plugin.logger.LogWarning((object)("Tried to get itemId for item " + text + " but failed"));
					}
					return _itemId;
				}
				set
				{
					_itemId = value;
				}
			}

			public GlobalItem(Item item)
			{
				this.item = item;
				_itemId = -1;
			}
		}

		public class ScrapItem : GlobalItem
		{
			public Func<int> rarityFunc;

			public ScrapItem(Item item, Func<int> func)
				: base(item)
			{
				rarityFunc = func;
			}

			public SpawnableItemWithRarity GetItemRarity()
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Expected O, but got Unknown
				SpawnableItemWithRarity val = new SpawnableItemWithRarity();
				val.spawnableItem = item;
				val.rarity = rarityFunc();
				return val;
			}
		}

		public class Flashlight : GlobalItem
		{
			public string assetName;

			public string displayName;

			public Item lethalVanillaItem;

			public int lethalHelmetIndex = -1;

			public int scarletHelmetIndex = -1;

			public Flashlight(string baseName, int lethalHelmetIndex)
				: base(null)
			{
				assetName = "Scarlet" + baseName;
				displayName = "D. " + baseName;
				this.lethalHelmetIndex = lethalHelmetIndex;
			}

			public bool ContainsItem(Item compareItem)
			{
				return (Object)(object)compareItem == (Object)(object)item || (Object)(object)compareItem == (Object)(object)lethalVanillaItem;
			}
		}

		public static ActionList onAssetsLoadEvent = new ActionList("onAssetsLoad");

		private const string mainAssetBundleName = "scarletmansion";

		public static AssetBundle MainAssetBundle = null;

		public static DungeonFlow dungeon;

		public static NetworkObjectListScriptableObject networkObjectList;

		public static AudioClip entranceAudioClip;

		public static ExtendedMod extendedMod;

		public static ExtendedDungeonFlow dungeonExtended;

		public static Enemy knight;

		public static Enemy maid;

		public static List<GlobalItem> globalItems;

		public static List<ScrapItem> scrapItems;

		public static Dictionary<string, Func<int>> itemRarityTable = new Dictionary<string, Func<int>>
		{
			{
				"Deco. crystal",
				() => SyncedInstance<PluginConfig>.Instance.crystalWeightValue
			},
			{
				"Shattered deco. crystal",
				() => SyncedInstance<PluginConfig>.Instance.crystalBrokenWeightValue
			},
			{
				"Demonic painting",
				() => 0
			},
			{
				"Maid's knife",
				() => 0
			},
			{
				"Doll Snow Globe",
				() => SyncedInstance<PluginConfig>.Instance.snowGlobeWeightValue
			}
		};

		public static Flashlight flashlight;

		public static Flashlight flashlightBB;

		public static ItemGroup genericItemGroup;

		public static ItemGroup tabletopItemGroup;

		public static ItemGroup smallItemGroup;

		public static bool dungeonMapHazardFound;

		public static GameObject dungeonTurretMapHazard;

		public static GameObject dungeonMinesMapHazard;

		public static GameObject dungeonSpikeTrapMapHazard;

		public static Sprite hoverIcon;

		private static ManualLogSource logger => Plugin.logger;

		public static GlobalItem GetGlobalItem(Item item)
		{
			return globalItems.FirstOrDefault((GlobalItem x) => (Object)(object)x.item == (Object)(object)item);
		}

		public static Flashlight GetFlashlight(Item item)
		{
			if (flashlight.ContainsItem(item))
			{
				return flashlight;
			}
			if (flashlightBB.ContainsItem(item))
			{
				return flashlightBB;
			}
			return null;
		}

		public static void LoadAssetBundle()
		{
			if ((Object)(object)MainAssetBundle == (Object)null)
			{
				Assembly executingAssembly = Assembly.GetExecutingAssembly();
				string[] manifestResourceNames = executingAssembly.GetManifestResourceNames();
				if (manifestResourceNames.Length >= 1)
				{
					string text = manifestResourceNames[0];
					using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(text);
					Plugin.logger.LogInfo((object)("Loading resource " + text));
					MainAssetBundle = AssetBundle.LoadFromStream(stream);
				}
			}
			dungeon = Assets.Load<DungeonFlow>("SDMLevel", onlyReportErrors: true);
			networkObjectList = Assets.Load<NetworkObjectListScriptableObject>("SDMList", onlyReportErrors: true);
			entranceAudioClip = Assets.Load<AudioClip>("entrance_ogg", onlyReportErrors: true);
			knight = new Enemy(Assets.Load<GameObject>("NET_KnightEnemy", onlyReportErrors: true), Assets.Load<TerminalNode>("KnightNode", onlyReportErrors: true), Assets.Load<TerminalKeyword>("KnightKeyword", onlyReportErrors: true));
			maid = new Enemy(Assets.Load<GameObject>("NET_MaidEnemy", onlyReportErrors: true), Assets.Load<TerminalNode>("MaidNode", onlyReportErrors: true), Assets.Load<TerminalKeyword>("MaidKeyword", onlyReportErrors: true));
			RegisterNetworkPrefab(networkObjectList.networkDungeon);
			RegisterNetworkPrefab(networkObjectList.networkDoors);
			RegisterNetworkPrefab(networkObjectList.networkItems);
			RegisterNetworkPrefab(networkObjectList.networkFrames);
			RegisterNetworkPrefab(networkObjectList.networkOther);
			globalItems = new List<GlobalItem>();
			scrapItems = new List<ScrapItem>();
			foreach (Item item3 in networkObjectList.items)
			{
				GlobalItem item = new GlobalItem(item3);
				globalItems.Add(item);
				Items.RegisterItem(item3);
				Plugin.logger.LogInfo((object)("Global Item " + item3.itemName + " registered"));
			}
			foreach (Item scrapItem in networkObjectList.scrapItems)
			{
				ScrapItem item2 = new ScrapItem(scrapItem, GetItemRarityFunction(scrapItem));
				scrapItems.Add(item2);
				globalItems.Add(item2);
				Items.RegisterScrap(scrapItem, 0, (LevelTypes)1);
				NetworkPrefabs.RegisterNetworkPrefab(scrapItem.spawnPrefab);
				Plugin.logger.LogInfo((object)("Scrap Item " + scrapItem.itemName + " registered"));
			}
			flashlight = new Flashlight("Pro Flashlight", 0);
			flashlightBB = new Flashlight("Flashlight", 1);
			globalItems.Add(flashlight);
			globalItems.Add(flashlightBB);
			onAssetsLoadEvent.Call();
		}

		public static Func<int> GetItemRarityFunction(Item item)
		{
			string itemName = item.itemName;
			if (itemRarityTable.ContainsKey(itemName))
			{
				return itemRarityTable[itemName];
			}
			Plugin.logger.LogError((object)("Could not find rarity function for " + itemName + ". Setting to default value 10"));
			return () => 10;
		}

		private static void RegisterNetworkPrefab(List<GameObject> list)
		{
			foreach (GameObject item in list)
			{
				NetworkPrefabs.RegisterNetworkPrefab(item);
			}
		}

		public static T Load<T>(string name, bool onlyReportErrors = true) where T : Object
		{
			if ((Object)(object)MainAssetBundle == (Object)null)
			{
				logger.LogError((object)"Trying to load in asset but asset bundle is missing");
				return default(T);
			}
			T val = MainAssetBundle.LoadAsset<T>(name);
			bool flag = (Object)(object)val == (Object)null;
			if (flag || onlyReportErrors)
			{
				logger.LogInfo((object)("Loading asset " + name));
			}
			if (flag)
			{
				logger.LogError((object)"...but it was not found");
			}
			return val;
		}
	}
	public static class AnalysisUtilities
	{
		public class Average
		{
			public List<float> values;

			public float total;

			public Average()
			{
				values = new List<float>();
			}

			public void Add(float value)
			{
				values.Add(value);
				total += value;
			}

			public float GetAverage()
			{
				if (values.Count == 0)
				{
					return 0f;
				}
				return total / (float)values.Count;
			}

			public float GetStdDev()
			{
				if (values.Count == 0)
				{
					return 0f;
				}
				float avg = GetAverage();
				float num = values.Sum(delegate(float i)
				{
					float num2 = i - avg;
					return num2 * num2;
				});
				return Mathf.Sqrt(num / (float)values.Count);
			}

			public override string ToString()
			{
				List<string> list = new List<string>();
				values.Sort();
				int num = Mathf.Clamp(values.Count, 1, 10);
				int num2 = values.Count / num;
				for (int i = 0; i * num2 < values.Count; i++)
				{
					float average = GetAverage(values.Skip(i * num2).Take(num2));
					list.Add($"[{i}]{average}");
				}
				string text = string.Join(", ", list);
				return "(" + text + ")";
			}

			public float GetAverage(IEnumerable<float> items)
			{
				return items.Sum() / (float)items.Count();
			}
		}
	}
	public static class DunGenAnalyis
	{
		public class Average
		{
			public float totalVolume;

			public float totalWeight;

			public Dictionary<string, bool> baseDictionary = new Dictionary<string, bool> { { "SM_MayorEntrance_FINAL_32x24 Tile", false } };

			public float average => (totalWeight > 0f) ? (totalVolume / totalWeight) : 0f;

			public void AddToAverage(float volume, float weight, string name)
			{
				bool value = false;
				if (!baseDictionary.TryGetValue(name, out value))
				{
					totalVolume += volume;
					totalWeight += weight;
				}
			}

			public void AddToBase(float volume, string name)
			{
				bool value = false;
				bool flag = baseDictionary.TryGetValue(name, out value);
				totalWeight = 1f;
				if (flag && !value)
				{
					totalVolume += volume;
					baseDictionary[name] = true;
				}
			}

			public override string ToString()
			{
				return $"{totalVolume / totalWeight}";
			}
		}

		public static void Analysis(DungeonFlow flow, StartOfRound startofround, RoundManager roundmanager)
		{
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			SelectableLevel[] levels = startofround.levels;
			foreach (SelectableLevel val in levels)
			{
				float num = val.factorySizeMultiplier * roundmanager.mapSizeMultiplier;
				Plugin.logger.LogInfo((object)$"{val.PlanetName}: {num}");
				IntRange length = flow.Length;
				int num2 = Mathf.RoundToInt((float)length.Min * num);
				int num3 = Mathf.RoundToInt((float)length.Max * num);
				float num4 = 0f;
				for (int j = 0; j <= num2; j++)
				{
					num4 += GetAverage(flow, num2, j, 0);
					num4 += GetAverage(flow, num2, j, 1);
					num4 += GetAverage(flow, num2, j, 2);
				}
				float num5 = 0f;
				for (int k = 0; k <= num3; k++)
				{
					num5 += GetAverage(flow, num3, k, 0);
					num5 += GetAverage(flow, num3, k, 1);
					num5 += GetAverage(flow, num3, k, 2);
				}
				Bounds dungeonBounds = Patch.GetDungeonBounds(num);
				float num6 = GetVolume(dungeonBounds) * 0.6f;
				string text = (num4 / num6).ToString("0.00");
				string text2 = (num5 / num6).ToString("0.00");
				Plugin.logger.LogInfo((object)$"Min size required: {num4} - {num5}");
				Plugin.logger.LogInfo((object)$"All space: {num6}");
				Plugin.logger.LogInfo((object)("Taken space: " + text + " - " + text2));
				Plugin.logger.LogInfo((object)"");
			}
		}

		public static float GetAverage(DungeonFlow flow, int length, int index, int lineIndex)
		{
			Average average = new Average();
			float num = (float)index / (float)length;
			if (num <= 1f)
			{
				if (num == 0f)
				{
					if (lineIndex == 0)
					{
						foreach (TileSet tileSet in flow.Nodes[0].TileSets)
						{
							ModifyAverage(tileSet, average, 0f);
						}
					}
				}
				else if (num == 1f)
				{
					foreach (TileSet tileSet2 in flow.Nodes[1].TileSets)
					{
						ModifyAverage(tileSet2, average, num);
					}
				}
				else if (index == 1)
				{
					if (lineIndex == 0)
					{
						foreach (DungeonArchetype dungeonArchetype in flow.Lines[0].DungeonArchetypes)
						{
							foreach (TileSet tileSet3 in dungeonArchetype.TileSets)
							{
								AddBase(tileSet3, average);
							}
						}
					}
				}
				else
				{
					GraphLine lineAtDepth = flow.GetLineAtDepth(num);
					foreach (DungeonArchetype dungeonArchetype2 in lineAtDepth.DungeonArchetypes)
					{
						foreach (TileSet tileSet4 in dungeonArchetype2.TileSets)
						{
							ModifyAverage(tileSet4, average, num);
						}
					}
				}
			}
			return average.average;
		}

		public static void AddBase(TileSet tileset, Average baseVol)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			foreach (GameObjectChance weight in tileset.TileWeights.Weights)
			{
				GameObject value = weight.Value;
				Tile component = value.GetComponent<Tile>();
				float volume = GetVolume(component.TileBoundsOverride);
				baseVol.AddToBase(volume, ((Object)weight.Value).name);
			}
		}

		public static void ModifyAverage(TileSet tileset, Average averageVol, float depth)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			foreach (GameObjectChance weight in tileset.TileWeights.Weights)
			{
				GameObject value = weight.Value;
				Tile component = value.GetComponent<Tile>();
				float volume = GetVolume(component.TileBoundsOverride);
				float num = weight.MainPathWeight * weight.DepthWeightScale.Evaluate(depth);
				averageVol.AddToAverage(volume * num, num, ((Object)weight.Value).name);
			}
		}

		public static float GetVolume(Bounds bounds)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//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)
			//IL_000f: 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)
			Vector3 size = ((Bounds)(ref bounds)).size;
			return size.x * size.y * size.z;
		}
	}
	public class DoorwayConnectionSisterChain : MonoBehaviour
	{
		public Doorway[] chain;

		public bool loop = true;

		[ContextMenu("Create Chain")]
		public void CreateChain()
		{
			if (chain == null || chain.Length <= 1)
			{
				return;
			}
			for (int i = 0; i < chain.Length; i++)
			{
				Doorway val = chain[i];
				List<Doorway> list = new List<Doorway>();
				if (i > 0 || loop)
				{
					Doorway item = chain[(i - 1 + chain.Length) % chain.Length];
					list.Add(item);
				}
				if (i < chain.Length - 1 || loop)
				{
					Doorway item2 = chain[(i + 1 + chain.Length) % chain.Length];
					list.Add(item2);
				}
				DoorwayConnectionSisterRuleInfo doorwayConnectionSisterRuleInfo = ((Component)val).GetComponent<DoorwayConnectionSisterRuleInfo>();
				if ((Object)(object)doorwayConnectionSisterRuleInfo == (Object)null)
				{
					doorwayConnectionSisterRuleInfo = ((Component)val).gameObject.AddComponent<DoorwayConnectionSisterRuleInfo>();
				}
				doorwayConnectionSisterRuleInfo.sisters = list.ToArray();
			}
		}

		public void OnDrawGizmosSelected()
		{
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: 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)
			if (chain == null || chain.Length <= 1)
			{
				return;
			}
			Color color = default(Color);
			for (int i = 0; i < chain.Length; i++)
			{
				if (loop || i != chain.Length - 1)
				{
					Doorway val = chain[i];
					Doorway val2 = chain[(i + 1) % chain.Length];
					((Color)(ref color))..ctor((float)i / (float)chain.Length, 1f, 1f);
					Gizmos.color = color;
					Gizmos.DrawLine(((Component)val).transform.position, ((Component)val2).transform.position);
				}
			}
		}
	}
	public class DoorwayConnectionSisterRuleInfo : MonoBehaviour
	{
		private Doorway _self;

		public Doorway[] sisters;

		public Doorway self
		{
			get
			{
				if ((Object)(object)_self == (Object)null)
				{
					_self = ((Component)this).GetComponent<Doorway>();
				}
				return _self;
			}
		}

		public void OnDrawGizmosSelected()
		{
			//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_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: 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_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = ((Component)this).transform.position;
			if (sisters == null)
			{
				return;
			}
			Doorway[] array = sisters;
			foreach (Doorway val in array)
			{
				Vector3 position2 = ((Component)val).transform.position;
				DoorwayConnectionSisterRuleInfo component = ((Component)val).GetComponent<DoorwayConnectionSisterRuleInfo>();
				if ((Object)(object)self == (Object)null)
				{
					Gizmos.color = Color.magenta;
				}
				else if ((Object)(object)component == (Object)null || component.sisters == null)
				{
					Gizmos.color = Color.yellow;
				}
				else if (!component.sisters.Contains(self))
				{
					Gizmos.color = Color.red;
				}
				else
				{
					Gizmos.color = Color.green;
				}
				Gizmos.DrawLine(position, position2);
			}
		}
	}
	public class MainRoomDoorwayGroups : MonoBehaviour
	{
		public List<Doorway> groupA;

		public List<Doorway> groupB;

		public List<Doorway> groupBasement;

		public List<Doorway> GrabDoorwayGroup(Doorway target)
		{
			if (groupA.Contains(target))
			{
				return groupA;
			}
			if (groupB.Contains(target))
			{
				return groupB;
			}
			if (groupBasement.Contains(target))
			{
				return groupBasement;
			}
			return null;
		}
	}
	public class RemoveConnectorIfConnectedDoorwayBasic : MonoBehaviour, IDungeonCompleteReceiver
	{
		public void OnDungeonComplete(Dungeon dungeon)
		{
			Doorway component = ((Component)this).GetComponent<Doorway>();
			if (!((Object)(object)component == (Object)null) && !((Object)(object)component.ConnectedDoorway == (Object)null) && component.ConnectedDoorway.DoorPrefabPriority == 0)
			{
				component.ConnectorSceneObjects[0].SetActive(false);
			}
		}
	}
	public class FloorCleanup : MonoBehaviour
	{
		[Serializable]
		public class State
		{
			public int value;

			public Material material;

			public float rotation;
		}

		[Header("References")]
		public MeshRenderer targetRenderer;

		public GameObject targerGameObject;

		public int bitValueCheck;

		[Header("Logic")]
		public GameObject[] neighbors;

		public int[] stateValues;

		public Material[] stateMaterials;

		public float[] stateRotations;

		public State[] states;

		private void Reset()
		{
			targetRenderer = ((Component)this).GetComponent<MeshRenderer>();
			targerGameObject = ((Component)this).gameObject;
		}

		public bool UpdateRender()
		{
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			int num = 0;
			int num2 = (1 << neighbors.Length) - 1;
			for (int i = 0; i < neighbors.Length; i++)
			{
				GameObject val = neighbors[i];
				if ((Object)(object)val != (Object)null && neighbors[i].activeSelf)
				{
					num += 1 << i;
				}
			}
			if (num == num2)
			{
				return false;
			}
			for (int j = 0; j < stateValues.Length; j++)
			{
				if (stateValues[j] == num)
				{
					((Renderer)targetRenderer).material = stateMaterials[j];
					((Component)targetRenderer).transform.localEulerAngles = new Vector3(0f, stateRotations[j], 0f);
					return false;
				}
			}
			bool activeSelf = targerGameObject.activeSelf;
			targerGameObject.SetActive(false);
			return activeSelf;
		}

		private void OnDrawGizmosSelected()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			Gizmos.color = Color.green;
			for (int i = 0; i < neighbors.Length; i++)
			{
				if ((bitValueCheck & (1 << i)) > 0)
				{
					Gizmos.DrawCube(neighbors[i].transform.position, Vector3.one);
				}
			}
		}
	}
	public class FloorCleanUpParent : MonoBehaviour, IDungeonCompleteReceiver
	{
		public FloorCleanup[] children;

		private void Reset()
		{
			children = ((Component)this).GetComponentsInChildren<FloorCleanup>();
		}

		public void OnDungeonComplete(Dungeon dungeon)
		{
			bool flag = true;
			while (flag)
			{
				flag = false;
				FloorCleanup[] array = children;
				foreach (FloorCleanup floorCleanup in array)
				{
					flag |= floorCleanup.UpdateRender();
				}
			}
		}
	}
	public class KnightSpawnPoint : MonoBehaviour
	{
		public int index;

		public const float minTime = 4f;

		public const float maxTime = 8f;

		public const float minSqrDistance = 36f;

		public void Start()
		{
			if (GameNetworkManager.Instance.isHostingGame)
			{
				((MonoBehaviour)this).StartCoroutine(GetNearbyPlayers());
			}
		}

		public IEnumerator GetNearbyPlayers()
		{
			while (true)
			{
				float randomWait = Random.Range(4f, 8f);
				yield return (object)new WaitForSeconds(randomWait);
				StartOfRound sround = StartOfRound.Instance;
				PlayerControllerB[] players = sround.allPlayerScripts;
				int playerCount = sround.connectedPlayersAmount + 1;
				int i = 0;
				while (i < playerCount)
				{
					PlayerControllerB player = players[i];
					if (player.isPlayerControlled || !player.isPlayerDead)
					{
						float dist = Vector3.SqrMagnitude(((Component)this).transform.position - ((Component)player).transform.position);
						if (dist <= 36f)
						{
							KnightSpawnManager.Instance.lastKnightSeenPlayer = index;
							Plugin.logger.LogInfo((object)$"Knight {index} has noticed player {player.playerUsername}");
						}
					}
					int num = i + 1;
					i = num;
				}
			}
		}
	}
	public class ScarletVent : MonoBehaviour
	{
		public AudioSource shakeAudioSource;

		public AudioSource summonAudioSource;

		public PlayAudioAnimationEvent audioEvent;

		[Header("Shake")]
		public ParticleSystem spawningPartciles;

		public ParticleSystem lightingParticles;

		public ParticleSystem emitParticles;

		public float volumeToRate = 1f;

		public static bool prewarm;

		private void Start()
		{
			if (!prewarm)
			{
				OpenVentClientRpc();
				prewarm = true;
				Plugin.logger.LogInfo((object)"Prewarming particles by forcing it emit now lmao");
			}
		}

		private void PlayParticleSystem(ParticleSystem ps)
		{
			if (!ps.isPlaying)
			{
				ps.Play();
			}
		}

		private void StopParticleSystem(ParticleSystem ps)
		{
			if (ps.isPlaying)
			{
				ps.Stop();
			}
		}

		public void OpenVentClientRpc()
		{
			emitParticles.Play();
			audioEvent.PlayAudio1Oneshot();
		}

		private void Update()
		{
			if (shakeAudioSource.isPlaying)
			{
				PlayParticleSystem(spawningPartciles);
				SetEmissionRate(spawningPartciles, shakeAudioSource.volume * volumeToRate);
				if (shakeAudioSource.volume >= 0.8f)
				{
					PlayParticleSystem(lightingParticles);
				}
				else
				{
					StopParticleSystem(lightingParticles);
				}
			}
			else
			{
				StopParticleSystem(spawningPartciles);
				StopParticleSystem(lightingParticles);
			}
		}

		private void SetEmissionRate(ParticleSystem ps, float mult)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			EmissionModule emission = ps.emission;
			((EmissionModule)(ref emission)).rateOverTimeMultiplier = mult;
		}
	}
	public class KnightVariant : EnemyAI
	{
		public AISearchRoutine searchForPlayers;

		private bool stoppingMovement;

		private bool hasStopped;

		public AnimationStopPoints animStopPoints;

		private float currentChaseSpeed = 10.875f;

		private float currentAnimSpeed = 1f;

		private PlayerControllerB previousTarget;

		private bool wasOwnerLastFrame;

		private float stopAndGoMinimumInterval;

		private float timeSinceHittingPlayer;

		public AudioClip[] springNoises;

		public Collider mainCollider;

		public override void Start()
		{
			((EnemyAI)this).Start();
			if (((NetworkBehaviour)this).IsOwner && Object.op_Implicit((Object)(object)KnightSpawnManager.Instance))
			{
				int spawnPointIndex = KnightSpawnManager.Instance.GetSpawnPointIndex();
				if (spawnPointIndex != -1)
				{
					SyncKnightReplacementClientRpc(spawnPointIndex);
				}
			}
		}

		public override void DoAIInterval()
		{
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: 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_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).DoAIInterval();
			StartOfRound instance = StartOfRound.Instance;
			if (instance.allPlayersDead || base.isEnemyDead)
			{
				return;
			}
			switch (base.currentBehaviourStateIndex)
			{
			case 1:
				if (searchForPlayers.inProgress)
				{
					((EnemyAI)this).StopSearch(searchForPlayers, true);
				}
				if (((EnemyAI)this).TargetClosestPlayer(1.5f, false, 70f))
				{
					if ((Object)(object)previousTarget != (Object)(object)base.targetPlayer)
					{
						previousTarget = base.targetPlayer;
						((EnemyAI)this).ChangeOwnershipOfEnemy(base.targetPlayer.actualClientId);
					}
					base.movingTowardsTargetPlayer = true;
				}
				else
				{
					((EnemyAI)this).SwitchToBehaviourState(0);
					((EnemyAI)this).ChangeOwnershipOfEnemy(instance.allPlayerScripts[0].actualClientId);
				}
				break;
			case 0:
			{
				if (!((NetworkBehaviour)this).IsServer)
				{
					((EnemyAI)this).ChangeOwnershipOfEnemy(instance.allPlayerScripts[0].actualClientId);
					break;
				}
				for (int i = 0; i < ModCompability.GetStartOfRoundScriptLength(); i++)
				{
					PlayerControllerB val = instance.allPlayerScripts[i];
					if (((EnemyAI)this).PlayerIsTargetable(val, false, false))
					{
						bool flag = !Physics.Linecast(((Component)this).transform.position + Vector3.up * 0.5f, ((Component)val.gameplayCamera).transform.position, instance.collidersAndRoomMaskAndDefault);
						bool flag2 = Vector3.SqrMagnitude(((Component)this).transform.position - ((Component)val).transform.position) < 900f;
						if (flag && flag2)
						{
							((EnemyAI)this).SwitchToBehaviourState(1);
							return;
						}
					}
				}
				base.agent.speed = 6f;
				if (!searchForPlayers.inProgress)
				{
					base.movingTowardsTargetPlayer = false;
					((EnemyAI)this).StartSearch(((Component)this).transform.position, searchForPlayers);
				}
				break;
			}
			}
		}

		public override void Update()
		{
			//IL_0356: Unknown result type (might be due to invalid IL or missing references)
			//IL_0361: Unknown result type (might be due to invalid IL or missing references)
			//IL_0366: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_0289: Unknown result type (might be due to invalid IL or missing references)
			//IL_0295: Unknown result type (might be due to invalid IL or missing references)
			//IL_029a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).Update();
			if (base.isEnemyDead)
			{
				return;
			}
			if (timeSinceHittingPlayer >= 0f)
			{
				timeSinceHittingPlayer -= Time.deltaTime;
			}
			int currentBehaviourStateIndex = base.currentBehaviourStateIndex;
			StartOfRound instance = StartOfRound.Instance;
			if (currentBehaviourStateIndex == 0 || currentBehaviourStateIndex != 1)
			{
				return;
			}
			if (((NetworkBehaviour)this).IsOwner)
			{
				if (stopAndGoMinimumInterval > 0f)
				{
					stopAndGoMinimumInterval -= Time.deltaTime;
				}
				if (!wasOwnerLastFrame)
				{
					wasOwnerLastFrame = true;
					if (!stoppingMovement && timeSinceHittingPlayer < 0.12f)
					{
						base.agent.speed = currentChaseSpeed;
					}
					else
					{
						base.agent.speed = 0f;
					}
				}
				bool flag = false;
				for (int i = 0; i < ModCompability.GetStartOfRoundScriptLength(); i++)
				{
					PlayerControllerB val = instance.allPlayerScripts[i];
					if (((EnemyAI)this).PlayerIsTargetable(val, false, false))
					{
						bool flag2 = val.HasLineOfSightToPosition(((Component)this).transform.position + Vector3.up * 1.6f, 68f, 60, -1f);
						bool flag3 = Vector3.SqrMagnitude(((Component)val.gameplayCamera).transform.position - base.eye.position) > 0.09f;
						if (flag2 && flag3)
						{
							flag = true;
						}
					}
				}
				if (base.stunNormalizedTimer > 0f)
				{
					flag = true;
				}
				if (flag != stoppingMovement && stopAndGoMinimumInterval <= 0f)
				{
					stopAndGoMinimumInterval = 0.15f;
					if (flag)
					{
						SetAnimationStopServerRpc();
					}
					else
					{
						SetAnimationGoServerRpc();
					}
					stoppingMovement = flag;
				}
			}
			if (stoppingMovement)
			{
				if (!animStopPoints.canAnimationStop)
				{
					return;
				}
				PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
				if (!hasStopped)
				{
					hasStopped = true;
					if (localPlayerController.HasLineOfSightToPosition(((Component)this).transform.position, 70f, 25, -1f))
					{
						float num = Vector3.SqrMagnitude(((Component)this).transform.position - ((Component)localPlayerController).transform.position);
						if (num < 16f)
						{
							localPlayerController.JumpToFearLevel(0.9f, true);
						}
						else if (num < 81f)
						{
							localPlayerController.JumpToFearLevel(0.4f, true);
						}
					}
					if (currentAnimSpeed > 2f)
					{
						RoundManager.PlayRandomClip(base.creatureVoice, springNoises, false, 1f, 0, 1000);
						if (animStopPoints.animationPosition == 1)
						{
							base.creatureAnimator.SetTrigger("springBoing");
						}
						else
						{
							base.creatureAnimator.SetTrigger("springBoingPosition2");
						}
					}
				}
				bool flag4 = Vector3.SqrMagnitude(((Component)localPlayerController).transform.position - ((Component)this).transform.position) > 0.0625f;
				if (mainCollider.isTrigger && flag4)
				{
					mainCollider.isTrigger = false;
				}
				base.creatureAnimator.SetFloat("walkSpeed", 0f);
				currentAnimSpeed = 0f;
				if (((NetworkBehaviour)this).IsOwner)
				{
					base.agent.speed = 0f;
				}
			}
			else
			{
				if (hasStopped)
				{
					hasStopped = false;
					mainCollider.isTrigger = true;
				}
				currentAnimSpeed = Mathf.Lerp(currentAnimSpeed, 5f, 3f * Time.deltaTime);
				base.creatureAnimator.SetFloat("walkSpeed", currentAnimSpeed);
				if (((NetworkBehaviour)this).IsOwner)
				{
					base.agent.speed = Mathf.Lerp(base.agent.speed, currentChaseSpeed, 4.5f * Time.deltaTime);
				}
			}
		}

		[ServerRpc]
		public void SetAnimationStopServerRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Invalid comparison between Unknown and I4
			//IL_00a5: 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_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Invalid comparison between Unknown and I4
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
				{
					if ((int)networkManager.LogLevel <= 1)
					{
						Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
					}
					return;
				}
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3882357060u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3882357060u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				SetAnimationStopClientRpc();
			}
		}

		[ClientRpc]
		public void SetAnimationStopClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1023489990u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1023489990u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					stoppingMovement = true;
				}
			}
		}

		[ServerRpc]
		public void SetAnimationGoServerRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Invalid comparison between Unknown and I4
			//IL_00a5: 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_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Invalid comparison between Unknown and I4
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
				{
					if ((int)networkManager.LogLevel <= 1)
					{
						Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
					}
					return;
				}
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1320084365u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1320084365u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				SetAnimationGoClientRpc();
			}
		}

		[ClientRpc]
		public void SetAnimationGoClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3930434877u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3930434877u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					stoppingMovement = false;
				}
			}
		}

		public override void OnCollideWithPlayer(Collider other)
		{
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).OnCollideWithPlayer(other);
			if (!stoppingMovement && base.currentBehaviourStateIndex == 1 && !(timeSinceHittingPlayer >= 0f))
			{
				PlayerControllerB val = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(other, false, false);
				if ((Object)(object)val != (Object)null)
				{
					timeSinceHittingPlayer = 0.2f;
					val.DamagePlayer(90, true, true, (CauseOfDeath)6, 1, false, default(Vector3));
					val.JumpToFearLevel(1f, true);
				}
			}
		}

		[ClientRpc]
		public void SyncKnightReplacementClientRpc(int index)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: 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_0071: 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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3956096293u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, index);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3956096293u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					SyncKnightReplacement(index);
				}
			}
		}

		public void SyncKnightReplacement(int index)
		{
			//IL_003d: 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_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: 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)
			Plugin.logger.LogInfo((object)$"Spawning knight at {index}");
			try
			{
				Transform spawnPointTransform = KnightSpawnManager.Instance.GetSpawnPointTransform(index);
				((Component)spawnPointTransform).gameObject.SetActive(false);
				((Component)this).transform.position = spawnPointTransform.position;
				((Component)this).transform.rotation = spawnPointTransform.rotation;
				base.serverPosition = spawnPointTransform.position;
				if ((Object)(object)base.agent == (Object)null)
				{
					base.agent = ((Component)this).GetComponentInChildren<NavMeshAgent>();
				}
				base.agent.Warp(spawnPointTransform.position);
				if (((NetworkBehaviour)this).IsOwner)
				{
					((EnemyAI)this).SyncPositionToClients();
				}
			}
			catch (Exception ex)
			{
				Plugin.logger.LogError((object)$"Tried to knight spawn at {index}, but completely failed");
				Plugin.logger.LogError((object)ex);
			}
		}

		protected override void __initializeVariables()
		{
			((EnemyAI)this).__initializeVariables();
		}

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_KnightVariant()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(3882357060u, new RpcReceiveHandler(__rpc_handler_3882357060));
			NetworkManager.__rpc_func_table.Add(1023489990u, new RpcReceiveHandler(__rpc_handler_1023489990));
			NetworkManager.__rpc_func_table.Add(1320084365u, new RpcReceiveHandler(__rpc_handler_1320084365));
			NetworkManager.__rpc_func_table.Add(3930434877u, new RpcReceiveHandler(__rpc_handler_3930434877));
			NetworkManager.__rpc_func_table.Add(3956096293u, new RpcReceiveHandler(__rpc_handler_3956096293));
		}

		private static void __rpc_handler_3882357060(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0029: 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_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Invalid comparison between Unknown and I4
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId)
			{
				if ((int)networkManager.LogLevel <= 1)
				{
					Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
				}
			}
			else
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((KnightVariant)(object)target).SetAnimationStopServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1023489990(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((KnightVariant)(object)target).SetAnimationStopClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1320084365(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0029: 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_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Invalid comparison between Unknown and I4
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId)
			{
				if ((int)networkManager.LogLevel <= 1)
				{
					Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
				}
			}
			else
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((KnightVariant)(object)target).SetAnimationGoServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3930434877(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((KnightVariant)(object)target).SetAnimationGoClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3956096293(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int index = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref index);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((KnightVariant)(object)target).SyncKnightReplacementClientRpc(index);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "KnightVariant";
		}
	}
	public class KnightSpawnManager : MonoBehaviour, IDungeonCompleteReceiver
	{
		public List<KnightSpawnPoint> spawnPoints;

		public List<KnightSpawnPoint> unusedSpawnPoints;

		public int lastKnightSeenPlayer = -1;

		public bool disableNextKnightSpecialSpawn;

		public static KnightSpawnManager Instance { get; private set; }

		private void Awake()
		{
			Instance = this;
		}

		public void OnDungeonComplete(Dungeon dungeon)
		{
			KnightSpawnPoint[] componentsInChildren = ((Component)dungeon).GetComponentsInChildren<KnightSpawnPoint>();
			spawnPoints = componentsInChildren.ToList();
			for (int i = 0; i < spawnPoints.Count; i++)
			{
				spawnPoints[i].index = i;
			}
			unusedSpawnPoints = componentsInChildren.ToList();
			Plugin.logger.LogInfo((object)$"Found {spawnPoints.Count} spawn points for the knight");
		}

		public int GetSpawnPointIndex()
		{
			if (disableNextKnightSpecialSpawn)
			{
				disableNextKnightSpecialSpawn = true;
				return -1;
			}
			if (unusedSpawnPoints.Count == 0)
			{
				return -1;
			}
			if (lastKnightSeenPlayer >= 0)
			{
				KnightSpawnPoint knightSpawnPoint = spawnPoints[lastKnightSeenPlayer];
				if (((Component)knightSpawnPoint).gameObject.activeInHierarchy)
				{
					Plugin.logger.LogInfo((object)$"Using the last knight {knightSpawnPoint.index} that saw a player");
					unusedSpawnPoints.Remove(knightSpawnPoint);
					lastKnightSeenPlayer = -1;
					return knightSpawnPoint.index;
				}
			}
			int index = Random.Range(0, unusedSpawnPoints.Count);
			KnightSpawnPoint knightSpawnPoint2 = unusedSpawnPoints[index];
			unusedSpawnPoints.RemoveAt(index);
			return knightSpawnPoint2.index;
		}

		public Transform GetSpawnPointTransform(int index)
		{
			return ((Component)spawnPoints[index]).transform;
		}
	}
	public struct ScarletNetworkParams : INetworkSerializeByMemcpy
	{
		public int scrapValue;

		public int specialValue;
	}
	public class ItemReference
	{
		public Item item;

		public int itemId;

		public int value;

		public ItemReference(Item item, int itemId, int value)
		{
			this.item = item;
			this.itemId = itemId;
			this.value = value;
		}

		public override string ToString()
		{
			string arg = (Object.op_Implicit((Object)(object)item) ? ((Object)item).name : "NULL");
			return $"{arg}:{itemId} ({value})";
		}
	}
	public class EnemyReference
	{
		public EnemyType enemy;

		public int index;

		public EnemyReference(EnemyType enemy, int index)
		{
			this.enemy = enemy;
			this.index = index;
		}

		public override string ToString()
		{
			string arg = (Object.op_Implicit((Object)(object)enemy) ? ((Object)enemy).name : "NULL");
			return $"{arg}:{index}";
		}
	}
	public class EnemyReferenceSpawnLogic : EnemyReference
	{
		public enum SpawnLogic
		{
			None,
			Special
		}

		public SpawnLogic logic;

		public EnemyReferenceSpawnLogic(EnemyType enemy, int index, SpawnLogic logic)
			: base(enemy, index)
		{
			this.logic = logic;
		}

		public void ApplySpawnLogic()
		{
			if (logic != 0)
			{
				string text = ((Object)enemy).name.ToLowerInvariant();
				if (text == "knight")
				{
					KnightSpawnManager.Instance.disableNextKnightSpecialSpawn = true;
				}
				else if (text == "jester")
				{
					JesterAIPatch.active = true;
				}
			}
		}

		public override string ToString()
		{
			string text = base.ToString();
			return text + " [" + logic.ToString() + "]";
		}
	}
	public class ScarletNetworkManager : NetworkBehaviour
	{
		public static ScarletNetworkManager Instance { get; private set; }

		private void Awake()
		{
			Instance = this;
		}

		[ServerRpc(RequireOwnership = false)]
		public void DestroyPlayerItemInSlotServerRpc(NetworkBehaviourReference playerRef, int itemSlot, ServerRpcParams callParams = default(ServerRpcParams))
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Invalid comparison between Unknown and I4
			//IL_005f: 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_007d: 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)
			//IL_008c: 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_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(3412664016u, callParams, (RpcDelivery)0);
				((FastBufferWriter)(ref val)).WriteValueSafe<NetworkBehaviourReference>(ref playerRef, default(ForNetworkSerializable));
				BytePacker.WriteValueBitPacked(val, itemSlot);
				((NetworkBehaviour)this).__endSendServerRpc(ref val, 3412664016u, callParams, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				PlayerControllerB val2 = default(PlayerControllerB);
				if (((NetworkBehaviourReference)(ref playerRef)).TryGet<PlayerControllerB>(ref val2, (NetworkManager)null))
				{
					Plugin.logger.LogInfo((object)$"P{((NetworkBehaviour)val2).OwnerClientId}, S{callParams.Receive.SenderClientId}");
					DestroyPlayerItemInSlotClientRpc(playerRef, itemSlot);
				}
				else
				{
					Plugin.logger.LogError((object)"Error trying to get player script (SERVERRPC)");
				}
			}
		}

		[ClientRpc]
		public void DestroyPlayerItemInSlotClientRpc(NetworkBehaviourReference playerRef, int itemSlot)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Invalid comparison between Unknown and I4
			//IL_005f: 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_007d: 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)
			//IL_008c: 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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(345840887u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkBehaviourReference>(ref playerRef, default(ForNetworkSerializable));
				BytePacker.WriteValueBitPacked(val2, itemSlot);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 345840887u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				PlayerControllerB val3 = default(PlayerControllerB);
				if (((NetworkBehaviourReference)(ref playerRef)).TryGet<PlayerControllerB>(ref val3, (NetworkManager)null) && !((NetworkBehaviour)val3).IsOwner)
				{
					val3.DestroyPlayerItemInSlot_SDM(itemSlot);
				}
				else if ((Object)(object)val3 == (Object)null)
				{
					Plugin.logger.LogError((object)"Error trying to get player script (CLIENTRPC)");
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void CreateItemServerRpc(int itemId, Vector3 position, ScarletNetworkParams callParams = default(ScarletNetworkParams))
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Invalid comparison between Unknown and I4
			//IL_005f: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(4119288164u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, itemId);
					((FastBufferWriter)(ref val2)).WriteValueSafe(ref position);
					((FastBufferWriter)(ref val2)).WriteValueSafe<ScarletNetworkParams>(ref callParams, default(ForStructs));
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 4119288164u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					CreateItem(itemId, fromScrapArray: false, position, null, callParams);
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void CreateItemServerRpc(int itemId, Vector3 position, NetworkBehaviourReference playerRef, ScarletNetworkParams callParams = default(ScarletNetworkParams))
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Invalid comparison between Unknown and I4
			//IL_005f: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: 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_00b8: 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_011a: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1939319057u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, itemId);
					((FastBufferWriter)(ref val2)).WriteValueSafe(ref position);
					((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkBehaviourReference>(ref playerRef, default(ForNetworkSerializable));
					((FastBufferWriter)(ref val2)).WriteValueSafe<ScarletNetworkParams>(ref callParams, default(ForStructs));
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1939319057u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					PlayerControllerB player = default(PlayerControllerB);
					((NetworkBehaviourReference)(ref playerRef)).TryGet<PlayerControllerB>(ref player, (NetworkManager)null);
					CreateItem(itemId, fromScrapArray: false, position, player, callParams);
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void CreateScrapItemServerRpc(int itemId, Vector3 position, ScarletNetworkParams callParams = default(ScarletNetworkParams))
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Invalid comparison between Unknown and I4
			//IL_005f: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1250011204u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, itemId);
					((FastBufferWriter)(ref val2)).WriteValueSafe(ref position);
					((FastBufferWriter)(ref val2)).WriteValueSafe<ScarletNetworkParams>(ref callParams, default(ForStructs));
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1250011204u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					CreateItem(itemId, fromScrapArray: true, position, null, callParams);
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void CreateScrapItemServerRpc(int itemId, Vector3 position, NetworkBehaviourReference playerRef, ScarletNetworkParams callParams = default(ScarletNetworkParams))
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Invalid comparison between Unknown and I4
			//IL_005f: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: 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_00b8: 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_011a: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3991430686u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, itemId);
					((FastBufferWriter)(ref val2)).WriteValueSafe(ref position);
					((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkBehaviourReference>(ref playerRef, default(ForNetworkSerializable));
					((FastBufferWriter)(ref val2)).WriteValueSafe<ScarletNetworkParams>(ref callParams, default(ForStructs));
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3991430686u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					PlayerControllerB player = default(PlayerControllerB);
					((NetworkBehaviourReference)(ref playerRef)).TryGet<PlayerControllerB>(ref player, (NetworkManager)null);
					CreateItem(itemId, fromScrapArray: true, position, player, callParams);
				}
			}
		}

		private void CreateItem(int itemId, bool fromScrapArray, Vector3 position, PlayerControllerB player, ScarletNetworkParams callParams = default(ScarletNetworkParams))
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: 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_00de: 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)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			GameObject prefab = ((!fromScrapArray) ? StartOfRound.Instance.allItemsList.itemsList[itemId].spawnPrefab : Utility.GetDungeonItems()[itemId].spawnableItem.spawnPrefab);
			GrabbableObject val = CreateGrabbableObject(prefab, player, position);
			((MonoBehaviour)this).StartCoroutine(WaitForEndOfFrameToUpdateItemInitialProperities(val));
			UpdateItemFallingProperites(val, position);
			UpdateItemElevator(val, player);
			if (val is IScarletItem scarletItem)
			{
				scarletItem.UpdateSpecialProperties(callParams.specialValue);
			}
			int scrapValue = callParams.scrapValue;
			if (scrapValue > 0)
			{
				UpdateItemValueProperties(val, scrapValue);
			}
			((NetworkBehaviour)val).NetworkObject.Spawn(false);
			if ((Object)(object)player == (Object)null)
			{
				CreateItemClientRpc(NetworkBehaviourReference.op_Implicit((NetworkBehaviour)(object)val), position, callParams);
			}
			else
			{
				CreateItemClientRpc(NetworkBehaviourReference.op_Implicit((NetworkBehaviour)(object)val), position, NetworkBehaviourReference.op_Implicit((NetworkBehaviour)(object)player), callParams);
			}
		}

		[ClientRpc]
		public void CreateItemClientRpc(NetworkBehaviourReference itemRef, Vector3 position, ScarletNetworkParams callParams = default(ScarletNetworkParams))
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Invalid comparison between Unknown and I4
			//IL_005f: 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_007d: 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)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3004287685u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkBehaviourReference>(ref itemRef, default(ForNetworkSerializable));
				((FastBufferWriter)(ref val2)).WriteValueSafe(ref position);
				((FastBufferWriter)(ref val2)).WriteValueSafe<ScarletNetworkParams>(ref callParams, default(ForStructs));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3004287685u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			Vector3 position2 = position;
			ScarletNetworkParams callParams2 = callParams;
			if (!((NetworkBehaviour)this).IsServer)
			{
				((MonoBehaviour)this).StartCoroutine(WaitForItem(itemRef, delegate(GrabbableObject c)
				{
					//IL_0008: Unknown result type (might be due to invalid IL or missing references)
					CreateItem(c, position2, null, callParams2);
				}));
			}
		}

		[ClientRpc]
		public void CreateItemClientRpc(NetworkBehaviourReference itemRef, Vector3 position, NetworkBehaviourReference playerRef, ScarletNetworkParams callParams = default(ScarletNetworkParams))
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Invalid comparison between Unknown and I4
			//IL_005f: 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_007d: 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)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2816052745u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkBehaviourReference>(ref itemRef, default(ForNetworkSerializable));
				((FastBufferWriter)(ref val2)).WriteValueSafe(ref position);
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkBehaviourReference>(ref playerRef, default(ForNetworkSerializable));
				((FastBufferWriter)(ref val2)).WriteValueSafe<ScarletNetworkParams>(ref callParams, default(ForStructs));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2816052745u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			Vector3 position2 = position;
			ScarletNetworkParams callParams2 = callParams;
			if (!((NetworkBehaviour)this).IsServer)
			{
				((MonoBehaviour)this).StartCoroutine(WaitForItemAndPlayer(itemRef, playerRef, delegate(GrabbableObject c, PlayerControllerB p)
				{
					//IL_0008: Unknown result type (might be due to invalid IL or missing references)
					CreateItem(c, position2, p, callParams2);
				}));
			}
		}

		private IEnumerator WaitForItem(NetworkBehaviourReference itemRef, Action<GrabbableObject> action)
		{
			//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)
			float t = Time.realtimeSinceStartup + 8f;
			GrabbableObject comp = default(GrabbableObject);
			while (!((NetworkBehaviourReference)(ref itemRef)).TryGet<GrabbableObject>(ref comp, (NetworkManager)null))
			{
				yield return null;
				if (Time.realtimeSinceStartup > t)
				{
					Plugin.logger.LogError((object)"Failed to find network object (ITEM)");
					yield break;
				}
			}
			yield return (object)new WaitForEndOfFrame();
			action(comp);
		}

		private IEnumerator WaitForItemAndPlayer(NetworkBehaviourReference itemRef, NetworkBehaviourReference playerRef, Action<GrabbableObject, PlayerControllerB> action)
		{
			//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_0015: 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)
			float t = Time.realtimeSinceStartup + 8f;
			GrabbableObject comp = default(GrabbableObject);
			while (!((NetworkBehaviourReference)(ref itemRef)).TryGet<GrabbableObject>(ref comp, (NetworkManager)null))
			{
				yield return null;
				if (Time.realtimeSinceStartup > t)
				{
					Plugin.logger.LogError((object)"Failed to find network object (ITEM)");
					yield break;
				}
			}
			PlayerControllerB player = default(PlayerControllerB);
			while (!((NetworkBehaviourReference)(ref playerRef)).TryGet<PlayerControllerB>(ref player, (NetworkManager)null))
			{
				yield return null;
				if (Time.realtimeSinceStartup > t)
				{
					Plugin.logger.LogError((object)"Failed to find network object (PLAYER)");
					yield break;
				}
			}
			yield return (object)new WaitForEndOfFrame();
			action(comp, player);
		}

		private void CreateItem(GrabbableObject item, Vector3 position, PlayerControllerB player, ScarletNetworkParams callParams = default(ScarletNetworkParams))
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			UpdateItemFallingProperites(item, position);
			UpdateItemElevator(item, player);
			if (item is IScarletItem scarletItem)
			{
				scarletItem.UpdateSpecialProperties(callParams.specialValue);
			}
			int scrapValue = callParams.scrapValue;
			if (scrapValue > 0)
			{
				UpdateItemValueProperties(item, scrapValue);
			}
		}

		private GrabbableObject CreateGrabbableObject(GameObject prefab, PlayerControllerB player, Vector3 position)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			Transform itemSpawnTransform = GetItemSpawnTransform(player);
			GameObject val = Object.Instantiate<GameObject>(prefab, position, Quaternion.identity, itemSpawnTransform);
			return val.GetComponent<GrabbableObject>();
		}

		private Transform GetItemSpawnTransform(PlayerControllerB player)
		{
			if ((((Object)(object)player != (Object)null && player.isInElevator) || StartOfRound.Instance.inShipPhase) && (Object)(object)RoundManager.Instance.spawnedScrapContainer != (Object)null)
			{
				return RoundManager.Instance.spawnedScrapContainer;
			}
			return StartOfRound.Instance.elevatorTransform;
		}

		private IEnumerator WaitForEndOfFrameToUpdateItemInitialProperities(GrabbableObject comp)
		{
			yield return (object)new WaitForEndOfFrame();
			UpdateItemInitialProperites(comp);
		}

		private void UpdateItemInitialProperites(GrabbableObject comp)
		{
			comp.reachedFloorTarget = false;
			comp.hasHitGround = false;
			comp.fallTime = 0f;
		}

		private void UpdateItemFallingProperites(GrabbableObject comp, Vector3 position)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			comp.startFallingPosition = position;
			comp.targetFloorPosition = comp.GetItemFloorPosition(position);
		}

		private void UpdateItemValueProperties(GrabbableObject comp, int value)
		{
			comp.SetScrapValue(value);
			RoundManager instance = RoundManager.Instance;
			instance.totalScrapValueInLevel += (float)value;
		}

		private void UpdateItemElevator(GrabbableObject comp, PlayerControllerB player)
		{
			if ((Object)(object)player != (Object)null && player.isInHangarShipRoom)
			{
				player.SetItemInElevator(true, true, comp);
			}
		}

		public void RequestEvilSkinApply(NetworkObjectReference reference, string enemyName)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			if (SyncedInstance<PluginConfig>.Instance.paintingEnemyEvilSkinValue && ScarletBedroom.ENEMY_EVIL_LIST.Contains(enemyName))
			{
				RequestEvilSkinApplyClientRpc(reference);
			}
		}

		[ClientRpc]
		public void RequestEvilSkinApplyClientRpc(NetworkObjectReference reference)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: 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_007d: 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)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(112037380u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref reference, default(ForNetworkSerializable));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 112037380u, val, (RpcDelivery)0);
			}
			NetworkObject val3 = default(NetworkObject);
			if ((int)base.__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost) || !((NetworkObjectReference)(ref reference)).TryGet(ref val3, (NetworkManager)null))
			{
				return;
			}
			EnemyAI componentInParent = ((Component)val3).GetComponentInParent<EnemyAI>();
			if ((Object)(object)componentInParent == (Object)null)
			{
				return;
			}
			string name = ((Object)componentInParent).name;
			try
			{
				Plugin.logger.LogInfo((object)("Applying evil material to " + name));
				ApplyMaterialToRenderers<SkinnedMeshRenderer>(((Component)componentInParent).GetComponentsInChildren<SkinnedMeshRenderer>());
				ApplyMaterialToRenderers<MeshRenderer>(((Component)componentInParent).GetComponentsInChildren<MeshRenderer>());
			}
			catch (Exception ex)
			{
				Plugin.logger.LogWarning((object)("Failed to apply evil material to " + name));
				Plugin.logger.LogWarning((object)ex.ToString());
			}
			static void ApplyMaterialToRenderers<T>(T[] renderers) where T : Renderer
			{
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0034: Expected O, but got Unknown
				foreach (T val4 in renderers)
				{
					Material[] materials = ((Renderer)val4).materials;
					for (int j = 0; j < materials.Length; j++)
					{
						Material val5 = new Material(Assets.networkObjectList.ghostMaterial);
						val5.mainTexture = materials[j].mainTexture;
						materials[j] = val5;
					}
					((Renderer)val4).materials = materials;
				}
			}
		}

		protected override void __initializeVariables()
		{
			((NetworkBehaviour)this).__initializeVariables();
		}

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_ScarletNetworkManager()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Expected O, but got Unknown
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Expected O, but got Unknown
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(3412664016u, new RpcReceiveHandler(__rpc_handler_3412664016));
			NetworkManager.__rpc_func_table.Add(345840887u, new RpcReceiveHandler(__rpc_handler_345840887));
			NetworkManager.__rpc_func_table.Add(4119288164u, new RpcReceiveHandler(__rpc_handler_4119288164));
			NetworkManager.__rpc_func_table.Add(1939319057u, new RpcReceiveHandler(__rpc_handler_1939319057));
			NetworkManager.__rpc_func_table.Add(1250011204u, new RpcReceiveHandler(__rpc_handler_1250011204));
			NetworkManager.__rpc_func_table.Add(3991430686u, new RpcReceiveHandler(__rpc_handler_3991430686));
			NetworkManager.__rpc_func_table.Add(3004287685u, new RpcReceiveHandler(__rpc_handler_3004287685));
			NetworkManager.__rpc_func_table.Add(2816052745u, new RpcReceiveHandler(__rpc_handler_2816052745));
			NetworkManager.__rpc_func_table.Add(112037380u, new RpcReceiveHandler(__rpc_handler_112037380));
		}

		private static void __rpc_handler_3412664016(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: 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_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkBehaviourReference playerRef = default(NetworkBehaviourReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkBehaviourReference>(ref playerRef, default(ForNetworkSerializable));
				int itemSlot = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref itemSlot);
				ServerRpcParams server = rpcParams.Server;
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((ScarletNetworkManager)(object)target).DestroyPlayerItemInSlotServerRpc(playerRef, itemSlot, server);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_345840887(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: 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_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkBehaviourReference playerRef = default(NetworkBehaviourReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkBehaviourReference>(ref playerRef, default(ForNetworkSerializable));
				int itemSlot = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref itemSlot);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((ScarletNetworkManager)(object)target).DestroyPlayerItemInSlotClientRpc(playerRef, itemSlot);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_4119288164(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: 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_005e: 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_0080: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int itemId = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref itemId);
				Vector3 position = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref position);
				ScarletNetworkParams callParams = default(ScarletNetworkParams);
				((FastBufferReader)(ref reader)).ReadValueSafe<ScarletNetworkParams>(ref callParams, default(ForStructs));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((ScarletNetworkManager)(object)target).CreateItemServerRpc(itemId, position, callParams);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1939319057(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: 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_0064: 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_0079: 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_008c: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int itemId = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref itemId);
				Vector3 position = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref position);
				NetworkBehaviourReference playerRef = default(NetworkBehaviourReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkBehaviourReference>(ref playerRef, default(ForNetworkSerializable));
				ScarletNetworkParams callParams = default(ScarletNetworkParams);
				((FastBufferReader)(ref reader)).ReadValueSafe<ScarletNetworkParams>(ref callParams, default(ForStructs));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((ScarletNetworkManager)(object)target).CreateItemServerRpc(itemId, position, playerRef, callParams);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1250011204(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: 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_005e: 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_0080: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int itemId = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref itemId);
				Vector3 position = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref position);
				ScarletNetworkParams callParams = default(ScarletNetworkParams);
				((FastBufferReader)(ref reader)).ReadValueSafe<ScarletNetworkParams>(ref callParams, default(ForStructs));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((ScarletNetworkManager)(object)target).CreateScrapItemServerRpc(itemId, position, callParams);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3991430686(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: 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_0064: 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_0079: 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_008c: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int itemId = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref itemId);
				Vector3 position = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref position);
				NetworkBehaviourReference playerRef = default(NetworkBehaviourReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkBehaviourReference>(ref playerRef, default(ForNetworkSerializable));
				ScarletNetworkParams callParams = default(ScarletNetworkParams);
				((FastBufferReader)(ref reader)).ReadValueSafe<ScarletNetworkParams>(ref callParams, default(ForStructs));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((ScarletNetworkManager)(object)target).CreateScrapItemServerRpc(itemId, position, playerRef, callParams);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3004287685(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: 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_0057: 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_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkBehaviourReference itemRef = default(NetworkBehaviourReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkBehaviourReference>(ref itemRef, default(ForNetworkSerializable));
				Vector3 position = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref position);
				ScarletNetworkParams callParams = default(ScarletNetworkParams);
				((FastBufferReader)(ref reader)).ReadValueSafe<ScarletNetworkParams>(ref callParams, default(ForStructs));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((ScarletNetworkManager)(object)target).CreateItemClientRpc(itemRef, position, callParams);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2816052745(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: 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_0057: 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_0072: 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_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkBehaviourReference itemRef = default(NetworkBehaviourReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkBehaviourReference>(ref itemRef, default(ForNetworkSerializable));
				Vector3 position = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref position);
				NetworkBehaviourReference playerRef = default(NetworkBehaviourReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkBehaviourReference>(ref playerRef, default(ForNetworkSerializable));
				ScarletNetworkParams callParams = default(ScarletNetworkParams);
				((FastBufferReader)(ref reader)).ReadValueSafe<ScarletNetworkParams>(ref callParams, default(ForStructs));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((ScarletNetworkManager)(object)target).CreateItemClientRpc(itemRef, position, playerRef, callParams);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_112037380(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: 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_0044: 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_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkObjectReference reference = default(NetworkObjectReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref reference, default(ForNetworkSerializable));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((ScarletNetworkManager)(object)target).RequestEvilSkinApplyClientRpc(reference);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "ScarletNetworkManager";
		}
	}
	public static class ScarletNetworkManagerUtility
	{
		public static int GetFlashlightId(FlashlightItem flashlightItem)
		{
			return Assets.GetFlashlight(((GrabbableObject)flashlightItem).itemProperties)?.itemId ?? (-1);
		}

		public static bool CreateFlashlight(PlayerControllerB player, FlashlightItem flashLight, FlandreCrystal crystal)
		{
			//IL_000e: 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_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing re

plugins/ScarletMansionMimicsPatch.dll

Decompiled 2 weeks ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using DunGen;
using GameNetcodeStuff;
using HarmonyLib;
using Mimics;
using Mimics.API;
using ScarletMansion;
using ScarletMansion.DunGenPatch;
using ScarletMansion.DunGenPatch.Doorways;
using ScarletMansion.GamePatch.Components;
using ScarletMansion.GamePatch.FixValues;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ScarletMansionMimicsPatch")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ScarletMansionMimicsPatch")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("6aab73ec-489e-4baa-8bd1-7ca944359cec")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ScarletMansionMimicsPatch;

public class Patch
{
	public class SDMMimicEventHandler : MimicEventHandler
	{
		public override string ModGUID => "ImoutoSama.ScarletMansionMimicsPatch";

		public override bool IsMyInteriorLoaded => Patch.active;

		public override void OnMimicCreated(MimicDoor mimicDoor, Doorway doorway)
		{
			DoorwayCleanup componentInChildren = ((Component)((Component)doorway).transform.parent).GetComponentInChildren<DoorwayCleanup>();
			if ((Object)(object)componentInChildren != (Object)null)
			{
				componentInChildren.overrideConnector = true;
				componentInChildren.overrideNoDoorway = true;
			}
			FixFireExit componentInChildren2 = ((Component)doorway).GetComponentInChildren<FixFireExit>(true);
			componentInChildren2.ForcefullyEnableDoorway();
			Transform mimicDoorMesh = Utility.FindChildRecurvisely(((Component)mimicDoor).transform, "DoorMesh");
			Transform mimicFrame = Utility.FindChildRecurvisely(((Component)mimicDoor).transform, "Frame");
			Transform mimicLight = Utility.FindChildRecurvisely(((Component)mimicDoor).transform, "Light");
			if (componentInChildren2.EnableVanillaFireExit)
			{
				FixDoorwayForVanillaFireExit(componentInChildren2, mimicDoorMesh, mimicFrame, mimicLight);
			}
			else
			{
				FixDoorwayForSDMFireExit(componentInChildren2, mimicDoorMesh, mimicFrame, mimicLight);
			}
			Plugin.logger.LogInfo((object)"Fixed a doorway for a mimic");
		}

		public override void OnMimicAttackStart(MimicDoor mimicDoor, PlayerControllerB playerToAttack)
		{
			Doorway componentInParent = ((Component)mimicDoor).GetComponentInParent<Doorway>();
			ScarletFireExit componentInChildren = ((Component)componentInParent).GetComponentInChildren<ScarletFireExit>();
			if (componentInChildren != null)
			{
				componentInChildren.DisableEnablePortal();
			}
		}
	}

	private static bool colorBlindModeLastValue;

	public static void Activate()
	{
		MimicsAPI.GetAPI().RegisterMimicEventHandler((MimicEventHandler)(object)new SDMMimicEventHandler());
		Plugin.Instance.harmony.PatchAll(typeof(Patch));
	}

	[HarmonyPrefix]
	[HarmonyPatch("Mimics.Mimics+RoundManagerPatch, Mimics", "SetExitIDsPatch")]
	public static void SetExitIDsPatchPrefix()
	{
		colorBlindModeLastValue = Mimics.ColorBlindMode;
	}

	[HarmonyPostfix]
	[HarmonyPatch("Mimics.Mimics+RoundManagerPatch, Mimics", "SetExitIDsPatch")]
	public static void SetExitIDsPatchPostfix()
	{
		Mimics.ColorBlindMode = colorBlindModeLastValue;
	}

	private static void FixDoorwayForVanillaFireExit(FixFireExit fixFireExit, Transform mimicDoorMesh, Transform mimicFrame, Transform mimicLight)
	{
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: 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_009b: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)mimicDoorMesh != (Object)null)
		{
			mimicDoorMesh.localPosition = new Vector3(-0.07f, 0f, 0.06f);
			Vector3 localScale = mimicDoorMesh.localScale;
			localScale.y = -0.0002f;
			localScale.z = -0.000161f;
			mimicDoorMesh.localScale = localScale;
		}
		else
		{
			Plugin.logger.LogWarning((object)"Could not find DoorMesh in mimic gameobject. It will look weird but nothing should break");
		}
		if ((Object)(object)mimicFrame != (Object)null)
		{
			mimicFrame.localPosition = new Vector3(0f, -0.02f, 0.07f);
			mimicFrame.localScale = new Vector3(1.08f, 1.008f, 1.02f);
		}
		else
		{
			Plugin.logger.LogWarning((object)"Could not find Frame in mimic gameobject. It will look weird but nothing should break");
		}
	}

	private static void FixDoorwayForSDMFireExit(FixFireExit fixFireExit, Transform mimicDoorMesh, Transform mimicFrame, Transform mimicLight)
	{
		Mimics.ColorBlindMode = true;
		fixFireExit.ForcefullyEnableSDMRender();
		fixFireExit.sdmFireExit.enablePortalAnimation = true;
		if ((Object)(object)mimicDoorMesh != (Object)null)
		{
			((Component)mimicDoorMesh).gameObject.SetActive(false);
		}
		else
		{
			Plugin.logger.LogWarning((object)"Could not find DoorMesh in mimic gameobject. It will look weird but nothing should break");
		}
		if ((Object)(object)mimicFrame != (Object)null)
		{
			((Component)mimicFrame).gameObject.SetActive(false);
		}
		else
		{
			Plugin.logger.LogWarning((object)"Could not find Frame in mimic gameobject. It will look weird but nothing should break");
		}
		if ((Object)(object)mimicLight != (Object)null)
		{
			((Component)mimicLight).gameObject.SetActive(false);
		}
		else
		{
			Plugin.logger.LogWarning((object)"Could not find Light in mimic gameobject. It will look weird but nothing should break");
		}
	}
}
[BepInPlugin("ImoutoSama.ScarletMansionMimicsPatch", "Scarlet Mansion Mimics Patch", "1.0.0")]
[BepInDependency("ImoutoSama.ScarletMansion", "1.3.12")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
	public const string modGUID = "ImoutoSama.ScarletMansionMimicsPatch";

	private const string modName = "Scarlet Mansion Mimics Patch";

	private const string modVersion = "1.0.0";

	public const string targetModGUID = "x753.Mimics";

	public const string targetModVersion = "2.6.0";

	public readonly Harmony harmony = new Harmony("ImoutoSama.ScarletMansionMimicsPatch");

	public static Plugin Instance { get; private set; }

	public static ManualLogSource logger { get; internal set; }

	private void Awake()
	{
		if ((Object)(object)Instance == (Object)null)
		{
			Instance = this;
		}
		logger = Logger.CreateLogSource("ImoutoSama.ScarletMansionMimicsPatch");
		logger.LogInfo((object)"Plugin Scarlet Mansion Mimics Patch has been added!");
		if (Chainloader.PluginInfos.ContainsKey("x753.Mimics"))
		{
			PluginInfo val = Chainloader.PluginInfos["x753.Mimics"];
			Version version = val.Metadata.Version;
			bool flag;
			if (string.IsNullOrWhiteSpace("2.6.0"))
			{
				flag = true;
			}
			else
			{
				Version version2 = new Version("2.6.0");
				flag = version >= version2;
			}
			if (flag)
			{
				logger.LogInfo((object)"Plugin Scarlet Mansion Mimics Patch has been added!");
				Patch.Activate();
			}
		}
	}
}

plugins/SCPCBDunGen.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
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.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using LethalLevelLoader;
using LobbyCompatibility.Attributes;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using On;
using PiggyVarietyMod;
using SCPCBDunGen.NetcodePatcher;
using SCPCBDunGen.Patches;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("ClientNetworkTransform")]
[assembly: IgnoresAccessChecksTo("DissonanceVoip")]
[assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")]
[assembly: IgnoresAccessChecksTo("Unity.Burst")]
[assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")]
[assembly: IgnoresAccessChecksTo("Unity.Collections")]
[assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Jobs")]
[assembly: IgnoresAccessChecksTo("Unity.Mathematics")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")]
[assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")]
[assembly: IgnoresAccessChecksTo("Unity.Services.QoS")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Relay")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("SCPCBDunGen")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("4.3.2.0")]
[assembly: AssemblyInformationalVersion("4.3.2+d9a5728c48b5bd1ea41b9ff279e69953ce6e183f")]
[assembly: AssemblyProduct("SCPCBDunGen")]
[assembly: AssemblyTitle("SCPCBDunGen")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("4.3.2.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
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 SCPCBDunGen
{
	public class SCP914InputStore : NetworkBehaviour
	{
		public List<GameObject> lContainedObjects;

		private SCP914InputStore()
		{
			lContainedObjects = new List<GameObject>();
		}

		private void OnTriggerEnter(Collider other)
		{
			if (((NetworkBehaviour)this).NetworkManager.IsServer)
			{
				SCPCBDunGen.Logger.LogInfo((object)("New thing entered input trigger: " + ((Object)((Component)other).gameObject).name + "."));
				lContainedObjects.Add(((Component)other).gameObject);
			}
		}

		private void OnTriggerExit(Collider other)
		{
			if (((NetworkBehaviour)this).NetworkManager.IsServer)
			{
				SCPCBDunGen.Logger.LogInfo((object)("Thing has left input trigger: " + ((Object)((Component)other).gameObject).name + "."));
				lContainedObjects.Remove(((Component)other).gameObject);
			}
		}

		protected override void __initializeVariables()
		{
			((NetworkBehaviour)this).__initializeVariables();
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "SCP914InputStore";
		}
	}
	public class SCP914Converter : NetworkBehaviour
	{
		public enum SCP914Setting
		{
			ROUGH,
			COARSE,
			ONETOONE,
			FINE,
			VERYFINE
		}

		public SCP914InputStore InputStore;

		public Collider colliderOutput;

		public InteractTrigger SettingKnobTrigger;

		public GameObject SettingKnobPivot;

		public AudioSource SettingKnobSoundSrc;

		public InteractTrigger ActivateTrigger;

		public AudioSource ActivateAudioSrc;

		public AudioSource RefineAudioSrc;

		public Animator DoorIn;

		public Animator DoorOut;

		private readonly (SCP914Setting, float)[] SCP914SettingRotations = new(SCP914Setting, float)[5]
		{
			(SCP914Setting.ROUGH, 90f),
			(SCP914Setting.COARSE, 45f),
			(SCP914Setting.ONETOONE, 0f),
			(SCP914Setting.FINE, -45f),
			(SCP914Setting.VERYFINE, -90f)
		};

		private Dictionary<Item, List<Item>>[] arItemMappings = new Dictionary<Item, List<Item>>[5]
		{
			new Dictionary<Item, List<Item>>(),
			new Dictionary<Item, List<Item>>(),
			new Dictionary<Item, List<Item>>(),
			new Dictionary<Item, List<Item>>(),
			new Dictionary<Item, List<Item>>()
		};

		private Dictionary<EnemyType, List<EnemyType>>[] arEnemyMappings = new Dictionary<EnemyType, List<EnemyType>>[5]
		{
			new Dictionary<EnemyType, List<EnemyType>>(),
			new Dictionary<EnemyType, List<EnemyType>>(),
			new Dictionary<EnemyType, List<EnemyType>>(),
			new Dictionary<EnemyType, List<EnemyType>>(),
			new Dictionary<EnemyType, List<EnemyType>>()
		};

		private Dictionary<Item, List<EnemyType>>[] arItemEnemyMappings = new Dictionary<Item, List<EnemyType>>[5]
		{
			new Dictionary<Item, List<EnemyType>>(),
			new Dictionary<Item, List<EnemyType>>(),
			new Dictionary<Item, List<EnemyType>>(),
			new Dictionary<Item, List<EnemyType>>(),
			new Dictionary<Item, List<EnemyType>>()
		};

		private Dictionary<EnemyType, List<Item>>[] arEnemyItemMappings = new Dictionary<EnemyType, List<Item>>[5]
		{
			new Dictionary<EnemyType, List<Item>>(),
			new Dictionary<EnemyType, List<Item>>(),
			new Dictionary<EnemyType, List<Item>>(),
			new Dictionary<EnemyType, List<Item>>(),
			new Dictionary<EnemyType, List<Item>>()
		};

		private int iCurrentState;

		private bool bActive;

		private Transform ScrapTransform;

		private RoundManager roundManager;

		private StartOfRound StartOfRound;

		private EnemyType MaskedType;

		public void AddConversion(SCP914Setting setting, Item itemInput, List<Item> lItemOutputs)
		{
			Dictionary<Item, List<Item>> dictionary = arItemMappings[(int)setting];
			if (dictionary.TryGetValue(itemInput, out var value))
			{
				value.AddRange(lItemOutputs);
			}
			else
			{
				arItemMappings[(int)setting].Add(itemInput, lItemOutputs);
			}
		}

		public void AddConversion(SCP914Setting setting, EnemyType enemyInput, List<EnemyType> lEnemyOutputs)
		{
			Dictionary<EnemyType, List<EnemyType>> dictionary = arEnemyMappings[(int)setting];
			if (dictionary.TryGetValue(enemyInput, out var value))
			{
				value.AddRange(lEnemyOutputs);
			}
			else
			{
				arEnemyMappings[(int)setting].Add(enemyInput, lEnemyOutputs);
			}
		}

		public void AddConversion(SCP914Setting setting, Item itemInput, List<EnemyType> lEnemyOutputs)
		{
			Dictionary<Item, List<EnemyType>> dictionary = arItemEnemyMappings[(int)setting];
			if (dictionary.TryGetValue(itemInput, out var value))
			{
				value.AddRange(lEnemyOutputs);
			}
			else
			{
				arItemEnemyMappings[(int)setting].Add(itemInput, lEnemyOutputs);
			}
		}

		public void AddConversion(SCP914Setting setting, EnemyType enemyInput, List<Item> lItemOutputs)
		{
			Dictionary<EnemyType, List<Item>> dictionary = arEnemyItemMappings[(int)setting];
			if (dictionary.TryGetValue(enemyInput, out var value))
			{
				value.AddRange(lItemOutputs);
			}
			else
			{
				arEnemyItemMappings[(int)setting].Add(enemyInput, lItemOutputs);
			}
		}

		private Dictionary<Item, List<Item>> GetItemMapping()
		{
			return arItemMappings[iCurrentState];
		}

		private Dictionary<EnemyType, List<EnemyType>> GetEnemyMapping()
		{
			return arEnemyMappings[iCurrentState];
		}

		private Dictionary<Item, List<EnemyType>> GetItemEnemyMapping()
		{
			return arItemEnemyMappings[iCurrentState];
		}

		private Dictionary<EnemyType, List<Item>> GetEnemyItemMapping()
		{
			return arEnemyItemMappings[iCurrentState];
		}

		private Vector3 GetRandomNavMeshPositionInCollider(Collider collider)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: 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_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			Bounds bounds = collider.bounds;
			Vector3 center = ((Bounds)(ref bounds)).center;
			bounds = collider.bounds;
			float x = ((Bounds)(ref bounds)).extents.x;
			bounds = collider.bounds;
			float num = Math.Min(x, ((Bounds)(ref bounds)).extents.z);
			center.x += Random.Range(0f - num, num);
			center.z += Random.Range(0f - num, num);
			ref float y = ref center.y;
			float num2 = y;
			bounds = collider.bounds;
			y = num2 - ((Bounds)(ref bounds)).extents.y / 2f;
			NavMeshHit val = default(NavMeshHit);
			if (NavMesh.SamplePosition(center, ref val, 5f, -1))
			{
				return ((NavMeshHit)(ref val)).position;
			}
			return center;
		}

		private Vector3 GetRandomPositionInCollider(Collider collider)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			Bounds bounds = collider.bounds;
			Vector3 center = ((Bounds)(ref bounds)).center;
			bounds = collider.bounds;
			float x = ((Bounds)(ref bounds)).extents.x;
			bounds = collider.bounds;
			float num = Math.Min(x, ((Bounds)(ref bounds)).extents.z);
			center.x += Random.Range(0f - num, num);
			center.z += Random.Range(0f - num, num);
			return center;
		}

		[ServerRpc(RequireOwnership = false)]
		public void TurnStateServerRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2627837757u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2627837757u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					int iNewState = (iCurrentState + 1) % 5;
					TurnStateClientRpc(iNewState);
				}
			}
		}

		[ClientRpc]
		public void TurnStateClientRpc(int iNewState)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: 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_0071: 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_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(301590527u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, iNewState);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 301590527u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					iCurrentState = iNewState;
					Quaternion rotation = SettingKnobPivot.transform.rotation;
					Vector3 eulerAngles = ((Quaternion)(ref rotation)).eulerAngles;
					eulerAngles.z = SCP914SettingRotations[iCurrentState].Item2;
					SettingKnobPivot.transform.rotation = Quaternion.Euler(eulerAngles);
					SettingKnobSoundSrc.Play();
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void ActivateServerRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1051910848u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1051910848u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost) && !bActive)
				{
					bActive = true;
					ActivateClientRpc();
					((MonoBehaviour)this).StartCoroutine(ConversionProcess());
				}
			}
		}

		[ClientRpc]
		public void ActivateClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3833341719u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3833341719u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					ActivateTrigger.interactable = false;
					SettingKnobTrigger.interactable = false;
					ActivateAudioSrc.Play();
					DoorIn.SetBoolString("open", false);
					DoorOut.SetBoolString("open", false);
				}
			}
		}

		[ClientRpc]
		public void RefineFinishClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(4143732333u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 4143732333u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					ActivateTrigger.interactable = true;
					SettingKnobTrigger.interactable = true;
					DoorIn.SetBoolString("open", true);
					DoorOut.SetBoolString("open", true);
				}
			}
		}

		[ClientRpc]
		public void SpawnItemsClientRpc(NetworkObjectReference[] arNetworkObjectReferences, int[] arScrapValues, bool bChargeBattery)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Invalid comparison between Unknown and I4
			//IL_005f: 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_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: 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_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: 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_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(4044311993u, val, (RpcDelivery)0);
				bool flag = arNetworkObjectReferences != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(arNetworkObjectReferences, default(ForNetworkSerializable));
				}
				bool flag2 = arScrapValues != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag2, default(ForPrimitives));
				if (flag2)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe<int>(arScrapValues, default(ForPrimitives));
				}
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref bChargeBattery, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 4044311993u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			NetworkObject val3 = default(NetworkObject);
			for (int i = 0; i < arNetworkObjectReferences.Length; i++)
			{
				SCPCBDunGen.Logger.LogInfo((object)$"Item conversion scrap value {i}: {arScrapValues[i]}");
				if (((NetworkObjectReference)(ref arNetworkObjectReferences[i])).TryGet(ref val3, (NetworkManager)null))
				{
					GrabbableObject component = ((Component)val3).GetComponent<GrabbableObject>();
					if (component.itemProperties.isScrap)
					{
						component.SetScrapValue(arScrapValues[i]);
					}
					if (component.itemProperties.requiresBattery)
					{
						component.insertedBattery.charge = (bChargeBattery ? 1f : 0f);
					}
				}
			}
		}

		private IEnumerator ConversionProcess()
		{
			RefineAudioSrc.Play();
			yield return (object)new WaitForSeconds(7f);
			if ((Object)(object)roundManager == (Object)null)
			{
				SCPCBDunGen.Logger.LogInfo((object)"Getting round manager");
				roundManager = Object.FindObjectOfType<RoundManager>();
				if ((Object)(object)roundManager == (Object)null)
				{
					SCPCBDunGen.Logger.LogError((object)"Failed to find round manager.");
					yield break;
				}
			}
			if ((Object)(object)ScrapTransform == (Object)null)
			{
				SCP914Converter sCP914Converter = this;
				GameObject obj = GameObject.FindGameObjectWithTag("MapPropsContainer");
				sCP914Converter.ScrapTransform = ((obj != null) ? obj.transform : null);
				if ((Object)(object)ScrapTransform == (Object)null)
				{
					SCPCBDunGen.Logger.LogError((object)"SCPCB Failed to find props container.");
					yield break;
				}
			}
			List<NetworkObjectReference> list = new List<NetworkObjectReference>();
			List<int> list2 = new List<int>();
			bool bChargeBattery = iCurrentState > 1;
			SCPCBDunGen.Logger.LogInfo((object)$"Contained item count: {InputStore.lContainedObjects.Count}");
			foreach (GameObject lContainedObject in InputStore.lContainedObjects)
			{
				GrabbableObject component = lContainedObject.GetComponent<GrabbableObject>();
				if ((Object)(object)component != (Object)null)
				{
					ConvertItem(list, list2, component);
					continue;
				}
				PlayerControllerB component2 = lContainedObject.GetComponent<PlayerControllerB>();
				if ((Object)(object)component2 != (Object)null)
				{
					ConvertPlayer(component2);
					continue;
				}
				EnemyAI componentInParent = lContainedObject.GetComponentInParent<EnemyAI>();
				if ((Object)(object)componentInParent != (Object)null)
				{
					ConvertEnemy(list, list2, componentInParent);
				}
			}
			SCPCBDunGen.Logger.LogInfo((object)"Finished spawning scrap, syncing with clients");
			SpawnItemsClientRpc(list.ToArray(), list2.ToArray(), bChargeBattery);
			InputStore.lContainedObjects.Clear();
			yield return (object)new WaitForSeconds(7f);
			RefineFinishClientRpc();
			bActive = false;
		}

		private void ConvertItemToItem(List<NetworkObjectReference> lNetworkObjectReferences, List<int> lScrapValues, GrabbableObject grabbable)
		{
			//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_00b3: 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_0077: 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_019e: Unknown result type (might be due to invalid IL or missing references)
			Vector3 randomPositionInCollider = GetRandomPositionInCollider(colliderOutput);
			GameObject val = null;
			NetworkObject val2 = null;
			GrabbableObject val3 = null;
			if (GetItemMapping().TryGetValue(grabbable.itemProperties, out List<Item> value))
			{
				SCPCBDunGen.Logger.LogInfo((object)"Mapping found");
				Item val4 = value[roundManager.AnomalyRandom.Next(value.Count)];
				if ((Object)(object)val4 != (Object)null)
				{
					SCPCBDunGen.Logger.LogInfo((object)"Conversion found");
					val = Object.Instantiate<GameObject>(val4.spawnPrefab, randomPositionInCollider, Quaternion.identity, ScrapTransform);
					val2 = val.GetComponent<NetworkObject>();
					val3 = val.GetComponent<GrabbableObject>();
				}
			}
			else
			{
				SCPCBDunGen.Logger.LogInfo((object)"No conversion, making new item copy with new scrap value");
				val = Object.Instantiate<GameObject>(grabbable.itemProperties.spawnPrefab, randomPositionInCollider, Quaternion.identity, ScrapTransform);
				val2 = val.GetComponent<NetworkObject>();
				val3 = val.GetComponent<GrabbableObject>();
			}
			SCPCBDunGen.Logger.LogInfo((object)"Preprocessing done");
			if ((Object)(object)val3 == (Object)null)
			{
				SCPCBDunGen.Logger.LogInfo((object)"Conversion was null, item is intended to be destroyed in process.");
				return;
			}
			Item itemProperties = val3.itemProperties;
			if (itemProperties.isScrap)
			{
				SCPCBDunGen.Logger.LogInfo((object)"Item is scrap or null, generating a copy with new value");
				GrabbableObject component = val.GetComponent<GrabbableObject>();
				int num = (int)((float)roundManager.AnomalyRandom.Next(itemProperties.minValue, itemProperties.maxValue) * roundManager.scrapValueMultiplier);
				component.SetScrapValue(num);
				SCPCBDunGen.Logger.LogInfo((object)$"new scrap value: {num}");
				lScrapValues.Add(num);
			}
			else
			{
				SCPCBDunGen.Logger.LogInfo((object)"Item is not scrap, adding empty scrap value");
				lScrapValues.Add(0);
			}
			val2.Spawn(true);
			lNetworkObjectReferences.Add(NetworkObjectReference.op_Implicit(val2));
		}

		private void ConvertItemToEnemy(GrabbableObject grabbable, EnemyType enemyType)
		{
			//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_001b: Unknown result type (might be due to invalid IL or missing references)
			Vector3 randomNavMeshPositionInCollider = GetRandomNavMeshPositionInCollider(colliderOutput);
			roundManager.SpawnEnemyGameObject(randomNavMeshPositionInCollider, 0f, -1, enemyType);
		}

		private void ConvertItem(List<NetworkObjectReference> lNetworkObjectReferences, List<int> lScrapValues, GrabbableObject grabbable)
		{
			if (grabbable.isHeld)
			{
				return;
			}
			SCPCBDunGen.Logger.LogInfo((object)("Found grabbable item " + ((Object)grabbable.itemProperties).name));
			Dictionary<Item, List<Item>> itemMapping = GetItemMapping();
			Dictionary<Item, List<EnemyType>> itemEnemyMapping = GetItemEnemyMapping();
			if (itemEnemyMapping.TryGetValue(grabbable.itemProperties, out var value))
			{
				if (roundManager.AnomalyRandom.Next(2) == 0 && itemMapping.ContainsKey(grabbable.itemProperties))
				{
					ConvertItemToItem(lNetworkObjectReferences, lScrapValues, grabbable);
				}
				else
				{
					ConvertItemToEnemy(grabbable, value[roundManager.AnomalyRandom.Next(value.Count)]);
				}
			}
			else
			{
				ConvertItemToItem(lNetworkObjectReferences, lScrapValues, grabbable);
			}
			Object.Destroy((Object)(object)((Component)grabbable).gameObject);
		}

		[ClientRpc]
		private void ConvertPlayerTeleportClientRpc(NetworkBehaviourReference netBehaviourRefPlayer, Vector3 vPosition)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Invalid comparison between Unknown and I4
			//IL_005f: 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_007d: 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)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Expected O, but got Unknown
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3018499267u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkBehaviourReference>(ref netBehaviourRefPlayer, default(ForNetworkSerializable));
				((FastBufferWriter)(ref val2)).WriteValueSafe(ref vPosition);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3018499267u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				NetworkBehaviour val3 = null;
				((NetworkBehaviourReference)(ref netBehaviourRefPlayer)).TryGet(ref val3, (NetworkManager)null);
				if ((Object)(object)val3 == (Object)null)
				{
					SCPCBDunGen.Logger.LogError((object)"Failed to get player controller.");
					return;
				}
				PlayerControllerB val4 = (PlayerControllerB)val3;
				val4.TeleportPlayer(vPosition, false, 0f, false, true);
			}
		}

		[ClientRpc]
		private void ConvertPlayerKillClientRpc(NetworkBehaviourReference netBehaviourRefPlayer)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: 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_007d: 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)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Expected O, but got Unknown
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1252059581u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkBehaviourReference>(ref netBehaviourRefPlayer, default(ForNetworkSerializable));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1252059581u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				NetworkBehaviour val3 = null;
				((NetworkBehaviourReference)(ref netBehaviourRefPlayer)).TryGet(ref val3, (NetworkManager)null);
				if ((Object)(object)val3 == (Object)null)
				{
					SCPCBDunGen.Logger.LogError((object)"Failed to get player controller.");
					return;
				}
				PlayerControllerB val4 = (PlayerControllerB)val3;
				val4.KillPlayer(Vector3.zero, true, (CauseOfDeath)6, 0, default(Vector3));
			}
		}

		[ClientRpc]
		private void ConvertPlayerAlterHealthClientRpc(NetworkBehaviourReference netBehaviourRefPlayer, int iHealthDelta)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Invalid comparison between Unknown and I4
			//IL_005f: 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_007d: 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)
			//IL_008c: 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_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Expected O, but got Unknown
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(527346026u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkBehaviourReference>(ref netBehaviourRefPlayer, default(ForNetworkSerializable));
				BytePacker.WriteValueBitPacked(val2, iHealthDelta);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 527346026u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				NetworkBehaviour val3 = null;
				((NetworkBehaviourReference)(ref netBehaviourRefPlayer)).TryGet(ref val3, (NetworkManager)null);
				if ((Object)(object)val3 == (Object)null)
				{
					SCPCBDunGen.Logger.LogError((object)"Failed to get player controller.");
					return;
				}
				PlayerControllerB val4 = (PlayerControllerB)val3;
				val4.DamagePlayer(iHealthDelta, true, true, (CauseOfDeath)8, 0, false, default(Vector3));
			}
		}

		[ClientRpc]
		private void ConvertPlayerRandomSkinClientRpc(NetworkBehaviourReference netBehaviourRefPlayer, int iSuitID)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Invalid comparison between Unknown and I4
			//IL_005f: 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_007d: 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)
			//IL_008c: 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_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Expected O, but got Unknown
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1669287785u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkBehaviourReference>(ref netBehaviourRefPlayer, default(ForNetworkSerializable));
				BytePacker.WriteValueBitPacked(val2, iSuitID);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1669287785u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			if ((Object)(object)StartOfRound == (Object)null)
			{
				StartOfRound = Object.FindObjectOfType<StartOfRound>();
				if ((Object)(object)StartOfRound == (Object)null)
				{
					SCPCBDunGen.Logger.LogError((object)"Failed to find StartOfRound.");
					return;
				}
			}
			NetworkBehaviour val3 = null;
			((NetworkBehaviourReference)(ref netBehaviourRefPlayer)).TryGet(ref val3, (NetworkManager)null);
			if ((Object)(object)val3 == (Object)null)
			{
				SCPCBDunGen.Logger.LogError((object)"Failed to get player controller.");
				return;
			}
			PlayerControllerB val4 = (PlayerControllerB)val3;
			int num = 0;
			foreach (UnlockableItem unlockable in StartOfRound.unlockablesList.unlockables)
			{
				if ((Object)(object)unlockable.suitMaterial != (Object)null)
				{
					SCPCBDunGen.Logger.LogInfo((object)$"Found suit at index {num}");
				}
				num++;
			}
			UnlockableItem val5 = StartOfRound.unlockablesList.unlockables[iSuitID];
			if (val5 == null)
			{
				SCPCBDunGen.Logger.LogError((object)$"Invalid suit ID: {iSuitID}");
				return;
			}
			Material suitMaterial = val5.suitMaterial;
			((Renderer)val4.thisPlayerModel).material = suitMaterial;
			((Renderer)val4.thisPlayerModelLOD1).material = suitMaterial;
			((Renderer)val4.thisPlayerModelLOD2).material = suitMaterial;
			((Renderer)val4.thisPlayerModelArms).material = suitMaterial;
			val4.currentSuitID = iSuitID;
		}

		private void ConvertPlayerRandomSkin(PlayerControllerB playerController)
		{
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)StartOfRound == (Object)null)
			{
				StartOfRound = Object.FindObjectOfType<StartOfRound>();
				if ((Object)(object)StartOfRound == (Object)null)
				{
					SCPCBDunGen.Logger.LogError((object)"Failed to find StartOfRound.");
					return;
				}
			}
			List<int> list = new List<int>();
			int num = 0;
			foreach (UnlockableItem unlockable in StartOfRound.unlockablesList.unlockables)
			{
				if ((Object)(object)unlockable.suitMaterial != (Object)null && num != playerController.currentSuitID)
				{
					list.Add(num);
				}
				num++;
			}
			int count = list.Count;
			if (count == 0)
			{
				SCPCBDunGen.Logger.LogError((object)"No suits to swap to found.");
				return;
			}
			int index = roundManager.AnomalyRandom.Next(0, count);
			NetworkBehaviourReference netBehaviourRefPlayer = NetworkBehaviourReference.op_Implicit((NetworkBehaviour)(object)playerController);
			ConvertPlayerRandomSkinClientRpc(netBehaviourRefPlayer, list[index]);
		}

		private IEnumerator ConvertPlayerMaskedWaitForSpawn(NetworkObjectReference netObjRefMasked, NetworkBehaviourReference netBehaviourRefPlayer)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: 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)
			NetworkObject netObjMasked = null;
			NetworkBehaviour netBehaviourPlayer = null;
			float fStartTime = Time.realtimeSinceStartup;
			yield return (object)new WaitUntil((Func<bool>)(() => Time.realtimeSinceStartup - fStartTime > 20f || ((NetworkObjectReference)(ref netObjRefMasked)).TryGet(ref netObjMasked, (NetworkManager)null)));
			yield return (object)new WaitUntil((Func<bool>)(() => Time.realtimeSinceStartup - fStartTime > 20f || ((NetworkBehaviourReference)(ref netBehaviourRefPlayer)).TryGet(ref netBehaviourPlayer, (NetworkManager)null)));
			PlayerControllerB playerController = (PlayerControllerB)netBehaviourPlayer;
			if ((Object)(object)playerController.deadBody == (Object)null)
			{
				yield return (object)new WaitUntil((Func<bool>)(() => Time.realtimeSinceStartup - fStartTime > 20f || (Object)(object)playerController.deadBody != (Object)null));
			}
			if ((Object)(object)playerController.deadBody != (Object)null)
			{
				playerController.deadBody.DeactivateBody(false);
				if ((Object)(object)netObjMasked != (Object)null)
				{
					MaskedPlayerEnemy component = ((Component)netObjMasked).GetComponent<MaskedPlayerEnemy>();
					component.mimickingPlayer = playerController;
					component.SetSuit(playerController.currentSuitID);
					((EnemyAI)component).SetEnemyOutside(false);
					playerController.redirectToEnemy = (EnemyAI)(object)component;
				}
			}
		}

		[ClientRpc]
		private void ConvertPlayerMaskedClientRpc(NetworkObjectReference netObjRefMasked, NetworkBehaviourReference netBehaviourRefPlayer)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Invalid comparison between Unknown and I4
			//IL_005f: 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_007d: 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)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Expected O, but got Unknown
			//IL_011f: 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_012f: 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_0152: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(358260797u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref netObjRefMasked, default(ForNetworkSerializable));
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkBehaviourReference>(ref netBehaviourRefPlayer, default(ForNetworkSerializable));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 358260797u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			NetworkBehaviour val3 = null;
			((NetworkBehaviourReference)(ref netBehaviourRefPlayer)).TryGet(ref val3, (NetworkManager)null);
			if ((Object)(object)val3 == (Object)null)
			{
				SCPCBDunGen.Logger.LogError((object)"Failed to get player controller.");
				return;
			}
			PlayerControllerB val4 = (PlayerControllerB)val3;
			val4.KillPlayer(Vector3.zero, true, (CauseOfDeath)5, 0, default(Vector3));
			if ((Object)(object)val4.deadBody != (Object)null)
			{
				val4.deadBody.DeactivateBody(false);
			}
			((MonoBehaviour)this).StartCoroutine(ConvertPlayerMaskedWaitForSpawn(netObjRefMasked, netBehaviourRefPlayer));
		}

		private void ConvertPlayerMasked(NetworkBehaviourReference netBehaviourRefPlayer, Vector3 vMaskedPosition)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			//IL_002e: 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_003e: 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_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: 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_01b0: Unknown result type (might be due to invalid IL or missing references)
			NetworkBehaviour val = null;
			((NetworkBehaviourReference)(ref netBehaviourRefPlayer)).TryGet(ref val, (NetworkManager)null);
			if ((Object)(object)val == (Object)null)
			{
				SCPCBDunGen.Logger.LogError((object)"Failed to get player controller.");
				return;
			}
			PlayerControllerB val2 = (PlayerControllerB)val;
			val2.KillPlayer(Vector3.zero, true, (CauseOfDeath)5, 0, default(Vector3));
			if ((Object)(object)StartOfRound == (Object)null)
			{
				StartOfRound = Object.FindObjectOfType<StartOfRound>();
				if ((Object)(object)StartOfRound == (Object)null)
				{
					SCPCBDunGen.Logger.LogError((object)"Failed to find StartOfRound.");
					return;
				}
			}
			if ((Object)(object)MaskedType == (Object)null)
			{
				SelectableLevel val3 = Array.Find(StartOfRound.levels, (SelectableLevel x) => x.PlanetName == "8 Titan");
				if ((Object)(object)val3 == (Object)null)
				{
					SCPCBDunGen.Logger.LogError((object)"Failed to get Titan level data.");
					return;
				}
				MaskedType = val3.Enemies.Find((SpawnableEnemyWithRarity x) => x.enemyType.enemyName == "Masked")?.enemyType;
				if ((Object)(object)MaskedType == (Object)null)
				{
					SCPCBDunGen.Logger.LogError((object)"Failed to get masked enemy type.");
					return;
				}
			}
			NetworkObjectReference netObjRefMasked = roundManager.SpawnEnemyGameObject(vMaskedPosition, 0f, -1, MaskedType);
			NetworkObject val4 = default(NetworkObject);
			if (((NetworkObjectReference)(ref netObjRefMasked)).TryGet(ref val4, (NetworkManager)null))
			{
				SCPCBDunGen.Logger.LogInfo((object)"Got network object for mask enemy");
				MaskedPlayerEnemy component = ((Component)val4).GetComponent<MaskedPlayerEnemy>();
				component.SetSuit(val2.currentSuitID);
				component.mimickingPlayer = val2;
				((EnemyAI)component).SetEnemyOutside(false);
				val2.redirectToEnemy = (EnemyAI)(object)component;
				if ((Object)(object)val2.deadBody != (Object)null)
				{
					val2.deadBody.DeactivateBody(false);
				}
			}
			ConvertPlayerMaskedClientRpc(netObjRefMasked, netBehaviourRefPlayer);
		}

		private void ConvertPlayer(PlayerControllerB playerController)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: 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_002c: 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_0057: 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_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			SCPCBDunGen.Logger.LogInfo((object)"Player detected, doing player conversion");
			SCP914Setting sCP914Setting = (SCP914Setting)iCurrentState;
			Vector3 randomNavMeshPositionInCollider = GetRandomNavMeshPositionInCollider(colliderOutput);
			NetworkBehaviourReference netBehaviourRefPlayer = NetworkBehaviourReference.op_Implicit((NetworkBehaviour)(object)playerController);
			ConvertPlayerTeleportClientRpc(netBehaviourRefPlayer, randomNavMeshPositionInCollider);
			switch (sCP914Setting)
			{
			case SCP914Setting.ROUGH:
				ConvertPlayerKillClientRpc(netBehaviourRefPlayer);
				break;
			case SCP914Setting.COARSE:
				ConvertPlayerAlterHealthClientRpc(netBehaviourRefPlayer, 50);
				break;
			case SCP914Setting.ONETOONE:
				ConvertPlayerRandomSkin(playerController);
				break;
			case SCP914Setting.FINE:
				ConvertPlayerAlterHealthClientRpc(netBehaviourRefPlayer, -50);
				break;
			case SCP914Setting.VERYFINE:
				if (!playerController.AllowPlayerDeath())
				{
					SCPCBDunGen.Logger.LogInfo((object)"Refined player with Very Fine, but player death is prevented. Doing nothing.");
				}
				else
				{
					ConvertPlayerMasked(NetworkBehaviourReference.op_Implicit((NetworkBehaviour)(object)playerController), randomNavMeshPositionInCollider);
				}
				break;
			default:
				SCPCBDunGen.Logger.LogError((object)"Invalid SCP 914 setting when attempting to convert player.");
				break;
			}
		}

		[ClientRpc]
		private void TeleportEnemyClientRpc(NetworkBehaviourReference netBehaviourRefEnemy, Vector3 vPosition)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Invalid comparison between Unknown and I4
			//IL_005f: 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_007d: 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)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Expected O, but got Unknown
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2839432350u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkBehaviourReference>(ref netBehaviourRefEnemy, default(ForNetworkSerializable));
				((FastBufferWriter)(ref val2)).WriteValueSafe(ref vPosition);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2839432350u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				NetworkBehaviour val3 = null;
				((NetworkBehaviourReference)(ref netBehaviourRefEnemy)).TryGet(ref val3, (NetworkManager)null);
				if ((Object)(object)val3 == (Object)null)
				{
					SCPCBDunGen.Logger.LogError((object)"Failed to get enemy AI.");
					return;
				}
				EnemyAI val4 = (EnemyAI)val3;
				val4.serverPosition = vPosition;
			}
		}

		private void MoveEnemy(EnemyAI enemy, Vector3 NavPosition)
		{
			//IL_0015: 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_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			SCPCBDunGen.Logger.LogInfo((object)$"No conversions for enemy: {enemy.enemyType.enemyName}. Teleporting to {NavPosition}");
			NetworkBehaviourReference netBehaviourRefEnemy = NetworkBehaviourReference.op_Implicit((NetworkBehaviour)(object)enemy);
			TeleportEnemyClientRpc(netBehaviourRefEnemy, NavPosition);
			enemy.agent.Warp(NavPosition);
			enemy.SyncPositionToClients();
			if (iCurrentState == 0)
			{
				enemy.KillEnemyOnOwnerClient(false);
			}
		}

		private void ConvertEnemyToEnemy(EnemyAI enemy)
		{
			//IL_000e: 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_006a: 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_0057: Unknown result type (might be due to invalid IL or missing references)
			Dictionary<EnemyType, List<EnemyType>> enemyMapping = GetEnemyMapping();
			Vector3 randomNavMeshPositionInCollider = GetRandomNavMeshPositionInCollider(colliderOutput);
			if (enemyMapping.TryGetValue(enemy.enemyType, out var value) && value.Count != 0)
			{
				EnemyType val = value[roundManager.AnomalyRandom.Next(value.Count)];
				roundManager.SpawnEnemyGameObject(randomNavMeshPositionInCollider, 0f, -1, val);
				Object.Destroy((Object)(object)((Component)enemy).gameObject);
			}
			MoveEnemy(enemy, randomNavMeshPositionInCollider);
		}

		private void ConvertEnemyToItem(List<NetworkObjectReference> lNetworkObjectReferences, List<int> lScrapValues, EnemyAI enemy)
		{
			//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_00ba: 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)
			//IL_00c3: 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_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			Vector3 randomPositionInCollider = GetRandomPositionInCollider(colliderOutput);
			GameObject val = null;
			NetworkObject val2 = null;
			GrabbableObject val3 = null;
			if (GetEnemyItemMapping().TryGetValue(enemy.enemyType, out List<Item> value))
			{
				SCPCBDunGen.Logger.LogInfo((object)"Mapping found");
				Item val4 = value[roundManager.AnomalyRandom.Next(value.Count)];
				Object.Destroy((Object)(object)((Component)enemy).gameObject);
				if ((Object)(object)val4 != (Object)null)
				{
					SCPCBDunGen.Logger.LogInfo((object)"Conversion found");
					val = Object.Instantiate<GameObject>(val4.spawnPrefab, randomPositionInCollider, Quaternion.identity, ScrapTransform);
					val2 = val.GetComponent<NetworkObject>();
					val3 = val.GetComponent<GrabbableObject>();
				}
			}
			else
			{
				SCPCBDunGen.Logger.LogInfo((object)"No conversion, teleporting enemy");
				Vector3 randomNavMeshPositionInCollider = GetRandomNavMeshPositionInCollider(colliderOutput);
				MoveEnemy(enemy, randomNavMeshPositionInCollider);
			}
			SCPCBDunGen.Logger.LogInfo((object)"Preprocessing done");
			if ((Object)(object)val3 == (Object)null)
			{
				SCPCBDunGen.Logger.LogInfo((object)"Conversion was null, item is intended to be destroyed in process.");
				return;
			}
			Item itemProperties = val3.itemProperties;
			if (itemProperties.isScrap)
			{
				SCPCBDunGen.Logger.LogInfo((object)"Item is scrap or null, generating a copy with new value");
				GrabbableObject component = val.GetComponent<GrabbableObject>();
				int num = (int)((float)roundManager.AnomalyRandom.Next(itemProperties.minValue, itemProperties.maxValue) * roundManager.scrapValueMultiplier);
				component.SetScrapValue(num);
				SCPCBDunGen.Logger.LogInfo((object)$"new scrap value: {num}");
				lScrapValues.Add(num);
			}
			else
			{
				SCPCBDunGen.Logger.LogInfo((object)"Item is not scrap, adding empty scrap value");
				lScrapValues.Add(0);
			}
			val2.Spawn(true);
			lNetworkObjectReferences.Add(NetworkObjectReference.op_Implicit(val2));
		}

		private void ConvertEnemy(List<NetworkObjectReference> lNetworkObjectReferences, List<int> lScrapValues, EnemyAI enemy)
		{
			//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_008a: Unknown result type (might be due to invalid IL or missing references)
			Dictionary<EnemyType, List<Item>> enemyItemMapping = GetEnemyItemMapping();
			Dictionary<EnemyType, List<EnemyType>> enemyMapping = GetEnemyMapping();
			if (GetEnemyMapping().TryGetValue(enemy.enemyType, out List<EnemyType> _))
			{
				if (roundManager.AnomalyRandom.Next(2) == 0 && GetEnemyItemMapping().ContainsKey(enemy.enemyType))
				{
					ConvertEnemyToItem(lNetworkObjectReferences, lScrapValues, enemy);
				}
				else
				{
					ConvertEnemyToEnemy(enemy);
				}
			}
			else if (GetEnemyItemMapping().ContainsKey(enemy.enemyType))
			{
				ConvertEnemyToItem(lNetworkObjectReferences, lScrapValues, enemy);
			}
			else
			{
				Vector3 randomNavMeshPositionInCollider = GetRandomNavMeshPositionInCollider(colliderOutput);
				MoveEnemy(enemy, randomNavMeshPositionInCollider);
			}
			Object.Destroy((Object)(object)((Component)enemy).gameObject);
		}

		protected override void __initializeVariables()
		{
			((NetworkBehaviour)this).__initializeVariables();
		}

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_SCP914Converter()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Expected O, but got Unknown
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Expected O, but got Unknown
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Expected O, but got Unknown
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Expected O, but got Unknown
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Expected O, but got Unknown
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(2627837757u, new RpcReceiveHandler(__rpc_handler_2627837757));
			NetworkManager.__rpc_func_table.Add(301590527u, new RpcReceiveHandler(__rpc_handler_301590527));
			NetworkManager.__rpc_func_table.Add(1051910848u, new RpcReceiveHandler(__rpc_handler_1051910848));
			NetworkManager.__rpc_func_table.Add(3833341719u, new RpcReceiveHandler(__rpc_handler_3833341719));
			NetworkManager.__rpc_func_table.Add(4143732333u, new RpcReceiveHandler(__rpc_handler_4143732333));
			NetworkManager.__rpc_func_table.Add(4044311993u, new RpcReceiveHandler(__rpc_handler_4044311993));
			NetworkManager.__rpc_func_table.Add(3018499267u, new RpcReceiveHandler(__rpc_handler_3018499267));
			NetworkManager.__rpc_func_table.Add(1252059581u, new RpcReceiveHandler(__rpc_handler_1252059581));
			NetworkManager.__rpc_func_table.Add(527346026u, new RpcReceiveHandler(__rpc_handler_527346026));
			NetworkManager.__rpc_func_table.Add(1669287785u, new RpcReceiveHandler(__rpc_handler_1669287785));
			NetworkManager.__rpc_func_table.Add(358260797u, new RpcReceiveHandler(__rpc_handler_358260797));
			NetworkManager.__rpc_func_table.Add(2839432350u, new RpcReceiveHandler(__rpc_handler_2839432350));
		}

		private static void __rpc_handler_2627837757(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((SCP914Converter)(object)target).TurnStateServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_301590527(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int iNewState = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref iNewState);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((SCP914Converter)(object)target).TurnStateClientRpc(iNewState);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1051910848(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((SCP914Converter)(object)target).ActivateServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3833341719(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((SCP914Converter)(object)target).ActivateClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_4143732333(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((SCP914Converter)(object)target).RefineFinishClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_4044311993(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: 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_0074: 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_0058: 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_00b9: 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)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: 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_00a3: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				NetworkObjectReference[] arNetworkObjectReferences = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref arNetworkObjectReferences, default(ForNetworkSerializable));
				}
				bool flag2 = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag2, default(ForPrimitives));
				int[] arScrapValues = null;
				if (flag2)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref arScrapValues, default(ForPrimitives));
				}
				bool bChargeBattery = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref bChargeBattery, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((SCP914Converter)(object)target).SpawnItemsClientRpc(arNetworkObjectReferences, arScrapValues, bChargeBattery);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3018499267(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: 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_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: 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_006f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkBehaviourReference netBehaviourRefPlayer = default(NetworkBehaviourReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkBehaviourReference>(ref netBehaviourRefPlayer, default(ForNetworkSerializable));
				Vector3 vPosition = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref vPosition);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((SCP914Converter)(object)target).ConvertPlayerTeleportClientRpc(netBehaviourRefPlayer, vPosition);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1252059581(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: 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_0044: 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_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkBehaviourReference netBehaviourRefPlayer = default(NetworkBehaviourReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkBehaviourReference>(ref netBehaviourRefPlayer, default(ForNetworkSerializable));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((SCP914Converter)(object)target).ConvertPlayerKillClientRpc(netBehaviourRefPlayer);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_527346026(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: 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_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkBehaviourReference netBehaviourRefPlayer = default(NetworkBehaviourReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkBehaviourReference>(ref netBehaviourRefPlayer, default(ForNetworkSerializable));
				int iHealthDelta = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref iHealthDelta);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((SCP914Converter)(object)target).ConvertPlayerAlterHealthClientRpc(netBehaviourRefPlayer, iHealthDelta);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1669287785(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: 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_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkBehaviourReference netBehaviourRefPlayer = default(NetworkBehaviourReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkBehaviourReference>(ref netBehaviourRefPlayer, default(ForNetworkSerializable));
				int iSuitID = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref iSuitID);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((SCP914Converter)(object)target).ConvertPlayerRandomSkinClientRpc(netBehaviourRefPlayer, iSuitID);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_358260797(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: 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_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: 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_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkObjectReference netObjRefMasked = default(NetworkObjectReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref netObjRefMasked, default(ForNetworkSerializable));
				NetworkBehaviourReference netBehaviourRefPlayer = default(NetworkBehaviourReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkBehaviourReference>(ref netBehaviourRefPlayer, default(ForNetworkSerializable));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((SCP914Converter)(object)target).ConvertPlayerMaskedClientRpc(netObjRefMasked, netBehaviourRefPlayer);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2839432350(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: 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_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: 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_006f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkBehaviourReference netBehaviourRefEnemy = default(NetworkBehaviourReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkBehaviourReference>(ref netBehaviourRefEnemy, default(ForNetworkSerializable));
				Vector3 vPosition = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref vPosition);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((SCP914Converter)(object)target).TeleportEnemyClientRpc(netBehaviourRefEnemy, vPosition);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "SCP914Converter";
		}
	}
	public class SCPDoorMover : NetworkBehaviour
	{
		public NavMeshObstacle navObstacle;

		public Animator doors;

		public List<AudioClip> doorAudioClips;

		public AudioClip doorAudioClipFast;

		public AudioSource doorSFXSource;

		public InteractTrigger ButtonA;

		public InteractTrigger ButtonB;

		private bool bDoorOpen;

		private bool bDoorWaiting;

		private List<EnemyAICollisionDetect> EnemiesInCollider = new List<EnemyAICollisionDetect>();

		private void OnTriggerEnter(Collider other)
		{
			if (!((Object)(object)NetworkManager.Singleton == (Object)null) && ((NetworkBehaviour)this).IsServer && ((Component)other).CompareTag("Enemy"))
			{
				EnemyAICollisionDetect component = ((Component)other).GetComponent<EnemyAICollisionDetect>();
				if (!((Object)(object)component == (Object)null))
				{
					SCPCBDunGen.Logger.LogInfo((object)("Enemy entered trigger: " + ((Object)component.mainScript.enemyType).name));
					EnemiesInCollider.Add(component);
				}
			}
		}

		private void OnTriggerExit(Collider other)
		{
			if (!((Object)(object)NetworkManager.Singleton == (Object)null) && ((NetworkBehaviour)this).IsServer && ((Component)other).CompareTag("Enemy"))
			{
				EnemyAICollisionDetect component = ((Component)other).GetComponent<EnemyAICollisionDetect>();
				if (!((Object)(object)component == (Object)null) && !EnemiesInCollider.Remove(component))
				{
					SCPCBDunGen.Logger.LogWarning((object)"Enemy left door trigger but somehow wasn't detected in trigger entry.");
				}
			}
		}

		private void Update()
		{
			if ((Object)(object)NetworkManager.Singleton == (Object)null || !((NetworkBehaviour)this).IsServer || bDoorOpen || bDoorWaiting || EnemiesInCollider.Count == 0)
			{
				return;
			}
			SCPCBDunGen.Logger.LogInfo((object)"Enemy attempting to open door...");
			float num = 0f;
			foreach (EnemyAICollisionDetect item in EnemiesInCollider)
			{
				EnemyAI mainScript = item.mainScript;
				if (!mainScript.isEnemyDead)
				{
					SCPCBDunGen.Logger.LogInfo((object)$"Enemy {((Object)mainScript.enemyType).name} with open mult {mainScript.openDoorSpeedMultiplier}");
					float val = mainScript.openDoorSpeedMultiplier;
					if (((Object)mainScript.enemyType).name == "MaskedPlayerEnemy")
					{
						val = 1f;
					}
					if (((Object)mainScript.enemyType).name == "Crawler")
					{
						val = 2f;
					}
					num = Math.Max(num, val);
				}
			}
			SCPCBDunGen.Logger.LogInfo((object)$"Highest multiplier is {num}.");
			if (num != 0f)
			{
				SCPCBDunGen.Logger.LogInfo((object)"Door being opened.");
				if (num > 1.5f)
				{
					OpenDoorFastServerRpc();
				}
				else
				{
					ToggleDoorServerRpc();
				}
			}
		}

		[ServerRpc]
		public void OpenDoorFastServerRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Invalid comparison between Unknown and I4
			//IL_00a5: 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_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Invalid comparison between Unknown and I4
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
				{
					if ((int)networkManager.LogLevel <= 1)
					{
						Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
					}
					return;
				}
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(289563691u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 289563691u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				SCPCBDunGen.Logger.LogInfo((object)"Opening door fast [SERVER].");
				bDoorWaiting = true;
				bDoorOpen = true;
				((Behaviour)navObstacle).enabled = false;
				OpenDoorFastClientRpc();
				((MonoBehaviour)this).StartCoroutine(DoorToggleButtonUsable());
			}
		}

		[ClientRpc]
		public void OpenDoorFastClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1678254293u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1678254293u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					SCPCBDunGen.Logger.LogInfo((object)"Opening door fast [CLIENT].");
					bDoorWaiting = true;
					bDoorOpen = true;
					ButtonA.interactable = false;
					ButtonB.interactable = false;
					((Behaviour)navObstacle).enabled = false;
					doorSFXSource.PlayOneShot(doorAudioClipFast);
					doors.SetTrigger("openfast");
				}
			}
		}

		private IEnumerator DoorToggleButtonUsable()
		{
			yield return (object)new WaitForSeconds(1f);
			bDoorWaiting = false;
			yield return (object)new WaitForSeconds(1f);
			EnableDoorButtonClientRpc();
		}

		[ServerRpc(RequireOwnership = false)]
		public void ToggleDoorServerRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(40313670u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 40313670u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost) && !bDoorWaiting)
				{
					bool flag = !bDoorOpen;
					string text = (flag ? "opening" : "closing");
					SCPCBDunGen.Logger.LogInfo((object)("Door is " + text + "."));
					bDoorWaiting = true;
					bDoorOpen = flag;
					((Behaviour)navObstacle).enabled = !flag;
					ToggleDoorClientRpc(bDoorOpen);
					((MonoBehaviour)this).StartCoroutine(DoorToggleButtonUsable());
				}
			}
		}

		[ClientRpc]
		public void ToggleDoorClientRpc(bool _bDoorOpen)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: 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_007d: 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)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(659555206u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref _bDoorOpen, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 659555206u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					bDoorOpen = _bDoorOpen;
					ButtonA.interactable = false;
					ButtonB.interactable = false;
					((Behaviour)navObstacle).enabled = !_bDoorOpen;
					doorSFXSource.PlayOneShot(doorAudioClips[Random.Range(0, doorAudioClips.Count)]);
					doors.SetTrigger(bDoorOpen ? "open" : "close");
				}
			}
		}

		[ClientRpc]
		public void EnableDoorButtonClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1538705838u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1538705838u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					ButtonA.interactable = true;
					ButtonB.interactable = true;
				}
			}
		}

		protected override void __initializeVariables()
		{
			((NetworkBehaviour)this).__initializeVariables();
		}

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_SCPDoorMover()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(289563691u, new RpcReceiveHandler(__rpc_handler_289563691));
			NetworkManager.__rpc_func_table.Add(1678254293u, new RpcReceiveHandler(__rpc_handler_1678254293));
			NetworkManager.__rpc_func_table.Add(40313670u, new RpcReceiveHandler(__rpc_handler_40313670));
			NetworkManager.__rpc_func_table.Add(659555206u, new RpcReceiveHandler(__rpc_handler_659555206));
			NetworkManager.__rpc_func_table.Add(1538705838u, new RpcReceiveHandler(__rpc_handler_1538705838));
		}

		private static void __rpc_handler_289563691(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0029: 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_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Invalid comparison between Unknown and I4
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId)
			{
				if ((int)networkManager.LogLevel <= 1)
				{
					Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
				}
			}
			else
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((SCPDoorMover)(object)target).OpenDoorFastServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1678254293(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((SCPDoorMover)(object)target).OpenDoorFastClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_40313670(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((SCPDoorMover)(object)target).ToggleDoorServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_659555206(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: 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_0044: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((SCPDoorMover)(object)target).ToggleDoorClientRpc(flag);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1538705838(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((SCPDoorMover)(object)target).EnableDoorButtonClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "SCPDoorMover";
		}
	}
	public struct SCP914Conversion
	{
		public string ItemName;

		public List<string> RoughResults { get; set; }

		public List<string> CoarseResults { get; set; }

		public List<string> OneToOneResults { get; set; }

		public List<string> FineResults { get; set; }

		public List<string> VeryFineResults { get; set; }
	}
	public class SCP914ConversionSet : KeyedCollection<string, SCP914Conversion>
	{
		protected override string GetKeyForItem(SCP914Conversion conversion)
		{
			return conversion.ItemName;
		}
	}
	[BepInPlugin("SCPCBDunGen", "SCPCBDunGen", "4.3.2")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[LobbyCompatibility(/*Could not decode attribute arguments.*/)]
	public class SCPCBDunGen : BaseUnityPlugin
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static Func<string, bool> <0>__Exists;

			public static Func<string, IEnumerable<string>> <1>__GetFiles;

			public static hook_SpawnScrapInLevel <2>__SetItemSpawnPoints;

			public static hook_SpawnScrapInLevel <3>__SCP914Configuration;
		}

		public static AssetBundle? SCPCBAssets;

		public SCP914ConversionSet SCP914Conversions = new SCP914ConversionSet();

		public static SCPCBDunGen Instance { get; private set; }

		internal static ManualLogSource Logger { get; private set; }

		private void Awake()
		{
			//IL_0289: Expected O, but got Unknown
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Expected O, but got Unknown
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			NetcodePatcher();
			Hook();
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			SCPCBAssets = AssetBundle.LoadFromFile(Path.Combine(directoryName, "scpcb_dungeon"));
			if ((Object)(object)SCPCBAssets == (Object)null)
			{
				Logger.LogError((object)"Failed to load SCPCB Dungeon assets.");
				return;
			}
			ExtendedDungeonFlow val = SCPCBAssets.LoadAsset<ExtendedDungeonFlow>("assets/Mods/SCP/data/SCPCBDunGenExtFlow.asset");
			if ((Object)(object)val == (Object)null)
			{
				Logger.LogError((object)"Failed to load SCP:CB Extended Dungeon Flow.");
				return;
			}
			ConfigEntry<bool> val2 = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Default914Recipes", true, new ConfigDescription("If false, any custom 914 Json files named \"default.json\" will be ignored (i.e. the default 914 config will not be loaded).\nSome custom 914 implementations may want to fully override the default settings, in which case this can be set to false.", (AcceptableValueBase)null, Array.Empty<object>()));
			ConfigEntry<bool> val3 = ((BaseUnityPlugin)this).Config.Bind<bool>("Mod Compatibility", "PiggysVarietyMod", true, new ConfigDescription("If Piggys Variety Mod is present and this setting is enabled, tesla gates can spawn in the SCP Foundation.\nWARNING: Ensure this value matches across all clients or desync will occur.", (AcceptableValueBase)null, Array.Empty<object>()));
			if (val3.Value && Chainloader.PluginInfos.ContainsKey("Piggy.PiggyVarietyMod"))
			{
				CompatPVM(val);
			}
			PatchedContent.RegisterExtendedDungeonFlow(val);
			foreach (string item in DiscoverConfiguredRecipeFiles())
			{
				if (!val2.Value && Path.GetFileName(item) == "default.json")
				{
					continue;
				}
				StreamReader streamReader = new StreamReader(item);
				string text = streamReader.ReadToEnd();
				try
				{
					List<SCP914Conversion> list = JsonConvert.DeserializeObject<List<SCP914Conversion>>(text);
					foreach (SCP914Conversion item2 in list)
					{
						if (SCP914Conve

plugins/SecretLabs.dll

Decompiled 2 weeks ago
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using SecretLabs.Patches;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;

[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("SecretLabs")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("SecretLabs")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SecretLabs")]
[assembly: AssemblyTitle("SecretLabs")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace SecretLabs
{
	[Serializable]
	public class Config : SyncedInstance<Config>
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static HandleNamedMessageDelegate <0>__OnRequestSync;

			public static HandleNamedMessageDelegate <1>__OnReceiveSync;
		}

		public bool customPriceEnabled;

		public int moonPrice;

		public Config(ConfigFile cfg)
		{
			InitInstance(this);
			customPriceEnabled = cfg.Bind<bool>("General", "CustomPriceEnabled", false, "Enable this if you wish to configure the moons route price below.").Value;
			moonPrice = cfg.Bind<int>("General", "MoonPrice", 700, "The route price of the Secret Labs moon.").Value;
		}

		public static void RequestSync()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			if (!SyncedInstance<Config>.IsClient)
			{
				return;
			}
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(SyncedInstance<Config>.IntSize, (Allocator)2, -1);
			try
			{
				SyncedInstance<Config>.MessageManager.SendNamedMessage("SecretLabs_OnRequestConfigSync", 0uL, val, (NetworkDelivery)3);
			}
			finally
			{
				((IDisposable)(FastBufferWriter)(ref val)).Dispose();
			}
		}

		public static void OnRequestSync(ulong clientId, FastBufferReader _)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			if (!SyncedInstance<Config>.IsHost)
			{
				return;
			}
			byte[] array = SyncedInstance<Config>.SerializeToBytes(SyncedInstance<Config>.Instance);
			int num = array.Length;
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(num + SyncedInstance<Config>.IntSize, (Allocator)2, -1);
			try
			{
				((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref num, default(ForPrimitives));
				((FastBufferWriter)(ref val)).WriteBytesSafe(array, -1, 0);
				SyncedInstance<Config>.MessageManager.SendNamedMessage("SecretLabs_OnReceiveConfigSync", clientId, val, (NetworkDelivery)3);
			}
			catch (Exception arg)
			{
				Plugin.Logger.LogDebug((object)$"Error occurred syncing config with client: {clientId}\n{arg}");
			}
			finally
			{
				((IDisposable)(FastBufferWriter)(ref val)).Dispose();
			}
		}

		public static void OnReceiveSync(ulong _, FastBufferReader reader)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			if (!((FastBufferReader)(ref reader)).TryBeginRead(SyncedInstance<Config>.IntSize))
			{
				Plugin.Logger.LogError((object)"Config sync error: Could not begin reading buffer.");
				return;
			}
			int num = default(int);
			((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num, default(ForPrimitives));
			if (!((FastBufferReader)(ref reader)).TryBeginRead(num))
			{
				Plugin.Logger.LogError((object)"Config sync error: Host could not sync.");
				return;
			}
			byte[] data = new byte[num];
			((FastBufferReader)(ref reader)).ReadBytesSafe(ref data, num, 0);
			SyncedInstance<Config>.SyncInstance(data);
			Plugin.Logger.LogDebug((object)"Successfully synced config with host.");
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")]
		public static void InitializeLocalPlayer()
		{
			//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_0063: Expected O, but got Unknown
			//IL_0021: 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_002c: Expected O, but got Unknown
			if (SyncedInstance<Config>.IsHost)
			{
				CustomMessagingManager messageManager = SyncedInstance<Config>.MessageManager;
				object obj = <>O.<0>__OnRequestSync;
				if (obj == null)
				{
					HandleNamedMessageDelegate val = OnRequestSync;
					<>O.<0>__OnRequestSync = val;
					obj = (object)val;
				}
				messageManager.RegisterNamedMessageHandler("SecretLabs_OnRequestConfigSync", (HandleNamedMessageDelegate)obj);
				SyncedInstance<Config>.Synced = true;
				return;
			}
			SyncedInstance<Config>.Synced = false;
			CustomMessagingManager messageManager2 = SyncedInstance<Config>.MessageManager;
			object obj2 = <>O.<1>__OnReceiveSync;
			if (obj2 == null)
			{
				HandleNamedMessageDelegate val2 = OnReceiveSync;
				<>O.<1>__OnReceiveSync = val2;
				obj2 = (object)val2;
			}
			messageManager2.RegisterNamedMessageHandler("SecretLabs_OnReceiveConfigSync", (HandleNamedMessageDelegate)obj2);
			RequestSync();
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(GameNetworkManager), "StartDisconnect")]
		public static void PlayerLeave()
		{
			SyncedInstance<Config>.RevertSync();
		}
	}
	[Serializable]
	public class SyncedInstance<T>
	{
		[NonSerialized]
		protected static int IntSize = 4;

		internal static CustomMessagingManager MessageManager => NetworkManager.Singleton.CustomMessagingManager;

		internal static bool IsClient => NetworkManager.Singleton.IsClient;

		internal static bool IsHost => NetworkManager.Singleton.IsHost;

		public static T Default { get; set; }

		public static T Instance { get; set; }

		public static bool Synced { get; internal set; }

		protected void InitInstance(T instance)
		{
			Default = instance;
			Instance = instance;
		}

		internal static void SyncInstance(byte[] data)
		{
			Instance = DeserializeFromBytes(data);
			Synced = true;
		}

		internal static void RevertSync()
		{
			Instance = Default;
			Synced = false;
		}

		public static byte[] SerializeToBytes(T val)
		{
			BinaryFormatter binaryFormatter = new BinaryFormatter();
			using MemoryStream memoryStream = new MemoryStream();
			try
			{
				binaryFormatter.Serialize(memoryStream, val);
				return memoryStream.ToArray();
			}
			catch (Exception arg)
			{
				Plugin.Logger.LogError((object)$"Error serializing instance: {arg}");
				return null;
			}
		}

		public static T DeserializeFromBytes(byte[] data)
		{
			BinaryFormatter binaryFormatter = new BinaryFormatter();
			using MemoryStream serializationStream = new MemoryStream(data);
			try
			{
				return (T)binaryFormatter.Deserialize(serializationStream);
			}
			catch (Exception arg)
			{
				Plugin.Logger.LogError((object)$"Error deserializing instance: {arg}");
				return default(T);
			}
		}
	}
	[BepInPlugin("SecretLabs", "SecretLabs", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private Harmony _harmony;

		public static ManualLogSource Logger;

		public static Config Config { get; internal set; }

		private void Awake()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			_harmony = new Harmony("SecretLabs");
			Config = new Config(((BaseUnityPlugin)this).Config);
			_harmony.PatchAll(typeof(RoutePatches));
			_harmony.PatchAll(typeof(Config));
			Logger.LogDebug((object)"Plugin SecretLabs is loaded!");
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "SecretLabs";

		public const string PLUGIN_NAME = "SecretLabs";

		public const string PLUGIN_VERSION = "1.0.0";
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "SecretLabs";

		public const string PLUGIN_NAME = "SecretLabs";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace SecretLabs.Patches
{
	[HarmonyPatch(typeof(Terminal))]
	public class RoutePatches
	{
		[HarmonyPatch("LoadNewNode")]
		[HarmonyPrefix]
		private static void LoadNewNodePatchBefore(ref TerminalNode node)
		{
			if (!SyncedInstance<Config>.Instance.customPriceEnabled)
			{
				return;
			}
			Terminal obj = Object.FindObjectOfType<Terminal>();
			Plugin.Logger.LogDebug((object)((Object)node).name);
			CompatibleNoun[] compatibleNouns = obj.terminalNodes.allKeywords.First((TerminalKeyword terminalKeyword) => terminalKeyword.word == "route").compatibleNouns;
			foreach (CompatibleNoun val in compatibleNouns)
			{
				if (!((Object)(object)val.result == (Object)null) && ((Object)val.result).name == "secret labsRoute")
				{
					val.result.itemCost = SyncedInstance<Config>.Instance.moonPrice;
				}
			}
		}

		[HarmonyPatch("LoadNewNodeIfAffordable")]
		[HarmonyPrefix]
		private static void LoadNewNodeIfAffordablePatch(ref TerminalNode node)
		{
			if (SyncedInstance<Config>.Instance.customPriceEnabled)
			{
				Plugin.Logger.LogDebug((object)((Object)node).name);
				if (!((Object)(object)node == (Object)null) && !(((Object)node).name != "secret labsRouteConfirm"))
				{
					node.itemCost = Math.Abs(SyncedInstance<Config>.Instance.moonPrice);
				}
			}
		}
	}
}

plugins/TeraScript.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using LethalLevelLoader;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("TeraScript")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("A template for Lethal Company")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("TeraScript")]
[assembly: AssemblyTitle("TeraScript")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace TeraScript
{
	public class DSBlinking : MonoBehaviour
	{
		[Serializable]
		public class DSBlinkingValues
		{
			public enum SwitchMode
			{
				simple,
				multi,
				broken
			}

			public bool IsActive;

			[Header("Max HDR bright")]
			[ColorUsage(true, true)]
			public Color MaxBright;

			[Header("blinking")]
			public float SwitchTime = 0.1f;

			[Header("Simple blinking, Increasing Blinking, Broken lamp")]
			public SwitchMode SwitchModes = SwitchMode.simple;

			[HideInInspector]
			public int mode;

			[HideInInspector]
			public int count;

			[Header("Shared Material")]
			public Material SharedMaterial;

			[Header("Shader String")]
			public string WorkingString = "_EmissiveColor";

			public IEnumerator ColorSwitch(float random)
			{
				while (true)
				{
					yield return (object)new WaitForSeconds(SwitchTime + random);
					if (SwitchModes == SwitchMode.simple)
					{
						mode = 1 - mode;
						if (mode == 0)
						{
							SharedMaterial.SetColor(WorkingString, Color.black);
						}
						else
						{
							SharedMaterial.SetColor(WorkingString, MaxBright);
						}
					}
					else if (SwitchModes == SwitchMode.multi)
					{
						mode++;
						if (mode > 2)
						{
							mode = 0;
						}
						if (mode == 0)
						{
							SharedMaterial.SetColor(WorkingString, Color.black);
						}
						else if (mode == 1)
						{
							SharedMaterial.SetColor(WorkingString, MaxBright * 0.5f);
						}
						else
						{
							SharedMaterial.SetColor(WorkingString, MaxBright);
						}
					}
					else
					{
						if (count < 10)
						{
							mode++;
							if (mode > 2)
							{
								mode = 0;
							}
							if (mode == 0)
							{
								SharedMaterial.SetColor(WorkingString, Color.black);
							}
							else if (mode == 1)
							{
								SharedMaterial.SetColor(WorkingString, MaxBright * 0.5f);
							}
							else
							{
								SharedMaterial.SetColor(WorkingString, MaxBright);
							}
						}
						else if (count < 20)
						{
							SharedMaterial.SetColor(WorkingString, MaxBright * 0.5f);
						}
						else
						{
							SharedMaterial.SetColor(WorkingString, MaxBright);
						}
						count++;
						if (count > 50)
						{
							count = 0;
						}
					}
					random = 0f;
				}
			}
		}

		public DSBlinkingValues[] _DSBlinkingValues;

		[Header("Shader String")]
		public string WorkingString = "_EmissiveColor";

		private void Awake()
		{
			Random.InitState((int)DateTime.Now.Ticks * 1000);
		}

		private void Start()
		{
			for (int i = 0; i < _DSBlinkingValues.Length; i++)
			{
				if (_DSBlinkingValues[i].IsActive)
				{
					float random = Random.Range(0.07f, 0.95f);
					((MonoBehaviour)this).StartCoroutine(_DSBlinkingValues[i].ColorSwitch(random));
				}
			}
		}

		private void Update()
		{
		}

		private void OnDestroy()
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < _DSBlinkingValues.Length; i++)
			{
				if (_DSBlinkingValues[i].IsActive)
				{
					_DSBlinkingValues[i].SharedMaterial.SetColor(WorkingString, _DSBlinkingValues[i].MaxBright);
				}
			}
		}
	}
	public class DSCaster : MonoBehaviour
	{
		[Header("'Water' - one of built in Unity layers:")]
		public string InteractLayer;

		[Space(10f)]
		public GameObject Canvas;

		public float RayLength = 1f;

		private int buttonsMask;

		private Material PrevMat = null;

		private Color PrevColor;

		[Header("Shader String")]
		public string WorkingString = "_EmissiveColor";

		private void Awake()
		{
			buttonsMask = LayerMask.GetMask(new string[1] { InteractLayer });
			if (Object.op_Implicit((Object)(object)Canvas))
			{
				Canvas.SetActive(false);
			}
		}

		private void Start()
		{
		}

		private void Update()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: 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_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			RaycastHit val = default(RaycastHit);
			if (Physics.Linecast(((Component)this).transform.position, ((Component)this).transform.TransformPoint(new Vector3(0f, 0f, RayLength)), ref val, buttonsMask))
			{
				if (Object.op_Implicit((Object)(object)Canvas))
				{
					Canvas.SetActive(true);
				}
				if (Input.GetMouseButtonUp(0))
				{
					((Component)((RaycastHit)(ref val)).collider).gameObject.GetComponent<DSTrigger>().DSTriggerExecute();
				}
				Material val2 = ((Component)((RaycastHit)(ref val)).collider).gameObject.GetComponent<Renderer>().materials[0];
				Color color = val2.GetColor(WorkingString);
				if ((Object)(object)PrevMat != (Object)(object)val2)
				{
					if (Object.op_Implicit((Object)(object)PrevMat))
					{
						PrevMat.SetColor(WorkingString, PrevColor);
					}
					PrevMat = val2;
					PrevColor = color;
					val2.SetColor(WorkingString, new Color(0f, 1.27f, 5f));
				}
			}
			else
			{
				if (Object.op_Implicit((Object)(object)Canvas))
				{
					Canvas.SetActive(false);
				}
				if (Object.op_Implicit((Object)(object)PrevMat))
				{
					PrevMat.SetColor(WorkingString, PrevColor);
					PrevMat = null;
				}
			}
		}

		private void FixedUpdate()
		{
		}
	}
	public class DSElevator : MonoBehaviour
	{
		[Header("Current mesh position, e.g. 1,2,3,4.. floor (from 1)")]
		public int StartFloor;

		[Space(10f)]
		public int TotalFloors;

		[Header("smaller = faster")]
		public float Speed = 5f;

		[HideInInspector]
		public bool IsMoving;

		[HideInInspector]
		public bool CallerBusy;

		[HideInInspector]
		public int CurrentFloor;

		private float TimeStart;

		private Vector3 StartPos;

		private Vector3 EndPos;

		private void Start()
		{
			CurrentFloor = StartFloor;
		}

		private void Update()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			if (IsMoving)
			{
				float num = Time.time - TimeStart;
				float num2 = num / Speed;
				((Component)this).transform.position = Vector3.Lerp(StartPos, EndPos, num2);
				if (num2 >= 1f)
				{
					IsMoving = false;
				}
			}
		}

		public void StartMoving(bool direction)
		{
			//IL_0090: 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_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: 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_00e8: 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_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_00c1: Unknown result type (might be due to invalid IL or missing references)
			if (!(!IsMoving & !CallerBusy))
			{
				return;
			}
			if (direction)
			{
				if (CurrentFloor + 1 > TotalFloors)
				{
					return;
				}
				CurrentFloor++;
			}
			else
			{
				if (CurrentFloor - 1 < 1)
				{
					return;
				}
				CurrentFloor--;
			}
			IsMoving = true;
			TimeStart = Time.time;
			StartPos = ((Component)this).transform.position;
			if (direction)
			{
				EndPos = ((Component)this).transform.position + Vector3.up * 4f;
			}
			else
			{
				EndPos = ((Component)this).transform.position - Vector3.up * 4f;
			}
		}
	}
	public class DSElevatorCaller : MonoBehaviour
	{
		[Header("!caller doesn't work with Y pos < 0 (negative numbers)!")]
		public DSElevator _DSElevator;

		[Header("smaller = faster")]
		public float Speed = 5f;

		private bool IsMoving;

		private float TimeStart;

		private Vector3 StartPos;

		private Vector3 EndPos;

		private void Start()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			StartPos = Vector3.zero;
			EndPos = Vector3.zero;
		}

		private void Update()
		{
			//IL_003b: 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_0076: Unknown result type (might be due to invalid IL or missing references)
			if (IsMoving)
			{
				float num = Time.time - TimeStart;
				float num2 = num / Speed;
				((Component)_DSElevator).transform.position = new Vector3(((Component)_DSElevator).transform.position.x, Mathf.Lerp(StartPos.y, EndPos.y, num2), ((Component)_DSElevator).transform.position.z);
				if (num2 >= 1f)
				{
					IsMoving = false;
					_DSElevator.CallerBusy = false;
				}
			}
		}

		public void StartMoving()
		{
			//IL_0032: 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)
			if (!(!IsMoving & !_DSElevator.IsMoving))
			{
				return;
			}
			StartPos.y = ((Component)_DSElevator).transform.position.y;
			EndPos.y = (int)((Component)this).transform.position.y;
			EndPos.y = (int)EndPos.y / 4;
			EndPos.y *= 4f;
			if (EndPos.y == StartPos.y)
			{
				return;
			}
			IsMoving = true;
			_DSElevator.CallerBusy = true;
			TimeStart = Time.time;
			int num = 0;
			num = ((!((StartPos.y < 0f) | (EndPos.y < 0f))) ? ((int)Mathf.Abs(StartPos.y - EndPos.y)) : ((int)(Mathf.Abs(StartPos.y) + Mathf.Abs(EndPos.y))));
			num /= 4;
			if (StartPos.y != EndPos.y)
			{
				if (StartPos.y > EndPos.y)
				{
					_DSElevator.CurrentFloor -= num;
				}
				else
				{
					_DSElevator.CurrentFloor += num;
				}
			}
		}
	}
	internal class DSGates : MonoBehaviour
	{
		public enum StartStates
		{
			opened,
			closed
		}

		public string AnimationOpen;

		public string AnimationClose;

		public StartStates StartState = StartStates.closed;

		private bool CurrentState;

		private void Start()
		{
			if (StartState == StartStates.closed)
			{
				((Component)this).GetComponent<Animation>().Play(AnimationClose);
				CurrentState = true;
			}
			else
			{
				((Component)this).GetComponent<Animation>().Play(AnimationOpen);
				CurrentState = false;
			}
		}

		private void Update()
		{
		}

		public void StartOpenClose()
		{
			if (((Component)this).GetComponent<Animation>().isPlaying)
			{
				return;
			}
			CurrentState = !CurrentState;
			if (CurrentState)
			{
				if (!((Component)this).GetComponent<Animation>().isPlaying)
				{
					((Component)this).GetComponent<Animation>().Play(AnimationClose);
				}
			}
			else if (!((Component)this).GetComponent<Animation>().isPlaying)
			{
				((Component)this).GetComponent<Animation>().Play(AnimationOpen);
			}
		}
	}
	public class DSReparent : MonoBehaviour
	{
		private void Start()
		{
		}

		private void Update()
		{
		}

		private void OnTriggerEnter(Collider other)
		{
			if (Object.op_Implicit((Object)(object)((Component)other).gameObject.GetComponent<CharacterController>()))
			{
				((Component)other).gameObject.transform.parent = ((Component)this).transform;
			}
		}

		private void OnTriggerExit(Collider other)
		{
			if (Object.op_Implicit((Object)(object)((Component)other).gameObject.GetComponent<CharacterController>()))
			{
				((Component)other).gameObject.transform.parent = null;
			}
		}
	}
	public class DSScrollTexture : MonoBehaviour
	{
		[Header("Texture Offsets")]
		public Vector2[] MoveRate;

		[Header("Shared Materials")]
		public Material[] SharedMaterials;

		[Header("Shader String")]
		public string WorkingString = "_EmissiveColorMap";

		private void Start()
		{
		}

		private void Update()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//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_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < SharedMaterials.Length; i++)
			{
				Vector2 textureOffset = SharedMaterials[i].GetTextureOffset(WorkingString);
				textureOffset += MoveRate[i] * Time.deltaTime;
				textureOffset.x %= 50f;
				textureOffset.y %= 50f;
				SharedMaterials[i].SetTextureOffset(WorkingString, textureOffset);
			}
		}

		private void OnDestroy()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < SharedMaterials.Length; i++)
			{
				SharedMaterials[i].SetTextureOffset(WorkingString, Vector2.zero);
			}
		}
	}
	public class DSTrigger : MonoBehaviour
	{
		public enum ExecMode
		{
			elevator_up,
			elevator_dwn,
			gate,
			elevator_call
		}

		public bool IsActive = true;

		public GameObject Executor;

		public ExecMode ExecModes = ExecMode.gate;

		private void Start()
		{
		}

		private void Update()
		{
		}

		public void DSTriggerExecute()
		{
			if (IsActive)
			{
				if (ExecModes == ExecMode.elevator_up)
				{
					Executor.GetComponent<DSElevator>().StartMoving(direction: true);
				}
				else if (ExecModes == ExecMode.elevator_dwn)
				{
					Executor.GetComponent<DSElevator>().StartMoving(direction: false);
				}
				else if (ExecModes == ExecMode.gate)
				{
					Executor.GetComponent<DSGates>().StartOpenClose();
				}
				else if (ExecModes == ExecMode.elevator_call)
				{
					Executor.GetComponent<DSElevatorCaller>().StartMoving();
				}
			}
		}
	}
	public class DSTvMovie : MonoBehaviour
	{
		[Serializable]
		public class DSTvMovieValues
		{
			public bool IsActive;

			[Header("max emission bright")]
			public float MaxBright = 3f;

			[Header("frames speed")]
			public float Speed;

			[Header("shared material")]
			public Material SharedMaterial;

			[Header("frames")]
			public Texture[] Frames;

			[HideInInspector]
			public int i;
		}

		public DSTvMovieValues[] _DSTvMovieValues;

		[Header("Shader String")]
		public string WorkingString = "_EmissiveColor";

		[Header("Shader String 2")]
		public string WorkingString2 = "_EmissiveColorMap";

		private void Awake()
		{
			Random.InitState((int)DateTime.Now.Ticks * 1000);
		}

		private void Start()
		{
			//IL_00a5: 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)
			for (int i = 0; i < _DSTvMovieValues.Length; i++)
			{
				if (_DSTvMovieValues[i].IsActive)
				{
					float num = Random.Range(1.5f, _DSTvMovieValues[i].MaxBright);
					float num2 = Random.Range(0.2f, 0.8f);
					float num3 = Random.Range(0.2f, 0.8f);
					float num4 = Random.Range(0.2f, 0.8f);
					_DSTvMovieValues[i].SharedMaterial.SetColor(WorkingString, new Color(num + num2, num + num3, num + num4));
				}
				else
				{
					_DSTvMovieValues[i].SharedMaterial.SetColor(WorkingString, Color.black);
				}
			}
		}

		private void Update()
		{
			for (int i = 0; i < _DSTvMovieValues.Length; i++)
			{
				if (_DSTvMovieValues[i].IsActive)
				{
					_DSTvMovieValues[i].i = (int)(Time.time * _DSTvMovieValues[i].Speed);
					_DSTvMovieValues[i].i = _DSTvMovieValues[i].i % _DSTvMovieValues[i].Frames.Length;
					_DSTvMovieValues[i].SharedMaterial.SetTexture(WorkingString2, _DSTvMovieValues[i].Frames[_DSTvMovieValues[i].i]);
				}
			}
		}

		private void OnDestroy()
		{
			for (int i = 0; i < _DSTvMovieValues.Length; i++)
			{
				if (_DSTvMovieValues[i].IsActive)
				{
				}
			}
		}
	}
	[BepInPlugin("Tolian.TeraSpace", "TeraSpace", "0.8.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public const string GUID = "Tolian.TeraSpace";

		public const string NAME = "TeraSpace";

		public const string VERSION = "0.8.0";

		private void Awake()
		{
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(directoryName, "teraspace"));
			if ((Object)(object)val == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"Failed to load Interior Dungeon assets.");
				return;
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Interior Assets loaded successfully");
			ExtendedDungeonFlow val2 = val.LoadAsset<ExtendedDungeonFlow>("Assets/LethalCompany/Mods/TeraSpace/TeraDungFlow.asset");
			PatchedContent.RegisterExtendedDungeonFlow(val2);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Loaded Extended DungeonFlow");
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "TeraScript";

		public const string PLUGIN_NAME = "TeraScript";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}