Decompiled source of LC Office v2.2.1

LCOffice.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using DunGen;
using DunGenPlus;
using GameNetcodeStuff;
using HarmonyLib;
using JLL;
using JLL.Components;
using JLL.ScriptableObjects;
using LCOffice.Components;
using LCOffice.NetcodePatcher;
using LCOffice.Patches;
using LethalLevelLoader;
using Microsoft.CodeAnalysis;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Serialization;
using UnityEngine.UI;

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace LCOffice
{
	[BepInPlugin("Piggy.LCOffice", "LCOffice", "2.2.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public enum PathCount
		{
			One = 1,
			Two,
			Three
		}

		public enum ScalePreset
		{
			Normal = 1,
			Large
		}

		private const string modGUID = "Piggy.LCOffice";

		private const string modName = "LCOffice";

		private const string modVersion = "2.2.1";

		private readonly Harmony harmony = new Harmony("Piggy.LCOffice");

		private static Plugin Instance;

		public static ManualLogSource mls;

		public static AssetBundle Bundle;

		public static ExtendedMod officeMod;

		public static ExtendedDungeonFlow officeDungeon;

		public static DunGenExtender officeExtender;

		private ConfigEntry<bool> configEnableScraps;

		public static ConfigEntry<PathCount> mainPaths;

		public static ConfigEntry<ScalePreset> generationScale;

		public static ConfigEntry<float> musicVolume;

		public static ConfigEntry<bool> elevatorMusicPitchdown;

		public static ConfigEntry<bool> cameraDisable;

		public static ConfigEntry<bool> controlRoomCameraDisable;

		public static ConfigEntry<int> cameraFrameSpeed;

		public static TerminalKeyword elevatorKeyword;

		public static TerminalKeyword elevator1Keyword;

		public static TerminalKeyword elevator2Keyword;

		public static TerminalKeyword elevator3Keyword;

		public static TerminalNode elevator1Node;

		public static TerminalNode elevator2Node;

		public static TerminalNode elevator3Node;

		public static GameObject ActualElevator;

		public static GameObject StoragePrefab;

		private void Awake()
		{
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Expected O, but got Unknown
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_026b: Expected O, but got Unknown
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_0281: Expected O, but got Unknown
			//IL_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Expected O, but got Unknown
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02af: Expected O, but got Unknown
			//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e0: Expected O, but got Unknown
			//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f6: Expected O, but got Unknown
			//IL_0304: Unknown result type (might be due to invalid IL or missing references)
			//IL_030e: Expected O, but got Unknown
			//IL_031a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0324: Expected O, but got Unknown
			//IL_0492: Unknown result type (might be due to invalid IL or missing references)
			//IL_0497: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04be: Expected O, but got Unknown
			//IL_04c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ec: Expected O, but got Unknown
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("Piggy.LCOffice");
			mls.LogInfo((object)"LC_Office is loaded!");
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			Bundle = AssetBundle.LoadFromFile(Path.Combine(directoryName, "lcoffice"));
			if ((Object)(object)Bundle == (Object)null)
			{
				mls.LogError((object)"Failed to load Office Dungeon assets.");
				return;
			}
			configEnableScraps = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "OfficeCustomScrap", true, new ConfigDescription("When enabled, enables custom scrap spawning.", (AcceptableValueBase)null, Array.Empty<object>()));
			mainPaths = ((BaseUnityPlugin)this).Config.Bind<PathCount>("General", "MainDungeonPaths", PathCount.Two, "The number of main paths the interior generates. (Main paths will be longer than other paths. Increasing this number increases the size of the dungeon but makes the distribution between elevator floors larger) (When set to \"One\" switches size and branch count numbers back similar to the 2.0.0 version.)");
			generationScale = ((BaseUnityPlugin)this).Config.Bind<ScalePreset>("General", "GenerationScale", ScalePreset.Normal, "A lot of people were telling me they don't like the overly large interior even though I personally prefer it. Because of this I've introduced this config where the default is now a much smaller generation but you can choose to play with the large scale if you prefer a challenge. The smaller default preset will lead more often to floors generating without any branch paths and dead ends.");
			musicVolume = ((BaseUnityPlugin)this).Config.Bind<float>("General", "ElevatorMusicVolume", 100f, "Set the volume of music played in the elevator. (0 - 100) (Client Sided)");
			elevatorMusicPitchdown = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ElevatorMusicPitchDown", false, "Change the pitch of the elevator music. (bc i like it) (Client Sided)");
			cameraDisable = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Disable Camera", false, "Disable cameras inside the office. (Client Sided)");
			controlRoomCameraDisable = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Disable Control Room Camera", false, "Disable camera inside the apparatus room. (Client Sided)");
			cameraFrameSpeed = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Camera Frame Speed", 10, "Specifies the camera speed inside the office. When set to a negative value uses the game's frame rate. (FPS) (Client Sided)");
			officeMod = ExtendedMod.Create("LC Office", "Piggy");
			officeDungeon = Bundle.LoadAsset<ExtendedDungeonFlow>("Assets/LethalCompany/Mods/LCOffice/ExtendedOfficeFlow.asset");
			officeDungeon.DungeonEvents.onApparatusTaken.AddListener((ParameterEvent<LungProp>)delegate
			{
				ElevatorSystem.System?.OnRemoveApparatus();
				Object.FindObjectOfType<WeirdScreen>()?.DisableScreen();
			});
			officeDungeon.DungeonEvents.onShipLeave.AddListener((Action)delegate
			{
				if (((NetworkBehaviour)RoundManager.Instance).IsHost || ((NetworkBehaviour)RoundManager.Instance).IsServer)
				{
					ElevatorSystem.Despawn();
				}
			});
			int value = (int)mainPaths.Value;
			int num = value;
			int num2 = num;
			if (num2 == 1)
			{
				ScalePreset value2 = generationScale.Value;
				ScalePreset scalePreset = value2;
				if (scalePreset == ScalePreset.Large)
				{
					officeDungeon.DungeonFlow.Length = new IntRange(8, 10);
					officeDungeon.DungeonFlow.BranchCount = new IntRange(4, 7);
				}
				else
				{
					officeDungeon.DungeonFlow.Length = new IntRange(5, 8);
					officeDungeon.DungeonFlow.BranchCount = new IntRange(3, 6);
				}
			}
			else
			{
				ScalePreset value3 = generationScale.Value;
				ScalePreset scalePreset2 = value3;
				if (scalePreset2 == ScalePreset.Large)
				{
					officeDungeon.DungeonFlow.Length = new IntRange(5, 6);
					officeDungeon.DungeonFlow.BranchCount = new IntRange(2, 3);
				}
				else
				{
					officeDungeon.DungeonFlow.Length = new IntRange(2, 3);
					officeDungeon.DungeonFlow.BranchCount = new IntRange(1, 3);
				}
			}
			officeMod.ExtendedDungeonFlows.Add(officeDungeon);
			officeExtender = Bundle.LoadAsset<DunGenExtender>("Assets/LethalCompany/Mods/LCOffice/OfficeExtender.asset");
			officeExtender.Properties.MainPathProperties.MainPathCount = value;
			officeExtender.DungeonFlow = officeDungeon.DungeonFlow;
			API.AddDunGenExtender(officeDungeon.DungeonFlow, officeExtender);
			mls.LogInfo((object)$"Office registered with Length: (min: {officeDungeon.DungeonFlow.Length.Min}, max: {officeDungeon.DungeonFlow.Length.Max}) BranchCount: (min: {officeDungeon.DungeonFlow.BranchCount.Min}, max: {officeDungeon.DungeonFlow.BranchCount.Max})");
			if (configEnableScraps.Value)
			{
				officeMod.ExtendedItems.AddRange(Bundle.LoadAllAssets<ExtendedItem>());
			}
			else
			{
				officeMod.ExtendedItems.Add(Bundle.LoadAsset<ExtendedItem>("Assets/LethalCompany/Mods/LCOffice/Items/UpturnedApparatus.asset"));
			}
			PatchedContent.RegisterExtendedMod(officeMod);
			JNetworkPrefabSet val = ScriptableObject.CreateInstance<JNetworkPrefabSet>();
			val.SetName = "LCOffice";
			val.AddPrefabs((JIdentifiablePrefab[])(object)new JIdentifiablePrefab[2]
			{
				new JIdentifiablePrefab
				{
					name = "Elevator",
					prefab = (ActualElevator = Bundle.LoadAsset<GameObject>("Assets/LethalCompany/Mods/LCOffice/Prefab/ActualElevator.prefab"))
				},
				new JIdentifiablePrefab
				{
					name = "StorageShelf",
					prefab = (StoragePrefab = Bundle.LoadAsset<GameObject>("Assets/LethalCompany/Mods/LCOffice/Prefab/ElevatorStorage.prefab"))
				}
			});
			JNetworkPrefabSet.NetworkPrefabSets.Add(val);
			elevator1Node = Bundle.LoadAsset<TerminalNode>("Assets/LethalCompany/Mods/LCOffice/Terminal/Elevator1Node.asset");
			elevator2Node = Bundle.LoadAsset<TerminalNode>("Assets/LethalCompany/Mods/LCOffice/Terminal/Elevator2Node.asset");
			elevator3Node = Bundle.LoadAsset<TerminalNode>("Assets/LethalCompany/Mods/LCOffice/Terminal/Elevator3Node.asset");
			elevatorKeyword = Bundle.LoadAsset<TerminalKeyword>("Assets/LethalCompany/Mods/LCOffice/Terminal/ElevatorKeyword.asset");
			elevator1Keyword = Bundle.LoadAsset<TerminalKeyword>("Assets/LethalCompany/Mods/LCOffice/Terminal/Elevator1f.asset");
			elevator2Keyword = Bundle.LoadAsset<TerminalKeyword>("Assets/LethalCompany/Mods/LCOffice/Terminal/Elevator2f.asset");
			elevator3Keyword = Bundle.LoadAsset<TerminalKeyword>("Assets/LethalCompany/Mods/LCOffice/Terminal/Elevator3f.asset");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"[LC_Office] Successfully loaded assets!");
			JLL.HarmonyPatch(harmony, mls, new Type[3]
			{
				typeof(TerminalPatch),
				typeof(LungPropPatch),
				typeof(MenuManagerPatch)
			});
			JLL.NetcodePatch(mls, Assembly.GetExecutingAssembly().GetTypes());
		}
	}
}
namespace LCOffice.Patches
{
	[HarmonyPatch(typeof(LungProp))]
	public class LungPropPatch
	{
		[HarmonyPatch("EquipItem")]
		[HarmonyPrefix]
		public static void patchEquipItem(LungProp __instance)
		{
			if ((Object)(object)ElevatorSystem.System != (Object)null && (Object)(object)ElevatorSystem.System.inserted == (Object)(object)__instance)
			{
				ElevatorSystem.System.PullLungServerRpc();
			}
		}
	}
	[HarmonyPatch(typeof(MenuManager))]
	internal class MenuManagerPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPrefix]
		public static void patchStart()
		{
			ElevatorSystem.Despawn();
		}
	}
	[HarmonyPatch(typeof(Terminal))]
	internal class TerminalPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch("Start")]
		private static void Start_Prefix(ref TerminalNodesList ___terminalNodes)
		{
			___terminalNodes.specialNodes.Add(Plugin.elevator1Node);
			___terminalNodes.specialNodes.Add(Plugin.elevator2Node);
			___terminalNodes.specialNodes.Add(Plugin.elevator3Node);
			AddKeyword(___terminalNodes, Plugin.elevatorKeyword);
			AddKeyword(___terminalNodes, Plugin.elevator1Keyword);
			AddKeyword(___terminalNodes, Plugin.elevator2Keyword);
			AddKeyword(___terminalNodes, Plugin.elevator3Keyword);
			TerminalKeyword[] allKeywords = ___terminalNodes.allKeywords;
			foreach (TerminalKeyword val in allKeywords)
			{
				if (val.word == "other")
				{
					val.specialKeywordResult.displayText = val.specialKeywordResult.displayText.TrimEnd() + "\n\n>ELEVATOR [1f, 2f, 3f]\r\nTo move an elevator to a specific floor\r\n\r\n\r\n";
				}
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch("RunTerminalEvents")]
		private static void RunTerminalEvents_Prefix(TerminalNode node)
		{
			if ((Object)(object)ElevatorSystem.System != (Object)null && (Object)(object)node != (Object)null && !Utility.IsNullOrWhiteSpace(node.terminalEvent) && node.terminalEvent.Length == 3 && node.terminalEvent.StartsWith("el") && int.TryParse(node.terminalEvent[2].ToString(), out var result))
			{
				ElevatorSystem.System.ElevatorTriggerServerRpc(result - 1);
			}
		}

		private static void AddKeyword(TerminalNodesList terminalNodes, TerminalKeyword keyword)
		{
			Array.Resize(ref terminalNodes.allKeywords, terminalNodes.allKeywords.Length + 1);
			terminalNodes.allKeywords[terminalNodes.allKeywords.Length - 1] = keyword;
		}
	}
}
namespace LCOffice.Components
{
	public class CameraCulling : MonoBehaviour
	{
		private Transform player;

		private GameObject[] playerObjects;

		public Camera camera;

		public Transform cullPos;

		public float followDistance = -1f;

		public float renderDistance = 10f;

		private float fps = 15f;

		private bool disabled;

		private float elapsed;

		public bool inControlRoom = false;

		private void Start()
		{
			player = ((Component)StartOfRound.Instance.localPlayerController).transform;
			playerObjects = StartOfRound.Instance.allPlayerObjects;
			camera = ((Component)this).GetComponent<Camera>();
			fps = Plugin.cameraFrameSpeed.Value;
			disabled = (inControlRoom ? Plugin.controlRoomCameraDisable.Value : Plugin.cameraDisable.Value) || fps == 0f;
			((Behaviour)camera).enabled = false;
			camera.Render();
			elapsed = Random.Range(0f, 1f);
		}

		private void Update()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			if (disabled || (Object)(object)player == (Object)null)
			{
				return;
			}
			float num = Vector3.Distance(cullPos.position, player.position);
			if (num <= renderDistance)
			{
				if (fps > 0f)
				{
					elapsed += Time.deltaTime;
					if (elapsed > 1f / fps)
					{
						elapsed = 0f;
						camera.Render();
					}
				}
				else
				{
					((Behaviour)camera).enabled = true;
				}
			}
			else
			{
				((Behaviour)camera).enabled = false;
			}
		}

		private void LateUpdate()
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			if (disabled || followDistance <= 0f)
			{
				return;
			}
			Transform val = null;
			float num = float.PositiveInfinity;
			GameObject[] array = playerObjects;
			foreach (GameObject val2 in array)
			{
				float num2 = Vector3.Distance(((Component)this).transform.position, val2.transform.position);
				if (num2 < followDistance && num2 < num)
				{
					val = val2.transform;
					num = num2;
				}
			}
			if ((Object)(object)val != (Object)null)
			{
				Vector3 val3 = val.position - ((Component)this).transform.position;
				((Vector3)(ref val3)).Normalize();
				((Component)this).transform.rotation = Quaternion.Slerp(((Component)this).transform.rotation, Quaternion.LookRotation(val3), 5f * Time.deltaTime);
			}
		}
	}
	public class ElevatorController : MonoBehaviour, IDungeonLoadListener
	{
		public Animator animator;

		public Animator doorAnim;

		public AudioSource doorSource;

		public AudioClip openClip;

		public AudioClip closeClip;

		public AudioSource source;

		public AudioClip upClip;

		public AudioClip upShortClip;

		public AudioClip downClip;

		public AudioClip downShortClip;

		public Animator screenDoorAnim;

		public List<Light> lights;

		public Transform storagePos;

		[HideInInspector]
		public Vector3 startPos;

		public ElevatorMusic music;

		[Header("Notice Board")]
		public Doorway[] topSockets;

		public GameObject topBlocker;

		public Doorway[] midSockets;

		public GameObject midBlocker;

		public Doorway[] bottomSockets;

		public GameObject bottomBlocker;

		public GameObject[] floorIndicators;

		private void Start()
		{
			//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)
			startPos = ((Component)this).transform.position;
			doorAnim.SetFloat("speed", 1f);
			OpenDoor(1);
		}

		public void PostDungeonGeneration()
		{
			ElevatorSystem.Spawn(((Component)this).transform);
			topBlocker.SetActive(!DoorwayConnected(topSockets));
			midBlocker.SetActive(!DoorwayConnected(midSockets));
			bottomBlocker.SetActive(!DoorwayConnected(bottomSockets));
		}

		private bool DoorwayConnected(Doorway[] sockets)
		{
			foreach (Doorway val in sockets)
			{
				if ((Object)(object)val.ConnectedDoorway != (Object)null)
				{
					return true;
				}
			}
			return false;
		}

		public void OpenDoor(int floor)
		{
			doorSource.PlayOneShot(openClip);
			doorAnim.SetBool("closed", true);
			if (floor == 1)
			{
				screenDoorAnim.SetBool("open", true);
			}
		}

		public void CloseDoor()
		{
			doorSource.PlayOneShot(closeClip);
			doorAnim.SetBool("closed", false);
			screenDoorAnim.SetBool("open", false);
		}

		public void ToggleLights(bool on)
		{
			foreach (Light light in lights)
			{
				((Behaviour)light).enabled = on;
			}
		}
	}
	public class ElevatorMusic : MonoBehaviour
	{
		[Serializable]
		public struct ElevatorTrack
		{
			public AudioClip music;

			public AudioClip downPitch;

			public readonly AudioClip Get(bool pitchDown)
			{
				return pitchDown ? downPitch : music;
			}
		}

		public AudioSource audioSource;

		private int currentMusic;

		private float musicPlayTimer = 0f;

		private bool pitchDown;

		private bool active = false;

		public ElevatorTrack[] elevatorTracks = new ElevatorTrack[0];

		private void Start()
		{
			audioSource.volume = 0.4f * (Plugin.musicVolume.Value / 100f);
			pitchDown = Plugin.elevatorMusicPitchdown.Value;
			active = true;
		}

		public void ToggleMusic(bool on)
		{
			active = on;
			audioSource.Stop();
		}

		private void Update()
		{
			if (!active || audioSource.isPlaying)
			{
				return;
			}
			musicPlayTimer += Time.deltaTime;
			if (musicPlayTimer > 0.5f)
			{
				musicPlayTimer = 0f;
				currentMusic++;
				if (currentMusic >= elevatorTracks.Length)
				{
					currentMusic = 0;
				}
				audioSource.PlayOneShot(elevatorTracks[currentMusic].Get(pitchDown));
			}
		}
	}
	public class ElevatorPannel : ElevatorBehavior
	{
		public Animator animator;

		public Animator lightAnimator;

		public InteractTrigger UpButton;

		public InteractTrigger MidButton;

		public InteractTrigger DownButton;

		[FormerlySerializedAs("panelLabel")]
		public TextMeshProUGUI display;

		public void SetInteractable(bool value)
		{
			UpButton.interactable = (MidButton.interactable = (DownButton.interactable = value));
		}

		private static void SubscribeListener(InteractTrigger trigger, int floor)
		{
			((UnityEvent<PlayerControllerB>)(object)trigger.onInteract).AddListener((UnityAction<PlayerControllerB>)delegate
			{
				ElevatorSystem.System.ElevatorTriggerServerRpc(floor);
			});
		}

		public override void Setup()
		{
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			ElevatorSystem.System.controlPannels.Add(this);
			SubscribeListener(UpButton, 2);
			SubscribeListener(MidButton, 1);
			SubscribeListener(DownButton, 0);
			((TMP_Text)display).font = ElevatorSystem.System.textFont;
			((Graphic)display).material = ElevatorSystem.System.textMaterial;
			((Graphic)display).color = ElevatorSystem.System.textColor;
			((TMP_Text)display).text = "Idle";
		}
	}
	public class ElevatorStorage : ElevatorBehavior
	{
		public Transform target;

		public override void Setup()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			target = ElevatorSystem.System.controller.storagePos;
			((Component)this).transform.rotation = target.rotation;
		}

		public void LateUpdate()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			if (base.InSystem)
			{
				((Component)this).transform.position = target.position;
			}
		}
	}
	public abstract class ElevatorBehavior : MonoBehaviour
	{
		public bool InSystem { get; private set; } = false;


		public virtual void Start()
		{
			((MonoBehaviour)this).StartCoroutine(AddToSystem());
		}

		public abstract void Setup();

		private IEnumerator AddToSystem()
		{
			yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)ElevatorSystem.System != (Object)null));
			Setup();
			InSystem = true;
		}
	}
	public class ElevatorSystem : NetworkBehaviour
	{
		public static int elevatorFloor;

		public Animator animator;

		public bool hasPower = true;

		public LungProp inserted = null;

		public BoxCollider interactTrigger;

		public Animator lungParent;

		public AudioSource socketSource;

		public AudioClip insertClip;

		public AudioClip removeClip;

		[HideInInspector]
		public List<ElevatorPannel> controlPannels = new List<ElevatorPannel>();

		[HideInInspector]
		public ElevatorController controller;

		[HideInInspector]
		public TMP_FontAsset textFont;

		[HideInInspector]
		public Material textMaterial;

		[HideInInspector]
		public Color textColor;

		private GameObject SparkParticle;

		public bool elevatorMoving { get; private set; } = false;


		public bool elevatorIdle { get; private set; } = true;


		public static ElevatorSystem System { get; private set; }

		public override void OnNetworkSpawn()
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			((NetworkBehaviour)this).OnNetworkSpawn();
			controller = Object.FindObjectOfType<ElevatorController>();
			elevatorFloor = 1;
			TMP_Text component = GameObject.Find("doorHydraulics").GetComponent<TMP_Text>();
			textFont = component.font;
			textMaterial = ((Graphic)component).material;
			textColor = new Color(1f, 0.3444f, 0f, 1f);
			System = this;
			((Component)this).transform.position = controller.startPos + new Vector3(4.55f, -21.5f, -2.8f);
			for (int i = 0; i < controller.floorIndicators.Length; i++)
			{
				controller.floorIndicators[i].SetActive(i == 1);
			}
		}

		public static void Spawn(Transform parent)
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)System != (Object)null) && (((NetworkBehaviour)RoundManager.Instance).IsServer || ((NetworkBehaviour)RoundManager.Instance).IsHost))
			{
				Plugin.mls.LogInfo((object)"Spawning Elevator On Host");
				GameObject val = Object.Instantiate<GameObject>(Plugin.ActualElevator, parent);
				val.transform.localRotation = Quaternion.Euler(0f, -90f, 0f);
				val.GetComponent<NetworkObject>().Spawn(false);
				Object.Instantiate<GameObject>(Plugin.StoragePrefab).GetComponent<NetworkObject>().Spawn(false);
			}
		}

		public static void Despawn()
		{
			if ((Object)(object)System != (Object)null)
			{
				Plugin.mls.LogInfo((object)"Despawning Elevator");
				((NetworkBehaviour)System).NetworkObject.Despawn(true);
				ElevatorStorage elevatorStorage = Object.FindObjectOfType<ElevatorStorage>();
				if (elevatorStorage != null)
				{
					((Component)elevatorStorage).GetComponent<NetworkObject>().Despawn(true);
				}
			}
		}

		public override void OnDestroy()
		{
			System = null;
			((NetworkBehaviour)this).OnDestroy();
		}

		private void LateUpdate()
		{
			//IL_0028: 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_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: 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_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)inserted != (Object)null)
			{
				((Component)inserted).transform.position = ((Component)lungParent).transform.position;
				Transform transform = ((Component)inserted).transform;
				Transform transform2 = ((Component)lungParent).transform;
				Quaternion rotation = (transform2.rotation *= Quaternion.Euler(Vector3.up * 90f));
				transform.rotation = rotation;
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void ElevatorTriggerServerRpc(int floor)
		{
			//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(723090621u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, floor);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 723090621u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost) && (hasPower || (Object)(object)inserted != (Object)null) && elevatorFloor != floor && elevatorIdle)
				{
					ElevatorTriggerClientRpc(floor, emergency: false);
				}
			}
		}

		[ClientRpc]
		private void ElevatorTriggerClientRpc(int floor, bool emergency)
		{
			//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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: 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(3076769372u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, floor);
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref emergency, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3076769372u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					((MonoBehaviour)this).StartCoroutine(TriggerElevator(floor, emergency));
				}
			}
		}

		private IEnumerator TriggerElevator(int floor, bool emergency)
		{
			bool goingUp = floor > elevatorFloor;
			controller.CloseDoor();
			elevatorIdle = false;
			foreach (ElevatorPannel pannel2 in controlPannels)
			{
				((TMP_Text)pannel2.display).text = "Processing...";
			}
			yield return (object)new WaitForSeconds(2f);
			controller.floorIndicators[floor].SetActive(true);
			bool shortDistance = Mathf.Abs(elevatorFloor - floor) == 1;
			AnimatorStateInfo currentAnimatorStateInfo = animator.GetCurrentAnimatorStateInfo(0);
			int animHash = ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).shortNameHash;
			controller.animator.SetInteger("floor", floor);
			animator.SetInteger("floor", floor);
			controller.source.PlayOneShot((!goingUp) ? (shortDistance ? controller.downShortClip : controller.downClip) : (shortDistance ? controller.upShortClip : controller.upClip));
			string directionLabel = (goingUp ? "Ascending" : "Descending");
			if (emergency)
			{
				directionLabel = "Emergency " + directionLabel;
			}
			Plugin.mls.LogInfo((object)$"Elevator {directionLabel} from {elevatorFloor} to {floor}");
			GameObject oldIndicator = controller.floorIndicators[elevatorFloor];
			elevatorFloor = floor;
			elevatorMoving = true;
			foreach (ElevatorPannel pannel3 in controlPannels)
			{
				((TMP_Text)pannel3.display).text = directionLabel;
				pannel3.lightAnimator.SetInteger("sta", floor);
			}
			yield return 0;
			yield return (object)new WaitUntil((Func<bool>)delegate
			{
				//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)
				AnimatorStateInfo currentAnimatorStateInfo3 = animator.GetCurrentAnimatorStateInfo(0);
				return animHash != ((AnimatorStateInfo)(ref currentAnimatorStateInfo3)).shortNameHash && ((AnimatorStateInfo)(ref currentAnimatorStateInfo3)).normalizedTime >= 0.98f;
			});
			elevatorMoving = false;
			controller.OpenDoor(elevatorFloor);
			oldIndicator.SetActive(false);
			yield return 0;
			yield return (object)new WaitUntil((Func<bool>)delegate
			{
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				AnimatorStateInfo currentAnimatorStateInfo2 = animator.GetCurrentAnimatorStateInfo(0);
				return ((AnimatorStateInfo)(ref currentAnimatorStateInfo2)).normalizedTime > 1.2f;
			});
			elevatorIdle = true;
			bool powered = hasPower || (Object)(object)inserted != (Object)null;
			string text = (powered ? "Idle" : "\"No Power\"");
			foreach (ElevatorPannel pannel in controlPannels)
			{
				((TMP_Text)pannel.display).text = text;
				pannel.SetInteractable(powered);
			}
		}

		public void OnInteract(PlayerControllerB player)
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)inserted == (Object)null && (Object)(object)player.currentlyHeldObjectServer != (Object)null)
			{
				GrabbableObject currentlyHeldObjectServer = player.currentlyHeldObjectServer;
				LungProp val = (LungProp)(object)((currentlyHeldObjectServer is LungProp) ? currentlyHeldObjectServer : null);
				if (val != null)
				{
					player.DiscardHeldObject(true, (NetworkObject)null, ((Component)lungParent).transform.position, true);
					((Collider)interactTrigger).enabled = false;
					PlaceLungServerRpc(NetworkObjectReference.op_Implicit(((NetworkBehaviour)val).NetworkObject));
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void PlaceLungServerRpc(NetworkObjectReference lungRef)
		{
			//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_0102: 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(3863345722u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref lungRef, default(ForNetworkSerializable));
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3863345722u, val, (RpcDelivery)0);
				}
				NetworkObject val3 = default(NetworkObject);
				LungProp val4 = default(LungProp);
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost) && (Object)(object)inserted == (Object)null && ((NetworkObjectReference)(ref lungRef)).TryGet(ref val3, (NetworkManager)null) && ((Component)val3).TryGetComponent<LungProp>(ref val4))
				{
					PlaceLungClientRpc(lungRef);
				}
			}
		}

		[ClientRpc]
		public void PlaceLungClientRpc(NetworkObjectReference lungRef)
		{
			//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(824781070u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref lungRef, default(ForNetworkSerializable));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 824781070u, val, (RpcDelivery)0);
			}
			NetworkObject val3 = default(NetworkObject);
			LungProp val4 = default(LungProp);
			if ((int)base.__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost) || !((NetworkObjectReference)(ref lungRef)).TryGet(ref val3, (NetworkManager)null) || !((Component)val3).TryGetComponent<LungProp>(ref val4))
			{
				return;
			}
			((GrabbableObject)val4).grabbableToEnemies = false;
			((Collider)interactTrigger).enabled = false;
			inserted = val4;
			lungParent.SetTrigger("LungPlaced");
			socketSource.PlayOneShot(insertClip);
			controller.ToggleLights(on: true);
			controller.music.ToggleMusic(on: true);
			foreach (ElevatorPannel controlPannel in controlPannels)
			{
				((TMP_Text)controlPannel.display).text = "Idle";
				controlPannel.SetInteractable(value: true);
			}
			Plugin.mls.LogInfo((object)$"Inserted Elevator Apparatus {(Object)(object)inserted == (Object)null}");
		}

		internal void OnRemoveApparatus()
		{
			if (((NetworkBehaviour)this).IsServer || ((NetworkBehaviour)this).IsHost)
			{
				PullLungClientRpc(elevatorSocket: false);
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void PullLungServerRpc()
		{
			//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(2077624078u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2077624078u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost) && !((Object)(object)inserted == (Object)null))
				{
					PullLungClientRpc(elevatorSocket: true);
				}
			}
		}

		private IEnumerator DropElevator()
		{
			yield return (object)new WaitForSeconds(4f);
			ElevatorTriggerClientRpc(0, emergency: true);
		}

		[ClientRpc]
		public void PullLungClientRpc(bool elevatorSocket)
		{
			//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_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: 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(307980026u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref elevatorSocket, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 307980026u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			if (elevatorSocket)
			{
				if ((Object)(object)inserted.sparkParticle != (Object)null)
				{
					if ((Object)(object)SparkParticle != (Object)null)
					{
						Object.Destroy((Object)(object)SparkParticle);
					}
					SparkParticle = Object.Instantiate<GameObject>(inserted.sparkParticle, ((Component)lungParent).transform.position, Quaternion.identity, (Transform)null);
				}
				inserted = null;
				socketSource.PlayOneShot(removeClip);
				lungParent.ResetTrigger("LungPlaced");
				((Collider)interactTrigger).enabled = true;
			}
			else
			{
				hasPower = false;
			}
			if (!hasPower && (Object)(object)inserted == (Object)null)
			{
				foreach (ElevatorPannel controlPannel in controlPannels)
				{
					((TMP_Text)controlPannel.display).text = "\"No Power\"";
					controlPannel.SetInteractable(value: false);
				}
				controller.ToggleLights(on: false);
				controller.music.ToggleMusic(on: false);
				if ((((NetworkBehaviour)this).IsHost || ((NetworkBehaviour)this).IsServer) && elevatorFloor != 0)
				{
					((MonoBehaviour)this).StartCoroutine(DropElevator());
				}
			}
			Plugin.mls.LogInfo((object)$"Removed Apparatus (Elevator Socker: {elevatorSocket}) (Has Inserted: {(Object)(object)inserted == (Object)null})");
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_ElevatorSystem()
		{
			//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
			NetworkManager.__rpc_func_table.Add(723090621u, new RpcReceiveHandler(__rpc_handler_723090621));
			NetworkManager.__rpc_func_table.Add(3076769372u, new RpcReceiveHandler(__rpc_handler_3076769372));
			NetworkManager.__rpc_func_table.Add(3863345722u, new RpcReceiveHandler(__rpc_handler_3863345722));
			NetworkManager.__rpc_func_table.Add(824781070u, new RpcReceiveHandler(__rpc_handler_824781070));
			NetworkManager.__rpc_func_table.Add(2077624078u, new RpcReceiveHandler(__rpc_handler_2077624078));
			NetworkManager.__rpc_func_table.Add(307980026u, new RpcReceiveHandler(__rpc_handler_307980026));
		}

		private static void __rpc_handler_723090621(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 floor = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref floor);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((ElevatorSystem)(object)target).ElevatorTriggerServerRpc(floor);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3076769372(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			{
				int floor = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref floor);
				bool emergency = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref emergency, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((ElevatorSystem)(object)target).ElevatorTriggerClientRpc(floor, emergency);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3863345722(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 lungRef = default(NetworkObjectReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref lungRef, default(ForNetworkSerializable));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((ElevatorSystem)(object)target).PlaceLungServerRpc(lungRef);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_824781070(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 lungRef = default(NetworkObjectReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref lungRef, default(ForNetworkSerializable));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((ElevatorSystem)(object)target).PlaceLungClientRpc(lungRef);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2077624078(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;
				((ElevatorSystem)(object)target).PullLungServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_307980026(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 elevatorSocket = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref elevatorSocket, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((ElevatorSystem)(object)target).PullLungClientRpc(elevatorSocket);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "ElevatorSystem";
		}
	}
	public class MetalDetector : MonoBehaviour
	{
		public bool powered = true;

		private bool shocking = false;

		public ParticleSystem particles;

		public AudioSource source;

		public AudioClip zapSound;

		public Light redLight;

		private Coroutine shockSequence;

		public void OnTriggerStay(Collider other)
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB val = default(PlayerControllerB);
			if (!powered || !((Component)other).CompareTag("Player") || !((Component)other).gameObject.TryGetComponent<PlayerControllerB>(ref val) || val.isPlayerDead)
			{
				return;
			}
			if (shocking)
			{
				val.KillPlayer(Vector3.up, true, (CauseOfDeath)11, 3, default(Vector3));
				return;
			}
			GrabbableObject[] itemSlots = val.ItemSlots;
			foreach (GrabbableObject val2 in itemSlots)
			{
				if (!((Object)(object)val2 == (Object)null) && !((Object)(object)val2.itemProperties == (Object)null) && val2.itemProperties.isConductiveMetal)
				{
					shockSequence = ((MonoBehaviour)this).StartCoroutine(ShockSequence());
					break;
				}
			}
		}

		public void PowerDown()
		{
			powered = false;
			StopShocking();
		}

		private IEnumerator ShockSequence()
		{
			Light obj = redLight;
			MetalDetector metalDetector = this;
			bool enabled = true;
			metalDetector.shocking = true;
			((Behaviour)obj).enabled = enabled;
			particles.Play();
			source.PlayOneShot(zapSound);
			yield return (object)new WaitForSeconds(1f);
			StopShocking();
		}

		private void StopShocking()
		{
			if (shockSequence != null)
			{
				((MonoBehaviour)this).StopCoroutine(shockSequence);
				shockSequence = null;
			}
			((Behaviour)redLight).enabled = (shocking = false);
		}
	}
	public class WeirdScreen : MonoBehaviour
	{
		private readonly Dictionary<string, string> MoonMessages = new Dictionary<string, string>
		{
			{ "Gorgonzola", "Needs more cheese..." },
			{ "Embrion", "Data has been Successfully Erased." },
			{ "Titan", "Please Evacuate this area" },
			{ "Icebound", "Contacting Jermey..." },
			{ "Siechi", "Samouri Online" },
			{ "Hyve", "Ya like Jaz?" },
			{ "Calist", "Connection Terminated" },
			{ "Asteroid-13", "They will find you" },
			{ "Motra", "Intruders Detected" },
			{ "Filitrios", "Batteries not Included" },
			{ "Alcatras", "Banana?" },
			{ "Fission-C", "Exterior Damage Detected\nRadiation Levels still Increasing" },
			{ "Etern", "Launch Sequence Initialized" },
			{ "Polarus", "Creature Detected Nearby" },
			{ "Oldred", "oil oil oil oil oil oil oil\noil oil oil oil oil oil oil oil\noil oil oil oil oil oil oil oil oil oil oil oil oil oil\noil oil oil oil oil oil oil oil oil oil oil oil oil oil oil oil oil oil oil oil oil oil oil oil oil oil oil oil oil oil oil oil oil oil oil oil oil oil oil" },
			{ "Trite", "Defense Turrets Online" },
			{ "Demetrica", "Life Support Offline" },
			{ "Cubatres", "■■■ ■■■■■■■ ■■■■■■" },
			{ "Cosmocos", "I can see you." },
			{ "Hyx", "You should not be here." },
			{ "Summit", "Bird Activation Scheduled" },
			{ "Pinnacle", "Fortitude Communications Offline" },
			{ "Nadir", "Canyon Defenses Online\nIntruders Detected" },
			{ "Conspire", "Clockwork Operational" },
			{ "Obstruction", "Signal Received\nSecure Encrypted Connection Established" },
			{ "Fortitude", "Lifeforms Detected\nAdvanced Security System Online" }
		};

		public TextMeshProUGUI screenText;

		private void Start()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			((TMP_Text)screenText).text = GetMessage(LevelManager.CurrentExtendedLevel);
			((Graphic)screenText).color = GetColor(LevelManager.CurrentExtendedLevel);
		}

		public void DisableScreen()
		{
			((TMP_Text)screenText).text = string.Empty;
		}

		public string GetMessage(ExtendedLevel level)
		{
			if (MoonMessages.TryGetValue(level.NumberlessPlanetName, out var value))
			{
				return value;
			}
			return "Terminal Offline";
		}

		public Color GetColor(ExtendedLevel level)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: 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)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: 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)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: 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_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			if (((ExtendedContent)level).TryGetTag("Cheese") || ((ExtendedContent)level).TryGetTag("Honey"))
			{
				return Color.yellow;
			}
			if (((ExtendedContent)level).TryGetTag("Fun"))
			{
				return Color.Lerp(Color.red, Color.white, 0.5f);
			}
			if (((ExtendedContent)level).TryGetTag("Argon"))
			{
				return Color.Lerp(Color.red, Color.blue, 0.5f);
			}
			if (((ExtendedContent)level).TryGetTag("Tundra"))
			{
				return Color.cyan;
			}
			if (((ExtendedContent)level).TryGetTag("Ocean"))
			{
				return Color.blue;
			}
			return Color.red;
		}
	}
}
namespace LCOffice.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}