Decompiled source of Wither v1.4.3

ScienceBird.Wither.dll

Decompiled 2 weeks 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 BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLevelLoader;
using LethalLib.Modules;
using LobbyCompatibility.Enums;
using LobbyCompatibility.Features;
using Microsoft.CodeAnalysis;
using ScienceBird.Wither.NetcodePatcher;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using WeatherRegistry;
using Wither.Inside;
using Wither.Mechanics;
using Wither.Patches;

[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("1.4.3.0")]
[assembly: AssemblyInformationalVersion("1.4.3+3e6b769898fa5b641ba4f66aafe4455308f3c61d")]
[assembly: AssemblyProduct("Wither")]
[assembly: AssemblyTitle("ScienceBird.Wither")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.4.3.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("1.4.3"), (CompatibilityLevel)2, (VersionStrictness)0);
		}
	}
	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.LogDebug((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";
		}
	}
	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)
			{
				if ((Object)(object)Instance != (Object)null)
				{
					GameObject gameObject = ((Component)Instance).gameObject;
					if (gameObject != null)
					{
						NetworkObject component = gameObject.GetComponent<NetworkObject>();
						if (component != null)
						{
							component.Despawn(true);
						}
					}
				}
				else
				{
					Wither.Logger.LogWarning((object)"Null instance! Network object despawn failed.");
				}
			}
			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.NetworkAssets.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", "1.4.3")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Wither : BaseUnityPlugin
	{
		public static AssetBundle NetworkAssets;

		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<bool> MysteriousScrap;

		public static ConfigEntry<int> MysteriousScrapRarity;

		public static ConfigEntry<int> MaxCatwalkTriggers;

		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_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			DyingApparatusOnly = ((BaseUnityPlugin)this).Config.Bind<bool>("Event", "Dying Apparatus Only", false, "Only allow the secret dying apparatus to be inserted.");
			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 aximum value an individual scrap will be worth (no other variance or modifiers will bring it above this value). Ex. at 300 the maximum for all items combined is 900", (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>()));
			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)");
			Patch();
			Logger.LogInfo((object)"ScienceBird.Wither v1.4.3 has loaded!");
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			NetworkAssets = AssetBundle.LoadFromFile(Path.Combine(directoryName, "withernetworkasset"));
			if (!((Object)(object)NetworkAssets == (Object)null))
			{
				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 = false;
			Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
			foreach (Assembly assembly in assemblies)
			{
				if (assembly.GetName().Name == "BMX.LobbyCompatibility")
				{
					Logger.LogDebug((object)"Found BMX!");
					flag = true;
					break;
				}
			}
			if (flag)
			{
				LobbyCompatibility.RegisterCompatibility();
			}
			Logger.LogDebug((object)"Patching...");
			Harmony.PatchAll();
			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 = "1.4.3";
	}
}
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_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02af: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Unknown result type (might be due to invalid IL or missing references)
			//IL_0285: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: 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_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_0422: Unknown result type (might be due to invalid IL or missing references)
			//IL_0427: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0340: Unknown result type (might be due to invalid IL or missing references)
			//IL_035b: Unknown result type (might be due to invalid IL or missing references)
			//IL_037b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0301: Unknown result type (might be due to invalid IL or missing references)
			//IL_0306: Unknown result type (might be due to invalid IL or missing references)
			//IL_0315: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_040b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0410: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)__instance == (Object)(object)InsertApparatus.insertedApparatus) || (!InsertApparatus.doingInsertion && !InsertApparatus.isInserted))
			{
				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.99f))
			{
				Vector3 val = ((Component)__instance).gameObject.transform.position - targetPosition;
				if (!(Mathf.Abs(((Vector3)(ref val)).magnitude) > 0.005f))
				{
					goto IL_0417;
				}
			}
			if (((Component)__instance).gameObject.transform.eulerAngles == rotLastFrame)
			{
				if (posSet && positionOffset != Vector3.zero)
				{
					posSet = false;
					targetPosition = ((Component)__instance).transform.position + positionOffset;
					Wither.Logger.LogDebug((object)$"Setting target position! {targetPosition}");
				}
				Wither.Logger.LogDebug((object)$"Fixing apparatus rotation! {((Component)__instance).gameObject.transform.eulerAngles}");
				((Component)__instance).transform.eulerAngles = targetRotation;
				Wither.Logger.LogDebug((object)$"Fixed apparatus rotation! {((Component)__instance).gameObject.transform.eulerAngles}");
				if (!posSet)
				{
					Wither.Logger.LogDebug((object)$"Fixing apparatus position! {((Component)__instance).gameObject.transform.position}");
					((Component)__instance).transform.position = targetPosition;
					Wither.Logger.LogDebug((object)$"Fixed apparatus position! {((Component)__instance).gameObject.transform.position}");
					__instance.targetFloorPosition = ((Component)__instance).transform.localPosition;
				}
			}
			goto IL_0417;
			IL_0417:
			rotLastFrame = ((Component)__instance).gameObject.transform.eulerAngles;
		}
	}
	[HarmonyPatch]
	public class FallPatch
	{
		[HarmonyPatch(typeof(GrabbableObject), "FallWithCurve")]
		[HarmonyPostfix]
		private static void AfterFall(GrabbableObject __instance)
		{
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: 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_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			if (StartOfRound.Instance.currentLevel.PlanetName != "115 Wither" || (Object)(object)__instance == (Object)null || (Object)(object)__instance.itemProperties == (Object)null)
			{
				return;
			}
			try
			{
				if ((!(((Object)__instance.itemProperties).name == "WitheredRobotToy") && !(((Object)__instance.itemProperties).name == "WitheredPhone") && !(((Object)__instance.itemProperties).name == "WitheredDentures")) || !(__instance.startFallingPosition.y - __instance.targetFloorPosition.y > 5f))
				{
					return;
				}
				float num = Mathf.Clamp(StartOfRound.Instance.objectFallToGroundCurveNoBounce.Evaluate(__instance.fallTime), 0f, 1f);
				if (num < 1f)
				{
					if (__instance.floorYRot == -1)
					{
						((Component)__instance).transform.rotation = Quaternion.Lerp(((Component)__instance).transform.rotation, Quaternion.Euler(__instance.itemProperties.restingRotation.x, ((Component)__instance).transform.eulerAngles.y, __instance.itemProperties.restingRotation.z), num * 0.3f);
					}
					else
					{
						((Component)__instance).transform.rotation = Quaternion.Lerp(((Component)__instance).transform.rotation, Quaternion.Euler(__instance.itemProperties.restingRotation.x, (float)(__instance.floorYRot + __instance.itemProperties.floorYOffset) + 90f, __instance.itemProperties.restingRotation.z), num * 0.3f);
					}
				}
				else
				{
					Wither.Logger.LogDebug((object)"Fall complete!");
					PropTP.propReady = true;
					__instance.fallTime = 1.02f;
				}
			}
			catch (Exception arg)
			{
				Wither.Logger.LogError((object)$"Exception on fallpatch: {arg}");
			}
		}
	}
	[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 AfterFall(StartOfRound __instance)
		{
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Invalid comparison between Unknown and I4
			foreach (ScrapItem scrapItem in Items.scrapItems)
			{
				if ((scrapItem.item.itemName.Contains("Apparatus") || scrapItem.item.itemName.Contains("apparatus")) && !scrapItem.item.itemName.Contains("concept"))
				{
					apparatusDict.TryAdd(scrapItem.item, (scrapItem.modName, scrapItem.item.itemName));
				}
			}
			foreach (ExtendedItem extendedItem in PatchedContent.ExtendedItems)
			{
				if ((int)((ExtendedContent)extendedItem).ContentType != 0 && (extendedItem.Item.itemName.Contains("Apparatus") || extendedItem.Item.itemName.Contains("apparatus")) && !extendedItem.Item.itemName.Contains("concept"))
				{
					apparatusDict.TryAdd(extendedItem.Item, (((ExtendedContent)extendedItem).ModName, 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 + " III " + 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 + " III " + 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).")));
				}
			}
		}
	}
	[HarmonyPatch]
	public class NightVisionPatches
	{
		[HarmonyPatch(typeof(PlayerControllerB), "SetNightVisionEnabled")]
		[HarmonyPostfix]
		private static void NightVisionUpdate(PlayerControllerB __instance)
		{
			if (InFactoryTrigger.isInFalseInterior)
			{
				((Behaviour)__instance.nightVision).enabled = false;
			}
		}

		[HarmonyPatch(typeof(EntranceTeleport), "TeleportPlayer")]
		[HarmonyPostfix]
		private static void EnterOrExitRealInterior(EntranceTeleport __instance)
		{
			InFactoryTrigger.isInFalseInterior = false;
		}
	}
	[HarmonyPatch]
	public class SeedWeightRandom
	{
		private static Random weightRandom;

		public static float[] randomWeightsTemp = new float[3];

		[HarmonyPatch(typeof(RoundManager), "FinishGeneratingNewLevelClientRpc")]
		[HarmonyPostfix]
		private static void SetWeights(RoundManager __instance)
		{
			if (!(__instance.currentLevel.PlanetName != "115 Wither"))
			{
				weightRandom = new Random(StartOfRound.Instance.randomMapSeed);
				for (int i = 0; i < 3; i++)
				{
					double num = weightRandom.NextDouble();
					float num2 = (float)(num * 2.0 + 0.5);
					randomWeightsTemp[i] = num2;
				}
				Wither.Logger.LogInfo((object)$"Random weights: {randomWeightsTemp[0]}, {randomWeightsTemp[1]}, {randomWeightsTemp[2]}");
			}
		}
	}
	[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
	{
		private int timesTriggered = 0;

		private int triggerThreshold;

		public AnimatedObjectTrigger animatedObjectTriggerShake;

		public AnimatedObjectTrigger animatedObjectTriggerFall;

		private bool initialSet = true;

		private bool bridgeFell;

		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))
			{
				timesTriggered++;
				if (timesTriggered < triggerThreshold)
				{
					animatedObjectTriggerShake.TriggerAnimation(GameNetworkManager.Instance.localPlayerController);
				}
				if (timesTriggered >= triggerThreshold)
				{
					bridgeFell = true;
					animatedObjectTriggerFall.TriggerAnimation(GameNetworkManager.Instance.localPlayerController);
				}
			}
		}

		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 bool elevatorFinishedMoving;

		public float elevatorFinishTimer;

		public bool elevatorIsAtBottom;

		public bool elevatorCalled;

		public bool elevatorMovingDown;

		private bool movingDownLastFrame = true;

		public bool calledDown;

		public float callCooldown;

		public AudioSource elevatorAudio;

		public AudioClip elevatorStartUpSFX;

		public AudioClip elevatorStartDownSFX;

		public AudioClip elevatorTravelSFX;

		public AudioClip elevatorFinishUpSFX;

		public AudioClip elevatorFinishDownSFX;

		public GameObject elevatorCalledBottomButton;

		public GameObject elevatorCalledTopButton;

		public Transform elevatorTopPoint;

		public Transform elevatorBottomPoint;

		public Transform elevatorInsidePoint;

		public Vector3 previousElevatorPosition;

		public bool elevatorDoorOpen;

		public AudioSource elevatorJingleMusic;

		private bool playMusic;

		private bool startedMusic;

		private float stopPlayingMusicTimer;

		public AudioClip[] elevatorHalloweenClips;

		public AudioClip[] elevatorHalloweenClipsLoop;

		private int selectedTrack = 0;

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

		private void OnEnable()
		{
			Wither.Logger.LogDebug((object)"Skipping elevator instance.");
		}

		private void OnDisable()
		{
			Wither.Logger.LogDebug((object)"Skipping elevator instance.");
		}

		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)
				{
					Wither.Logger.LogDebug((object)$"Elevator playing track {selectedTrack}");
					if (elevatorMovingDown)
					{
						elevatorJingleMusic.clip = elevatorHalloweenClips[selectedTrack];
						elevatorJingleMusic.Play();
						elevatorJingleMusic.volume = 1f;
					}
					else
					{
						elevatorJingleMusic.clip = elevatorHalloweenClipsLoop[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);
			elevatorCalledTopButton.SetActive(!elevatorMovingDown || elevatorCalled);
			elevatorCalledBottomButton.SetActive(elevatorMovingDown || elevatorCalled);
			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, elevatorHalloweenClips.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;
				Wither.Logger.LogDebug((object)"Elevator finished moving!");
				PlayFinishAudio(!elevatorMovingDown);
				ElevatorFinishServerRpc(!elevatorMovingDown);
			}
			else
			{
				elevatorFinishTimer -= Time.deltaTime;
			}
		}

		private void SwitchElevatorDirection()
		{
			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)
				{
					Wither.Logger.LogDebug((object)"Elevator finished moving B!");
					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_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(3790258295u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref atTop, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3790258295u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ElevatorFinishClientRpc(atTop);
			}
		}

		[ClientRpc]
		public void ElevatorFinishClientRpc(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_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(1937480629u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref atTop, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1937480629u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && !((NetworkBehaviour)this).IsServer)
				{
					PlayFinishAudio(atTop);
					elevatorFinishedMoving = true;
				}
			}
		}

		private void PlayFinishAudio(bool atTop)
		{
			if (atTop)
			{
				elevatorAudio.PlayOneShot(elevatorFinishUpSFX);
			}
			else
			{
				elevatorAudio.PlayOneShot(elevatorFinishDownSFX);
			}
		}

		[ServerRpc]
		public void SetElevatorMovingServerRpc(bool movingDown)
		{
			//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_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(4177772202u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref movingDown, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 4177772202u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				SetElevatorMovingClientRpc(movingDown);
			}
		}

		[ClientRpc]
		public void SetElevatorMovingClientRpc(bool movingDown)
		{
			//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(2992794047u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref movingDown, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2992794047u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && !((NetworkBehaviour)this).IsServer)
				{
					elevatorMovingDown = movingDown;
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void CallElevatorServerRpc(bool callDown)
		{
			//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 != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3708986968u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref callDown, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3708986968u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					CallElevatorOnServer(callDown);
				}
			}
		}

		public void CallElevatorOnServer(bool callDown)
		{
			if (elevatorMovingDown != callDown)
			{
				elevatorCalled = true;
				callCooldown = 4f;
				SetElevatorCalledClientRpc(elevatorCalled, elevatorMovingDown);
			}
		}

		public void SetElevatorDoorOpen()
		{
			elevatorDoorOpen = true;
		}

		public void SetElevatorDoorClosed()
		{
			elevatorDoorOpen = false;
		}

		[ClientRpc]
		public void SetElevatorCalledClientRpc(bool setCalled, bool elevatorDown)
		{
			//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(3225999829u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref setCalled, default(ForPrimitives));
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref elevatorDown, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3225999829u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && !((NetworkBehaviour)this).IsServer)
				{
					elevatorCalled = setCalled;
					elevatorMovingDown = elevatorDown;
				}
			}
		}

		public void CallElevator(bool callDown)
		{
			Wither.Logger.LogDebug((object)$"Call elevator 0; call down: {callDown}; elevator moving down: {elevatorMovingDown}");
			CallElevatorServerRpc(callDown);
		}

		[ServerRpc(RequireOwnership = false)]
		public void PressElevatorButtonServerRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2289072103u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2289072103u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					PressElevatorButtonOnServer();
				}
			}
		}

		public void PressElevatorButtonOnServer(bool requireFinishedMoving = false)
		{
			if (elevatorFinishedMoving || (elevatorFinishTimer < 0.16f && !requireFinishedMoving))
			{
				SwitchElevatorDirection();
			}
		}

		public void PressElevatorButton()
		{
			PressElevatorButtonServerRpc();
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_CustomElevatorController()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Expected O, but got Unknown
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Expected O, but got Unknown
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Expected O, but got Unknown
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(1040526011u, new RpcReceiveHandler(__rpc_handler_1040526011));
			NetworkManager.__rpc_func_table.Add(4066554235u, new RpcReceiveHandler(__rpc_handler_4066554235));
			NetworkManager.__rpc_func_table.Add(529070910u, new RpcReceiveHandler(__rpc_handler_529070910));
			NetworkManager.__rpc_func_table.Add(3790258295u, new RpcReceiveHandler(__rpc_handler_3790258295));
			NetworkManager.__rpc_func_table.Add(1937480629u, new RpcReceiveHandler(__rpc_handler_1937480629));
			NetworkManager.__rpc_func_table.Add(4177772202u, new RpcReceiveHandler(__rpc_handler_4177772202));
			NetworkManager.__rpc_func_table.Add(2992794047u, new RpcReceiveHandler(__rpc_handler_2992794047));
			NetworkManager.__rpc_func_table.Add(3708986968u, new RpcReceiveHandler(__rpc_handler_3708986968));
			NetworkManager.__rpc_func_table.Add(3225999829u, new RpcReceiveHandler(__rpc_handler_3225999829));
			NetworkManager.__rpc_func_table.Add(2289072103u, new RpcReceiveHandler(__rpc_handler_2289072103));
		}

		private static void __rpc_handler_1040526011(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: 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_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Invalid comparison between Unknown and I4
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId)
			{
				if ((int)networkManager.LogLevel <= 1)
				{
					Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
				}
			}
			else
			{
				bool setOn = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref setOn, default(ForPrimitives));
				int track = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref track);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((CustomElevatorController)(object)target).SetElevatorMusicServerRpc(setOn, track);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_4066554235(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool setOn = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref setOn, default(ForPrimitives));
				int track = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref track);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((CustomElevatorController)(object)target).SetElevatorMusicClientRpc(setOn, track);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_529070910(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool elevatorFinishedMovingClientRpc = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref elevatorFinishedMovingClientRpc, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((CustomElevatorController)(object)target).SetElevatorFinishedMovingClientRpc(elevatorFinishedMovingClientRpc);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

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

		private static void __rpc_handler_1937480629(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool atTop = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref atTop, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((CustomElevatorController)(object)target).ElevatorFinishClientRpc(atTop);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

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

		private static void __rpc_handler_2992794047(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool elevatorMovingClientRpc = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref elevatorMovingClientRpc, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((CustomElevatorController)(object)target).SetElevatorMovingClientRpc(elevatorMovingClientRpc);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3708986968(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool callDown = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref callDown, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((CustomElevatorController)(object)target).CallElevatorServerRpc(callDown);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3225999829(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 setCalled = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref setCalled, default(ForPrimitives));
				bool elevatorDown = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref elevatorDown, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((CustomElevatorController)(object)target).SetElevatorCalledClientRpc(setCalled, elevatorDown);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2289072103(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;
				((CustomElevatorController)(object)target).PressElevatorButtonServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "CustomElevatorController";
		}
	}
	public class InsertApparatus : NetworkBehaviour
	{
		public StartOfRound playersManager;

		public AnimatedObjectTrigger objectsEnableTrigger;

		public InteractTrigger insertTrigger;

		public AnimatedObjectTrigger animatedDoorTrigger;

		public static bool isInserted;

		public NetworkObject apparatusContainer;

		public static bool doingInsertion;

		private bool initialSet = true;

		private NetworkObject networkedApp;

		public static GrabbableObject? insertedApparatus;

		public static bool loafPresent;

		private void Update()
		{
			if (initialSet)
			{
				insertedApparatus = null;
				ApparatusRotationPatch.posSet = true;
				ApparatusRotationPatch.initialSet = true;
				playersManager = Object.FindObjectOfType<StartOfRound>();
				doingInsertion = false;
				isInserted = false;
				playersManager = Object.FindObjectOfType<StartOfRound>();
				loafPresent = false;
				Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
				foreach (Assembly assembly in assemblies)
				{
					if (assembly.GetName().Name == "FacilityMeltdown")
					{
						Wither.Logger.LogDebug((object)"Found loaf!");
						loafPresent = true;
						break;
					}
				}
				initialSet = false;
			}
			if (!isInserted)
			{
				if ((Object)(object)GameNetworkManager.Instance.localPlayerController.currentlyHeldObjectServer != (Object)null && (GameNetworkManager.Instance.localPlayerController.currentlyHeldObjectServer.itemProperties.itemName.Contains("Apparatus") || GameNetworkManager.Instance.localPlayerController.currentlyHeldObjectServer.itemProperties.itemName.Contains("apparatus")) && !GameNetworkManager.Instance.localPlayerController.currentlyHeldObjectServer.itemProperties.itemName.Contains("concept"))
				{
					if (StartOfRound.Instance.localPlayerUsingController)
					{
						insertTrigger.hoverTip = "Insert apparatus: [D-pad up]";
					}
					else
					{
						insertTrigger.hoverTip = "Insert apparatus: [ E ]";
					}
				}
				else
				{
					insertTrigger.hoverTip = "Nothing to insert";
				}
			}
			else
			{
				if (!((Object)(object)insertedApparatus == (Object)null))
				{
					return;
				}
				GameObject val = GameObject.Find("WitherLungPosition");
				if ((Object)(object)val != (Object)null)
				{
					GrabbableObject componentInChildren = val.GetComponentInChildren<GrabbableObject>();
					if ((Object)(object)componentInChildren != (Object)null)
					{
						insertedApparatus = componentInChildren;
					}
				}
			}
		}

		public void InsertItem()
		{
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
			if (!((Object)(object)localPlayerController.currentlyHeldObjectServer != (Object)null) || (((!localPlayerController.currentlyHeldObjectServer.itemProperties.itemName.Contains("Apparatus") && !localPlayerController.currentlyHeldObjectServer.itemProperties.itemName.Contains("apparatus")) || localPlayerController.currentlyHeldObjectServer.itemProperties.itemName.Contains("concept") || Wither.DyingApparatusOnly.Value) && !(localPlayerController.currentlyHeldObjectServer.itemProperties.itemName == "Dying apparatus")) || localPlayerController.isGrabbingObjectAnimation)
			{
				return;
			}
			if ((Object)(object)localPlayerController.currentlyHeldObjectServer.radarIcon != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)localPlayerController.currentlyHeldObjectServer.radarIcon).gameObject);
			}
			if ((Object)(object)((Component)localPlayerController.currentlyHeldObjectServer).gameObject.GetComponentInChildren<ScanNodeProperties>() != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)((Component)localPlayerController.currentlyHeldObjectServer).gameObject.GetComponentInChildren<ScanNodeProperties>()).gameObject);
			}
			AudioSource[] componentsInChildren = ((Component)localPlayerController.currentlyHeldObjectServer).GetComponentsInChildren<AudioSource>();
			if (componentsInChildren != null)
			{
				AudioSource[] array = componentsInChildren;
				foreach (AudioSource val in array)
				{
					val.Stop();
				}
			}
			DestroyChildObjectsServerRpc((int)localPlayerController.playerClientId);
			ParentObjectToSlotServerRpc(NetworkObjectReference.op_Implicit(((Component)localPlayerController.currentlyHeldObjectServer).gameObject.GetComponent<NetworkObject>()));
			localPlayerController.DiscardHeldObject(true, apparatusContainer, new Vector3(0f, 0f, 0f), false);
			AudioSource component = ((Component)apparatusContainer).GetComponent<AudioSource>();
			if ((Object)(object)component != (Object)null)
			{
				component.Play();
			}
			else
			{
				Wither.Logger.LogError((object)"Null audio player!");
			}
			objectsEnableTrigger.TriggerAnimation(GameNetworkManager.Instance.localPlayerController);
			animatedDoorTrigger.TriggerAnimation(GameNetworkManager.Instance.localPlayerController);
		}

		[ServerRpc(RequireOwnership = false)]
		public void DestroyChildObjectsServerRpc(int playerObj)
		{
			//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 != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3246329587u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, playerObj);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3246329587u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					DestroyChildObjectsClientRpc(playerObj);
				}
			}
		}

		[ClientRpc]
		public void DestroyChildObjectsClientRpc(int playerObj)
		{
			//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)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(4108723283u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, playerObj);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 4108723283u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			doingInsertion = true;
			if ((Object)(object)playersManager.allPlayerScripts[playerObj] == (Object)(object)GameNetworkManager.Instance.localPlayerController)
			{
				return;
			}
			if ((Object)(object)playersManager.allPlayerScripts[playerObj].currentlyHeldObjectServer.radarIcon != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)playersManager.allPlayerScripts[playerObj].currentlyHeldObjectServer.radarIcon).gameObject);
			}
			if ((Object)(object)((Component)((Component)playersManager.allPlayerScripts[playerObj].currentlyHeldObjectServer).gameObject.GetComponentInChildren<ScanNodeProperties>()).gameObject != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)((Component)playersManager.allPlayerScripts[playerObj].currentlyHeldObjectServer).gameObject.GetComponentInChildren<ScanNodeProperties>()).gameObject);
			}
			AudioSource[] componentsInChildren = ((Component)playersManager.allPlayerScripts[playerObj].currentlyHeldObjectServer).GetComponentsInChildren<AudioSource>();
			if (componentsInChildren != null)
			{
				AudioSource[] array = componentsInChildren;
				foreach (AudioSource val3 in array)
				{
					val3.Stop();
				}
			}
			AudioSource component = ((Component)apparatusContainer).GetComponent<AudioSource>();
			if ((Object)(object)component != (Object)null)
			{
				component.Play();
			}
			else
			{
				Wither.Logger.LogError((object)"Null audio player!");
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void ParentObjectToSlotServerRpc(NetworkObjectReference grabbableObjectNetObject)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: 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(3403964814u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref grabbableObjectNetObject, default(ForNetworkSerializable));
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3403964814u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				if (((NetworkObjectReference)(ref grabbableObjectNetObject)).TryGet(ref networkedApp, (NetworkManager)null))
				{
					ParentObjectToSlotClientRpc(grabbableObjectNetObject);
				}
				else
				{
					Wither.Logger.LogError((object)"ServerRpc: Could not find networked apparatus.");
				}
			}
		}

		[ClientRpc]
		public void ParentObjectToSlotClientRpc(NetworkObjectReference grabbableObjectNetObject)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1637632712u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref grabbableObjectNetObject, default(ForNetworkSerializable));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1637632712u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (((NetworkObjectReference)(ref grabbableObjectNetObject)).TryGet(ref networkedApp, (NetworkManager)null))
				{
					isInserted = true;
					((Component)networkedApp).gameObject.GetComponentInChildren<GrabbableObject>().EnablePhysics(false);
					((Component)networkedApp).gameObject.GetComponentInChildren<GrabbableObject>().grabbable = false;
					Wither.Logger.LogDebug((object)$"Setting apparatus value to {((Component)networkedApp).gameObject.GetComponentInChildren<GrabbableObject>().scrapValue}");
					PropTP.apparatusValue = ((Component)networkedApp).gameObject.GetComponentInChildren<GrabbableObject>().scrapValue;
				}
				else
				{
					Wither.Logger.LogError((object)"ClientRpc: Could not find networked apparatus.");
				}
			}
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_InsertApparatus()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(3246329587u, new RpcReceiveHandler(__rpc_handler_3246329587));
			NetworkManager.__rpc_func_table.Add(4108723283u, new RpcReceiveHandler(__rpc_handler_4108723283));
			NetworkManager.__rpc_func_table.Add(3403964814u, new RpcReceiveHandler(__rpc_handler_3403964814));
			NetworkManager.__rpc_func_table.Add(1637632712u, new RpcReceiveHandler(__rpc_handler_1637632712));
		}

		private static void __rpc_handler_3246329587(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 playerObj = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerObj);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((InsertApparatus)(object)target).DestroyChildObjectsServerRpc(playerObj);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_4108723283(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 playerObj = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerObj);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((InsertApparatus)(object)target).DestroyChildObjectsClientRpc(playerObj);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3403964814(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkObjectReference grabbableObjectNetObject = default(NetworkObjectReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref grabbableObjectNetObject, default(ForNetworkSerializable));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((InsertApparatus)(object)target).ParentObjectToSlotServerRpc(grabbableObjectNetObject);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1637632712(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkObjectReference grabbableObjectNetObject = default(NetworkObjectReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref grabbableObjectNetObject, default(ForNetworkSerializable));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((InsertApparatus)(object)target).ParentObjectToSlotClientRpc(grabbableObjectNetObject);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "InsertApparatus";
		}
	}
	public class PropTP : NetworkBehaviour
	{
		public GameObject[] scrapProps;

		public Vector3 telePosition;

		public ScanNodeProperties[] scanNodes;

		private int scrapIndex = -1;

		public static bool doingTP;

		public AudioSource clangPlayer;

		private Vector3 posDiff;

		private Vector3 posDiff1;

		private Vector3 posDiff2;

		private int scrapValue = 0;

		private bool foundPrefabs = false;

		private int failCount = 0;

		private string[] scrapNames = new string[3] { "WitheredRobotToy(Clone)", "WitheredOldPhone(Clone)", "WitheredDentures(Clone)" };

		private float[] randomWeights = new float[3];

		private bool initialSet = true;

		public static bool propReady;

		private int propCycleFailsafe = 0;

		private int minVal;

		private int maxVal;

		public static int apparatusValue;

		private void Update()
		{
			//IL_0316: Unknown result type (might be due to invalid IL or missing references)
			//IL_032a: 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_0334: Unknown result type (might be due to invalid IL or missing references)
			//IL_033b: Unknown result type (might be due to invalid IL or missing references)
			//IL_034d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0352: Unknown result type (might be due to invalid IL or missing references)
			//IL_0357: Unknown result type (might be due to invalid IL or missing references)
			//IL_036a: Unknown result type (might be due to invalid IL or missing references)
			//IL_037c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0381: Unknown result type (might be due to invalid IL or missing references)
			//IL_0386: Unknown result type (might be due to invalid IL or missing references)
			//IL_0399: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b5: Unknown result type (might be due to invalid IL or missing references)
			if (initialSet)
			{
				apparatusValue = 0;
				if (Wither.MinValue.Value > Wither.MaxValue.Value)
				{
					minVal = 50;
					maxVal = 300;
				}
				else
				{
					minVal = Wither.MinValue.Value;
					maxVal = Wither.MaxValue.Value;
				}
				if (SeedWeightRandom.randomWeightsTemp[0] > 0f)
				{
					propReady = false;
					randomWeights = SeedWeightRandom.randomWeightsTemp;
					initialSet = false;
					SeedWeightRandom.randomWeightsTemp = new float[3];
				}
			}
			if (!foundPrefabs)
			{
				int i;
				for (i = 0; i < 3; i++)
				{
					if (Object.op_Implicit((Object)(object)GameObject.Find(scrapNames[i])))
					{
						GameObject[] array = (from obj in Resources.FindObjectsOfTypeAll<GameObject>()
							where ((Object)obj).name == scrapNames[i]
							select obj).ToArray();
						if (array.Length > 1)
						{
							GameObject[] array2 = array;
							foreach (GameObject val in array2)
							{
								if (!val.GetComponent<GrabbableObject>().isInShipRoom && !val.GetComponent<GrabbableObject>().scrapPersistedThroughRounds)
								{
									scrapProps[i] = val;
									break;
								}
							}
						}
						else
						{
							scrapProps[i] = GameObject.Find(scrapNames[i]);
						}
						if (i == 0)
						{
							Wither.Logger.LogDebug((object)"Found prefabs!");
							foundPrefabs = true;
						}
					}
					else
					{
						foundPrefabs = false;
					}
				}
				GameObject val2 = GameObject.Find("DyingLungApparatus(Clone)");
				GameObject[] array3 = (from obj in Resources.FindObjectsOfTypeAll<GameObject>()
					where ((Object)obj).name == "DyingLungApparatus(Clone)"
					select obj).ToArray();
				if