Decompiled source of ScarletDevilMansion v1.3.16

ScarletMansion.dll

Decompiled 3 days 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.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 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
			}
		};

		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;
		}

		private static string GetAssemblyName()
		{
			return Assembly.GetExecutingAssembly().FullName.Split(new char[1] { ',' })[0];
		}

		public static void LoadAssetBundle()
		{
			if ((Object)(object)MainAssetBundle == (Object)null)
			{
				using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(GetAssemblyName() + ".scarletmansion");
				MainAssetBundle = AssetBundle.LoadFromStream(stream);
			}
			dungeon = Assets.Load<DungeonFlow>("SDMLevel", onlyReportErrors: true);
			networkObjectList = Assets.Load<NetworkObjectListScriptableObject>("SDMList", onlyReportErrors: true);
			entranceAudioClip = Assets.Load<AudioClip>("entrance", onlyReportErrors: true);
			knight = new Enemy(Assets.Load<GameObject>("NET_KnightEnemy", onlyReportErrors: true), Assets.Load<TerminalNode>("KnightNode", onlyReportErrors: true), Assets.Load<TerminalKeyword>("KnightKeyword", 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 item2 in networkObjectList.items)
			{
				ScrapItem item = new ScrapItem(item2, GetItemRarityFunction(item2));
				scrapItems.Add(item);
				globalItems.Add(item);
			}
			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 references)
			//IL_0027: 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_00db: 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_01a2: Unknown result type (might be due to invalid IL or missing references)
			int colorIndex = crystal.colorIndex;
			Vector3 position = ((Component)crystal).transform.position + Vector3.up * 0.25f;
			int flashlightId = GetFlashlightId(flashLight);
			int scrapValue = ((GrabbableObject)crystal).scrapValue;
			int num = scrapValue;
			Item targetTransformation = crystal.targetTransformation;
			if (Object.op_Implicit((Object)(object)targetTransformation))
			{
				num = Mathf.RoundToInt((float)num * 0.5f);
			}
			if (flashlightId == -1)
			{
				string text = (Object.op_Implicit((Object)(object)flashLight) ? ((GrabbableObject)flashLight).itemProperties.itemName : "NULL");
				Plugin.logger.LogErro

ScarletMansionMimicsPatch.dll

Decompiled 3 days 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();
			}
		}
	}
}