Decompiled source of EnergeticShip v0.2.3

EnergeticShip.dll

Decompiled 5 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using EnergeticShip.NetcodePatcher;
using GameNetcodeStuff;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using On;
using On.GameNetcodeStuff;
using TerminalApi;
using TerminalApi.Classes;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Events;

[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: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("UnityEngine")]
[assembly: AssemblyCompany("EnergeticShip")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Energetic ship plugin")]
[assembly: AssemblyFileVersion("0.2.1.0")]
[assembly: AssemblyInformationalVersion("0.2.1")]
[assembly: AssemblyProduct("EnergeticShip")]
[assembly: AssemblyTitle("EnergeticShip")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.2.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
		NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<float>();
		NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<float>();
	}
}
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 EnergeticShip
{
	public class Actions
	{
		public class Action
		{
			public enum ActionType
			{
				PassiveEffect,
				SingleAction
			}

			public delegate void Callback();

			private bool active;

			private Callback startCB;

			private Callback stopCB;

			private bool needsEnergyConstantly;

			private ActionType type;

			public float energyUsage { get; }

			public float elapsedSeconds { get; set; }

			public Action(ActionType type, Callback startCB, Callback stopCB, float energyUsage, bool needsEnergyConstantly = false)
			{
				this.type = type;
				this.startCB = startCB;
				this.stopCB = stopCB;
				this.energyUsage = energyUsage;
				this.needsEnergyConstantly = needsEnergyConstantly;
				elapsedSeconds = 0f;
			}

			public bool EnoughEnergyToStart()
			{
				return Plugin.EnergySystem().GetShipEnergy() >= energyUsage;
			}

			public void Start(bool resume = false)
			{
				if (NetworkManager.Singleton.IsServer)
				{
					if (type == ActionType.PassiveEffect)
					{
						active = true;
						if (NeedsEnergyConstantly())
						{
							Plugin.EnergySystem().ScheduleAction(this);
						}
					}
					else if (!resume)
					{
						Plugin.EnergySystem().AddShipEnergy(0f - energyUsage);
					}
					startCB();
				}
				else if (type == ActionType.PassiveEffect)
				{
					active = true;
				}
			}

			public void Stop()
			{
				Plugin.logger.LogInfo((object)string.Format("[{0}]: Disabling effect: {1}", NetworkManager.Singleton.IsServer ? "Server" : "Client", this));
				if (NetworkManager.Singleton.IsServer)
				{
					if (type == ActionType.PassiveEffect)
					{
						active = false;
						if (NeedsEnergyConstantly())
						{
							Plugin.EnergySystem().UnscheduleAction(this);
						}
					}
					if (stopCB != null)
					{
						stopCB();
					}
				}
				else if (type == ActionType.PassiveEffect)
				{
					active = false;
				}
			}

			public bool NeedsEnergyConstantly()
			{
				return needsEnergyConstantly;
			}

			public bool IsActive()
			{
				return active;
			}
		}

		[CompilerGenerated]
		private static class <>O
		{
			public static hook_TeleportPlayerOutWithInverseTeleporter <0>__OnTeleportPlayerOutWithInverseTeleporter;

			public static hook_TeleportPlayerOutClientRpc <1>__OnTeleportPlayerOutClientRpc;

			public static hook_beamUpPlayer <2>__OnbeamUpPlayer;

			public static hook_DropAllHeldItems <3>__OnDropAllHeldItems;

			public static hook_KillPlayer <4>__OnKillPlayer;

			public static UnityAction<PlayerControllerB> <5>__runSafeReturn;
		}

		public static readonly Action SCALE_MAP = new Action(Action.ActionType.PassiveEffect, delegate
		{
			Plugin.EnergySystem().ScaleMapClientRpc(2f);
		}, delegate
		{
			Plugin.EnergySystem().ScaleMapClientRpc(0.5f);
		}, 3f, needsEnergyConstantly: true);

		public static readonly Action DISABLE_WEATHER = new Action(Action.ActionType.SingleAction, delegate
		{
			Plugin.EnergySystem().ClearWeatherClientRpc();
		}, delegate
		{
		}, 25f);

		public static readonly Action TARGET_TELEPORT = new Action(Action.ActionType.PassiveEffect, delegate
		{
		}, delegate
		{
		}, 7f);

		public static readonly Action KEEP_ITEMS_TELEPORT = new Action(Action.ActionType.PassiveEffect, delegate
		{
		}, delegate
		{
		}, 15f);

		public static readonly Action SAFETY_GUARD = new Action(Action.ActionType.PassiveEffect, delegate
		{
			Plugin.EnergySystem().SafetyGuardClientRpc(active: true);
			Plugin.EnergySystem().SafetyGuardRunning = true;
		}, delegate
		{
			Plugin.EnergySystem().SafetyGuardClientRpc(active: false);
			Plugin.EnergySystem().SafetyGuardRunning = false;
		}, 0f);

		public static readonly Action TARGETED_BLAST = new Action(Action.ActionType.SingleAction, SpawnTargetedBlasts, delegate
		{
		}, 10f);

		private const float MAX_BEACON_DISTANCE = 14f;

		private static bool SafetyRetreatActive = false;

		private static bool currentlyRunningTeleportOnServer = false;

		private static bool serverAllowedTeleport = false;

		private static bool allowedToBeamUpPlayer = false;

		private static bool allowedToKeepSomeItems = false;

		private static int firstKeepItemSlot = 0;

		private static int secondKeepItemSlot = 0;

		public static void InitActions()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Expected O, but got Unknown
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Expected O, but got Unknown
			object obj = <>O.<0>__OnTeleportPlayerOutWithInverseTeleporter;
			if (obj == null)
			{
				hook_TeleportPlayerOutWithInverseTeleporter val = OnTeleportPlayerOutWithInverseTeleporter;
				<>O.<0>__OnTeleportPlayerOutWithInverseTeleporter = val;
				obj = (object)val;
			}
			ShipTeleporter.TeleportPlayerOutWithInverseTeleporter += (hook_TeleportPlayerOutWithInverseTeleporter)obj;
			object obj2 = <>O.<1>__OnTeleportPlayerOutClientRpc;
			if (obj2 == null)
			{
				hook_TeleportPlayerOutClientRpc val2 = OnTeleportPlayerOutClientRpc;
				<>O.<1>__OnTeleportPlayerOutClientRpc = val2;
				obj2 = (object)val2;
			}
			ShipTeleporter.TeleportPlayerOutClientRpc += (hook_TeleportPlayerOutClientRpc)obj2;
			object obj3 = <>O.<2>__OnbeamUpPlayer;
			if (obj3 == null)
			{
				hook_beamUpPlayer val3 = OnbeamUpPlayer;
				<>O.<2>__OnbeamUpPlayer = val3;
				obj3 = (object)val3;
			}
			ShipTeleporter.beamUpPlayer += (hook_beamUpPlayer)obj3;
			object obj4 = <>O.<3>__OnDropAllHeldItems;
			if (obj4 == null)
			{
				hook_DropAllHeldItems val4 = OnDropAllHeldItems;
				<>O.<3>__OnDropAllHeldItems = val4;
				obj4 = (object)val4;
			}
			PlayerControllerB.DropAllHeldItems += (hook_DropAllHeldItems)obj4;
			object obj5 = <>O.<4>__OnKillPlayer;
			if (obj5 == null)
			{
				hook_KillPlayer val5 = OnKillPlayer;
				<>O.<4>__OnKillPlayer = val5;
				obj5 = (object)val5;
			}
			PlayerControllerB.KillPlayer += (hook_KillPlayer)obj5;
		}

		private static void OnKillPlayer(orig_KillPlayer orig, PlayerControllerB self, Vector3 bodyVelocity, bool spawnBody, CauseOfDeath causeOfDeath, int deathAnimation, Vector3 positionOffset)
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Invalid comparison between Unknown and I4
			//IL_008a: 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_0090: Unknown result type (might be due to invalid IL or missing references)
			int livingPlayers = StartOfRound.Instance.livingPlayers;
			Plugin.logger.LogInfo((object)string.Format("[{0}]: Player {1} tries to die because of {2}. Safety guard active: {3}, Players alive: {4}", NetworkManager.Singleton.IsServer ? "Server" : "Client", self, causeOfDeath, SAFETY_GUARD.IsActive(), livingPlayers));
			if (!SAFETY_GUARD.IsActive() || livingPlayers > 1 || (int)causeOfDeath == 2)
			{
				orig.Invoke(self, bodyVelocity, spawnBody, causeOfDeath, deathAnimation, positionOffset);
				return;
			}
			Plugin.logger.LogInfo((object)("[" + (NetworkManager.Singleton.IsServer ? "Server" : "Client") + "]: Prevented death"));
			if (!SafetyRetreatActive)
			{
				Plugin.logger.LogInfo((object)("[" + (NetworkManager.Singleton.IsServer ? "Server" : "Client") + "]: Initiate teleport"));
				Plugin.EnergySystem().PlayTriggerSafetyGuardSoundClientRpc(PlayerScriptIndex(self));
				StartOfRound.Instance.mapScreen.SwitchRadarTargetAndSync(PlayerRadarIndex(self));
				GetShipTeleporter().PressTeleportButtonOnLocalClient();
				((UnityEvent<PlayerControllerB>)(object)StartOfRound.Instance.playerTeleportedEvent).AddListener((UnityAction<PlayerControllerB>)runSafeReturn);
				SafetyRetreatActive = true;
			}
		}

		private static int PlayerScriptIndex(PlayerControllerB player)
		{
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			for (int i = 0; i < allPlayerScripts.Length; i++)
			{
				if ((Object)(object)allPlayerScripts[i] == (Object)(object)player)
				{
					return i;
				}
			}
			return -1;
		}

		private static int PlayerRadarIndex(PlayerControllerB player)
		{
			List<TransformAndName> radarTargets = StartOfRound.Instance.mapScreen.radarTargets;
			for (int i = 0; i < radarTargets.Count; i++)
			{
				if ((Object)(object)((Component)radarTargets[i].transform).gameObject.GetComponent<PlayerControllerB>() == (Object)(object)player)
				{
					return i;
				}
			}
			return -1;
		}

		private static void runSafeReturn(PlayerControllerB self)
		{
			//IL_0044: 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)
			((UnityEvent<PlayerControllerB>)(object)StartOfRound.Instance.playerTeleportedEvent).RemoveListener((UnityAction<PlayerControllerB>)runSafeReturn);
			SafetyRetreatActive = false;
			SAFETY_GUARD.Stop();
			Plugin.EnergySystem().DisableSafetyGuardServerRpc();
		}

		private static ShipTeleporter GetShipTeleporter()
		{
			ShipTeleporter[] array = Object.FindObjectsOfType<ShipTeleporter>();
			if (array != null)
			{
				for (int i = 0; i < array.Length; i++)
				{
					if (!array[i].isInverseTeleporter)
					{
						return array[i];
					}
				}
			}
			return null;
		}

		private static void OnTeleportPlayerOutClientRpc(orig_TeleportPlayerOutClientRpc orig, ShipTeleporter self, int playerObjToTeleport, Vector3 targetPos)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: 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)
			//IL_015c: Expected O, but got Unknown
			//IL_015c: Expected O, but got Unknown
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			Plugin.logger.LogInfo((object)string.Format("[{0}]: Intercepted TelerportPlayerOutClientRpc for {1} with pos {2}", NetworkManager.Singleton.IsServer ? "Server" : "Client", playerObjToTeleport, targetPos));
			Vector3 val = targetPos;
			ShipTeleporter shipInverseTeleporter = GetShipInverseTeleporter();
			bool flag = false;
			PlayerControllerB teleportTargetPlayer = null;
			if (NetworkManager.Singleton.IsServer && !currentlyRunningTeleportOnServer)
			{
				currentlyRunningTeleportOnServer = true;
				if (KEEP_ITEMS_TELEPORT.IsActive() && KEEP_ITEMS_TELEPORT.EnoughEnergyToStart())
				{
					PlayerControllerB playerToTeleport = StartOfRound.Instance.allPlayerScripts[playerObjToTeleport];
					Plugin.logger.LogInfo((object)("[" + (NetworkManager.Singleton.IsServer ? "Server" : "Client") + "]: Activating keep items from inverse teleporter"));
					Plugin.EnergySystem().AddShipEnergy(0f - KEEP_ITEMS_TELEPORT.energyUsage);
					int[] array = generateKeepItemSlots(playerToTeleport);
					Plugin.EnergySystem().AllowToKeepSomeItemsOnTeleportClientRpc(array[0], array[1]);
				}
				if (TARGET_TELEPORT.IsActive() && TARGET_TELEPORT.EnoughEnergyToStart())
				{
					PlayerControllerB val2 = StartOfRound.Instance.allPlayerScripts[playerObjToTeleport];
					if ((Object)StartOfRound.Instance.mapScreen.targetedPlayer == (Object)val2)
					{
						Plugin.logger.LogInfo((object)string.Format("[{0}]: Did not teleport player {1} to himself", NetworkManager.Singleton.IsServer ? "Server" : "Client", playerObjToTeleport));
						return;
					}
					Plugin.logger.LogInfo((object)("[" + (NetworkManager.Singleton.IsServer ? "Server" : "Client") + "]: Teleporter is active and ship has enough energy"));
					Plugin.EnergySystem().AddShipEnergy(0f - TARGET_TELEPORT.energyUsage);
					teleportTargetPlayer = StartOfRound.Instance.mapScreen.targetedPlayer;
					val = ((Component)teleportTargetPlayer).transform.position;
					ManualLogSource logger = Plugin.logger;
					string obj = (NetworkManager.Singleton.IsServer ? "Server" : "Client");
					Vector3 val3 = val;
					logger.LogInfo((object)("[" + obj + "]: Reroute teleport to position: " + ((object)(Vector3)(ref val3)).ToString()));
					flag = true;
				}
			}
			serverAllowedTeleport = true;
			orig.Invoke(self, playerObjToTeleport, val);
			if (((NetworkBehaviour)StartOfRound.Instance.allPlayerScripts[playerObjToTeleport]).IsOwner)
			{
				Plugin.logger.LogInfo((object)string.Format("[{0}]: Teleported {1}", NetworkManager.Singleton.IsServer ? "Server" : "Client", playerObjToTeleport));
				shipInverseTeleporter.TeleportPlayerOutWithInverseTeleporter(playerObjToTeleport, val);
			}
			if (flag)
			{
				Plugin.EnergySystem().AdjustFlagsAfterTeleportPlayerOutClientRpc(playerObjToTeleport, Array.FindIndex(StartOfRound.Instance.allPlayerScripts, (PlayerControllerB e) => (Object)(object)e == (Object)(object)teleportTargetPlayer));
			}
			if (NetworkManager.Singleton.IsServer)
			{
				currentlyRunningTeleportOnServer = false;
			}
		}

		private static ShipTeleporter GetShipInverseTeleporter()
		{
			ShipTeleporter[] array = Object.FindObjectsOfType<ShipTeleporter>();
			if (array != null)
			{
				for (int i = 0; i < array.Length; i++)
				{
					if (array[i].isInverseTeleporter)
					{
						return array[i];
					}
				}
			}
			return null;
		}

		private static int[] generateKeepItemSlots(PlayerControllerB playerToTeleport)
		{
			int[] array = new int[2];
			array[0] = Random.RandomRangeInt(0, playerToTeleport.ItemSlots.Length);
			array[1] = (array[0] + Random.RandomRangeInt(1, playerToTeleport.ItemSlots.Length)) % playerToTeleport.ItemSlots.Length;
			return array;
		}

		private static void OnTeleportPlayerOutWithInverseTeleporter(orig_TeleportPlayerOutWithInverseTeleporter orig, ShipTeleporter self, int playerObj, Vector3 targetPos)
		{
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			bool flag = false;
			if (serverAllowedTeleport)
			{
				Plugin.logger.LogInfo((object)string.Format("[{0}]: Teleport {1} to {2}", NetworkManager.Singleton.IsServer ? "Server" : "Client", playerObj, targetPos));
				orig.Invoke(self, playerObj, targetPos);
				serverAllowedTeleport = false;
			}
			else
			{
				Plugin.logger.LogInfo((object)string.Format("[{0}]: Teleport BLOCKED {1} to {2}", NetworkManager.Singleton.IsServer ? "Server" : "Client", playerObj, targetPos));
			}
		}

		public static void KeepItemsNormalTeleportCallback(ulong clientId)
		{
			Plugin.logger.LogInfo((object)string.Format("[{0}]: KeepItemsTeleportCallback for id {1}", NetworkManager.Singleton.IsServer ? "Server" : "Client", clientId));
			if (KEEP_ITEMS_TELEPORT.IsActive() && Plugin.EnergySystem().GetShipEnergy() > KEEP_ITEMS_TELEPORT.energyUsage && StartOfRound.Instance.mapScreen.targetedPlayer.actualClientId == clientId)
			{
				Plugin.logger.LogInfo((object)("[" + (NetworkManager.Singleton.IsServer ? "Server" : "Client") + "]: Activating keep items from normal teleporter"));
				Plugin.EnergySystem().AddShipEnergy(0f - KEEP_ITEMS_TELEPORT.energyUsage);
				int[] array = generateKeepItemSlots(StartOfRound.Instance.mapScreen.targetedPlayer);
				Plugin.EnergySystem().AllowToKeepSomeItemsOnTeleportClientRpc(array[0], array[1]);
			}
		}

		public static void AllowToBeamUpPlayer()
		{
			allowedToBeamUpPlayer = true;
		}

		private static IEnumerator OnbeamUpPlayer(orig_beamUpPlayer orig, ShipTeleporter self)
		{
			Plugin.logger.LogInfo((object)("[" + (NetworkManager.Singleton.IsServer ? "Server" : "Client") + "]: Ask to beam up player"));
			Plugin.EnergySystem().AskToBeamUpPlayerServerRpc();
			while (!allowedToBeamUpPlayer)
			{
				yield return (object)new WaitForSeconds(0.001f);
			}
			Plugin.logger.LogInfo((object)("[" + (NetworkManager.Singleton.IsServer ? "Server" : "Client") + "]: Got permission to beam up"));
			allowedToBeamUpPlayer = false;
			IEnumerator enumerator = orig.Invoke(self);
			while (enumerator.MoveNext())
			{
				yield return enumerator.Current;
			}
		}

		public static void AllowToKeepSomeItems(int firstSlot, int secondSlot)
		{
			allowedToKeepSomeItems = true;
			firstKeepItemSlot = firstSlot;
			secondKeepItemSlot = secondSlot;
		}

		private static void OnDropAllHeldItems(orig_DropAllHeldItems orig, PlayerControllerB self, bool itemsFall = true, bool disconnecting = false)
		{
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			if (allowedToKeepSomeItems)
			{
				Plugin.logger.LogInfo((object)string.Format("[{0}]: Keeping items in slot {1}, {2}", NetworkManager.Singleton.IsServer ? "Server" : "Client", firstKeepItemSlot, secondKeepItemSlot));
				allowedToKeepSomeItems = false;
				float num = 0f;
				for (int i = 0; i < self.ItemSlots.Length; i++)
				{
					if (i == firstKeepItemSlot || i == secondKeepItemSlot)
					{
						continue;
					}
					GrabbableObject val = self.ItemSlots[i];
					if ((Object)(object)val == (Object)null)
					{
						continue;
					}
					num += val.itemProperties.weight - 1f;
					if (itemsFall)
					{
						val.parentObject = null;
						val.heldByPlayerOnServer = false;
						if (self.isInElevator)
						{
							((Component)val).transform.SetParent(self.playersManager.elevatorTransform, true);
						}
						else
						{
							((Component)val).transform.SetParent(self.playersManager.propsContainer, true);
						}
						self.SetItemInElevator(self.isInHangarShipRoom, self.isInElevator, val);
						val.EnablePhysics(true);
						val.EnableItemMeshes(true);
						((Component)val).transform.localScale = val.originalScale;
						val.isHeld = false;
						val.isPocketed = false;
						val.startFallingPosition = ((Component)val).transform.parent.InverseTransformPoint(((Component)val).transform.position);
						val.FallToGround(true);
						val.fallTime = Random.Range(-0.3f, 0.05f);
						if (((NetworkBehaviour)self).IsOwner)
						{
							val.DiscardItemOnClient();
						}
						else if (!val.itemProperties.syncDiscardFunction)
						{
							val.playerHeldBy = null;
						}
					}
					if (((NetworkBehaviour)self).IsOwner && !disconnecting)
					{
						((Behaviour)HUDManager.Instance.holdingTwoHandedItem).enabled = false;
						((Behaviour)HUDManager.Instance.itemSlotIcons[i]).enabled = false;
						HUDManager.Instance.ClearControlTips();
						self.activatingItem = false;
					}
					self.ItemSlots[i] = null;
				}
				if (self.isHoldingObject && self.currentItemSlot != firstKeepItemSlot && self.currentItemSlot != secondKeepItemSlot)
				{
					self.isHoldingObject = false;
					if ((Object)(object)self.currentlyHeldObjectServer != (Object)null)
					{
						self.SetSpecialGrabAnimationBool(false, self.currentlyHeldObjectServer);
					}
					self.playerBodyAnimator.SetBool("cancelHolding", true);
					self.playerBodyAnimator.SetTrigger("Throw");
					self.activatingItem = false;
					self.twoHanded = false;
					self.currentlyHeldObjectServer = null;
				}
				self.carryWeight = Mathf.Clamp(self.carryWeight - num, 0f, 10f);
			}
			else
			{
				Plugin.logger.LogInfo((object)("[" + (NetworkManager.Singleton.IsServer ? "Server" : "Client") + "]: Dropping all items"));
				orig.Invoke(self, itemsFall, disconnecting);
			}
		}

		public static void ScaleMap(float scale)
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			TerminalAccessibleObject[] array = Object.FindObjectsOfType<TerminalAccessibleObject>();
			int num = 0;
			TerminalAccessibleObject[] array2 = (TerminalAccessibleObject[])(object)new TerminalAccessibleObject[array.Length];
			TerminalAccessibleObject[] array3 = array;
			foreach (TerminalAccessibleObject val in array3)
			{
				array2[num] = val;
				num++;
			}
			TerminalAccessibleObject[] array4 = array2;
			TerminalAccessibleObject[] array5 = array4;
			foreach (TerminalAccessibleObject val2 in array5)
			{
				RectTransform componentInParent = ((Component)val2.mapRadarText).GetComponentInParent<RectTransform>();
				Transform transform = ((Component)componentInParent).transform;
				transform.localScale *= scale;
			}
			Camera mapCamera = StartOfRound.Instance.mapScreen.mapCamera;
			mapCamera.orthographicSize *= scale;
		}

		public static void ClearWeather()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			StartOfRound.Instance.currentLevel.currentWeather = (LevelWeatherType)(-1);
			RoundManager.Instance.SetToCurrentLevelWeather();
			StartOfRound.Instance.SetMapScreenInfoToCurrentLevel();
		}

		public static void SpawnTargetedBlasts()
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			Plugin.EnergySystem().AddShipEnergy(TARGETED_BLAST.energyUsage);
			GrabbableObject[] array = (from obj in Object.FindObjectsOfType<GrabbableObject>()
				where !obj.isHeld && ((object)obj.itemProperties).Equals((object?)Plugin.TargetBeaconItem)
				select obj).ToArray();
			foreach (GrabbableObject val in array)
			{
				Vector3 position = ((Component)val).transform.position;
				Plugin.EnergySystem().AddShipEnergy(0f - TARGETED_BLAST.energyUsage);
				Plugin.EnergySystem().SpawnExplosionClientRpc(position + Vector3.up);
			}
		}

		public static void SpawnBlastExplosion(Vector3 pos)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			((MonoBehaviour)Plugin.EnergySystem()).StartCoroutine(ScheduleExplosion(pos));
		}

		private static IEnumerator ScheduleExplosion(Vector3 pos)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			GrabbableObject[] targetBeacons = (from obj in Object.FindObjectsOfType<GrabbableObject>()
				where !obj.isHeld && Vector3.Distance(((Component)obj).transform.position, pos) < 14f && ((object)obj.itemProperties).Equals((object?)Plugin.TargetBeaconItem)
				select obj).ToArray();
			GrabbableObject[] array = targetBeacons;
			foreach (GrabbableObject obj2 in array)
			{
				((Component)obj2).GetComponent<AudioSource>().PlayOneShot(Plugin.BlastBuildup);
			}
			yield return (object)new WaitForSeconds(1.75f);
			Landmine.SpawnExplosion(pos, true, 5.7f, 6f, 30, 35f, (GameObject)null, false);
			Collider[] colliders = Physics.OverlapSphere(pos, 5.7f, 524288, (QueryTriggerInteraction)2);
			Collider[] array2 = colliders;
			foreach (Collider collider in array2)
			{
				EnemyAICollisionDetect componentInChildren2 = ((Component)collider).gameObject.GetComponentInChildren<EnemyAICollisionDetect>();
				if ((Object)componentInChildren2 != (Object)null && ((NetworkBehaviour)componentInChildren2.mainScript).IsOwner)
				{
					bool canDie = componentInChildren2.mainScript.enemyType.canDie;
					componentInChildren2.mainScript.enemyType.canDie = true;
					componentInChildren2.mainScript.KillEnemyOnOwnerClient(!canDie);
					componentInChildren2.mainScript.enemyType.canDie = canDie;
				}
			}
		}
	}
	internal class Commands
	{
		private const string NOT_ENOUGH_ENERGY = "Not enough energy\n";

		public static void InitCommands()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Expected O, but got Unknown
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Expected O, but got Unknown
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Expected O, but got Unknown
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Expected O, but got Unknown
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Expected O, but got Unknown
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: Expected O, but got Unknown
			//IL_02be: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c4: Expected O, but got Unknown
			CommandInfo val = new CommandInfo();
			val.Category = "other";
			val.Description = string.Format("Scales map view for {0} {1}/min.", Actions.SCALE_MAP.energyUsage, "E");
			val.DisplayTextSupplier = ScaleMap;
			TerminalApi.AddCommand("scalemap", val, (string)null, false);
			val = new CommandInfo();
			val.Category = "other";
			val.Description = string.Format("Cleares weather from orbited planet {0} {1}.", Actions.DISABLE_WEATHER.energyUsage, "E");
			val.DisplayTextSupplier = ClearWeather;
			TerminalApi.AddCommand("clearweather", val, (string)null, false);
			val = new CommandInfo();
			val.Category = "other";
			val.Description = string.Format("Targets the inverse teleporter at the player selected on the map. {0} {1}/teleported person.", Actions.TARGET_TELEPORT.energyUsage, "E");
			val.DisplayTextSupplier = TargetTeleporter;
			TerminalApi.AddCommand("targettp", val, (string)null, false);
			val = new CommandInfo();
			val.Category = "other";
			val.Description = string.Format("Keeps two random slots when teleporting a player. {0} {1}/teleported person.", Actions.KEEP_ITEMS_TELEPORT.energyUsage, "E");
			val.DisplayTextSupplier = KeepItemTeleporter;
			TerminalApi.AddCommand("keeptp", val, (string)null, false);
			val = new CommandInfo();
			val.Category = "other";
			val.Description = string.Format("Prevents a crew wipeout ONCE by teleporting the last player back to ship. {0} {1}.", Actions.SAFETY_GUARD.energyUsage, "E");
			val.DisplayTextSupplier = SafetyGuard;
			TerminalApi.AddCommand("guard", val, (string)null, false);
			val = new CommandInfo();
			val.Category = "other";
			val.Description = string.Format("Issues a devastating blast on ALL placed target beacons. {0} {1}/target beacon.", Actions.TARGETED_BLAST.energyUsage, "E");
			val.DisplayTextSupplier = TargetedBlast;
			TerminalApi.AddCommand("blast", val, (string)null, false);
			val = new CommandInfo();
			val.Category = "other";
			val.Description = "Displays the ships current energy.";
			val.DisplayTextSupplier = PrintShipEnergy;
			TerminalApi.AddCommand("energy", val, (string)null, false);
			val = new CommandInfo();
			val.Category = "other";
			val.Description = "Consumes a battery to load ship energy.";
			val.DisplayTextSupplier = LoadShipEnergy;
			TerminalApi.AddCommand("load", val, (string)null, false);
		}

		public static string PrintShipEnergy()
		{
			//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)
			if (NetworkManager.Singleton.IsServer)
			{
				return "Ship energy: " + Plugin.EnergySystem().GetShipEnergy() + " E\n";
			}
			Plugin.EnergySystem().PrintShipEnergyServerRpc();
			return "";
		}

		public static string LoadShipEnergy()
		{
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			if (NetworkManager.Singleton.IsServer)
			{
				RoundManager val = Object.FindAnyObjectByType<RoundManager>();
				GrabbableObject[] array = (from obj in Object.FindObjectsOfType<GrabbableObject>()
					where obj.isInShipRoom && !obj.isHeld && ((object)obj.itemProperties).Equals((object?)Plugin.BatteryItem)
					select obj).ToArray();
				if (array.Length != 0)
				{
					GrabbableObject val2 = array[0];
					val.scrapCollectedThisRound.Remove(val2);
					Object.Destroy((Object)(object)((Component)val2).gameObject);
					EnergeticShipSystem energeticShipSystem = Plugin.EnergySystem();
					energeticShipSystem.AddShipEnergy(50f);
					energeticShipSystem.PlayConsumeBatterySoundClientRpc();
					return string.Format("Loaded battery\nShip energy is now {0} {1}\n", energeticShipSystem.GetShipEnergy(), "E");
				}
				return "No battery found in ship (mustn't be held by a player)\n";
			}
			Plugin.EnergySystem().LoadShipEnergyServerRpc();
			return "";
		}

		public static string ScaleMap()
		{
			//IL_0069: 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)
			if (NetworkManager.Singleton.IsServer)
			{
				if (!Actions.SCALE_MAP.EnoughEnergyToStart())
				{
					return "Not enough energy\n";
				}
				if (Actions.SCALE_MAP.IsActive())
				{
					Actions.SCALE_MAP.Stop();
					return "Disabled scaled map\n";
				}
				Actions.SCALE_MAP.Start();
				return "Enabled scaled map\n";
			}
			Plugin.EnergySystem().ScaleMapServerRpc();
			return "";
		}

		public static string TargetTeleporter()
		{
			//IL_0069: 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)
			if (NetworkManager.Singleton.IsServer)
			{
				if (!Actions.TARGET_TELEPORT.EnoughEnergyToStart())
				{
					return "Not enough energy\n";
				}
				if (Actions.TARGET_TELEPORT.IsActive())
				{
					Actions.TARGET_TELEPORT.Stop();
					return "Disabled targeted inverse teleporter\n";
				}
				Actions.TARGET_TELEPORT.Start();
				return "Enabled targeted inverse teleporter\n";
			}
			Plugin.EnergySystem().TargetTeleporterServerRpc();
			return "";
		}

		public static string KeepItemTeleporter()
		{
			//IL_0069: 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)
			if (NetworkManager.Singleton.IsServer)
			{
				if (Actions.KEEP_ITEMS_TELEPORT.IsActive())
				{
					Actions.KEEP_ITEMS_TELEPORT.Stop();
					return "Disabled keep item teleporter\n";
				}
				if (!Actions.KEEP_ITEMS_TELEPORT.EnoughEnergyToStart())
				{
					return "Not enough energy\n";
				}
				Actions.KEEP_ITEMS_TELEPORT.Start();
				return "Enabled keep item teleporter\n";
			}
			Plugin.EnergySystem().KeepItemTeleporterServerRpc();
			return "";
		}

		public static string SafetyGuard()
		{
			//IL_005d: 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)
			if (NetworkManager.Singleton.IsServer)
			{
				if (Actions.SAFETY_GUARD.IsActive())
				{
					return "Safety guard already enabled\n";
				}
				if (!Actions.SAFETY_GUARD.EnoughEnergyToStart())
				{
					return "Not enough energy\n";
				}
				Actions.SAFETY_GUARD.Start();
				return "Enabled safety guard\n";
			}
			Plugin.EnergySystem().SafetyGuardServerRpc();
			return "";
		}

		public static string ClearWeather()
		{
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			if (NetworkManager.Singleton.IsServer)
			{
				if (!Actions.DISABLE_WEATHER.EnoughEnergyToStart())
				{
					return "Not enough energy\n";
				}
				if (!StartOfRound.Instance.inShipPhase)
				{
					return "Can only be run from orbit\n";
				}
				Actions.DISABLE_WEATHER.Start();
				return "Cleared weather from " + ((Object)RoundManager.Instance.currentLevel).name + "\n";
			}
			Plugin.EnergySystem().ClearWeatherServerRpc();
			return "";
		}

		public static string TargetedBlast()
		{
			//IL_005d: 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)
			if (NetworkManager.Singleton.IsServer)
			{
				if (!Actions.TARGETED_BLAST.EnoughEnergyToStart())
				{
					return "Not enough energy\n";
				}
				if (StartOfRound.Instance.inShipPhase)
				{
					return "Can only be run on planet\n";
				}
				Actions.TARGETED_BLAST.Start();
				return "Issuing blasts...\n";
			}
			Plugin.EnergySystem().TargetedBlastServerRpc();
			return "";
		}
	}
	public class EnergeticShipSystem : NetworkBehaviour
	{
		public const string ENERGY_UNIT = "E";

		private NetworkVariable<float> shipEnergy = new NetworkVariable<float>(0f, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		private HashSet<Actions.Action> runningActions = new HashSet<Actions.Action>();

		public bool SafetyGuardRunning = false;

		private void Start()
		{
			Plugin.logger.LogInfo((object)"Loaded EnergeticShipSystem");
		}

		public void Save()
		{
			string currentSaveFileName = GameNetworkManager.Instance.currentSaveFileName;
			ES3.Save<int>("ShipEnergy", (int)shipEnergy.Value, currentSaveFileName);
			ES3.Save<bool>("ScaleMap", Actions.SCALE_MAP.IsActive(), currentSaveFileName);
			ES3.Save<bool>("TargetTeleport", Actions.TARGET_TELEPORT.IsActive(), currentSaveFileName);
			ES3.Save<bool>("KeepItemsTeleport", Actions.KEEP_ITEMS_TELEPORT.IsActive(), currentSaveFileName);
			ES3.Save<bool>("SafetyGuard", Actions.SAFETY_GUARD.IsActive(), currentSaveFileName);
		}

		public void Load()
		{
			string currentSaveFileName = GameNetworkManager.Instance.currentSaveFileName;
			shipEnergy.Value = ES3.Load<int>("ShipEnergy", currentSaveFileName, 0);
			ResumeAction("ScaleMap", Actions.SCALE_MAP, currentSaveFileName);
			ResumeAction("TargetTeleport", Actions.TARGET_TELEPORT, currentSaveFileName);
			ResumeAction("KeepItemsTeleport", Actions.KEEP_ITEMS_TELEPORT, currentSaveFileName);
			ResumeAction("SafetyGuard", Actions.SAFETY_GUARD, currentSaveFileName);
		}

		private void ResumeAction(string id, Actions.Action action, string saveFile)
		{
			if (ES3.Load<bool>(id, saveFile, false))
			{
				action.Start(resume: true);
			}
		}

		public override void OnNetworkSpawn()
		{
			if (!((NetworkBehaviour)this).IsServer)
			{
				((Object)((Component)this).gameObject).hideFlags = (HideFlags)0;
			}
		}

		public void ScheduleAction(Actions.Action action)
		{
			runningActions.Add(action);
		}

		public void UnscheduleAction(Actions.Action action)
		{
			runningActions.Remove(action);
		}

		private void Update()
		{
			foreach (Actions.Action runningAction in runningActions)
			{
				runningAction.elapsedSeconds += Time.deltaTime;
				if (runningAction.elapsedSeconds > 60f)
				{
					float num = (float)Math.Floor(runningAction.elapsedSeconds / 60f);
					shipEnergy.Value = Math.Max(shipEnergy.Value - num * runningAction.energyUsage, 0f);
					runningAction.elapsedSeconds %= 60f;
				}
			}
			if (shipEnergy.Value != 0f)
			{
				return;
			}
			foreach (Actions.Action runningAction2 in runningActions)
			{
				runningAction2.Stop();
			}
		}

		public float GetShipEnergy()
		{
			return shipEnergy.Value;
		}

		public void AddShipEnergy(float energy)
		{
			if (((NetworkBehaviour)this).IsServer)
			{
				NetworkVariable<float> obj = shipEnergy;
				obj.Value += energy;
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void PrintShipEnergyServerRpc(ServerRpcParams serverRpcParams = default(ServerRpcParams))
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_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)
			//IL_00c2: 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))
				{
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(327099819u, serverRpcParams, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendServerRpc(ref val, 327099819u, serverRpcParams, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					PrintToConsoleOnClient(Commands.PrintShipEnergy(), serverRpcParams);
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void LoadShipEnergyServerRpc(ServerRpcParams serverRpcParams = default(ServerRpcParams))
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_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)
			//IL_00c2: 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))
				{
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(1719844743u, serverRpcParams, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendServerRpc(ref val, 1719844743u, serverRpcParams, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					PrintToConsoleOnClient(Commands.LoadShipEnergy(), serverRpcParams);
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void ScaleMapServerRpc(ServerRpcParams serverRpcParams = default(ServerRpcParams))
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_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)
			//IL_00c2: 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))
				{
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(2268540407u, serverRpcParams, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendServerRpc(ref val, 2268540407u, serverRpcParams, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					PrintToConsoleOnClient(Commands.ScaleMap(), serverRpcParams);
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void TargetTeleporterServerRpc(ServerRpcParams serverRpcParams = default(ServerRpcParams))
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_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)
			//IL_00c2: 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))
				{
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(453839098u, serverRpcParams, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendServerRpc(ref val, 453839098u, serverRpcParams, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					PrintToConsoleOnClient(Commands.TargetTeleporter(), serverRpcParams);
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void KeepItemTeleporterServerRpc(ServerRpcParams serverRpcParams = default(ServerRpcParams))
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_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)
			//IL_00c2: 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))
				{
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(2328724554u, serverRpcParams, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendServerRpc(ref val, 2328724554u, serverRpcParams, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					PrintToConsoleOnClient(Commands.KeepItemTeleporter(), serverRpcParams);
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void SafetyGuardServerRpc(ServerRpcParams serverRpcParams = default(ServerRpcParams))
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_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)
			//IL_00c2: 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))
				{
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(3446508352u, serverRpcParams, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendServerRpc(ref val, 3446508352u, serverRpcParams, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					PrintToConsoleOnClient(Commands.SafetyGuard(), serverRpcParams);
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void DisableSafetyGuardServerRpc(ServerRpcParams serverRpcParams = default(ServerRpcParams))
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_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))
				{
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(329466118u, serverRpcParams, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendServerRpc(ref val, 329466118u, serverRpcParams, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					SafetyGuardClientRpc(active: false);
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void ClearWeatherServerRpc(ServerRpcParams serverRpcParams = default(ServerRpcParams))
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_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)
			//IL_00c2: 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))
				{
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(596058619u, serverRpcParams, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendServerRpc(ref val, 596058619u, serverRpcParams, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					PrintToConsoleOnClient(Commands.ClearWeather(), serverRpcParams);
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void TargetedBlastServerRpc(ServerRpcParams serverRpcParams = default(ServerRpcParams))
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_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)
			//IL_00c2: 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))
				{
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(1663088082u, serverRpcParams, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendServerRpc(ref val, 1663088082u, serverRpcParams, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					PrintToConsoleOnClient(Commands.TargetedBlast(), serverRpcParams);
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void AskToBeamUpPlayerServerRpc(ServerRpcParams serverRpcParams = default(ServerRpcParams))
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_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)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: 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))
				{
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(757558856u, serverRpcParams, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendServerRpc(ref val, 757558856u, serverRpcParams, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					ulong senderClientId = serverRpcParams.Receive.SenderClientId;
					Plugin.logger.LogInfo((object)string.Format("[{0}]: Got request to beam up from {1}", NetworkManager.Singleton.IsServer ? "Server" : "Client", senderClientId));
					ClientRpcParams val2 = default(ClientRpcParams);
					val2.Send = new ClientRpcSendParams
					{
						TargetClientIds = new ulong[1] { senderClientId }
					};
					ClientRpcParams clientRpcParams = val2;
					Actions.KeepItemsNormalTeleportCallback(senderClientId);
					AllowToBeamUpPlayerClientRpc(clientRpcParams);
				}
			}
		}

		private void PrintToConsoleOnClient(string text, ServerRpcParams serverRpcParams)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: 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_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: 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_0051: Unknown result type (might be due to invalid IL or missing references)
			ulong senderClientId = serverRpcParams.Receive.SenderClientId;
			if (((NetworkBehaviour)this).NetworkManager.ConnectedClients.ContainsKey(senderClientId))
			{
				ClientRpcParams val = default(ClientRpcParams);
				val.Send = new ClientRpcSendParams
				{
					TargetClientIds = new ulong[1] { senderClientId }
				};
				ClientRpcParams clientRpcParams = val;
				PrintOnConsoleClientRpc(text, clientRpcParams);
			}
		}

		[ClientRpc]
		private void PrintOnConsoleClientRpc(string text, ClientRpcParams clientRpcParams = default(ClientRpcParams))
		{
			//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))
			{
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(179660411u, clientRpcParams, (RpcDelivery)0);
				bool flag = text != null;
				((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val)).WriteValueSafe(text, false);
				}
				((NetworkBehaviour)this).__endSendClientRpc(ref val, 179660411u, clientRpcParams, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				Terminal terminal = TerminalApi.Terminal;
				terminal.modifyingText = true;
				terminal.screenText.text = terminal.screenText.text.Substring(0, terminal.screenText.text.Length - terminal.textAdded);
				terminal.currentText = terminal.screenText.text;
				terminal.screenText.text = terminal.screenText.text + text;
				terminal.currentText = terminal.screenText.text;
				terminal.textAdded = 0;
			}
		}

		[ClientRpc]
		public void ScaleMapClientRpc(float scale)
		{
			//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(3673020210u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref scale, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3673020210u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					Actions.ScaleMap(scale);
				}
			}
		}

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

		[ClientRpc]
		public void SpawnExplosionClientRpc(Vector3 pos)
		{
			//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_0089: 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)
			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(3574048784u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe(ref pos);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3574048784u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					Actions.SpawnBlastExplosion(pos);
				}
			}
		}

		[ClientRpc]
		public void SafetyGuardClientRpc(bool active)
		{
			//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(1354440091u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref active, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1354440091u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && !NetworkManager.Singleton.IsServer)
			{
				if (active)
				{
					Actions.SAFETY_GUARD.Start();
				}
				else
				{
					Actions.SAFETY_GUARD.Stop();
				}
			}
		}

		[ClientRpc]
		public void AdjustFlagsAfterTeleportPlayerOutClientRpc(int teleportedPlayerObj, int teleportTargetPlayerObj)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: 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_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			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(2953186452u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, teleportedPlayerObj);
					BytePacker.WriteValueBitPacked(val2, teleportTargetPlayerObj);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2953186452u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					Plugin.logger.LogInfo((object)string.Format("[{0}]: Adjust flags for {1} to those of {2}", NetworkManager.Singleton.IsServer ? "Server" : "Client", teleportedPlayerObj, teleportTargetPlayerObj));
					PlayerControllerB val3 = StartOfRound.Instance.allPlayerScripts[teleportedPlayerObj];
					PlayerControllerB val4 = StartOfRound.Instance.allPlayerScripts[teleportTargetPlayerObj];
					val3.isInElevator = val4.isInElevator;
					val3.isInHangarShipRoom = val4.isInHangarShipRoom;
					val3.isInsideFactory = val4.isInsideFactory;
				}
			}
		}

		[ClientRpc]
		public void AllowToKeepSomeItemsOnTeleportClientRpc(int firstSlot, int secondSlot)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: 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_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			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(1530522610u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, firstSlot);
					BytePacker.WriteValueBitPacked(val2, secondSlot);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1530522610u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					Actions.AllowToKeepSomeItems(firstSlot, secondSlot);
				}
			}
		}

		[ClientRpc]
		public void AllowToBeamUpPlayerClientRpc(ClientRpcParams clientRpcParams = default(ClientRpcParams))
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(3731298290u, clientRpcParams, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val, 3731298290u, clientRpcParams, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					Plugin.logger.LogInfo((object)("[" + (NetworkManager.Singleton.IsServer ? "Server" : "Client") + "]: Received beam up permisson rpc"));
					Actions.AllowToBeamUpPlayer();
				}
			}
		}

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

		[ClientRpc]
		public void PlayTriggerSafetyGuardSoundClientRpc(int playerIndex)
		{
			//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(1607310359u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, playerIndex);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1607310359u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					StartOfRound.Instance.allPlayerScripts[playerIndex].statusEffectAudio.PlayOneShot(Plugin.TriggerSafetyGuard);
				}
			}
		}

		protected override void __initializeVariables()
		{
			if (shipEnergy == null)
			{
				throw new Exception("EnergeticShipSystem.shipEnergy cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)shipEnergy).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)shipEnergy, "shipEnergy");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)shipEnergy);
			((NetworkBehaviour)this).__initializeVariables();
		}

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_EnergeticShipSystem()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Expected O, but got Unknown
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Expected O, but got Unknown
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Expected O, but got Unknown
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Expected O, but got Unknown
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Expected O, but got Unknown
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Expected O, but got Unknown
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Expected O, but got Unknown
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Expected O, but got Unknown
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Expected O, but got Unknown
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Expected O, but got Unknown
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Expected O, but got Unknown
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Expected O, but got Unknown
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Expected O, but got Unknown
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(327099819u, new RpcReceiveHandler(__rpc_handler_327099819));
			NetworkManager.__rpc_func_table.Add(1719844743u, new RpcReceiveHandler(__rpc_handler_1719844743));
			NetworkManager.__rpc_func_table.Add(2268540407u, new RpcReceiveHandler(__rpc_handler_2268540407));
			NetworkManager.__rpc_func_table.Add(453839098u, new RpcReceiveHandler(__rpc_handler_453839098));
			NetworkManager.__rpc_func_table.Add(2328724554u, new RpcReceiveHandler(__rpc_handler_2328724554));
			NetworkManager.__rpc_func_table.Add(3446508352u, new RpcReceiveHandler(__rpc_handler_3446508352));
			NetworkManager.__rpc_func_table.Add(329466118u, new RpcReceiveHandler(__rpc_handler_329466118));
			NetworkManager.__rpc_func_table.Add(596058619u, new RpcReceiveHandler(__rpc_handler_596058619));
			NetworkManager.__rpc_func_table.Add(1663088082u, new RpcReceiveHandler(__rpc_handler_1663088082));
			NetworkManager.__rpc_func_table.Add(757558856u, new RpcReceiveHandler(__rpc_handler_757558856));
			NetworkManager.__rpc_func_table.Add(179660411u, new RpcReceiveHandler(__rpc_handler_179660411));
			NetworkManager.__rpc_func_table.Add(3673020210u, new RpcReceiveHandler(__rpc_handler_3673020210));
			NetworkManager.__rpc_func_table.Add(2541718605u, new RpcReceiveHandler(__rpc_handler_2541718605));
			NetworkManager.__rpc_func_table.Add(3574048784u, new RpcReceiveHandler(__rpc_handler_3574048784));
			NetworkManager.__rpc_func_table.Add(1354440091u, new RpcReceiveHandler(__rpc_handler_1354440091));
			NetworkManager.__rpc_func_table.Add(2953186452u, new RpcReceiveHandler(__rpc_handler_2953186452));
			NetworkManager.__rpc_func_table.Add(1530522610u, new RpcReceiveHandler(__rpc_handler_1530522610));
			NetworkManager.__rpc_func_table.Add(3731298290u, new RpcReceiveHandler(__rpc_handler_3731298290));
			NetworkManager.__rpc_func_table.Add(2322007611u, new RpcReceiveHandler(__rpc_handler_2322007611));
			NetworkManager.__rpc_func_table.Add(1607310359u, new RpcReceiveHandler(__rpc_handler_1607310359));
		}

		private static void __rpc_handler_327099819(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_0033: 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_004d: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ServerRpcParams server = rpcParams.Server;
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((EnergeticShipSystem)(object)target).PrintShipEnergyServerRpc(server);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1719844743(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_0033: 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_004d: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ServerRpcParams server = rpcParams.Server;
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((EnergeticShipSystem)(object)target).LoadShipEnergyServerRpc(server);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2268540407(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_0033: 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_004d: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ServerRpcParams server = rpcParams.Server;
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((EnergeticShipSystem)(object)target).ScaleMapServerRpc(server);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_453839098(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_0033: 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_004d: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ServerRpcParams server = rpcParams.Server;
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((EnergeticShipSystem)(object)target).TargetTeleporterServerRpc(server);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2328724554(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_0033: 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_004d: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ServerRpcParams server = rpcParams.Server;
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((EnergeticShipSystem)(object)target).KeepItemTeleporterServerRpc(server);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3446508352(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_0033: 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_004d: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ServerRpcParams server = rpcParams.Server;
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((EnergeticShipSystem)(object)target).SafetyGuardServerRpc(server);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_329466118(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_0033: 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_004d: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ServerRpcParams server = rpcParams.Server;
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((EnergeticShipSystem)(object)target).DisableSafetyGuardServerRpc(server);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_596058619(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_0033: 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_004d: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ServerRpcParams server = rpcParams.Server;
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((EnergeticShipSystem)(object)target).ClearWeatherServerRpc(server);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1663088082(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_0033: 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_004d: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ServerRpcParams server = rpcParams.Server;
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((EnergeticShipSystem)(object)target).TargetedBlastServerRpc(server);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_757558856(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_0033: 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_004d: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ServerRpcParams server = rpcParams.Server;
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((EnergeticShipSystem)(object)target).AskToBeamUpPlayerServerRpc(server);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_179660411(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_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: 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_0089: 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 text = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref text, false);
				}
				ClientRpcParams client = rpcParams.Client;
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((EnergeticShipSystem)(object)target).PrintOnConsoleClientRpc(text, client);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3673020210(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)
			{
				float scale = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref scale, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((EnergeticShipSystem)(object)target).ScaleMapClientRpc(scale);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

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

		private static void __rpc_handler_3574048784(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: 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)
			{
				Vector3 pos = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref pos);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((EnergeticShipSystem)(object)target).SpawnExplosionClientRpc(pos);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1354440091(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 active = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref active, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((EnergeticShipSystem)(object)target).SafetyGuardClientRpc(active);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2953186452(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int teleportedPlayerObj = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref teleportedPlayerObj);
				int teleportTargetPlayerObj = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref teleportTargetPlayerObj);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((EnergeticShipSystem)(object)target).AdjustFlagsAfterTeleportPlayerOutClientRpc(teleportedPlayerObj, teleportTargetPlayerObj);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1530522610(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int firstSlot = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref firstSlot);
				int secondSlot = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref secondSlot);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((EnergeticShipSystem)(object)target).AllowToKeepSomeItemsOnTeleportClientRpc(firstSlot, secondSlot);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3731298290(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_0033: 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_004d: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ClientRpcParams client = rpcParams.Client;
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((EnergeticShipSystem)(object)target).AllowToBeamUpPlayerClientRpc(client);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

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

		private static void __rpc_handler_1607310359(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 playerIndex = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerIndex);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((EnergeticShipSystem)(object)target).PlayTriggerSafetyGuardSoundClientRpc(playerIndex);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "EnergeticShipSystem";
		}
	}
	[BepInPlugin("EnergeticShip", "EnergeticShip", "0.2.3")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency("atomic.terminalapi", "1.5.0")]
	public class Plugin : BaseUnityPlugin
	{
		public const bool DEBUG = false;

		private static GameObject energeticShipSystemObjectPrefab;

		private static GameObject TargetBeaconRadarIconPrefab;

		private static AssetBundle assetBundle;

		public static ManualLogSource logger;

		public static Item BatteryItem;

		public static Item TargetBeaconItem;

		public static AudioClip ConsumeBattery;

		public static AudioClip TriggerSafetyGuard;

		public static AudioClip BlastBuildup;

		private static EnergeticShipSystem energyShipSystem;

		private void Awake()
		{
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Expected O, but got Unknown
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Expected O, but got Unknown
			logger = ((BaseUnityPlugin)this).Logger;
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin EnergeticShip is loaded!");
			RunNetCodeSetup();
			LoadAssetBundle();
			RegisterItems();
			ConsumeBattery = assetBundle.LoadAsset<AudioClip>("battery_consumption");
			TriggerSafetyGuard = assetBundle.LoadAsset<AudioClip>("trigger_safety_guard");
			BlastBuildup = assetBundle.LoadAsset<AudioClip>("blast_buildup");
			Commands.InitCommands();
			Actions.InitActions();
			StartOfRound.Start += new hook_Start(RegisterEnergyShipSystem);
			bool flag = false;
			GameNetworkManager.SaveGame += new hook_SaveGame(OnGameSave);
			energeticShipSystemObjectPrefab = NetworkPrefabs.CreateNetworkPrefab("EnergeticShipSystem");
			((Object)energeticShipSystemObjectPrefab).hideFlags = (HideFlags)52;
			energeticShipSystemObjectPrefab.AddComponent<EnergeticShipSystem>();
			NetworkObject component = energeticShipSystemObjectPrefab.GetComponent<NetworkObject>();
			component.DestroyWithScene = true;
			component.DontDestroyWithOwner = true;
		}

		public static EnergeticShipSystem EnergySystem()
		{
			if ((Object)(object)energyShipSystem == (Object)null)
			{
				energyShipSystem = Object.FindObjectOfType<EnergeticShipSystem>();
			}
			return energyShipSystem;
		}

		private void MONEY(orig_Start orig, Terminal self)
		{
			orig.Invoke(self);
			self.groupCredits = 1000;
		}

		private void RunNetCodeSetup()
		{
			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);
					}
				}
			}
		}

		private void LoadAssetBundle()
		{
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			assetBundle = AssetBundle.LoadFromFile(Path.Combine(directoryName, "energeticship_assets"));
			if ((Object)(object)assetBundle == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"Failed to load custom assets.");
			}
			else
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Loaded asset bundle");
			}
		}

		private void RegisterItems()
		{
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Expected O, but got Unknown
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Expected O, but got Unknown
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Expected O, but got Unknown
			int num = 30;
			BatteryItem = assetBundle.LoadAsset<Item>("Battery");
			NetworkPrefabs.RegisterNetworkPrefab(BatteryItem.spawnPrefab);
			Items.RegisterScrap(BatteryItem, num, (LevelTypes)(-1));
			Items.RegisterShopItem(BatteryItem, (TerminalNode)null, (TerminalNode)null, TerminalApi.CreateTerminalNode("A battery containing pure plasma empowering the ships systems", false, ""), 250);
			TargetBeaconItem = assetBundle.LoadAsset<Item>("TargetBeacon");
			NetworkPrefabs.RegisterNetworkPrefab(TargetBeaconItem.spawnPrefab);
			Items.RegisterItem(TargetBeaconItem);
			Items.RegisterShopItem(TargetBeaconItem, (Ter