Decompiled source of ShipInventory v1.1.6

WarperSan-ShipInventory/ShipInventory.dll

Decompiled a week 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.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using CSync.Extensions;
using CSync.Lib;
using GameNetcodeStuff;
using HarmonyLib;
using InteractiveTerminalAPI.Compat;
using InteractiveTerminalAPI.UI;
using InteractiveTerminalAPI.UI.Application;
using InteractiveTerminalAPI.UI.Cursor;
using InteractiveTerminalAPI.UI.Page;
using InteractiveTerminalAPI.UI.Screen;
using LethalConfig;
using LethalConfig.ConfigItems;
using LethalConfig.ConfigItems.Options;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json.Linq;
using ShipInventory.Applications;
using ShipInventory.Compatibility;
using ShipInventory.Helpers;
using ShipInventory.NetcodePatcher;
using ShipInventory.Objects;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.InputSystem;

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

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

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

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace ShipInventory
{
	public class Config : SyncedConfig2<Config>
	{
		public enum OverrideMode
		{
			NONE,
			NEVER,
			ALL
		}

		public enum PermissionLevel
		{
			HOST_ONLY,
			CLIENTS_ONLY,
			EVERYONE,
			NO_ONE
		}

		public readonly ConfigEntry<string> LangUsed;

		[SyncedEntryField]
		public readonly SyncedEntry<string> Blacklist;

		[SyncedEntryField]
		public readonly SyncedEntry<float> SpawnDelay;

		[SyncedEntryField]
		public readonly SyncedEntry<bool> RequireInOrbit;

		[SyncedEntryField]
		public readonly SyncedEntry<int> StopAfter;

		[SyncedEntryField]
		public readonly SyncedEntry<PermissionLevel> ChutePermission;

		[SyncedEntryField]
		public readonly SyncedEntry<bool> ActAsSafe;

		[SyncedEntryField]
		public readonly SyncedEntry<int> MaxItemCount;

		[SyncedEntryField]
		public readonly SyncedEntry<bool> PersistThroughFire;

		[SyncedEntryField]
		public readonly SyncedEntry<PermissionLevel> InventoryPermission;

		[SyncedEntryField]
		public readonly SyncedEntry<bool> ShowConfirmation;

		[SyncedEntryField]
		public readonly SyncedEntry<bool> YesPlease;

		[SyncedEntryField]
		public readonly SyncedEntry<bool> ShowTrademark;

		[SyncedEntryField]
		public readonly SyncedEntry<OverrideMode> OverrideTrigger;

		public Config(ConfigFile cfg)
			: base("ShipInventory")
		{
			//IL_004d: 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)
			//IL_0071: Expected O, but got Unknown
			//IL_0071: Expected O, but got Unknown
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Expected O, but got Unknown
			//IL_00de: Expected O, but got Unknown
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Expected O, but got Unknown
			//IL_010b: Expected O, but got Unknown
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Expected O, but got Unknown
			//IL_0139: Expected O, but got Unknown
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Expected O, but got Unknown
			//IL_0166: Expected O, but got Unknown
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Expected O, but got Unknown
			//IL_019e: Expected O, but got Unknown
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Expected O, but got Unknown
			//IL_01cf: Expected O, but got Unknown
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Expected O, but got Unknown
			//IL_01fc: Expected O, but got Unknown
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_021f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Expected O, but got Unknown
			//IL_0229: Expected O, but got Unknown
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Expected O, but got Unknown
			//IL_0261: Expected O, but got Unknown
			//IL_026e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0284: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Expected O, but got Unknown
			//IL_028e: Expected O, but got Unknown
			//IL_029b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: Expected O, but got Unknown
			//IL_02bb: Expected O, but got Unknown
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0307: Expected O, but got Unknown
			//IL_0307: Expected O, but got Unknown
			LangUsed = cfg.Bind<string>("Language", "Lang", "en", (ConfigDescription)null);
			Lang.LoadLang(LangUsed.Value);
			string text = Lang.Get("CHUTE_SECTION");
			Blacklist = SyncedBindingExtensions.BindSyncedEntry<string>(cfg, new ConfigDefinition(text, "ChuteBlacklist"), "", new ConfigDescription(Lang.Get("DESCRIPTION_BLACKLIST"), (AcceptableValueBase)null, Array.Empty<object>()));
			Blacklist.Changed += delegate(object _, SyncedSettingChangedEventArgs<string> e)
			{
				ItemManager.UpdateBlacklist(e.NewValue);
			};
			ItemManager.UpdateBlacklist(Blacklist.Value);
			SpawnDelay = SyncedBindingExtensions.BindSyncedEntry<float>(cfg, new ConfigDefinition(text, "ChuteDelay"), 0.5f, new ConfigDescription(Lang.Get("DESCRIPTION_SPAWN_DELAY"), (AcceptableValueBase)null, Array.Empty<object>()));
			RequireInOrbit = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, new ConfigDefinition(text, "ChuteInOrbit"), false, new ConfigDescription(Lang.Get("DESCRIPTION_REQUIRE_IN_ORBIT"), (AcceptableValueBase)null, Array.Empty<object>()));
			StopAfter = SyncedBindingExtensions.BindSyncedEntry<int>(cfg, new ConfigDefinition(text, "ChuteMaxCapacity"), 30, new ConfigDescription(Lang.Get("DESCRIPTION_STOP_AFTER"), (AcceptableValueBase)null, Array.Empty<object>()));
			ChutePermission = SyncedBindingExtensions.BindSyncedEntry<PermissionLevel>(cfg, new ConfigDefinition(text, "ChutePermission"), PermissionLevel.EVERYONE, new ConfigDescription(Lang.Get("DESCRIPTION_CHUTE_PERMISSION"), (AcceptableValueBase)null, Array.Empty<object>()));
			string text2 = Lang.Get("INVENTORY_SECTION");
			ActAsSafe = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, new ConfigDefinition(text2, "ChuteSafe"), false, new ConfigDescription(Lang.Get("DESCRIPTION_AS_SAFE"), (AcceptableValueBase)null, Array.Empty<object>()));
			MaxItemCount = SyncedBindingExtensions.BindSyncedEntry<int>(cfg, new ConfigDefinition(text2, "MaxItemCount"), 1969420, new ConfigDescription(Lang.Get("DESCRIPTION_MAX_ITEM_COUNT"), (AcceptableValueBase)null, Array.Empty<object>()));
			PersistThroughFire = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, new ConfigDefinition(text2, "PersistThroughFire"), false, new ConfigDescription(Lang.Get("DESCRIPTION_PERSIST_THROUGH_FIRE"), (AcceptableValueBase)null, Array.Empty<object>()));
			InventoryPermission = SyncedBindingExtensions.BindSyncedEntry<PermissionLevel>(cfg, new ConfigDefinition(text2, "InventoryPermission"), PermissionLevel.EVERYONE, new ConfigDescription(Lang.Get("DESCRIPTION_INVENTORY_PERMISSION"), (AcceptableValueBase)null, Array.Empty<object>()));
			string text3 = Lang.Get("TERMINAL_SECTION");
			ShowConfirmation = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, new ConfigDefinition(text3, "ShowConfirmation"), true, new ConfigDescription(Lang.Get("DESCRIPTION_SHOW_CONFIRMATION"), (AcceptableValueBase)null, Array.Empty<object>()));
			YesPlease = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, new ConfigDefinition(text3, "YesPlease"), false, new ConfigDescription(Lang.Get("DESCRIPTION_YES_PLEASE"), (AcceptableValueBase)null, Array.Empty<object>()));
			ShowTrademark = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, new ConfigDefinition(text3, "ShowTrademark"), true, new ConfigDescription(Lang.Get("DESCRIPTION_SHOW_TRADEMARK"), (AcceptableValueBase)null, Array.Empty<object>()));
			string text4 = Lang.Get("DEBUG_SECTION");
			OverrideTrigger = SyncedBindingExtensions.BindSyncedEntry<OverrideMode>(cfg, new ConfigDefinition(text4, "OverrideTrigger"), OverrideMode.NONE, new ConfigDescription(string.Format(Lang.Get("DESCRIPTION_OVERRIDE_TRIGGER"), "NONE", "NEVER", "ALL"), (AcceptableValueBase)null, Array.Empty<object>()));
			if (LethalConfigCompatibility.enabled)
			{
				LethalConfigCompatibility.AddConfigs(this);
			}
		}
	}
	public static class Constants
	{
		public const string SHIP_PATH = "Environment/HangarShip";

		public const string STORED_ITEMS = "shipInventoryItems";

		public const string VENT_PREFAB = "VentChute";

		public const string MOD_ICON = "icon";

		public const string BUNDLE = "ShipInventory.Resources.si-bundle";

		public const string LAYER_PROPS = "Props";

		public const string LAYER_IGNORE = "Ignore Raycast";

		public const string LAYER_INTERACTABLE = "InteractableObject";

		public const int ITEMS_PER_PAGE = 10;
	}
	[BepInPlugin("ShipInventory", "ShipInventory", "1.1.5")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency("com.sigurd.csync", "5.0.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class ShipInventory : BaseUnityPlugin
	{
		public static Config Config;

		private static Harmony? Harmony { get; set; }

		private void Awake()
		{
			Logger.SetLogger(((BaseUnityPlugin)this).Logger);
			if (!Bundle.LoadBundle("ShipInventory.Resources.si-bundle"))
			{
				Logger.Error("Failed to load the bundle. This mod will not continue further.");
				return;
			}
			Config = new Config(((BaseUnityPlugin)this).Config);
			PrepareNetwork();
			Patch();
			InteractiveTerminalManager.RegisterApplication<ShipApplication>("ship", true);
			Logger.Info("ShipInventory v1.1.5 has loaded!");
		}

		private static void Patch()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			Logger.Debug("Patching...");
			if (Harmony == null)
			{
				Harmony = new Harmony("ShipInventory");
			}
			Harmony.PatchAll();
			Logger.Debug("Finished patching!");
		}

		private static void PrepareNetwork()
		{
			Logger.Debug("Prepare RPCs...");
			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);
					}
				}
			}
			Logger.Debug("RPCs prepared!");
			Logger.Debug("Loading all prefabs...");
			NetworkPrefabUtils.PrefabData prefabData = new NetworkPrefabUtils.PrefabData();
			prefabData.name = "VentChute";
			prefabData.onLoad = LoadVent;
			prefabData.onSetup = SetUpVent;
			NetworkPrefabUtils.LoadPrefab(prefabData);
			Logger.Debug("All prefabs loaded!");
		}

		private static void LoadVent(GameObject obj)
		{
			obj.AddComponent<ChuteInteract>();
			Item val = ScriptableObject.CreateInstance<Item>();
			val.isScrap = true;
			val.lockedInDemo = true;
			val.itemName = "VENT_CHUTE";
			val.spawnPrefab = NetworkPrefabUtils.GetPrefab("VentChute");
			val.saveItemVariable = true;
		}

		private static void SetUpVent(GameObject vent)
		{
			//IL_004d: 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)
			ChuteInteract chuteInteract = (ChuteInteract.Instance = vent.GetComponent<ChuteInteract>());
			InteractTrigger component = ((Component)chuteInteract).GetComponent<InteractTrigger>();
			((UnityEvent<PlayerControllerB>)(object)component.onInteract).AddListener((UnityAction<PlayerControllerB>)chuteInteract.StoreHeldItem);
			component.timeToHold = 0.5f;
			vent.transform.localPosition = new Vector3(1.9f, 1f, -4.5f);
			vent.transform.localRotation = Quaternion.Euler(35f, 0f, 0f);
			chuteInteract.UpdateValue();
		}

		public static void PrepareItems()
		{
			Logger.Debug("Preparing items...");
			Item[] array = Resources.FindObjectsOfTypeAll<Item>();
			foreach (Item val in array)
			{
				if (!((Object)(object)val.spawnPrefab == (Object)null))
				{
					GrabbableObject component = val.spawnPrefab.GetComponent<GrabbableObject>();
					if (!((Object)(object)component == (Object)null) && !(component is RagdollGrabbableObject))
					{
						Logger.Debug($"Adding the item '{val.itemName}' with the ID '{((Object)val).GetInstanceID()}'.");
						ItemManager.ALLOWED_ITEMS.TryAdd(((Object)val).GetInstanceID(), val);
					}
				}
			}
			Logger.Debug("Items prepared!");
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "ShipInventory";

		public const string PLUGIN_NAME = "ShipInventory";

		public const string PLUGIN_VERSION = "1.1.5";
	}
}
namespace ShipInventory.Patches
{
	[HarmonyPatch(typeof(GameNetworkManager))]
	public class GameNetworkManager_Patches
	{
		[HarmonyPrefix]
		[HarmonyPatch("SaveItemsInShip")]
		private static void SaveChuteItems(GameNetworkManager __instance)
		{
			ES3.DeleteKey("shipGrabbableItemIDs", __instance.currentSaveFileName);
			ES3.DeleteKey("shipGrabbableItemPos", __instance.currentSaveFileName);
			ES3.DeleteKey("shipScrapValues", __instance.currentSaveFileName);
			ES3.DeleteKey("shipItemSaveData", __instance.currentSaveFileName);
			Logger.Debug("Saving chute items...");
			IEnumerable<ItemData> items = ItemManager.GetItems();
			if (items.Any())
			{
				ES3.Save<ItemData[]>("shipInventoryItems", items.ToArray(), __instance.currentSaveFileName);
			}
			else
			{
				ES3.DeleteKey("shipInventoryItems", __instance.currentSaveFileName);
			}
			Logger.Debug("Chute items saved!");
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	public class PlayerControllerB_Patches
	{
		[HarmonyPostfix]
		[HarmonyPatch("ConnectClientToPlayerObject")]
		private static void RequestOnConnect(PlayerControllerB __instance)
		{
			ShipInventory.PrepareItems();
			if (!((NetworkBehaviour)__instance).IsHost)
			{
				ChuteInteract.Instance?.RequestItems();
			}
		}
	}
	[HarmonyPatch(typeof(RoundManager))]
	public class RoundManager_Patches
	{
		[HarmonyPostfix]
		[HarmonyPatch("DespawnPropsAtEndOfRound")]
		private static void ClearInventory(RoundManager __instance)
		{
			if (((NetworkBehaviour)__instance).IsServer)
			{
				List<ItemData> list = ItemManager.GetItems().ToList();
				for (int i = 0; i < list.Count; i++)
				{
					ItemData value = list[i];
					value.PERSISTED_THROUGH_ROUNDS = true;
					list[i] = value;
				}
				if (StartOfRound.Instance.allPlayersDead && !ShipInventory.Config.ActAsSafe.Value)
				{
					list.Clear();
					Logger.Debug("Clearing the ship...");
				}
				ItemManager.SetItems(list, updateAll: true);
			}
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRound_Patches
	{
		[HarmonyPostfix]
		[HarmonyPatch("LoadShipGrabbableItems")]
		private static void LoadStoredItems()
		{
			if (!ES3.KeyExists("shipInventoryItems", GameNetworkManager.Instance.currentSaveFileName))
			{
				ItemManager.SetItems(Array.Empty<ItemData>());
				return;
			}
			Logger.Debug("Loading stored items...");
			ItemManager.SetItems(ES3.Load<ItemData[]>("shipInventoryItems", GameNetworkManager.Instance.currentSaveFileName));
			Logger.Debug("Loaded stored items!");
		}

		[HarmonyPostfix]
		[HarmonyPatch("ResetShip")]
		private static void ResetInventory()
		{
			if (!ShipInventory.Config.PersistThroughFire.Value)
			{
				ItemManager.SetItems(Array.Empty<ItemData>());
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("GetValueOfAllScrap")]
		private static void GetValueOfAllScrap(ref int __result, bool onlyScrapCollected, bool onlyNewScrap)
		{
			foreach (ItemData item2 in ItemManager.GetItems())
			{
				if (!item2.PERSISTED_THROUGH_ROUNDS)
				{
					Item item = item2.GetItem();
					if (!((Object)(object)item == (Object)null) && item.isScrap)
					{
						__result += item2.SCRAP_VALUE;
					}
				}
			}
		}
	}
}
namespace ShipInventory.Objects
{
	public class ChuteInteract : NetworkBehaviour
	{
		public static ChuteInteract? Instance;

		private Transform itemRestorePoint = null;

		private ParticleSystem spawnParticles = null;

		private readonly Queue<ItemData> spawnQueue = new Queue<ItemData>();

		private Coroutine? spawnCoroutine;

		private Collider[] itemsInChute = Array.Empty<Collider>();

		private InteractTrigger _trigger = null;

		public override void OnNetworkSpawn()
		{
			_trigger = ((Component)this).GetComponent<InteractTrigger>();
			itemRestorePoint = ((Component)this).transform.Find("DropNode");
			spawnParticles = ((Component)this).GetComponentInChildren<ParticleSystem>();
			((NetworkBehaviour)this).OnNetworkSpawn();
		}

		public void UpdateValue()
		{
			GrabbableObject component = ((Component)this).GetComponent<GrabbableObject>();
			if (!((Object)(object)component == (Object)null))
			{
				component.scrapValue = ItemManager.GetTotalValue();
				component.OnHitGround();
			}
		}

		public void StoreHeldItem(PlayerControllerB player)
		{
			GrabbableObject currentlyHeldObjectServer = player.currentlyHeldObjectServer;
			if (currentlyHeldObjectServer == null)
			{
				Logger.Info("Player '" + player.playerUsername + "' is not holding any item.");
				return;
			}
			ItemManager.StoreItem(currentlyHeldObjectServer);
			currentlyHeldObjectServer.isInShipRoom = false;
			currentlyHeldObjectServer.scrapPersistedThroughRounds = true;
			player.SetItemInElevator(true, true, currentlyHeldObjectServer);
			Logger.Debug("Despawn held object...");
			player.DestroyItemInSlotAndSync(player.currentItemSlot);
		}

		[ServerRpc(RequireOwnership = false)]
		public void StoreItemServerRpc(ItemData data)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2604567583u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<ItemData>(ref data, default(ForNetworkSerializable));
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2604567583u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					Logger.Debug("Server received new item!");
					Logger.Debug("Sending new item to clients...");
					StoreItemClientRpc(data);
				}
			}
		}

		[ClientRpc]
		private void StoreItemClientRpc(ItemData data)
		{
			//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(2860415655u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<ItemData>(ref data, default(ForNetworkSerializable));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2860415655u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					Logger.Debug("Client received new item!");
					ItemManager.Add(data);
					Logger.Debug("Client added new item!");
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void SpawnItemServerRpc(ItemData data, int count = 1)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(742435175u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<ItemData>(ref data, default(ForNetworkSerializable));
				BytePacker.WriteValueBitPacked(val2, count);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 742435175u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost))
			{
				return;
			}
			Item item = data.GetItem();
			if (item == null)
			{
				return;
			}
			IEnumerable<ItemData> instances = ItemManager.GetInstances(data, count);
			foreach (ItemData item2 in instances)
			{
				spawnQueue.Enqueue(item2);
			}
			if (spawnCoroutine == null)
			{
				spawnCoroutine = ((MonoBehaviour)this).StartCoroutine(SpawnCoroutine());
			}
			Logger.Debug($"Server scheduled to spawn {instances.Count()} new items!");
		}

		[ClientRpc]
		public void SpawnItemClientRpc(NetworkObjectReference networkObject, ItemData data)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2565643691u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref networkObject, default(ForNetworkSerializable));
				((FastBufferWriter)(ref val2)).WriteValueSafe<ItemData>(ref data, default(ForNetworkSerializable));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2565643691u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			Logger.Debug("Updating the items...");
			ItemManager.Remove(data);
			Logger.Debug("Items updated!");
			Item item = data.GetItem();
			NetworkObject val3 = default(NetworkObject);
			if (((NetworkObjectReference)(ref networkObject)).TryGet(ref val3, (NetworkManager)null) && !((Object)(object)item == (Object)null))
			{
				GrabbableObject component = ((Component)val3).GetComponent<GrabbableObject>();
				if (item.isScrap)
				{
					component.SetScrapValue(data.SCRAP_VALUE);
				}
				component.scrapPersistedThroughRounds = data.PERSISTED_THROUGH_ROUNDS;
				if (item.saveItemVariable)
				{
					component.LoadItemSaveData(data.SAVE_DATA);
				}
				component.isInShipRoom = true;
				component.isInElevator = true;
				((MonoBehaviour)component).StartCoroutine(PlayDropSound(component));
				spawnParticles.Play();
				Logger.Debug("Item setup!");
			}
		}

		private IEnumerator SpawnCoroutine()
		{
			while (spawnQueue.Count > 0)
			{
				if (itemsInChute.Length >= ShipInventory.Config.StopAfter.Value)
				{
					yield return (object)new WaitForEndOfFrame();
					continue;
				}
				ItemData data = spawnQueue.Dequeue();
				Item item = data.GetItem();
				if (!((Object)(object)item == (Object)null))
				{
					GameObject newItem = Object.Instantiate<GameObject>(item.spawnPrefab) ?? throw new NullReferenceException();
					newItem.transform.SetParent(itemRestorePoint, false);
					GrabbableObject grabObj = newItem.GetComponent<GrabbableObject>();
					((Component)grabObj).transform.localPosition = Vector3.zero;
					if (grabObj.itemProperties.itemSpawnsOnGround)
					{
						((Component)grabObj).transform.localRotation = Quaternion.Euler(grabObj.itemProperties.restingRotation);
					}
					else
					{
						grabObj.OnHitGround();
					}
					NetworkObject networkObj = ((NetworkBehaviour)grabObj).NetworkObject;
					networkObj.Spawn(false);
					SpawnItemClientRpc(NetworkObjectReference.op_Implicit(networkObj), data);
					yield return (object)new WaitForSeconds(ShipInventory.Config.SpawnDelay.Value);
				}
			}
			spawnCoroutine = null;
		}

		private static IEnumerator PlayDropSound(GrabbableObject grabbable)
		{
			yield return null;
			yield return null;
			grabbable.PlayDropSFX();
			grabbable.OnHitGround();
		}

		public void RequestItems()
		{
			Logger.Debug("Requesting the items to the server...");
			RequestItemsServerRpc(GameNetworkManager.Instance.localPlayerController.playerClientId);
		}

		public void RequestItemsAll()
		{
			if (!((NetworkBehaviour)GameNetworkManager.Instance.localPlayerController).IsClient)
			{
				IEnumerable<ulong> source = from p in StartOfRound.Instance.allPlayerScripts
					where ((NetworkBehaviour)p).IsClient
					select p.playerClientId;
				RequestItemsServerRpc(source.ToArray());
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void RequestItemsServerRpc(params ulong[] ids)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: 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_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2352724517u, val, (RpcDelivery)0);
				bool flag = ids != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe<ulong>(ids, default(ForPrimitives));
				}
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2352724517u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				Logger.Debug("Item request heard!");
				Logger.Debug("Sending the items to client " + string.Join(", ", ids) + "...");
				RequestItemsClientRpc(ItemManager.GetItems().ToArray(), new ClientRpcParams
				{
					Send = new ClientRpcSendParams
					{
						TargetClientIds = ids
					}
				});
			}
		}

		[ClientRpc]
		private void RequestItemsClientRpc(ItemData[] data, ClientRpcParams @params = 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_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: 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_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: 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(1333804348u, @params, (RpcDelivery)0);
				bool flag = data != null;
				((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val)).WriteValueSafe<ItemData>(data, default(ForNetworkSerializable));
				}
				((NetworkBehaviour)this).__endSendClientRpc(ref val, 1333804348u, @params, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				Logger.Debug("Client received items!");
				IReadOnlyList<ulong> source = @params.Send.TargetClientIds ?? Array.Empty<ulong>();
				if (source.Contains(GameNetworkManager.Instance.localPlayerController.playerClientId))
				{
					ItemManager.SetItems(data.ToList());
					Logger.Debug("Client updated items!");
				}
			}
		}

		private void UpdateTrigger()
		{
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)_trigger) && GameNetworkManager.Instance != null && NetworkManager.Singleton != null)
			{
				PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
				if (localPlayerController != null && localPlayerController.isInHangarShipRoom)
				{
					ItemManager.UpdateTrigger(_trigger, localPlayerController);
					itemsInChute = Physics.OverlapBox(itemRestorePoint.position, new Vector3(1f, 0.25f, 1.25f) / 2f, itemRestorePoint.rotation, 1 << LayerMask.NameToLayer("Props"));
					((Component)this).gameObject.layer = LayerMask.NameToLayer((itemsInChute.Length != 0) ? "Ignore Raycast" : "InteractableObject");
				}
			}
		}

		private void Update()
		{
			UpdateTrigger();
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_ChuteInteract()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(2604567583u, new RpcReceiveHandler(__rpc_handler_2604567583));
			NetworkManager.__rpc_func_table.Add(2860415655u, new RpcReceiveHandler(__rpc_handler_2860415655));
			NetworkManager.__rpc_func_table.Add(742435175u, new RpcReceiveHandler(__rpc_handler_742435175));
			NetworkManager.__rpc_func_table.Add(2565643691u, new RpcReceiveHandler(__rpc_handler_2565643691));
			NetworkManager.__rpc_func_table.Add(2352724517u, new RpcReceiveHandler(__rpc_handler_2352724517));
			NetworkManager.__rpc_func_table.Add(1333804348u, new RpcReceiveHandler(__rpc_handler_1333804348));
		}

		private static void __rpc_handler_2604567583(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)
			{
				ItemData data = default(ItemData);
				((FastBufferReader)(ref reader)).ReadValueSafe<ItemData>(ref data, default(ForNetworkSerializable));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((ChuteInteract)(object)target).StoreItemServerRpc(data);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2860415655(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)
			{
				ItemData data = default(ItemData);
				((FastBufferReader)(ref reader)).ReadValueSafe<ItemData>(ref data, default(ForNetworkSerializable));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((ChuteInteract)(object)target).StoreItemClientRpc(data);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_742435175(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ItemData data = default(ItemData);
				((FastBufferReader)(ref reader)).ReadValueSafe<ItemData>(ref data, default(ForNetworkSerializable));
				int count = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref count);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((ChuteInteract)(object)target).SpawnItemServerRpc(data, count);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2565643691(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkObjectReference networkObject = default(NetworkObjectReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref networkObject, default(ForNetworkSerializable));
				ItemData data = default(ItemData);
				((FastBufferReader)(ref reader)).ReadValueSafe<ItemData>(ref data, default(ForNetworkSerializable));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((ChuteInteract)(object)target).SpawnItemClientRpc(networkObject, data);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2352724517(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_006e: 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_0058: 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 flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				ulong[] ids = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref ids, default(ForPrimitives));
				}
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((ChuteInteract)(object)target).RequestItemsServerRpc(ids);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1333804348(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_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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: 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));
				ItemData[] data = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe<ItemData>(ref data, default(ForNetworkSerializable));
				}
				ClientRpcParams client = rpcParams.Client;
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((ChuteInteract)(object)target).RequestItemsClientRpc(data, client);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "ChuteInteract";
		}
	}
	[Serializable]
	public struct ItemData : INetworkSerializable
	{
		public int ID;

		public int SCRAP_VALUE;

		public int SAVE_DATA;

		public bool PERSISTED_THROUGH_ROUNDS;

		public ItemData(GrabbableObject item)
		{
			SCRAP_VALUE = 0;
			SAVE_DATA = 0;
			ID = ((Object)item.itemProperties).GetInstanceID();
			if (item.itemProperties.isScrap)
			{
				SCRAP_VALUE = item.scrapValue;
			}
			if (item.itemProperties.saveItemVariable)
			{
				SAVE_DATA = item.GetItemDataToSave();
			}
			PERSISTED_THROUGH_ROUNDS = item.scrapPersistedThroughRounds;
		}

		public Item? GetItem()
		{
			return ItemManager.ALLOWED_ITEMS.GetValueOrDefault(ID);
		}

		public unsafe void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			((BufferSerializer<int>*)(&serializer))->SerializeValue<int>(ref ID, default(ForPrimitives));
			((BufferSerializer<int>*)(&serializer))->SerializeValue<int>(ref SCRAP_VALUE, default(ForPrimitives));
			((BufferSerializer<int>*)(&serializer))->SerializeValue<int>(ref SAVE_DATA, default(ForPrimitives));
			((BufferSerializer<bool>*)(&serializer))->SerializeValue<bool>(ref PERSISTED_THROUGH_ROUNDS, default(ForPrimitives));
		}
	}
}
namespace ShipInventory.Helpers
{
	internal static class Bundle
	{
		private static AssetBundle? loadedBundle;

		public static bool LoadBundle(string name)
		{
			Stream manifestResourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(name);
			if (manifestResourceStream == null)
			{
				Logger.Error("No bundle named '" + name + "'.");
				return false;
			}
			loadedBundle = AssetBundle.LoadFromStream(manifestResourceStream);
			if ((Object)(object)loadedBundle == (Object)null)
			{
				Logger.Error("Failed to load custom assets.");
				return false;
			}
			return true;
		}

		public static T? LoadAsset<T>(string name) where T : Object
		{
			if ((Object)(object)loadedBundle == (Object)null)
			{
				Logger.Error("Tried to load asset from unloaded bundle.");
				return default(T);
			}
			T val = loadedBundle.LoadAsset<T>(name);
			if ((Object)(object)val == (Object)null)
			{
				Logger.Error("No asset named '" + name + "' was found.");
			}
			return val;
		}
	}
	public static class ItemManager
	{
		private static IEnumerable<ItemData> storedItems = Array.Empty<ItemData>();

		internal static readonly Dictionary<int, Item> ALLOWED_ITEMS = new Dictionary<int, Item>();

		private static string[] BLACKLIST = Array.Empty<string>();

		public static IEnumerable<ItemData> GetItems()
		{
			return new List<ItemData>(from i in storedItems
				orderby i.GetItem()?.itemName, i.SCRAP_VALUE
				select i);
		}

		public static IEnumerable<ItemData> GetInstances(ItemData data, int count)
		{
			Item item = data.GetItem();
			if (item == null)
			{
				return Array.Empty<ItemData>();
			}
			if (count == 1)
			{
				return storedItems.Where((ItemData d) => d.Equals(data)).Take(1);
			}
			return storedItems.Where((ItemData d) => d.ID == data.ID).Take(count);
		}

		public static int GetTotalValue()
		{
			return storedItems.Sum((ItemData i) => i.SCRAP_VALUE);
		}

		public static void SetItems(IEnumerable<ItemData> newItems, bool updateAll = false)
		{
			Logger.Debug($"Setting items from {storedItems.Count()} to {newItems.Count()}...");
			storedItems = newItems;
			ChuteInteract.Instance?.UpdateValue();
			if (updateAll)
			{
				ChuteInteract.Instance?.RequestItemsAll();
			}
		}

		internal static void Add(ItemData data)
		{
			SetItems(storedItems.Append(data));
		}

		internal static void Remove(ItemData data)
		{
			List<ItemData> list = storedItems.ToList();
			list.Remove(data);
			SetItems(list);
		}

		public static void StoreItem(GrabbableObject item)
		{
			if (!((Object)(object)ChuteInteract.Instance == (Object)null))
			{
				ItemData data = new ItemData(item);
				item.OnBroughtToShip();
				Logger.Debug("Sending new item to server...");
				ChuteInteract.Instance.StoreItemServerRpc(data);
			}
		}

		internal static void UpdateBlacklist(string blacklistString)
		{
			BLACKLIST = (from s in blacklistString.Split(',', StringSplitOptions.RemoveEmptyEntries)
				select s.Trim().ToLower()).ToArray();
		}

		internal static void UpdateTrigger(InteractTrigger trigger, PlayerControllerB local)
		{
			if (!local.isHoldingObject || (Object)(object)local.currentlyHeldObjectServer == (Object)null)
			{
				trigger.interactable = false;
				trigger.disabledHoverTip = Lang.Get("NOT_HOLDING_ITEM");
				return;
			}
			if (ShipInventory.Config.OverrideTrigger.Value == Config.OverrideMode.NEVER)
			{
				trigger.interactable = false;
				trigger.disabledHoverTip = "Disabled by HOST";
				return;
			}
			if (ShipInventory.Config.OverrideTrigger.Value == Config.OverrideMode.ALL)
			{
				trigger.interactable = true;
				return;
			}
			switch (ShipInventory.Config.ChutePermission.Value)
			{
			case Config.PermissionLevel.HOST_ONLY:
				if (((NetworkBehaviour)local).IsHost)
				{
					break;
				}
				goto case Config.PermissionLevel.NO_ONE;
			case Config.PermissionLevel.CLIENTS_ONLY:
				if (!((NetworkBehaviour)local).IsHost)
				{
					break;
				}
				goto case Config.PermissionLevel.NO_ONE;
			case Config.PermissionLevel.NO_ONE:
				trigger.interactable = false;
				trigger.disabledHoverTip = Lang.Get("CHUTE_PERMISSION_MISSING");
				return;
			}
			if (!StartOfRound.Instance.inShipPhase && ShipInventory.Config.RequireInOrbit.Value)
			{
				trigger.interactable = false;
				trigger.disabledHoverTip = Lang.Get("NOT_IN_ORBIT");
				return;
			}
			if (storedItems.Count() == ShipInventory.Config.MaxItemCount.Value)
			{
				trigger.interactable = false;
				trigger.disabledHoverTip = Lang.Get("INVENTORY_FULL");
				return;
			}
			GrabbableObject currentlyHeldObjectServer = local.currentlyHeldObjectServer;
			Item itemProperties = currentlyHeldObjectServer.itemProperties;
			if (BLACKLIST.Contains(itemProperties.itemName.ToLower()))
			{
				trigger.interactable = false;
				trigger.disabledHoverTip = Lang.Get("ITEM_BLACKLISTED");
			}
			else if (!ALLOWED_ITEMS.ContainsKey(((Object)itemProperties).GetInstanceID()) || currentlyHeldObjectServer.itemUsedUp)
			{
				trigger.interactable = false;
				trigger.disabledHoverTip = Lang.Get("ITEM_NOT_ALLOWED");
			}
			else
			{
				trigger.interactable = local.isHoldingObject;
			}
		}
	}
	public class Lang
	{
		private static string? PATH;

		private static JObject? LANG;

		public static bool LoadLang(string lang)
		{
			if (PATH == null)
			{
				string codeBase = Assembly.GetExecutingAssembly().CodeBase;
				UriBuilder uriBuilder = new UriBuilder(codeBase);
				PATH = Path.GetDirectoryName(Uri.UnescapeDataString(uriBuilder.Path));
			}
			if (PATH == null)
			{
				return false;
			}
			string text = "lang-" + lang + ".json";
			string path = Path.Combine(PATH, text);
			if (!File.Exists(path))
			{
				Logger.Error("The file '" + text + "' was not found at '" + PATH + "'.");
				return lang != "en" && LoadLang("en");
			}
			string text2 = File.ReadAllText(path);
			LANG = JObject.Parse(text2);
			Logger.Info("Lang '" + lang + "' loaded!");
			return true;
		}

		public static string Get(string id)
		{
			JObject? lANG = LANG;
			return ((lANG == null) ? null : ((object)lANG.GetValue(id))?.ToString()) ?? id;
		}
	}
	internal static class Logger
	{
		private static ManualLogSource? log;

		public static void SetLogger(ManualLogSource logSource)
		{
			log = logSource;
		}

		private static void Log(LogLevel level, object? content)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			ManualLogSource? obj = log;
			if (obj != null)
			{
				obj.Log(level, content ?? "null");
			}
		}

		public static void Info(object? content)
		{
			Log((LogLevel)16, content);
		}

		public static void Debug(object? content)
		{
			Log((LogLevel)32, content);
		}

		public static void Error(object? content)
		{
			Log((LogLevel)2, content);
		}
	}
	public static class NetworkPrefabUtils
	{
		public class PrefabData
		{
			public string name = "";

			public Action<GameObject>? onLoad;

			public Action<GameObject>? onSetup;

			public GameObject? gameObject;
		}

		[HarmonyPatch(typeof(GameNetworkManager))]
		internal class GameNetworkManager_Patches
		{
			[HarmonyPostfix]
			[HarmonyPatch("Start")]
			private static void AddPrefabsToNetwork(GameNetworkManager __instance)
			{
				foreach (PrefabData prefab in prefabs)
				{
					GameObject val = Bundle.LoadAsset<GameObject>(prefab.name);
					if (val != null)
					{
						prefab.onLoad?.Invoke(val);
						NetworkManager.Singleton.AddNetworkPrefab(val);
						prefab.gameObject = val;
					}
				}
			}
		}

		[HarmonyPatch(typeof(StartOfRound))]
		internal class StartOfRound_Patches
		{
			[HarmonyPrefix]
			[HarmonyPatch("Start")]
			private static void SetUpPrefabs(StartOfRound __instance)
			{
				//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c0: Expected O, but got Unknown
				GameObject val = GameObject.Find("Environment/HangarShip");
				foreach (PrefabData prefab2 in prefabs)
				{
					GameObject val2 = null;
					if (((NetworkBehaviour)__instance).IsServer || ((NetworkBehaviour)__instance).IsHost)
					{
						GameObject prefab = GetPrefab(prefab2.name);
						if (prefab == null)
						{
							Logger.Error("The prefab '" + prefab2.name + "' was not found in the bundle!");
							continue;
						}
						val2 = Object.Instantiate<GameObject>(prefab);
						NetworkObject networkObject = val2.GetComponent<NetworkBehaviour>().NetworkObject;
						networkObject.Spawn(false);
						networkObject.TrySetParent(val, true);
					}
					foreach (Transform item in val.transform)
					{
						Transform val3 = item;
						if (((Object)((Component)val3).gameObject).name != prefab2.name + "(Clone)")
						{
							continue;
						}
						val2 = ((Component)val3).gameObject;
						break;
					}
					if (val2 == null)
					{
						Logger.Error("The prefab '" + prefab2.name + "' was not found in the scene!");
					}
					else
					{
						prefab2.onSetup?.Invoke(val2);
					}
				}
			}
		}

		private static readonly List<PrefabData> prefabs = new List<PrefabData>();

		public static void LoadPrefab(PrefabData data)
		{
			prefabs.Add(data);
		}

		public static GameObject? GetPrefab(string name)
		{
			string name2 = name;
			return prefabs.FirstOrDefault((PrefabData p) => p.name == name2)?.gameObject;
		}
	}
}
namespace ShipInventory.Compatibility
{
	public static class LethalConfigCompatibility
	{
		public const string LETHAL_CONFIG = "ainavt.lc.lethalconfig";

		private static bool? _enabled;

		public static bool enabled
		{
			get
			{
				bool valueOrDefault = _enabled.GetValueOrDefault();
				if (!_enabled.HasValue)
				{
					valueOrDefault = Chainloader.PluginInfos.ContainsKey("ainavt.lc.lethalconfig");
					_enabled = valueOrDefault;
				}
				return _enabled.Value;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void AddConfigs(Config config)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: 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_005b: Expected O, but got Unknown
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Expected O, but got Unknown
			//IL_006c: 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_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Expected O, but got Unknown
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Expected O, but got Unknown
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Expected O, but got Unknown
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Expected O, but got Unknown
			//IL_00b8: 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_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Expected O, but got Unknown
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Expected O, but got Unknown
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Expected O, but got Unknown
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Expected O, but got Unknown
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Expected O, but got Unknown
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Expected O, but got Unknown
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Expected O, but got Unknown
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Expected O, but got Unknown
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Expected O, but got Unknown
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Expected O, but got Unknown
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Expected O, but got Unknown
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Expected O, but got Unknown
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Expected O, but got Unknown
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Expected O, but got Unknown
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Expected O, but got Unknown
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Expected O, but got Unknown
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: Expected O, but got Unknown
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0264: Expected O, but got Unknown
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_0286: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: Expected O, but got Unknown
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Expected O, but got Unknown
			//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: Expected O, but got Unknown
			//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cc: Expected O, but got Unknown
			//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Expected O, but got Unknown
			LethalConfigManager.SetModIcon(Bundle.LoadAsset<Sprite>("icon"));
			LethalConfigManager.SetModDescription("Adds an inventory to the ship, allowing it to store items and retrieve them.");
			LethalConfigManager.AddConfigItem((BaseConfigItem)new TextInputFieldConfigItem(config.Blacklist.Entry, new TextInputFieldOptions
			{
				Name = Lang.Get("NAME_BLACKLIST"),
				TrimText = true,
				NumberOfLines = 10,
				RequiresRestart = false
			}));
			ConfigEntry<float> entry = config.SpawnDelay.Entry;
			FloatInputFieldOptions val = new FloatInputFieldOptions
			{
				Name = Lang.Get("NAME_SPAWN_DELAY")
			};
			((BaseRangeOptions<float>)val).Min = 0f;
			((BaseRangeOptions<float>)val).Max = float.MaxValue;
			((BaseOptions)val).RequiresRestart = false;
			LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatInputFieldConfigItem(entry, val));
			LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(config.RequireInOrbit.Entry, new BoolCheckBoxOptions
			{
				Name = Lang.Get("NAME_REQUIRES_IN_ORBIT"),
				RequiresRestart = false
			}));
			ConfigEntry<int> entry2 = config.StopAfter.Entry;
			IntSliderOptions val2 = new IntSliderOptions
			{
				Name = Lang.Get("NAME_STOP_AFTER")
			};
			((BaseRangeOptions<int>)val2).Min = 1;
			((BaseRangeOptions<int>)val2).Max = 1969420;
			((BaseOptions)val2).RequiresRestart = false;
			LethalConfigManager.AddConfigItem((BaseConfigItem)new IntSliderConfigItem(entry2, val2));
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)new EnumDropDownConfigItem<Config.PermissionLevel>(config.ChutePermission.Entry, new EnumDropDownOptions
			{
				Name = Lang.Get("NAME_CHUTE_PERMISSION")
			}));
			LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(config.ActAsSafe.Entry, new BoolCheckBoxOptions
			{
				Name = Lang.Get("NAME_AS_SAFE"),
				RequiresRestart = false
			}));
			ConfigEntry<int> entry3 = config.MaxItemCount.Entry;
			IntSliderOptions val3 = new IntSliderOptions
			{
				Name = Lang.Get("NAME_MAX_ITEM_COUNT")
			};
			((BaseRangeOptions<int>)val3).Min = 1;
			((BaseRangeOptions<int>)val3).Max = 1969420;
			((BaseOptions)val3).RequiresRestart = false;
			LethalConfigManager.AddConfigItem((BaseConfigItem)new IntSliderConfigItem(entry3, val3));
			LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(config.PersistThroughFire.Entry, new BoolCheckBoxOptions
			{
				Name = Lang.Get("NAME_PERSIST_THROUGH_FIRE"),
				RequiresRestart = false
			}));
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)new EnumDropDownConfigItem<Config.PermissionLevel>(config.InventoryPermission.Entry, new EnumDropDownOptions
			{
				Name = Lang.Get("NAME_INVENTORY_PERMISSION")
			}));
			LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(config.ShowConfirmation.Entry, new BoolCheckBoxOptions
			{
				Name = Lang.Get("NAME_SHOW_CONFIRMATION"),
				RequiresRestart = false
			}));
			LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(config.YesPlease.Entry, new BoolCheckBoxOptions
			{
				Name = Lang.Get("NAME_YES_PLEASE"),
				RequiresRestart = false
			}));
			LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(config.ShowTrademark.Entry, new BoolCheckBoxOptions
			{
				Name = Lang.Get("NAME_SHOW_TRADEMARK"),
				RequiresRestart = false
			}));
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)new EnumDropDownConfigItem<Config.OverrideMode>(config.OverrideTrigger.Entry, new EnumDropDownOptions
			{
				Name = Lang.Get("NAME_OVERRIDE_TRIGGER"),
				RequiresRestart = false
			}));
			LethalConfigManager.SkipAutoGenFor((ConfigEntryBase)(object)config.LangUsed);
			ConfigManager.Register<Config>((SyncedConfig2<Config>)(object)config);
		}
	}
}
namespace ShipInventory.Applications
{
	public class ShipApplication : PageApplication
	{
		private readonly string INVENTORY_TITLE = Lang.Get("INVENTORY_TITLE");

		private readonly string UNKNOWN = Lang.Get("UNKNOWN");

		private readonly string HOME_MESSAGE = Lang.Get("HOME_MESSAGE");

		private readonly string WELCOME_MESSAGE = Lang.Get("WELCOME_MESSAGE");

		private readonly string TRADEMARK = Lang.Get("TRADEMARK");

		private readonly string POSITIVE_ANSWER = Lang.Get("POSITIVE_ANSWER");

		private readonly string NEGATIVE_ANSWER = Lang.Get("NEGATIVE_ANSWER");

		private readonly string BLOCKED_ANSWER = Lang.Get("BLOCKED_ANSWER");

		private Action<CallbackContext>? LastExitPerformedAction;

		private readonly string CONFIRMATION_TITLE = Lang.Get("CONFIRMATION_TITLE");

		private readonly string CONFIRMATION_MESSAGE = Lang.Get("CONFIRMATION_MESSAGE");

		private readonly string PERMISSION_MISSING_TITLE = Lang.Get("PERMISSION_MISSING_TITLE");

		private readonly string PERMISSION_MISSING_MESSAGE = Lang.Get("PERMISSION_MISSING_MESSAGE");

		private Action? ConfirmExitCallback;

		private readonly string SHIP_INFO = Lang.Get("SHIP_INFO");

		private readonly string STATUS_TITLE = Lang.Get("STATUS_TITLE");

		private readonly string SHIP_INFO_TOTAL = Lang.Get("SHIP_INFO_TOTAL");

		private readonly string SHIP_INFO_COUNT = Lang.Get("SHIP_INFO_COUNT");

		private readonly string SHIP_INFO_KEEP_HEADER = Lang.Get("SHIP_INFO_KEEP_HEADER");

		private readonly string SHIP_INFO_KEEP_ON_WIPE = Lang.Get("SHIP_INFO_KEEP_ON_WIPE");

		private readonly string SHIP_INFO_KEEP_ON_FIRE = Lang.Get("SHIP_INFO_KEEP_ON_FIRE");

		private readonly string SHIP_INFO_IN_ORBIT = Lang.Get("SHIP_INFO_IN_ORBIT");

		private readonly string SINGLE_RETRIEVE = Lang.Get("SINGLE_RETRIEVE");

		private readonly string TEXT_SINGLE_RETRIEVE = Lang.Get("TEXT_SINGLE_RETRIEVE");

		private readonly string SINGLE_RETRIEVE_MESSAGE = Lang.Get("SINGLE_RETRIEVE_MESSAGE");

		private readonly string SINGLE_ITEM_FORMAT = Lang.Get("SINGLE_ITEM_FORMAT");

		private readonly string TYPE_RETRIEVE = Lang.Get("TYPE_RETRIEVE");

		private readonly string TEXT_TYPE_RETRIEVE = Lang.Get("TEXT_TYPE_RETRIEVE");

		private readonly string TYPE_RETRIEVE_MESSAGE = Lang.Get("TYPE_RETRIEVE_MESSAGE");

		private readonly string TYPE_ITEM_FORMAT = Lang.Get("TYPE_ITEM_FORMAT");

		private readonly string RANDOM_RETRIEVE = Lang.Get("RANDOM_RETRIEVE");

		private readonly string TEXT_RANDOM_RETRIEVE = Lang.Get("TEXT_RANDOM_RETRIEVE");

		private readonly string ALL_RETRIEVE = Lang.Get("ALL_RETRIEVE");

		private readonly string TEXT_ALL_RETRIEVE = Lang.Get("TEXT_ALL_RETRIEVE");

		public override void Initialization()
		{
			MainScreen(0);
		}

		protected override int GetEntriesPerPage<T>(T[] entries)
		{
			return GetEntriesPerPage();
		}

		private static int GetEntriesPerPage()
		{
			return 10;
		}

		private void MainScreen(int selectedIndex)
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Expected O, but got Unknown
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Expected O, but got Unknown
			//IL_0067: Expected O, but got Unknown
			PlayerControllerB localPlayerController = StartOfRound.Instance.localPlayerController;
			CursorElement[] array = (CursorElement[])(object)new CursorElement[5]
			{
				RetrieveSingleElement(),
				RetrieveTypeElement(),
				RetrieveRandomElement(),
				RetrieveAllElement(),
				InfoCursorElement()
			};
			CursorMenu val = new CursorMenu();
			((BaseCursorMenu<CursorElement>)val).cursorIndex = (ItemManager.GetItems().Any() ? selectedIndex : (array.Length - 1));
			((BaseCursorMenu<CursorElement>)val).elements = array;
			CursorMenu val2 = val;
			BoxedScreen val3 = CreateScreen(INVENTORY_TITLE, (ITextElement[])(object)new ITextElement[5]
			{
				(ITextElement)TextElement.Create(string.Format(WELCOME_MESSAGE, HUDManager.Instance.playerLevels[localPlayerController.playerLevelNumber].levelName, localPlayerController.playerUsername)),
				(ITextElement)TextElement.Create(" "),
				(ITextElement)TextElement.Create(HOME_MESSAGE),
				(ITextElement)TextElement.Create(" "),
				(ITextElement)val2
			});
			base.currentPage = PageCursorElement.Create(0, (IScreen[])(object)new IScreen[1] { (IScreen)val3 }, (CursorMenu[])(object)new CursorMenu[1] { val2 });
			((BaseInteractiveApplication<CursorMenu, CursorElement>)(object)this).SwitchScreen((IScreen)(object)val3, val2, true);
		}

		private string BoolToString(bool value)
		{
			return value ? ("<color=green>" + POSITIVE_ANSWER + "</color>") : ("<color=red>" + NEGATIVE_ANSWER + "</color>");
		}

		private static bool CanRetrieve()
		{
			PlayerControllerB localPlayerController = StartOfRound.Instance.localPlayerController;
			switch (ShipInventory.Config.InventoryPermission.Value)
			{
			case Config.PermissionLevel.HOST_ONLY:
				if (((NetworkBehaviour)localPlayerController).IsHost)
				{
					break;
				}
				goto case Config.PermissionLevel.NO_ONE;
			case Config.PermissionLevel.CLIENTS_ONLY:
				if (!((NetworkBehaviour)localPlayerController).IsHost)
				{
					break;
				}
				goto case Config.PermissionLevel.NO_ONE;
			case Config.PermissionLevel.NO_ONE:
				return false;
			}
			return true;
		}

		private void RegisterExitAction(Action<CallbackContext> action)
		{
			UnregisterExitAction();
			LastExitPerformedAction = action;
			InputUtils_Compat.CursorExitKey.performed -= ((TerminalApplication)this).OnScreenExit;
			InputUtils_Compat.CursorExitKey.performed += action;
		}

		private void UnregisterExitAction()
		{
			if (LastExitPerformedAction != null)
			{
				InputUtils_Compat.CursorExitKey.performed -= LastExitPerformedAction;
				LastExitPerformedAction = null;
			}
			InputUtils_Compat.CursorExitKey.performed -= ((TerminalApplication)this).OnScreenExit;
			InputUtils_Compat.CursorExitKey.performed += ((TerminalApplication)this).OnScreenExit;
		}

		private BoxedScreen CreateScreen(string title, ITextElement[] elements)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Expected O, but got Unknown
			UnregisterExitAction();
			BoxedScreen val = new BoxedScreen();
			val.Title = title;
			ITextElement[] array = (ITextElement[])((!ShipInventory.Config.ShowTrademark.Value) ? ((Array)Array.Empty<ITextElement>()) : ((Array)new ITextElement[2]
			{
				(ITextElement)TextElement.Create(" "),
				(ITextElement)TextElement.Create(TRADEMARK)
			}));
			int num = 0;
			ITextElement[] array2 = (ITextElement[])(object)new ITextElement[elements.Length + array.Length];
			ReadOnlySpan<ITextElement> readOnlySpan = new ReadOnlySpan<ITextElement>(elements);
			readOnlySpan.CopyTo(new Span<ITextElement>(array2).Slice(num, readOnlySpan.Length));
			num += readOnlySpan.Length;
			ReadOnlySpan<ITextElement> readOnlySpan2 = new ReadOnlySpan<ITextElement>(array);
			readOnlySpan2.CopyTo(new Span<ITextElement>(array2).Slice(num, readOnlySpan2.Length));
			num += readOnlySpan2.Length;
			val.elements = array2;
			return val;
		}

		private void ConfirmElement(string message, Action? confirmCallback, Action? declineCallback = null)
		{
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Expected O, but got Unknown
			//IL_0070: 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_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Expected O, but got Unknown
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Expected O, but got Unknown
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Expected O, but got Unknown
			//IL_011f: Expected O, but got Unknown
			Action declineCallback2 = declineCallback;
			Action confirmCallback2 = confirmCallback;
			if (!ShipInventory.Config.ShowConfirmation.Value)
			{
				confirmCallback2?.Invoke();
				return;
			}
			ConfirmExitCallback = declineCallback2;
			bool flag = CanRetrieve();
			int cursorIndex = 0;
			CursorElement[] elements;
			if (flag)
			{
				elements = (CursorElement[])(object)new CursorElement[2]
				{
					new CursorElement
					{
						Name = NEGATIVE_ANSWER,
						Action = delegate
						{
							if (declineCallback2 != null)
							{
								declineCallback2();
							}
							else
							{
								MainScreen(0);
							}
						}
					},
					new CursorElement
					{
						Name = POSITIVE_ANSWER,
						Action = delegate
						{
							confirmCallback2?.Invoke();
						}
					}
				};
				if (ShipInventory.Config.YesPlease.Value)
				{
					cursorIndex = 1;
				}
			}
			else
			{
				elements = (CursorElement[])(object)new CursorElement[1]
				{
					new CursorElement
					{
						Name = BLOCKED_ANSWER,
						Action = delegate
						{
							if (declineCallback2 != null)
							{
								declineCallback2();
							}
							else
							{
								MainScreen(0);
							}
						}
					}
				};
			}
			CursorMenu val = new CursorMenu();
			((BaseCursorMenu<CursorElement>)val).cursorIndex = cursorIndex;
			((BaseCursorMenu<CursorElement>)val).elements = elements;
			CursorMenu val2 = val;
			BoxedScreen val3 = ((!flag) ? CreateScreen(PERMISSION_MISSING_TITLE, (ITextElement[])(object)new ITextElement[3]
			{
				(ITextElement)TextElement.Create(PERMISSION_MISSING_MESSAGE),
				(ITextElement)TextElement.Create(" "),
				(ITextElement)val2
			}) : CreateScreen(CONFIRMATION_TITLE, (ITextElement[])(object)new ITextElement[5]
			{
				(ITextElement)TextElement.Create(message),
				(ITextElement)TextElement.Create(" "),
				(ITextElement)TextElement.Create(CONFIRMATION_MESSAGE),
				(ITextElement)TextElement.Create(" "),
				(ITextElement)val2
			}));
			base.currentPage = PageCursorElement.Create(0, (IScreen[])(object)new IScreen[1] { (IScreen)val3 }, (CursorMenu[])(object)new CursorMenu[1] { val2 });
			((BaseInteractiveApplication<CursorMenu, CursorElement>)(object)this).SwitchScreen((IScreen)(object)val3, val2, true);
			RegisterExitAction(OnConfirmExit);
		}

		private void OnConfirmExit(CallbackContext context)
		{
			ConfirmExitCallback?.Invoke();
		}

		private CursorElement InfoCursorElement()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			return new CursorElement
			{
				Name = SHIP_INFO,
				Action = GetInfo
			};
		}

		private void GetInfo()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			//IL_0019: Expected O, but got Unknown
			CursorMenu val = new CursorMenu();
			((BaseCursorMenu<CursorElement>)val).cursorIndex = 0;
			((BaseCursorMenu<CursorElement>)val).elements = Array.Empty<CursorElement>();
			CursorMenu val2 = val;
			BoxedScreen val3 = CreateScreen(STATUS_TITLE, (ITextElement[])(object)new ITextElement[8]
			{
				(ITextElement)TextElement.Create(string.Format(SHIP_INFO_TOTAL, ItemManager.GetTotalValue())),
				(ITextElement)TextElement.Create(string.Format(SHIP_INFO_COUNT, ItemManager.GetItems().Count(), ShipInventory.Config.MaxItemCount.Value)),
				(ITextElement)TextElement.Create(" "),
				(ITextElement)TextElement.Create(string.Format(SHIP_INFO_IN_ORBIT, BoolToString(!ShipInventory.Config.RequireInOrbit.Value))),
				(ITextElement)TextElement.Create(" "),
				(ITextElement)TextElement.Create(SHIP_INFO_KEEP_HEADER),
				(ITextElement)TextElement.Create(string.Format(SHIP_INFO_KEEP_ON_WIPE, BoolToString(ShipInventory.Config.ActAsSafe.Value))),
				(ITextElement)TextElement.Create(string.Format(SHIP_INFO_KEEP_ON_FIRE, BoolToString(ShipInventory.Config.PersistThroughFire.Value)))
			});
			base.currentPage = PageCursorElement.Create(0, (IScreen[])(object)new IScreen[1] { (IScreen)val3 }, (CursorMenu[])(object)new CursorMenu[1] { val2 });
			((BaseInteractiveApplication<CursorMenu, CursorElement>)(object)this).SwitchScreen((IScreen)(object)val3, val2, true);
			RegisterExitAction(OnInfoExit);
		}

		private void OnInfoExit(CallbackContext context)
		{
			MainScreen(4);
		}

		private CursorElement RetrieveSingleElement()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: 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_0054: Expected O, but got Unknown
			return new CursorElement
			{
				Name = SINGLE_RETRIEVE,
				Active = (CursorElement _) => ItemManager.GetItems().Any(),
				SelectInactive = false,
				Action = delegate
				{
					RetrieveSingle();
				}
			};
		}

		private CursorElement RenderSingle(ItemData itemData, bool onlyGroup, int index)
		{
			//IL_006c: 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_0092: Expected O, but got Unknown
			Item item = itemData.GetItem();
			string name = UNKNOWN;
			if (item != null)
			{
				name = string.Format(SINGLE_ITEM_FORMAT, item.itemName, itemData.SCRAP_VALUE);
			}
			return new CursorElement
			{
				Name = name,
				Action = delegate
				{
					string tEXT_SINGLE_RETRIEVE = TEXT_SINGLE_RETRIEVE;
					tEXT_SINGLE_RETRIEVE = string.Format(tEXT_SINGLE_RETRIEVE, name);
					ConfirmElement(tEXT_SINGLE_RETRIEVE, delegate
					{
						ChuteInteract.Instance?.SpawnItemServerRpc(itemData);
						if (onlyGroup)
						{
							MainScreen(0);
						}
						else
						{
							RetrieveSingle(index);
						}
					}, delegate
					{
						RetrieveSingle(index);
					});
				}
			};
		}

		private void RetrieveSingle(int selectedIndex = 0)
		{
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Expected O, but got Unknown
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Expected O, but got Unknown
			//IL_00c9: Expected O, but got Unknown
			int entriesPerPage = GetEntriesPerPage();
			IEnumerable<ItemData> items = ItemManager.GetItems();
			int num = items.Count();
			ValueTuple<ItemData[][], CursorMenu[], IScreen[]> pageEntries = ((PageApplication)this).GetPageEntries<ItemData>(items.ToArray());
			ItemData[][] item = pageEntries.Item1;
			CursorMenu[] item2 = pageEntries.Item2;
			IScreen[] item3 = pageEntries.Item3;
			for (int i = 0; i < item.Length; i++)
			{
				CursorElement[] array = (CursorElement[])(object)new CursorElement[item[i].Length];
				for (int j = 0; j < array.Length; j++)
				{
					ItemData itemData = item[i][j];
					if (!itemData.Equals(default(ItemData)))
					{
						array[j] = RenderSingle(itemData, num == 1, i * entriesPerPage + j);
					}
				}
				int num2 = i;
				CursorMenu val = new CursorMenu();
				((BaseCursorMenu<CursorElement>)val).cursorIndex = 0;
				((BaseCursorMenu<CursorElement>)val).elements = array;
				item2[num2] = val;
				item3[i] = (IScreen)(object)CreateScreen(INVENTORY_TITLE, (ITextElement[])(object)new ITextElement[3]
				{
					(ITextElement)TextElement.Create(SINGLE_RETRIEVE_MESSAGE),
					(ITextElement)TextElement.Create(" "),
					(ITextElement)item2[i]
				});
			}
			if (selectedIndex >= num)
			{
				selectedIndex = num - 1;
			}
			int num3 = selectedIndex / entriesPerPage;
			int cursorIndex = selectedIndex % entriesPerPage;
			((BaseCursorMenu<CursorElement>)(object)item2[num3]).cursorIndex = cursorIndex;
			base.currentPage = PageCursorElement.Create(num3, item3, item2);
			((BaseInteractiveApplication<CursorMenu, CursorElement>)this).currentCursorMenu = base.currentPage.GetCurrentCursorMenu();
			((TerminalApplication)this).currentScreen = ((PageElement)base.currentPage).GetCurrentScreen();
			RegisterExitAction(OnRetrieveSingleExit);
		}

		private void OnRetrieveSingleExit(CallbackContext context)
		{
			MainScreen(0);
		}

		private CursorElement RetrieveTypeElement()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: 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_0054: Expected O, but got Unknown
			return new CursorElement
			{
				Name = TYPE_RETRIEVE,
				Active = (CursorElement _) => ItemManager.GetItems().Any(),
				SelectInactive = false,
				Action = delegate
				{
					RetrieveType();
				}
			};
		}

		private CursorElement RenderType(IGrouping<int, ItemData> group, bool onlyGroup, int index)
		{
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Expected O, but got Unknown
			IGrouping<int, ItemData> group2 = group;
			Item item = group2.First().GetItem();
			int amount = group2.Count();
			string name = UNKNOWN;
			if (item != null)
			{
				name = string.Format(TYPE_ITEM_FORMAT, item.itemName, amount, group2.Sum((ItemData data) => data.SCRAP_VALUE));
			}
			return new CursorElement
			{
				Name = name,
				Action = delegate
				{
					string tEXT_TYPE_RETRIEVE = TEXT_TYPE_RETRIEVE;
					tEXT_TYPE_RETRIEVE = string.Format(tEXT_TYPE_RETRIEVE, amount, item?.itemName ?? UNKNOWN);
					ConfirmElement(tEXT_TYPE_RETRIEVE, delegate
					{
						ChuteInteract.Instance?.SpawnItemServerRpc(group2.First(), amount);
						if (onlyGroup)
						{
							MainScreen(1);
						}
						else
						{
							RetrieveType(index);
						}
					}, delegate
					{
						RetrieveType(index);
					});
				}
			};
		}

		private void RetrieveType(int selectedIndex = 0)
		{
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Expected O, but got Unknown
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Expected O, but got Unknown
			//IL_00d2: Expected O, but got Unknown
			int entriesPerPage = GetEntriesPerPage();
			IEnumerable<IGrouping<int, ItemData>> source = from i in ItemManager.GetItems()
				group i by i.ID;
			int num = source.Count();
			ValueTuple<IGrouping<int, ItemData>[][], CursorMenu[], IScreen[]> pageEntries = ((PageApplication)this).GetPageEntries<IGrouping<int, ItemData>>(source.ToArray());
			IGrouping<int, ItemData>[][] item = pageEntries.Item1;
			CursorMenu[] item2 = pageEntries.Item2;
			IScreen[] item3 = pageEntries.Item3;
			for (int j = 0; j < item.Length; j++)
			{
				CursorElement[] array = (CursorElement[])(object)new CursorElement[item[j].Length];
				for (int k = 0; k < array.Length; k++)
				{
					IGrouping<int, ItemData> grouping = item[j][k];
					if (grouping != null)
					{
						array[k] = RenderType(grouping, num == 1, j * entriesPerPage + k);
					}
				}
				int num2 = j;
				CursorMenu val = new CursorMenu();
				((BaseCursorMenu<CursorElement>)val).cursorIndex = 0;
				((BaseCursorMenu<CursorElement>)val).elements = array;
				item2[num2] = val;
				item3[j] = (IScreen)(object)CreateScreen(INVENTORY_TITLE, (ITextElement[])(object)new ITextElement[3]
				{
					(ITextElement)TextElement.Create(TYPE_RETRIEVE_MESSAGE),
					(ITextElement)TextElement.Create(" "),
					(ITextElement)item2[j]
				});
			}
			if (selectedIndex >= num)
			{
				selectedIndex = num - 1;
			}
			int num3 = selectedIndex / entriesPerPage;
			int cursorIndex = selectedIndex % entriesPerPage;
			((BaseCursorMenu<CursorElement>)(object)item2[num3]).cursorIndex = cursorIndex;
			base.currentPage = PageCursorElement.Create(num3, item3, item2);
			((BaseInteractiveApplication<CursorMenu, CursorElement>)this).currentCursorMenu = base.currentPage.GetCurrentCursorMenu();
			((TerminalApplication)this).currentScreen = ((PageElement)base.currentPage).GetCurrentScreen();
			RegisterExitAction(OnRetrieveTypeExit);
		}

		private void OnRetrieveTypeExit(CallbackContext context)
		{
			MainScreen(1);
		}

		private CursorElement RetrieveRandomElement()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: 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_0054: Expected O, but got Unknown
			return new CursorElement
			{
				Name = RANDOM_RETRIEVE,
				Active = (CursorElement _) => ItemManager.GetItems().Any(),
				SelectInactive = false,
				Action = RetrieveRandom
			};
		}

		private void RetrieveRandom()
		{
			IEnumerable<ItemData> items = ItemManager.GetItems();
			object randomObj = items.ElementAt(Random.Range(0, items.Count()));
			string tEXT_RANDOM_RETRIEVE = TEXT_RANDOM_RETRIEVE;
			if (1 == 0)
			{
			}
			string text = ((randomObj is ItemData) ? ((ItemData)randomObj).GetItem()?.itemName : ((EnemyType)(((randomObj is EnemyType) ? randomObj : null)?)).enemyName);
			if (1 == 0)
			{
			}
			string arg = text ?? UNKNOWN;
			tEXT_RANDOM_RETRIEVE = string.Format(tEXT_RANDOM_RETRIEVE, arg);
			ConfirmElement(tEXT_RANDOM_RETRIEVE, delegate
			{
				if (randomObj is ItemData)
				{
					ItemData data = (ItemData)randomObj;
					if (true)
					{
						ChuteInteract.Instance?.SpawnItemServerRpc(data);
					}
				}
				MainScreen(2);
			}, delegate
			{
				MainScreen(2);
			});
		}

		private CursorElement RetrieveAllElement()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: 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_0054: Expected O, but got Unknown
			return new CursorElement
			{
				Name = ALL_RETRIEVE,
				Active = (CursorElement _) => ItemManager.GetItems().Any(),
				SelectInactive = false,
				Action = RetrieveAll
			};
		}

		private void RetrieveAll()
		{
			string message = string.Format(TEXT_ALL_RETRIEVE, ItemManager.GetItems().Sum((ItemData i) => i.SCRAP_VALUE));
			ConfirmElement(message, delegate
			{
				foreach (IGrouping<int, ItemData> item in from i in ItemManager.GetItems()
					group i by i.ID)
				{
					ChuteInteract.Instance?.SpawnItemServerRpc(item.First(), item.Count());
				}
				MainScreen(3);
			}, delegate
			{
				MainScreen(3);
			});
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}
namespace ShipInventory.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}