Decompiled source of Wither v2.0.0

ScienceBird.Wither.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using GoodItemScan;
using HarmonyLib;
using LethalLevelLoader;
using LethalLib.Modules;
using LethalModDataLib.Attributes;
using LethalModDataLib.Features;
using LobbyCompatibility.Enums;
using LobbyCompatibility.Features;
using Microsoft.CodeAnalysis;
using ScienceBird.Wither.NetcodePatcher;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Events;
using UnityEngine.Rendering.HighDefinition;
using UnityEngine.UI;
using WeatherRegistry;
using Wither.Events;
using Wither.Inside;
using Wither.Mechanics;
using Wither.Patches;
using Wither.Scripts;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ScienceBird.Wither")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("2.0.0.0")]
[assembly: AssemblyInformationalVersion("2.0.0+3e6b769898fa5b641ba4f66aafe4455308f3c61d")]
[assembly: AssemblyProduct("Wither")]
[assembly: AssemblyTitle("ScienceBird.Wither")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Wither
{
	public class LobbyCompatibility
	{
		public static void RegisterCompatibility()
		{
			PluginHelper.RegisterPlugin("ScienceBird.Wither", Version.Parse("2.0.0"), (CompatibilityLevel)2, (VersionStrictness)0);
		}
	}
	public class NetworkHandler : NetworkBehaviour
	{
		public static NetworkHandler Instance { get; private set; }

		public static event Action<string> LevelEvent;

		public override void OnNetworkSpawn()
		{
			NetworkHandler.LevelEvent = null;
			if ((NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer) && (Object)(object)Instance != (Object)null)
			{
				GameObject gameObject = ((Component)Instance).gameObject;
				if (gameObject != null)
				{
					NetworkObject component = gameObject.GetComponent<NetworkObject>();
					if (component != null)
					{
						component.Despawn(true);
					}
				}
			}
			Instance = this;
			((NetworkBehaviour)this).OnNetworkSpawn();
		}

		[ClientRpc]
		public void EventClientRpc(string eventName)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: 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(1849323834u, val, (RpcDelivery)0);
				bool flag = eventName != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(eventName, false);
				}
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1849323834u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				NetworkHandler.LevelEvent?.Invoke(eventName);
			}
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_NetworkHandler()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(1849323834u, new RpcReceiveHandler(__rpc_handler_1849323834));
		}

		private static void __rpc_handler_1849323834(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_0061: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				string eventName = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref eventName, false);
				}
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((NetworkHandler)(object)target).EventClientRpc(eventName);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "NetworkHandler";
		}
	}
	[HarmonyPatch]
	public class NetworkObjectManager
	{
		private static GameObject networkPrefab;

		[HarmonyPostfix]
		[HarmonyPatch(typeof(GameNetworkManager), "Start")]
		public static void Init()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			if (!((Object)(object)networkPrefab != (Object)null))
			{
				networkPrefab = (GameObject)Wither.ExtraAssets.LoadAsset("WitherNetworkHandler");
				networkPrefab.AddComponent<NetworkHandler>();
				NetworkManager.Singleton.AddNetworkPrefab(networkPrefab);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(StartOfRound), "Awake")]
		private static void SpawnNetworkHandler()
		{
			//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)
			if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer)
			{
				GameObject val = Object.Instantiate<GameObject>(networkPrefab, Vector3.zero, Quaternion.identity);
				val.GetComponent<NetworkObject>().Spawn(false);
			}
		}
	}
	[BepInPlugin("ScienceBird.Wither", "Wither", "2.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Wither : BaseUnityPlugin
	{
		public static AssetBundle ExtraAssets;

		public static ConfigEntry<bool> VanillaPlusMode;

		public static ConfigEntry<bool> DyingApparatusOnly;

		public static ConfigEntry<float> QuotaFraction;

		public static ConfigEntry<int> MinValue;

		public static ConfigEntry<int> MaxValue;

		public static ConfigEntry<bool> ScaleWithApparatus;

		public static ConfigEntry<int> ScalingBase;

		public static ConfigEntry<float> ExtraMultiplier;

		public static ConfigEntry<bool> MysteriousScrap;

		public static ConfigEntry<int> MysteriousScrapRarity;

		public static ConfigEntry<int> MaxCatwalkTriggers;

		public static ConfigEntry<bool> GarageStartOpen;

		public static bool doLobbyCompat;

		public static bool mrovWeatherPresent;

		public static bool mrovTerminalPresent;

		public static bool testPresent;

		public static bool evaisaPresent;

		public static bool zaggyPresent;

		public static Wither Instance { get; private set; }

		internal static ManualLogSource Logger { get; private set; }

		internal static Harmony? Harmony { get; set; }

		private void Awake()
		{
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Expected O, but got Unknown
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Expected O, but got Unknown
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Expected O, but got Unknown
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Expected O, but got Unknown
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			VanillaPlusMode = ((BaseUnityPlugin)this).Config.Bind<bool>("Event", "Vanilla Plus Mode", false, "Removes everything from the map related to the special event (dying apparatus is not removed).");
			QuotaFraction = ((BaseUnityPlugin)this).Config.Bind<float>("Event", "Quota Fraction", 0.3f, new ConfigDescription("The fraction of the quota that the average total reward value should be (the average value of all 3 items combined). Ex. 0.3 means 30% of the quota, so if your quota is 1000 the total value will add up to 300 (which is 30% of 1000). This means each individual scrap would be worth 100.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.05f, 3f), Array.Empty<object>()));
			MinValue = ((BaseUnityPlugin)this).Config.Bind<int>("Event", "Minimum Individual Value", 50, new ConfigDescription("The minimum value an individual scrap will be worth (no other variance or modifiers will bring it below this value). Ex. at 50 the minimum for all items combined is 150.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(10, 1000), Array.Empty<object>()));
			MaxValue = ((BaseUnityPlugin)this).Config.Bind<int>("Event", "Maximum Individual Value", 600, new ConfigDescription("The maximum value an individual scrap will be worth (no other variance or modifiers will bring it above this value). Ex. at 600 the maximum for all items combined is 1800", (AcceptableValueBase)(object)new AcceptableValueRange<int>(100, 5000), Array.Empty<object>()));
			ScaleWithApparatus = ((BaseUnityPlugin)this).Config.Bind<bool>("Event", "Scale With Apparatus", true, "Scale the value of the reward items based on the apparatus inserted.");
			ScalingBase = ((BaseUnityPlugin)this).Config.Bind<int>("Event", "Scaling Base", 50, new ConfigDescription("If 'Scale With Apparatus' is enabled, this is the 'neutral' value. So, value calculations are unchanged if the apparatus is worth exactly this much (if it's worth more, value is adjusted by how many times bigger it is, vice versa for smaller).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 200), Array.Empty<object>()));
			ExtraMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Event", "4th Item Multiplier", 2.5f, new ConfigDescription("The scaling factor applied exclusively to the value of the 4th harder to reach item. It otherwise has the same base value calculations and variations as the other items, but is ignored for the quota fraction (quota fraction still acts as if there are only 3 items).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 5f), Array.Empty<object>()));
			DyingApparatusOnly = ((BaseUnityPlugin)this).Config.Bind<bool>("Event", "Dying Apparatus Only", false, "Only allow the secret dying apparatus to be inserted.");
			MysteriousScrap = ((BaseUnityPlugin)this).Config.Bind<bool>("Mysterious Scrap", "Spawn Mysterious Scrap", false, "A strange new object appears on Wither (silly joke item not intended for serious play, no need to enable unless you're curious).");
			MysteriousScrapRarity = ((BaseUnityPlugin)this).Config.Bind<int>("Mysterious Scrap", "Mysterious Scrap Rarity", 20, new ConfigDescription("Rarity for an average scrap item is ~30 (will only ever spawn on Wither under normal circumstances).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 250), Array.Empty<object>()));
			MaxCatwalkTriggers = ((BaseUnityPlugin)this).Config.Bind<int>("Other Map Features", "Max Catwalk Triggers", 4, "Maximum amount of times the fragile catwalk can potentially be walked on before it breaks (will vary randomly between 2 and this number)");
			GarageStartOpen = ((BaseUnityPlugin)this).Config.Bind<bool>("Other Map Features", "Garage Door Starts Open", false, "If enabled, the garage door in the desert area of the map will start open (instead of needing to be opened from the other side).");
			Patch();
			ModDataHandler.RegisterInstance((object)typeof(TerminalEntryPatches), (string)null);
			Logger.LogInfo((object)"ScienceBird.Wither v2.0.0 has loaded!");
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			ExtraAssets = AssetBundle.LoadFromFile(Path.Combine(directoryName, "extrawitherassets"));
			if (!((Object)(object)ExtraAssets == (Object)null))
			{
				FootstepsPatch.LoadAssets();
				GreenDogPatch.LoadAssets();
				TerminalEntryPatches.LoadAssets();
				NetcodePatcher();
			}
		}

		internal static void Patch()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony = new Harmony("ScienceBird.Wither");
			}
			bool flag = Chainloader.PluginInfos.ContainsKey("BMX.LobbyCompatibility");
			evaisaPresent = Chainloader.PluginInfos.ContainsKey("LethalLib");
			mrovWeatherPresent = Chainloader.PluginInfos.ContainsKey("mrov.WeatherRegistry");
			mrovTerminalPresent = Chainloader.PluginInfos.ContainsKey("TerminalFormatter");
			testPresent = Chainloader.PluginInfos.ContainsKey("TestAccount666.GoodItemScan");
			zaggyPresent = Chainloader.PluginInfos.ContainsKey("Zaggy1024.TwoRadarMaps");
			if (flag)
			{
				LobbyCompatibility.RegisterCompatibility();
			}
			Logger.LogDebug((object)"Patching...");
			Harmony.PatchAll();
			if (testPresent)
			{
				GoodItemScanPatch.DoPatching();
			}
			Logger.LogDebug((object)"Finished patching!");
		}

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

		private static void NetcodePatcher()
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array2 = methods;
				foreach (MethodInfo methodInfo in array2)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "ScienceBird.Wither";

		public const string PLUGIN_NAME = "Wither";

		public const string PLUGIN_VERSION = "2.0.0";
	}
}
namespace Wither.Scripts
{
	public class DataSync : NetworkBehaviour
	{
		public static DataSync Instance { get; private set; }

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
				return;
			}
			Object.Destroy((Object)(object)((Component)Instance).gameObject);
			Instance = this;
		}

		[ClientRpc]
		public void UpdateTerminalPatchClientRpc(bool unlocked, bool unread)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2318981889u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref unlocked, default(ForPrimitives));
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref unread, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2318981889u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && !((NetworkBehaviour)this).IsServer)
				{
					TerminalEntryPatches.unlocked = unlocked;
					TerminalEntryPatches.unread = unread;
				}
			}
		}

		[ClientRpc]
		public void SetVanillaPlusModeClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1414889917u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1414889917u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && !((NetworkBehaviour)this).IsServer)
				{
					ScenePatches.DisableEventObjects();
				}
			}
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_DataSync()
		{
			//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
			NetworkManager.__rpc_func_table.Add(2318981889u, new RpcReceiveHandler(__rpc_handler_2318981889));
			NetworkManager.__rpc_func_table.Add(1414889917u, new RpcReceiveHandler(__rpc_handler_1414889917));
		}

		private static void __rpc_handler_2318981889(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool unlocked = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref unlocked, default(ForPrimitives));
				bool unread = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref unread, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((DataSync)(object)target).UpdateTerminalPatchClientRpc(unlocked, unread);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1414889917(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;
				((DataSync)(object)target).SetVanillaPlusModeClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "DataSync";
		}
	}
	public class LethalLibApparatusCheck
	{
		public static void AddApparatuses()
		{
			foreach (ScrapItem scrapItem in Items.scrapItems)
			{
				if (InsertApparatus.IsApparatus(scrapItem.item.itemName))
				{
					ModdedApparatusConfig.apparatusDict.TryAdd(scrapItem.item, (ModdedApparatusConfig.FilterSpecialCharacters(scrapItem.modName), ModdedApparatusConfig.FilterSpecialCharacters(scrapItem.item.itemName)));
				}
			}
		}
	}
	public class MrovBlackoutCheck : NetworkBehaviour
	{
		public static string CheckCurrentWeather()
		{
			Weather currentWeather = WeatherManager.GetCurrentWeather(StartOfRound.Instance.currentLevel);
			if ((Object)(object)currentWeather != (Object)null)
			{
				return currentWeather.Name;
			}
			return "";
		}

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

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "MrovBlackoutCheck";
		}
	}
	public class MysteriousScrap : NetworkBehaviour
	{
		private void OnEnable()
		{
			SetRarity();
		}

		public void SetRarity()
		{
			if ((Object)(object)RoundManager.Instance.currentLevel != (Object)null)
			{
				int num = 0;
				for (int i = 0; i < RoundManager.Instance.currentLevel.spawnableScrap.Count; i++)
				{
					if (RoundManager.Instance.currentLevel.spawnableScrap[i].spawnableItem.itemName == "Ricardorb")
					{
						num = i;
						break;
					}
				}
				Wither.Logger.LogDebug((object)$"Setting spawning to {Wither.MysteriousScrap.Value} for strange scrap (rarity {Wither.MysteriousScrapRarity.Value}, index {num}).");
				if (Wither.MysteriousScrap.Value)
				{
					RoundManager.Instance.currentLevel.spawnableScrap[num].rarity = Wither.MysteriousScrapRarity.Value;
				}
				else
				{
					RoundManager.Instance.currentLevel.spawnableScrap[num].rarity = 0;
				}
			}
			else
			{
				Wither.Logger.LogWarning((object)"No selectable level found, skipping scrap config check.");
			}
		}

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

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "MysteriousScrap";
		}
	}
}
namespace Wither.Patches
{
	[HarmonyPatch]
	public class ApparatusRotationPatch
	{
		public static bool initialSet = true;

		public static Vector3 rotLastFrame = Vector3.zero;

		public static Vector3 targetRotation;

		public static Vector3 targetPosition;

		public static Vector3 positionOffset;

		public static bool posSet = true;

		private static bool tempInitial = true;

		[HarmonyPatch(typeof(GrabbableObject), "LateUpdate")]
		[HarmonyPostfix]
		[HarmonyAfter(new string[] { "me.loaforc.facilitymeltdown" })]
		private static void UpdateRotation(GrabbableObject __instance)
		{
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: 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_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0282: Unknown result type (might be due to invalid IL or missing references)
			//IL_0287: Unknown result type (might be due to invalid IL or missing references)
			//IL_028c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0358: Unknown result type (might be due to invalid IL or missing references)
			//IL_035d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_030f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0303: Unknown result type (might be due to invalid IL or missing references)
			//IL_032f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0341: Unknown result type (might be due to invalid IL or missing references)
			//IL_0346: Unknown result type (might be due to invalid IL or missing references)
			if ((!InsertApparatus.doingInsertion && !InsertApparatus.isInserted) || !((Object)(object)__instance == (Object)(object)InsertApparatus.insertedApparatus))
			{
				return;
			}
			__instance.grabbable = false;
			if (initialSet)
			{
				if (ModdedApparatusConfig.configDict.TryGetValue(__instance.itemProperties, out (ConfigEntry<string>, ConfigEntry<string>) value))
				{
					string[] array = value.Item1.Value.Split(",");
					string[] array2 = value.Item2.Value.Split(",");
					Vector3 zero = Vector3.zero;
					if (array.Length == 3 && float.TryParse(array[0], NumberStyles.Float, CultureInfo.InvariantCulture, out var result) && float.TryParse(array[1], NumberStyles.Float, CultureInfo.InvariantCulture, out var result2) && float.TryParse(array[2], NumberStyles.Float, CultureInfo.InvariantCulture, out var result3))
					{
						((Vector3)(ref zero))..ctor(result, result2, result3);
					}
					Vector3 zero2 = Vector3.zero;
					if (array2.Length == 3 && float.TryParse(array2[0], NumberStyles.Float, CultureInfo.InvariantCulture, out var result4) && float.TryParse(array2[1], NumberStyles.Float, CultureInfo.InvariantCulture, out var result5) && float.TryParse(array2[2], NumberStyles.Float, CultureInfo.InvariantCulture, out var result6))
					{
						((Vector3)(ref zero2))..ctor(result4, result5, result6);
					}
					targetRotation = zero + new Vector3(0f, 193f, 0f);
					Wither.Logger.LogDebug((object)$"Setting target to: {targetRotation}");
					positionOffset = zero2;
					Wither.Logger.LogDebug((object)$"Setting offset to: {positionOffset}");
				}
				else
				{
					Wither.Logger.LogDebug((object)"Couldn't find apparatus in dictionary!");
					targetRotation = new Vector3(0f, 193f, 0f);
					positionOffset = Vector3.zero;
				}
				initialSet = false;
			}
			if (positionOffset == Vector3.zero)
			{
				targetPosition = ((Component)__instance).gameObject.transform.position;
			}
			if (!(Mathf.Abs(Quaternion.Dot(((Component)__instance).gameObject.transform.rotation, Quaternion.Euler(targetRotation))) < 0.999f))
			{
				Vector3 val = ((Component)__instance).gameObject.transform.position - targetPosition;
				if (!(Mathf.Abs(((Vector3)(ref val)).magnitude) > 0.005f))
				{
					goto IL_034d;
				}
			}
			if (((Component)__instance).gameObject.transform.eulerAngles == rotLastFrame)
			{
				if (posSet && positionOffset != Vector3.zero)
				{
					posSet = false;
					targetPosition = ((Component)__instance).transform.position + positionOffset;
				}
				((Component)__instance).transform.eulerAngles = targetRotation;
				if (!posSet)
				{
					((Component)__instance).transform.position = targetPosition;
					__instance.targetFloorPosition = ((Component)__instance).transform.localPosition;
				}
			}
			goto IL_034d;
			IL_034d:
			rotLastFrame = ((Component)__instance).gameObject.transform.eulerAngles;
		}
	}
	[HarmonyPatch]
	public class BetterDustClouds
	{
		private static bool initialSet = true;

		private static bool enableBuffer = true;

		private static bool transitionBuffer = false;

		private static bool transitionOverride = true;

		[HarmonyPatch(typeof(TimeOfDay), "Update")]
		[HarmonyPostfix]
		private static void ReEnable(TimeOfDay __instance)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Invalid comparison between Unknown and I4
			if (ScenePatches.onWither && (int)__instance.currentLevelWeather == 0)
			{
				GameObject effectObject = __instance.effects[0].effectObject;
				if ((Object)(object)effectObject != (Object)null && (!effectObject.activeInHierarchy || !__instance.effects[0].effectEnabled) && (Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)null && !GameNetworkManager.Instance.localPlayerController.isInsideFactory)
				{
					effectObject.SetActive(true);
					__instance.effects[0].effectEnabled = true;
				}
			}
		}

		[HarmonyPatch(typeof(TimeOfDay), "Start")]
		[HarmonyPostfix]
		private static void SetInitial(TimeOfDay __instance)
		{
			initialSet = true;
		}

		[HarmonyPatch(typeof(TimeOfDay), "SetWeatherEffects")]
		[HarmonyPrefix]
		private static void CheckBefore(TimeOfDay __instance)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			if (ScenePatches.onWither)
			{
				GameObject effectObject = TimeOfDay.Instance.effects[0].effectObject;
				if ((int)__instance.currentLevelWeather == 0 && (Object)(object)effectObject != (Object)null)
				{
					enableBuffer = __instance.effects[0].effectEnabled;
					transitionBuffer = __instance.effects[0].transitioning;
					__instance.effects[0].effectEnabled = false;
					__instance.effects[0].transitioning = transitionOverride;
				}
			}
		}

		[HarmonyPatch(typeof(TimeOfDay), "SetWeatherEffects")]
		[HarmonyPostfix]
		private static void ChangeEffectObject(TimeOfDay __instance)
		{
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Expected O, but got Unknown
			//IL_016f: 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_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0259: Unknown result type (might be due to invalid IL or missing references)
			//IL_0274: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: Unknown result type (might be due to invalid IL or missing references)
			//IL_0278: Unknown result type (might be due to invalid IL or missing references)
			//IL_0282: Unknown result type (might be due to invalid IL or missing references)
			//IL_0287: Unknown result type (might be due to invalid IL or missing references)
			//IL_028c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0294: Unknown result type (might be due to invalid IL or missing references)
			GameObject effectObject = TimeOfDay.Instance.effects[0].effectObject;
			if (!ScenePatches.onWither)
			{
				if (initialSet && (Object)(object)effectObject != (Object)null && effectObject.activeInHierarchy)
				{
					AudioSource componentInChildren = effectObject.GetComponentInChildren<AudioSource>();
					if ((Object)(object)componentInChildren != (Object)null)
					{
						componentInChildren.Stop();
					}
					LocalVolumetricFog component = effectObject.GetComponent<LocalVolumetricFog>();
					if ((Object)(object)component != (Object)null)
					{
						component.parameters.meanFreePath = 17f;
					}
					__instance.effects[0].lerpPosition = true;
					initialSet = false;
				}
			}
			else
			{
				if ((int)__instance.currentLevelWeather != 0 || !((Object)(object)effectObject != (Object)null))
				{
					return;
				}
				__instance.effects[0].effectEnabled = enableBuffer;
				__instance.effects[0].transitioning = transitionBuffer;
				transitionOverride = true;
				if (initialSet)
				{
					enableBuffer = true;
					__instance.effects[0].lerpPosition = false;
					GameObject val = (GameObject)Wither.ExtraAssets.LoadAsset("WitherDustCloudsAmbience");
					if ((Object)(object)val != (Object)null)
					{
						LocalVolumetricFog component2 = effectObject.GetComponent<LocalVolumetricFog>();
						if ((Object)(object)component2 != (Object)null)
						{
							component2.parameters.meanFreePath = 8f;
						}
						if (!Object.op_Implicit((Object)(object)effectObject.GetComponentInChildren<AudioSource>()))
						{
							GameObject val2 = Object.Instantiate<GameObject>(val, Vector3.zero, Quaternion.identity);
							val2.transform.SetParent(effectObject.transform, false);
						}
						AudioSource componentInChildren2 = effectObject.GetComponentInChildren<AudioSource>();
						if ((Object)(object)componentInChildren2 != (Object)null)
						{
							componentInChildren2.Play();
						}
						else
						{
							Wither.Logger.LogError((object)"Null dust clouds audio!");
						}
					}
					initialSet = false;
				}
				if (__instance.effects[0].effectEnabled && (Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)null && !GameNetworkManager.Instance.localPlayerController.isInsideFactory)
				{
					__instance.effects[0].transitioning = false;
					if ((Object)(object)__instance.effects[0].effectObject != (Object)null)
					{
						Vector3 val3 = ((!GameNetworkManager.Instance.localPlayerController.isPlayerDead) ? ((Component)StartOfRound.Instance.localPlayerController).transform.position : ((Component)StartOfRound.Instance.spectateCamera).transform.position);
						val3 += Vector3.up * 4f;
						effectObject.transform.position = val3;
					}
				}
				else if (!__instance.effects[0].transitioning)
				{
					transitionOverride = false;
				}
			}
		}
	}
	[HarmonyPatch]
	public class DustSpaceClouds
	{
		[HarmonyPatch(typeof(StartOfRound), "SetMapScreenInfoToCurrentLevel")]
		[HarmonyPostfix]
		[HarmonyPriority(0)]
		private static void AddSpaceToMapScreen(StartOfRound __instance)
		{
			string text = ((TMP_Text)__instance.screenLevelDescription).text;
			if (text.Contains("115 Wither") && text.Contains("DustClouds"))
			{
				text = text.Replace("DustClouds", "Dust Clouds");
				((TMP_Text)__instance.screenLevelDescription).text = text;
			}
		}

		[HarmonyPatch(typeof(Terminal), "LoadNewNode")]
		[HarmonyPostfix]
		[HarmonyPriority(0)]
		[HarmonyAfter(new string[] { "mrov.terminalformatter" })]
		private static void AddSpaceToTerminal(Terminal __instance)
		{
			if (__instance.currentText.Contains("DustClouds"))
			{
				__instance.currentText = __instance.currentText.Replace("DustClouds", "Dust Clouds");
				__instance.screenText.text = __instance.currentText;
			}
		}
	}
	[HarmonyPatch]
	public class FallDamagePatch
	{
		[HarmonyPatch(typeof(PlayerControllerB), "DamagePlayer")]
		[HarmonyPrefix]
		private static void OnPlayerDamaged(PlayerControllerB __instance, ref int damageNumber, CauseOfDeath causeOfDeath, bool fallDamage, out bool __state)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Invalid comparison between Unknown and I4
			__state = false;
			if (ScenePatches.onWither && (int)causeOfDeath == 2 && FallDamageTrigger.fallImmune)
			{
				damageNumber = 0;
				__state = true;
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "DamagePlayer")]
		[HarmonyPostfix]
		private static void AfterPlayerDamaged(PlayerControllerB __instance, ref int damageNumber, CauseOfDeath causeOfDeath, bool fallDamage, bool __state)
		{
			if (ScenePatches.onWither && __state)
			{
				__instance.playerBodyAnimator.ResetTrigger("Damage");
			}
		}
	}
	[HarmonyPatch]
	public class FalseInteriorPatches
	{
		public static ManualCameraRenderer twoRadarCam;

		private static bool TargetPlayerOutsideTrueInterior(ManualCameraRenderer radarCam)
		{
			int targetTransformIndex = radarCam.targetTransformIndex;
			int num = (((Object)(object)radarCam.targetedPlayer != (Object)null) ? ((int)radarCam.targetedPlayer.playerClientId) : (-1));
			return (Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)null && ((num != -1 && (!radarCam.targetedPlayer.isInsideFactory || TargetPlayerInFalseInterior(radarCam))) || (radarCam.radarTargets[targetTransformIndex].isNonPlayer && Object.op_Implicit((Object)(object)((Component)radarCam.radarTargets[targetTransformIndex].transform).GetComponent<RadarBoosterItem>()) && !((GrabbableObject)((Component)radarCam.radarTargets[targetTransformIndex].transform).GetComponent<RadarBoosterItem>()).isInFactory));
		}

		private static bool TargetPlayerInFalseInterior(ManualCameraRenderer radarCam)
		{
			int targetTransformIndex = radarCam.targetTransformIndex;
			int num = (((Object)(object)radarCam.targetedPlayer != (Object)null) ? ((int)radarCam.targetedPlayer.playerClientId) : (-1));
			return num != -1 && InFactoryTrigger.playersInFalseInterior != null && !radarCam.radarTargets[targetTransformIndex].isNonPlayer && ((InFactoryTrigger.isInFalseInterior && (Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)(object)radarCam.targetedPlayer) || InFactoryTrigger.playersInFalseInterior.Contains(num));
		}

		private static bool ValidCam(ManualCameraRenderer radarCam)
		{
			return ScenePatches.onWither && (Object)(object)radarCam.cam == (Object)(object)radarCam.mapCamera && !radarCam.overrideCameraForOtherUse;
		}

		[HarmonyPatch(typeof(ManualCameraRenderer), "SetLineToExitFromRadarTarget")]
		[HarmonyPrefix]
		public static bool ExitLinePatch(ManualCameraRenderer __instance)
		{
			if (ValidCam(__instance) && TargetPlayerInFalseInterior(__instance))
			{
				((Renderer)__instance.lineFromRadarTargetToExit).enabled = false;
				return false;
			}
			return true;
		}

		[HarmonyPatch(typeof(ManualCameraRenderer), "MapCameraFocusOnPosition")]
		[HarmonyPostfix]
		private static void ClippingPatch(ManualCameraRenderer __instance)
		{
			if (ValidCam(__instance) && TargetPlayerOutsideTrueInterior(__instance))
			{
				Camera mapCamera = __instance.mapCamera;
				mapCamera.farClipPlane += 5f;
			}
		}

		[HarmonyPatch(typeof(StartOfRound), "SwitchMapMonitorPurpose")]
		[HarmonyPostfix]
		private static void OnRadarEnable(StartOfRound __instance, bool displayInfo)
		{
			if (Wither.zaggyPresent && (Object)(object)twoRadarCam == (Object)null)
			{
				twoRadarCam = ((Component)Object.FindObjectOfType<Terminal>()).GetComponent<ManualCameraRenderer>();
			}
			if (!displayInfo)
			{
				FieldInfo fieldInfo = AccessTools.Field(typeof(ManualCameraRenderer), "checkedForContourMap");
				if (fieldInfo != null)
				{
					fieldInfo.SetValue(__instance.mapScreen, false);
				}
			}
			if (ScenePatches.onWither)
			{
				ToggleShipIcon(__instance.mapScreen, displayInfo);
				if ((Object)(object)twoRadarCam != (Object)null)
				{
					ToggleShipIcon(twoRadarCam, displayInfo);
				}
			}
		}

		private static void ToggleShipIcon(ManualCameraRenderer radarCam, bool show)
		{
			if (!((Object)(object)radarCam.shipArrowUI != (Object)null))
			{
				return;
			}
			Transform val = radarCam.shipArrowUI.transform.Find("ShipIcon");
			if ((Object)(object)val != (Object)null)
			{
				if (!show)
				{
					((Component)val).gameObject.SetActive(false);
				}
				else
				{
					((Component)val).gameObject.SetActive(true);
				}
			}
		}

		[HarmonyPatch(typeof(ManualCameraRenderer), "Update")]
		[HarmonyPostfix]
		private static void ContourPosShipArrowUpdatePatch(ManualCameraRenderer __instance)
		{
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: 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_00ce: Unknown result type (might be due to invalid IL or missing references)
			if (ValidCam(__instance))
			{
				ManualCameraRenderer mapScreen = StartOfRound.Instance.mapScreen;
				if ((Object)(object)mapScreen.contourMap != (Object)null && (((Object)(object)__instance.targetedPlayer != (Object)null && !__instance.targetedPlayer.isInsideFactory) || ((Object)(object)__instance.targetedPlayer == (Object)null && ((Component)__instance.headMountedCamTarget).transform.position.y > -80f)))
				{
					mapScreen.contourMap.transform.position = new Vector3(mapScreen.contourMap.transform.position.x, ((Component)__instance.headMountedCamTarget).transform.position.y - 4f, mapScreen.contourMap.transform.position.z);
				}
				if (TargetPlayerInFalseInterior(__instance))
				{
					__instance.shipArrowUI.SetActive(false);
				}
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "SetNightVisionEnabled")]
		[HarmonyPostfix]
		private static void NightVisionUpdate(PlayerControllerB __instance)
		{
			if (InFactoryTrigger.isInFalseInterior)
			{
				((Behaviour)__instance.nightVision).enabled = false;
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "TeleportPlayer")]
		[HarmonyPostfix]
		private static void OnTeleport(PlayerControllerB __instance)
		{
			if (!ScenePatches.onWither || (Object)(object)StartOfRound.Instance == (Object)null || InFactoryTrigger.playersInFalseInterior == null || StartOfRound.Instance.inShipPhase)
			{
				return;
			}
			if ((Object)(object)__instance == (Object)(object)GameNetworkManager.Instance.localPlayerController)
			{
				InFactoryTrigger.isInFalseInterior = false;
				return;
			}
			int num = (int)__instance.playerClientId;
			if (num >= 0 && InFactoryTrigger.playersInFalseInterior.Contains(num))
			{
				InFactoryTrigger.playersInFalseInterior.Remove(num);
			}
		}
	}
	[HarmonyPatch]
	public class FootstepsPatch
	{
		public static bool swappedSurface;

		public static AudioClip[] sandClips;

		public static AudioClip sandHitClip;

		public static AudioClip[] gravelClips;

		public static AudioClip gravelHitClip;

		public static void LoadAssets()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected O, but got Unknown
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Expected O, but got Unknown
			AudioClip val = (AudioClip)Wither.ExtraAssets.LoadAsset("sand1");
			AudioClip val2 = (AudioClip)Wither.ExtraAssets.LoadAsset("sand2");
			AudioClip val3 = (AudioClip)Wither.ExtraAssets.LoadAsset("sand3");
			AudioClip val4 = (AudioClip)Wither.ExtraAssets.LoadAsset("sand4");
			sandHitClip = (AudioClip)Wither.ExtraAssets.LoadAsset("HitSand");
			sandClips = (AudioClip[])(object)new AudioClip[4] { val, val2, val3, val4 };
		}

		[HarmonyPatch(typeof(RoundManager), "SyncScrapValuesClientRpc")]
		[HarmonyPostfix]
		private static void OnSync(RoundManager __instance)
		{
			if (!ScenePatches.onWither || swappedSurface)
			{
				return;
			}
			for (int i = 0; i < StartOfRound.Instance.footstepSurfaces.Length; i++)
			{
				if (StartOfRound.Instance.footstepSurfaces[i].surfaceTag == "Gravel")
				{
					gravelClips = StartOfRound.Instance.footstepSurfaces[i].clips;
					gravelHitClip = StartOfRound.Instance.footstepSurfaces[i].hitSurfaceSFX;
					StartOfRound.Instance.footstepSurfaces[i].clips = sandClips;
					StartOfRound.Instance.footstepSurfaces[i].hitSurfaceSFX = sandHitClip;
					swappedSurface = true;
				}
			}
		}

		[HarmonyPatch(typeof(StartOfRound), "ShipLeave")]
		[HarmonyPrefix]
		private static void OnLeave(StartOfRound __instance)
		{
			if (!swappedSurface)
			{
				return;
			}
			for (int i = 0; i < StartOfRound.Instance.footstepSurfaces.Length; i++)
			{
				if (StartOfRound.Instance.footstepSurfaces[i].surfaceTag == "Gravel")
				{
					StartOfRound.Instance.footstepSurfaces[i].clips = gravelClips;
					StartOfRound.Instance.footstepSurfaces[i].hitSurfaceSFX = gravelHitClip;
					swappedSurface = false;
				}
			}
		}
	}
	public class GoodItemScanPatch
	{
		public static void DoPatching()
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Expected O, but got Unknown
			Harmony? harmony = Wither.Harmony;
			if (harmony != null)
			{
				harmony.Patch((MethodBase)AccessTools.Method(typeof(Scanner), "AssignNodeToUIElement", (Type[])null, (Type[])null), new HarmonyMethod(typeof(ScanElementPatch).GetMethod("AssignNodePatch")), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
			Harmony? harmony2 = Wither.Harmony;
			if (harmony2 != null)
			{
				harmony2.Patch((MethodBase)AccessTools.Method(typeof(StartOfRound), "Start", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(ScanElementPatch).GetMethod("OnStart")), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
		}
	}
	public class ScanElementPatch
	{
		public static bool scanDone;

		public static void OnStart(StartOfRound __instance)
		{
			scanDone = false;
		}

		public static void AssignNodePatch(Scanner __instance, ScanNodeProperties node)
		{
			if (!TerminalEntryPatches.unlocked && ScenePatches.onWither && node.headerText == "Withered lasher")
			{
				scanDone = true;
				LasherManager.Instance.LasherEnemyScanLocal();
			}
		}
	}
	[HarmonyPatch]
	public class GreenDogPatch
	{
		public static Material greenMat;

		public static bool checking = false;

		public static Vector3 spawnLocation = new Vector3(-120.4989f, 65.56802f, -44.3673f);

		public static void LoadAssets()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			greenMat = (Material)Wither.ExtraAssets.LoadAsset("MouthDogTexGreen");
		}

		[HarmonyPatch(typeof(EnemyAI), "Start")]
		[HarmonyPostfix]
		private static void OnDogSpawn(EnemyAI __instance)
		{
			//IL_0018: 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)
			if (!checking)
			{
				return;
			}
			MouthDogAI val = (MouthDogAI)(object)((__instance is MouthDogAI) ? __instance : null);
			if (val != null && Vector3.Distance(((Component)val).transform.position, spawnLocation) < 15f)
			{
				SkinnedMeshRenderer[] skinnedMeshRenderers = ((EnemyAI)val).skinnedMeshRenderers;
				foreach (SkinnedMeshRenderer val2 in skinnedMeshRenderers)
				{
					((Renderer)val2).material = greenMat;
				}
			}
		}
	}
	[HarmonyPatch]
	public class InteriorPowerPatches
	{
		[HarmonyPatch(typeof(RoundManager), "TurnOnAllLights")]
		[HarmonyPostfix]
		private static void OnPowerChange(RoundManager __instance, bool on)
		{
			if (ScenePatches.onWither)
			{
				if (on)
				{
					AnimatedLightsManager.Instance.PowerOn();
				}
				else
				{
					AnimatedLightsManager.Instance.PowerOff();
				}
			}
		}
	}
	[HarmonyPatch]
	public class LasherHitPatches
	{
		[HarmonyPatch(typeof(SprayPaintItem), "TrySprayingWeedKillerBottle")]
		[HarmonyPrefix]
		private static bool SprayLasherPatch(SprayPaintItem __instance)
		{
			//IL_0034: 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_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: 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_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			if (!ScenePatches.onWither)
			{
				return true;
			}
			PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
			List<RaycastHit> list = new List<RaycastHit>();
			Vector3 val = ((Component)localPlayerController.gameplayCamera).transform.position - ((Component)localPlayerController.gameplayCamera).transform.forward * 0.7f;
			RaycastHit[] source = Physics.SphereCastAll(val, 0.8f, ((Component)localPlayerController.gameplayCamera).transform.forward, 4.5f, 524288, (QueryTriggerInteraction)2);
			list = source.OrderBy((RaycastHit x) => ((RaycastHit)(ref x)).distance).ToList();
			for (int i = 0; i < list.Count; i++)
			{
				RaycastHit val2 = list[i];
				if (Object.op_Implicit((Object)(object)((Component)((RaycastHit)(ref val2)).collider).gameObject.GetComponent<LasherCollision>()))
				{
					val2 = list[i];
					((Component)((RaycastHit)(ref val2)).collider).gameObject.GetComponent<LasherCollision>().lasherScript.KillLasherLocal();
					return false;
				}
			}
			return true;
		}

		[HarmonyPatch(typeof(ShotgunItem), "ShootGun")]
		[HarmonyPostfix]
		private static void ShootLasherPatch(ShotgunItem __instance, Vector3 shotgunPosition, Vector3 shotgunForward)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			if (!ScenePatches.onWither || (Object)(object)__instance.heldByEnemy != (Object)null)
			{
				return;
			}
			RaycastHit[] array = (RaycastHit[])(object)new RaycastHit[10];
			Ray val = default(Ray);
			((Ray)(ref val))..ctor(shotgunPosition - shotgunForward * 10f, shotgunForward);
			int num = Physics.SphereCastNonAlloc(val, 5f, array, 15f, 524288, (QueryTriggerInteraction)2);
			RaycastHit val2 = default(RaycastHit);
			IHittable val3 = default(IHittable);
			for (int i = 0; i < num; i++)
			{
				if (Object.op_Implicit((Object)(object)((Component)((RaycastHit)(ref array[i])).transform).GetComponent<LasherCollision>()))
				{
					if (((RaycastHit)(ref array[i])).distance == 0f)
					{
						Wither.Logger.LogDebug((object)"Spherecast started inside lasher collider.");
					}
					else if (!Physics.Linecast(shotgunPosition, ((RaycastHit)(ref array[i])).point, ref val2, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1) && ((Component)((RaycastHit)(ref array[i])).transform).TryGetComponent<IHittable>(ref val3) && !val3.Hit(1, shotgunForward, ((GrabbableObject)__instance).playerHeldBy, true, -1))
					{
					}
				}
			}
		}
	}
	[HarmonyPatch]
	public class ModdedApparatusConfig
	{
		public static Dictionary<Item, (string, string)> apparatusDict = new Dictionary<Item, (string, string)>();

		public static Dictionary<Item, (ConfigEntry<string>, ConfigEntry<string>)> configDict = new Dictionary<Item, (ConfigEntry<string>, ConfigEntry<string>)>();

		[HarmonyPrefix]
		[HarmonyAfter(new string[] { "imabatby.lethallevelloader" })]
		[HarmonyPatch(typeof(StartOfRound), "Start")]
		private static void OnStart(StartOfRound __instance)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Invalid comparison between Unknown and I4
			if (Wither.evaisaPresent)
			{
				LethalLibApparatusCheck.AddApparatuses();
			}
			foreach (ExtendedItem extendedItem in PatchedContent.ExtendedItems)
			{
				if ((int)((ExtendedContent)extendedItem).ContentType != 0 && InsertApparatus.IsApparatus(extendedItem.Item.itemName))
				{
					apparatusDict.TryAdd(extendedItem.Item, (FilterSpecialCharacters(((ExtendedContent)extendedItem).ModName), FilterSpecialCharacters(extendedItem.Item.itemName)));
				}
			}
			ConfigLoader();
		}

		private static void ConfigLoader()
		{
			foreach (KeyValuePair<Item, (string, string)> item in apparatusDict)
			{
				string text = "0,0,0";
				string text2 = "0,0,0";
				Wither.Logger.LogDebug((object)("Found apparatus: " + item.Value.Item2));
				if (item.Value.Item2.ToLower().Contains("egyptapparatus"))
				{
					text = "-90,0,0";
					text2 = "0,-0.1,0";
				}
				if (!item.Value.Item2.ToLower().Contains("egyptlapparatus"))
				{
					if (item.Value.Item2.ToLower().Contains("dull apparatus") || item.Value.Item2.ToLower().Contains("mech apparatus"))
					{
						text2 = "0.07,0,0";
					}
					configDict.TryAdd(item.Key, (((BaseUnityPlugin)Wither.Instance).Config.Bind<string>("Rotation Offsets", item.Value.Item2 + " - " + item.Value.Item1, text, "If this apparatus is appearing incorrectly in the socket, adjust its rotation here (should be a comma-separated string of x,y,z rotation angles)."), ((BaseUnityPlugin)Wither.Instance).Config.Bind<string>("Position Offsets", item.Value.Item2 + " - " + item.Value.Item1, text2, "If this apparatus is appearing incorrectly in the socket, adjust its position here (should be a comma-separated string of x,y,z displacement).")));
				}
			}
		}

		public static string FilterSpecialCharacters(string input)
		{
			return input.Replace("\n", "").Replace("\t", "").Replace("\\", "")
				.Replace("\"", "")
				.Replace("'", "")
				.Replace("[", "")
				.Replace("]", "");
		}
	}
	[HarmonyPatch]
	public class SaveDataSyncPatches
	{
		public static GameObject saveSyncPrefab;

		public static DataSync saveSyncScript;

		[HarmonyPatch(typeof(GameNetworkManager), "Start")]
		[HarmonyPostfix]
		public static void InitializeAssets()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			saveSyncPrefab = (GameObject)Wither.ExtraAssets.LoadAsset("SaveDataSync");
			NetworkManager.Singleton.AddNetworkPrefab(saveSyncPrefab);
		}

		[HarmonyPatch(typeof(StartOfRound), "Start")]
		[HarmonyPostfix]
		private static void SpawnSyncScript(StartOfRound __instance)
		{
			//IL_004a: 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)
			Wither.Logger.LogDebug((object)$"Wither entry unlocked: {TerminalEntryPatches.unlocked}, Wither entry unread: {TerminalEntryPatches.unread}");
			if ((Object)(object)saveSyncScript == (Object)null && ((NetworkBehaviour)__instance).IsServer)
			{
				GameObject val = Object.Instantiate<GameObject>(saveSyncPrefab, Vector3.zero, Quaternion.identity);
				val.GetComponent<NetworkObject>().Spawn(false);
				saveSyncScript = val.GetComponent<DataSync>();
			}
		}

		[HarmonyPatch(typeof(StartOfRound), "OnClientConnect")]
		[HarmonyPostfix]
		private static void OnConnectionServer(StartOfRound __instance)
		{
			if (!((NetworkBehaviour)__instance).IsServer)
			{
				return;
			}
			Wither.Logger.LogDebug((object)$"Wither entry unlocked: {TerminalEntryPatches.unlocked}, Wither entry unread: {TerminalEntryPatches.unread}");
			if ((Object)(object)saveSyncScript == (Object)null)
			{
				if ((Object)(object)DataSync.Instance != (Object)null)
				{
					saveSyncScript = DataSync.Instance;
				}
				else
				{
					saveSyncScript = Object.FindObjectOfType<DataSync>();
				}
			}
			if ((Object)(object)saveSyncScript != (Object)null)
			{
				saveSyncScript.UpdateTerminalPatchClientRpc(TerminalEntryPatches.unlocked, TerminalEntryPatches.unread);
			}
			else
			{
				Wither.Logger.LogWarning((object)"Host unable to find save sync script and sync saved values to clients.");
			}
		}
	}
	[HarmonyPatch]
	public class ScenePatches
	{
		public static bool onWither;

		private static bool done;

		private static bool waitingForLoad;

		[HarmonyPatch(typeof(StartOfRound), "SceneManager_OnLoadComplete1")]
		[HarmonyPostfix]
		private static void OnLoad(StartOfRound __instance, string sceneName)
		{
			InFactoryTrigger.isInFalseInterior = false;
			if (InFactoryTrigger.playersInFalseInterior != null)
			{
				InFactoryTrigger.playersInFalseInterior.Clear();
			}
			if (sceneName == "WitherScene")
			{
				onWither = true;
				if (Wither.mrovWeatherPresent && MrovBlackoutCheck.CheckCurrentWeather() == "Blackout" && (Object)(object)AnimatedLightsManager.Instance != (Object)null)
				{
					AnimatedLightsManager.Instance.PowerOff(ignoreCheck: true);
					AnimatedLightsManager.Instance.EndAlarmSequence();
				}
			}
		}

		[HarmonyPatch(typeof(GiantKiwiAI), "SpawnBirdNest")]
		[HarmonyPrefix]
		private static bool OnKiwiSpawn(GiantKiwiAI __instance)
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: 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_00b1: 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)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: 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)
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: 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)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			if (!onWither)
			{
				return true;
			}
			GameObject[] array = (from x in GameObject.FindGameObjectsWithTag("OutsideAINode")
				orderby NestDistanceCheck(x.transform.position, ((Component)StartOfRound.Instance.shipLandingPosition).transform.position) descending
				select x).ToArray();
			Vector3 val = array[0].transform.position;
			Random random = new Random(StartOfRound.Instance.randomMapSeed + 288);
			int num = random.Next(0, array.Length / 3);
			bool flag = false;
			Vector3 val2 = Vector3.zero;
			for (int i = 0; i < array.Length; i++)
			{
				val = array[num].transform.position;
				val = RoundManager.Instance.GetRandomNavMeshPositionInBoxPredictable(val, 15f, default(NavMeshHit), random, RoundManager.Instance.GetLayermaskForEnemySizeLimit(((EnemyAI)__instance).enemyType), 1f);
				val = RoundManager.Instance.PositionWithDenialPointsChecked(val, array, ((EnemyAI)__instance).enemyType, ((EnemyAI)__instance).enemyType.nestDistanceFromShip);
				flag = __instance.CheckPathFromNodeToShip(array[num].transform);
				if (flag)
				{
					val2 = RoundManager.Instance.PositionEdgeCheck(val, ((EnemyAI)__instance).enemyType.nestSpawnPrefabWidth);
				}
				if (val2 == Vector3.zero || !flag)
				{
					num++;
					if (num > array.Length - 1)
					{
						val = RoundManager.Instance.GetRandomNavMeshPositionInBoxPredictable(array[0].transform.position, 15f, default(NavMeshHit), random, RoundManager.Instance.GetLayermaskForEnemySizeLimit(((EnemyAI)__instance).enemyType), 1f);
						break;
					}
					continue;
				}
				val = val2;
				break;
			}
			GameObject val3 = Object.Instantiate<GameObject>(__instance.birdNestPrefab, val, Quaternion.Euler(Vector3.zero), RoundManager.Instance.mapPropsContainer.transform);
			val3.transform.Rotate(Vector3.up, (float)random.Next(-180, 180), (Space)0);
			if (!Object.op_Implicit((Object)(object)val3.gameObject.GetComponentInChildren<NetworkObject>()))
			{
				Wither.Logger.LogError((object)("Error: No NetworkObject found in enemy nest spawn prefab that was just spawned on the host: '" + ((Object)val3).name + "'"));
			}
			else
			{
				val3.gameObject.GetComponentInChildren<NetworkObject>().Spawn(true);
			}
			__instance.birdNestAmbience = val3.GetComponent<AudioSource>();
			__instance.birdNest = val3;
			((Behaviour)((EnemyAI)__instance).agent).enabled = false;
			((Component)__instance).transform.position = __instance.birdNest.transform.position;
			((Component)__instance).transform.rotation = __instance.birdNest.transform.rotation;
			((Behaviour)((EnemyAI)__instance).agent).enabled = true;
			return false;
		}

		private static float NestDistanceCheck(Vector3 position, Vector3 shipPosition)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			if (position.z > 50f || (position.y > 40f && position.x > -155f) || (position.y < 40f && position.x < -75f))
			{
				return 0f;
			}
			return Vector3.Distance(position, shipPosition);
		}

		[HarmonyPatch(typeof(StartOfRound), "Update")]
		[HarmonyPostfix]
		[HarmonyAfter(new string[] { "voxx.LethalElementsPlugin" })]
		private static void OnLatestLoad(StartOfRound __instance)
		{
			if (onWither && waitingForLoad && !__instance.shipDoorsAnimator.GetBool("Closed"))
			{
				waitingForLoad = false;
				GameObject val = GameObject.Find("Terrain/TerrainMain/Terrain/GrassTerrain");
				GameObject val2 = GameObject.Find("Terrain/TerrainMain/Terrain/RockTerrain");
				GameObject val3 = GameObject.Find("Terrain/TerrainMain/Terrain/SandTerrain");
				((Renderer)val.GetComponent<MeshRenderer>()).enabled = false;
				((Renderer)val2.GetComponent<MeshRenderer>()).enabled = false;
				((Renderer)val3.GetComponent<MeshRenderer>()).enabled = false;
			}
		}

		[HarmonyPatch(typeof(StartOfRound), "SwitchMapMonitorPurpose")]
		[HarmonyPostfix]
		private static void InitialSetup(StartOfRound __instance, bool displayInfo)
		{
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Expected O, but got Unknown
			if (!onWither || __instance.inShipPhase || displayInfo || done)
			{
				return;
			}
			done = true;
			waitingForLoad = true;
			GameObject val = GameObject.Find("CatwalksMesa/IndustrialEntranceR/GarageDoor");
			if ((Object)(object)val != (Object)null)
			{
				Transform val2 = val.transform.Find("Door");
				if ((Object)(object)val2 != (Object)null)
				{
					((Component)val2).gameObject.SetActive(true);
				}
			}
			GrabbableObject[] array = (from x in Object.FindObjectsOfType<GrabbableObject>()
				where x is LungProp && (Object)(object)x.itemProperties != (Object)null && x.itemProperties.itemName == "Dying apparatus" && !x.isInShipRoom && !x.scrapPersistedThroughRounds
				select x).ToArray();
			if (array.Length != 0)
			{
				LungProp val3 = (LungProp)array.First();
				val3.isLungPowered = true;
				val3.isLungDocked = true;
				AudioSource componentInChildren = ((Component)val3).gameObject.GetComponentInChildren<AudioSource>();
				componentInChildren.loop = true;
				componentInChildren.Play();
			}
			if ((Object)(object)LasherManager.Instance != (Object)null)
			{
				LasherManager.Instance.InitialDeactivate();
			}
			if ((Object)(object)SpecialEventHandler.Instance != (Object)null && ((NetworkBehaviour)__instance).IsServer)
			{
				if (Wither.GarageStartOpen.Value)
				{
					SpecialEventHandler.Instance.garageLeverAnimTrigger.TriggerAnimation(GameNetworkManager.Instance.localPlayerController);
					SpecialEventHandler.Instance.garageDoorAnimTrigger.TriggerAnimation(GameNetworkManager.Instance.localPlayerController);
				}
				if (Wither.VanillaPlusMode.Value && (Object)(object)DataSync.Instance != (Object)null)
				{
					DisableEventObjects();
					DataSync.Instance.SetVanillaPlusModeClientRpc();
				}
			}
		}

		[HarmonyPatch(typeof(StartOfRound), "OnShipLandedMiscEvents")]
		[HarmonyPostfix]
		private static void OnLand(StartOfRound __instance)
		{
			if (!onWither)
			{
				return;
			}
			List<GameObject> list = new List<GameObject>();
			list.Add(GameObject.Find("Spotlight1/Spotlight_big_v4_Holder/Spotlight_big_v4_Spotlight/OutsideSpotlight1"));
			list.Add(GameObject.Find("Spotlight2/Spotlight_big_v4_Holder/Spotlight_big_v4_Spotlight/OutsideSpotlight1"));
			list.Add(GameObject.Find("Lights/WallLight2/Light"));
			list.Add(GameObject.Find("Lights/WallLight4/Light"));
			list.Add(GameObject.Find("Lights/PitBroadIllum"));
			list.Add(GameObject.Find("ExtraFanPitLights/BroadPitIllum"));
			list.Add(GameObject.Find("PitLightE/Point Light"));
			list.Add(GameObject.Find("PitLightS/Point Light"));
			list.Add(GameObject.Find("PitLightW/Point Light"));
			list.Add(GameObject.Find("Bar Lights/Neon Bars/Point Light (3)"));
			list.Add(GameObject.Find("Bar Lights/Neon Bars/Point Light (4)"));
			list.Add(GameObject.Find("Bar Lights/Neon Bars (1)/Point Light (3)"));
			list.Add(GameObject.Find("Bar Lights/Neon Bars (2)/Point Light (3)"));
			list.Add(GameObject.Find("Bar Lights/Neon Bars (2)/Point Light (4)"));
			list.Add(GameObject.Find("Bar Lights/Neon Bars (3)/Point Light (3)"));
			list.Add(GameObject.Find("Bar Lights/Neon Bars (3)/Point Light (4)"));
			list.Add(GameObject.Find("2short (3)/HangingLight (40)/Light (1)"));
			list.Add(GameObject.Find("IndustrialEntranceL/HangingLight/Light"));
			foreach (GameObject item in list)
			{
				if ((Object)(object)item != (Object)null)
				{
					AnimatedLightsManager.RestartLight(item);
				}
			}
		}

		[HarmonyPatch(typeof(StartOfRound), "ShipLeave")]
		[HarmonyPostfix]
		private static void OnLeave(StartOfRound __instance)
		{
			onWither = false;
			done = false;
		}

		public static void DisableEventObjects()
		{
			SpecialEventHandler.Instance.topFloorObjects.SetActive(false);
			SpecialEventHandler.Instance.interiorScrapDrop.SetActive(false);
			SpecialEventHandler.Instance.interiorBreakerBox.SetActive(false);
			SpecialEventHandler.Instance.exteriorBreakerBox.SetActive(false);
		}
	}
	[HarmonyPatch]
	public class TerminalEntryPatches
	{
		[ModData(/*Could not decode attribute arguments.*/)]
		public static bool unlocked = false;

		[ModData(/*Could not decode attribute arguments.*/)]
		public static bool unread = true;

		public static TerminalNode lasherFile;

		public static void LoadAssets()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			lasherFile = (TerminalNode)Wither.ExtraAssets.LoadAsset("LasherFile");
		}

		[HarmonyPatch(typeof(Terminal), "OnSubmit")]
		[HarmonyPrefix]
		private static bool TerminalSubmit(Terminal __instance)
		{
			if (!__instance.terminalInUse || ((Object)(object)__instance.currentNode != (Object)null && __instance.currentNode.acceptAnything))
			{
				return true;
			}
			if (unlocked)
			{
				string text = __instance.screenText.text.Substring(__instance.screenText.text.Length - __instance.textAdded);
				text = __instance.RemovePunctuation(text);
				string separator = text.Trim();
				string[] array = text.Split(separator);
				text = text.ToLower();
				if (text == "lasher" || text == "lashers" || (text.Length >= 8 && "withered lashers".Contains(text)))
				{
					__instance.screenText.ActivateInputField();
					((Selectable)__instance.screenText).Select();
					__instance.LoadNewNode(lasherFile);
					unread = false;
					return false;
				}
			}
			return true;
		}

		[HarmonyPatch(typeof(Terminal), "LoadNewNode")]
		[HarmonyPrefix]
		[HarmonyBefore(new string[] { "mrov.terminalformatter" })]
		private static void TerminalTextCheck(Terminal __instance, TerminalNode node, out bool __state)
		{
			if (unlocked && node.displayText.Contains("[currentScannedEnemiesList]"))
			{
				__state = true;
			}
			else
			{
				__state = false;
			}
		}

		[HarmonyPatch(typeof(Terminal), "LoadNewNode")]
		[HarmonyPostfix]
		[HarmonyPriority(0)]
		[HarmonyAfter(new string[] { "mrov.terminalformatter" })]
		private static void TerminalLogsTextOverride(Terminal __instance, bool __state)
		{
			if (!__state || !unlocked)
			{
				return;
			}
			string text = (unread ? " (NEW)" : "");
			Match match = Regex.Match(__instance.currentText, "(?<!^)(?<!^(?:\\s|[-|/]|\\\\n|\\\\)+)([\\s\\S]+)(?!(?:\\s|[-|/]|\\\\n|n)+$)(?!$)");
			if (match.Success)
			{
				int num = 0;
				int num2 = 0;
				char c = '\\';
				char c2 = 'n';
				if (!__instance.currentText.StartsWith("\n") && __instance.currentText.First() == c)
				{
					num = -1;
				}
				if (!__instance.currentText.EndsWith("\n") && __instance.currentText.Last() == c2)
				{
					num2 = 1;
				}
				string text2 = __instance.currentText.Substring(__instance.currentText.IndexOf(match.Value) - 1 + num, match.Value.Length + 2 - num + num2);
				string[] array = __instance.currentText.Split(text2);
				string text3 = (Wither.mrovTerminalPresent ? " " : "");
				text2 = text2 + "\n" + text3 + "Withered lashers" + text;
				if (text2.Contains("NO DATA COLLECTED") || text2.Contains("Scan creatures to unlock their data."))
				{
					text2 += "\n";
				}
				string text4 = array[0] + text2 + array[1];
				if (text4.Contains("No data collected on wildlife. Scans are required.") || text4.Contains("NO DATA COLLECTED") || text4.Contains("Scan creatures to unlock their data."))
				{
					List<string> list = text4.Split("\n").ToList();
					list.RemoveAll((string x) => x.Contains("No data collected on wildlife. Scans are required.") || x.Contains("NO DATA COLLECTED") || x.Contains("Scan creatures to unlock their data."));
					text4 = string.Join("\n", list);
				}
				__instance.currentText = text4;
				__instance.screenText.text = __instance.currentText;
			}
			else
			{
				Wither.Logger.LogError((object)"Failed to trim terminal text!");
			}
		}

		[HarmonyPatch(typeof(HUDManager), "AssignNewNodes")]
		[HarmonyPostfix]
		private static void DetectLasherScan(HUDManager __instance)
		{
			if (unlocked || !ScenePatches.onWither || Wither.testPresent)
			{
				return;
			}
			for (int i = 0; i < __instance.scanElements.Length; i++)
			{
				if (__instance.scanNodes.Count <= 0 || !__instance.scanNodes.TryGetValue(__instance.scanElements[i], out var value) || !((Object)(object)value != (Object)null))
				{
					continue;
				}
				try
				{
					if (__instance.NodeIsNotVisible(value, i) || ((Component)__instance.scanElements[i]).gameObject.activeSelf || !(value.headerText == "Withered lasher"))
					{
						continue;
					}
					LasherManager.Instance.LasherEnemyScanLocal();
					break;
				}
				catch (Exception arg)
				{
					Wither.Logger.LogError((object)$"Error in scan node patch: {arg}");
				}
			}
		}
	}
	[HarmonyPatch]
	public class TooltipPatch
	{
		private RaycastHit hit;

		private static bool flag;

		[HarmonyPatch(typeof(PlayerControllerB), "SetHoverTipAndCurrentInteractTrigger")]
		[HarmonyPrefix]
		private static void TooltipDetectApparatus(PlayerControllerB __instance)
		{
			//IL_004e: 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_0068: Unknown result type (might be due to invalid IL or missing references)
			if ((!InsertApparatus.isInserted && !InsertApparatus.doingInsertion) || __instance.isGrabbingObjectAnimation || __instance.inSpecialMenu || __instance.quickMenuManager.isMenuOpen)
			{
				return;
			}
			Ray val = default(Ray);
			((Ray)(ref val))..ctor(((Component)__instance.gameplayCamera).transform.position, ((Component)__instance.gameplayCamera).transform.forward);
			RaycastHit val2 = default(RaycastHit);
			if (!Physics.Raycast(val, ref val2, __instance.grabDistance, __instance.interactableObjectsMask) || ((Component)((RaycastHit)(ref val2)).collider).gameObject.layer == 8 || ((Component)((RaycastHit)(ref val2)).collider).gameObject.layer == 30)
			{
				return;
			}
			string tag = ((Component)((RaycastHit)(ref val2)).collider).tag;
			if (tag == "PhysicsProp")
			{
				GrabbableObject component = ((Component)((RaycastHit)(ref val2)).collider).gameObject.GetComponent<GrabbableObject>();
				if ((Object)(object)component != (Object)null && (Object)(object)component == (Object)(object)InsertApparatus.insertedApparatus)
				{
					flag = true;
				}
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "SetHoverTipAndCurrentInteractTrigger")]
		[HarmonyPostfix]
		[HarmonyAfter(new string[] { "me.loaforc.facilitymeltdown" })]
		private static void DisableTooltip(PlayerControllerB __instance)
		{
			if ((InsertApparatus.isInserted || InsertApparatus.doingInsertion) && flag)
			{
				flag = false;
				((Behaviour)__instance.cursorIcon).enabled = false;
				((TMP_Text)__instance.cursorTip).text = "";
			}
		}
	}
}
namespace Wither.Mechanics
{
	public class CatwalkTrigger : NetworkBehaviour
	{
		[CompilerGenerated]
		private sealed class <TriggerCooldown>d__11 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public CatwalkTrigger <>4__this;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <TriggerCooldown>d__11(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0032: Unknown result type (might be due to invalid IL or missing references)
				//IL_003c: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>4__this.onCooldown = true;
					<>2__current = (object)new WaitForSeconds(0.6f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<>4__this.onCooldown = false;
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		private int timesTriggered = 0;

		private int triggerThreshold;

		public AnimatedObjectTrigger animatedObjectTriggerShake;

		public AnimatedObjectTrigger animatedObjectTriggerFall;

		private bool initialSet = true;

		private bool bridgeFell;

		private bool onCooldown = false;

		private void Update()
		{
			if (initialSet)
			{
				if (((NetworkBehaviour)this).IsServer)
				{
					triggerThreshold = Random.Range(2, Wither.MaxCatwalkTriggers.Value + 1);
					Wither.Logger.LogDebug((object)$"Catwalk triggers: {triggerThreshold}");
					SetThresholdClientRpc(triggerThreshold);
				}
				initialSet = false;
			}
		}

		[ClientRpc]
		public void SetThresholdClientRpc(int threshold)
		{
			//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)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2189927576u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, threshold);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2189927576u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && !((NetworkBehaviour)this).IsServer)
				{
					triggerThreshold = threshold;
				}
			}
		}

		private void OnTriggerEnter(Collider other)
		{
			if (!bridgeFell)
			{
				PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
				if ((Object)(object)component != (Object)null && (Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)(object)component)
				{
					AddToBridgeInstabilityServerRpc();
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void AddToBridgeInstabilityServerRpc()
		{
			//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)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3568143984u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3568143984u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost) && !onCooldown)
			{
				timesTriggered++;
				if (timesTriggered < triggerThreshold)
				{
					animatedObjectTriggerShake.TriggerAnimation(GameNetworkManager.Instance.localPlayerController);
				}
				if (timesTriggered >= triggerThreshold)
				{
					bridgeFell = true;
					animatedObjectTriggerFall.TriggerAnimation(GameNetworkManager.Instance.localPlayerController);
				}
				((MonoBehaviour)this).StartCoroutine(TriggerCooldown());
			}
		}

		[IteratorStateMachine(typeof(<TriggerCooldown>d__11))]
		private IEnumerator TriggerCooldown()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <TriggerCooldown>d__11(0)
			{
				<>4__this = this
			};
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_CatwalkTrigger()
		{
			//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
			NetworkManager.__rpc_func_table.Add(2189927576u, new RpcReceiveHandler(__rpc_handler_2189927576));
			NetworkManager.__rpc_func_table.Add(3568143984u, new RpcReceiveHandler(__rpc_handler_3568143984));
		}

		private static void __rpc_handler_2189927576(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 thresholdClientRpc = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref thresholdClientRpc);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((CatwalkTrigger)(object)target).SetThresholdClientRpc(thresholdClientRpc);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3568143984(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((CatwalkTrigger)(object)target).AddToBridgeInstabilityServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "CatwalkTrigger";
		}
	}
	public class CustomElevatorController : NetworkBehaviour
	{
		public Animator elevatorAnimator;

		public Transform elevatorPoint;

		public float elevatorFinishTimer;

		public float callCooldown;

		public bool elevatorFinishedMoving;

		public bool elevatorIsAtBottom;

		public bool elevatorCalled;

		public bool elevatorMovingDown;

		private bool movingDownLastFrame = true;

		public bool calledDown;

		public AudioSource elevatorAudio;

		public AudioSource elevatorAudioTop;

		public AudioSource elevatorJingleMusic;

		public AudioClip elevatorStartUpSFX;

		public AudioClip elevatorStartDownSFX;

		public AudioClip elevatorTravelSFX;

		public AudioClip elevatorFinishUpSFX;

		public AudioClip elevatorFinishDownSFX;

		public AudioClip elevatorCrashSFX;

		public AudioClip elevatorSmashSFX;

		public AudioClip[] elevatorJingleClips;

		public AudioClip[] elevatorJingleClipsLong;

		public Transform elevatorTopPoint;

		public Transform elevatorBottomPoint;

		public Transform elevatorInsidePoint;

		public Collider crashDamageTrigger;

		public Vector3 previousElevatorPosition;

		public bool elevatorDoorOpen;

		private bool playMusic;

		private bool startedMusic;

		private float stopPlayingMusicTimer;

		private int selectedTrack = 0;

		public static bool permanentlyDisabled;

		public void Start()
		{
			permanentlyDisabled = false;
		}

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

		[ClientRpc]
		public void SetElevatorMusicClientRpc(bool setOn, int track)
		{
			//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)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(4066554235u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref setOn, default(ForPrimitives));
					BytePacker.WriteValueBitPacked(val2, track);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 4066554235u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && !((NetworkBehaviour)this).IsServer)
				{
					selectedTrack = track;
					playMusic = setOn;
				}
			}
		}

		public void LateUpdate()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			previousElevatorPosition = elevatorInsidePoint.position;
		}

		public void Update()
		{
			if (!playMusic)
			{
				if (stopPlayingMusicTimer <= 0f)
				{
					if (elevatorJingleMusic.isPlaying)
					{
						if (elevatorJingleMusic.pitch < 0.5f)
						{
							AudioSource obj = elevatorJingleMusic;
							obj.volume -= Time.deltaTime * 3f;
							if (elevatorJingleMusic.volume <= 0.01f)
							{
								elevatorJingleMusic.Stop();
							}
						}
						else
						{
							AudioSource obj2 = elevatorJingleMusic;
							obj2.pitch -= Time.deltaTime;
							elevatorJingleMusic.volume = Mathf.Max(elevatorJingleMusic.volume - Time.deltaTime * 2f, 0.4f);
						}
					}
				}
				else
				{
					stopPlayingMusicTimer -= Time.deltaTime;
				}
			}
			else
			{
				stopPlayingMusicTimer = 1.5f;
				if (!elevatorJingleMusic.isPlaying)
				{
					if (elevatorMovingDown)
					{
						elevatorJingleMusic.clip = elevatorJingleClips[selectedTrack];
						elevatorJingleMusic.Play();
						elevatorJingleMusic.volume = 1f;
					}
					else
					{
						elevatorJingleMusic.clip = elevatorJingleClipsLong[selectedTrack];
						elevatorJingleMusic.Play();
						elevatorJingleMusic.volume = 1f;
					}
				}
				AudioSource obj3 = elevatorJingleMusic;
				AudioSource obj4 = elevatorJingleMusic;
				float num2 = (obj4.pitch += Time.deltaTime * 2f);
				obj3.pitch = Mathf.Clamp(num2, 0.3f, 1f);
			}
			elevatorAnimator.SetBool("ElevatorGoingUp", !elevatorMovingDown);
			if (elevatorMovingDown != movingDownLastFrame)
			{
				movingDownLastFrame = elevatorMovingDown;
				if (elevatorMovingDown)
				{
					elevatorAudio.PlayOneShot(elevatorStartDownSFX);
				}
				else
				{
					elevatorAudio.PlayOneShot(elevatorStartUpSFX);
				}
				if (((NetworkBehaviour)this).IsServer)
				{
					SetElevatorMovingServerRpc(elevatorMovingDown);
				}
			}
			if (!((NetworkBehaviour)this).IsServer)
			{
				return;
			}
			if (elevatorFinishedMoving)
			{
				if (((NetworkBehaviour)this).IsServer && startedMusic)
				{
					playMusic = false;
					startedMusic = false;
					SetElevatorMusicServerRpc(setOn: false, selectedTrack);
				}
			}
			else if (((NetworkBehaviour)this).IsServer && !startedMusic)
			{
				startedMusic = true;
				playMusic = true;
				selectedTrack = Random.Range(0, elevatorJingleClips.Length);
				SetElevatorMusicServerRpc(setOn: true, selectedTrack);
			}
			if (elevatorFinishedMoving)
			{
				if (elevatorCalled)
				{
					if (callCooldown <= 0f)
					{
						SwitchElevatorDirection();
						SetElevatorCalledClientRpc(setCalled: false, elevatorMovingDown);
					}
					else
					{
						callCooldown -= Time.deltaTime;
					}
				}
			}
			else if (elevatorFinishTimer <= 0f)
			{
				elevatorFinishedMoving = true;
				PlayFinishAudio(!elevatorMovingDown);
				ElevatorFinishServerRpc(!elevatorMovingDown);
			}
			else
			{
				elevatorFinishTimer -= Time.deltaTime;
			}
		}

		private void SwitchElevatorDirection()
		{
			if (!permanentlyDisabled)
			{
				elevatorMovingDown = !elevatorMovingDown;
				elevatorFinishedMoving = false;
				elevatorFinishTimer = 14f;
				elevatorCalled = false;
				SetElevatorFinishedMovingClientRpc(finished: false);
			}
		}

		[ClientRpc]
		public void SetElevatorFinishedMovingClientRpc(bool finished)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(529070910u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref finished, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 529070910u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && !((NetworkBehaviour)this).IsServer)
				{
					elevatorFinishedMoving = finished;
				}
			}
		}

		public void AnimationEvent_ElevatorFinishTop()
		{
			if (!elevatorMovingDown && !elevatorFinishedMoving)
			{
				elevatorFinishedMoving = true;
				if (((NetworkBehaviour)this).IsServer)
				{
					PlayFinishAudio(!elevatorMovingDown);
					ElevatorFinishServerRpc(!elevatorMovingDown);
				}
			}
		}

		public void AnimationEvent_ElevatorStartFromBottom()
		{
			ShakePlayerCamera(shakeHard: false);
		}

		public void AnimationEvent_ElevatorHitBottom()
		{
			ShakePlayerCamera(shakeHard: true);
		}

		public void AnimationEvent_ElevatorTravel()
		{
			elevatorAudio.PlayOneShot(elevatorTravelSFX);
		}

		public void AnimationEvent_ElevatorFinishBottom()
		{
			if (elevatorMovingDown && !elevatorFinishedMoving)
			{
				elevatorFinishedMoving = true;
				if (((NetworkBehaviour)this).IsServer)
				{
					PlayFinishAudio(!elevatorMovingDown);
					ElevatorFinishServerRpc(!elevatorMovingDown);
				}
			}
		}

		private void ShakePlayerCamera(bool shakeHard)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			if (Vector3.Distance(((Component)StartOfRound.Instance.audioListener).transform.position, elevatorPoint.position) < 4f)
			{
				if (shakeHard)
				{
					HUDManager.Instance.ShakeCamera((ScreenShakeType)1);
				}
				else
				{
					HUDManager.Instance.ShakeCamera((ScreenShakeType)2);
				}
			}
		}

		[ServerRpc]
		public void ElevatorFinishServerRpc(bool atTop)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: 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_00c3: 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)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Invalid comparison between Unknown and I4
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_