Decompiled source of ShipInventory v1.1.1

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.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using CSync.Extensions;
using CSync.Lib;
using GameNetcodeStuff;
using HarmonyLib;
using InteractiveTerminalAPI.UI;
using InteractiveTerminalAPI.UI.Application;
using InteractiveTerminalAPI.UI.Cursor;
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.Helpers;
using ShipInventory.NetcodePatcher;
using ShipInventory.Objects;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Events;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ShipInventory")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.1.1.0")]
[assembly: AssemblyInformationalVersion("1.1.1+0ebae8d6253e3aacc99b7543f2f347b87b9042e0")]
[assembly: AssemblyProduct("ShipInventory")]
[assembly: AssemblyTitle("ShipInventory")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.1.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 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<bool> ActAsSafe;

		[SyncedEntryField]
		public readonly SyncedEntry<int> MaxItemCount;

		[SyncedEntryField]
		public readonly SyncedEntry<bool> PersistThroughFire;

		[SyncedEntryField]
		public readonly SyncedEntry<bool> ShowConfirmation;

		[SyncedEntryField]
		public readonly SyncedEntry<bool> NoSteamID;

		[SyncedEntryField]
		public readonly SyncedEntry<OverrideMode> OverrideTrigger;

		[SyncedEntryField]
		public readonly SyncedEntry<bool> LetAsItem;

		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_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Expected O, but got Unknown
			//IL_0171: Expected O, but got Unknown
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Expected O, but got Unknown
			//IL_01a2: Expected O, but got Unknown
			//IL_01af: 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_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Expected O, but got Unknown
			//IL_0207: Expected O, but got Unknown
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Expected O, but got Unknown
			//IL_0234: Expected O, but got Unknown
			//IL_024c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Expected O, but got Unknown
			//IL_0280: Expected O, but got Unknown
			//IL_028d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b7: Expected O, but got Unknown
			//IL_02b7: 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>()));
			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>()));
			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>()));
			NoSteamID = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, new ConfigDefinition(text3, "NoSteamID"), false, new ConfigDescription(Lang.Get("DESCRIPTION_NO_STEAM_ID"), (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>()));
			LetAsItem = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, new ConfigDefinition(text4, "LetAsItem"), false, new ConfigDescription(string.Format(Lang.Get("DESCRIPTION_LET_AS_ITEM"), "GrabbableObject"), (AcceptableValueBase)null, Array.Empty<object>()));
			RegisterLethalConfig();
		}

		private void RegisterLethalConfig()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected O, but got Unknown
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Expected O, but got Unknown
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Expected O, but got Unknown
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Expected O, but got Unknown
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Expected O, but got Unknown
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Expected O, but got Unknown
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Expected O, but got Unknown
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: 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_00ee: Expected O, but got Unknown
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Expected O, but got Unknown
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Expected O, but got Unknown
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Expected O, but got Unknown
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Expected O, but got Unknown
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Expected O, but got Unknown
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Expected O, but got Unknown
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Expected O, but got Unknown
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Expected O, but got Unknown
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Expected O, but got Unknown
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Expected O, but got Unknown
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Expected O, but got Unknown
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Expected O, but got Unknown
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Expected O, but got Unknown
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Expected O, but got Unknown
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Expected O, but got Unknown
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: Expected O, but got Unknown
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Expected O, but got Unknown
			//IL_0283: Unknown result type (might be due to invalid IL or missing references)
			//IL_028d: Expected O, but got Unknown
			//IL_0294: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b2: Expected O, but got Unknown
			//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b7: Expected O, but got Unknown
			LethalConfigManager.AddConfigItem((BaseConfigItem)new TextInputFieldConfigItem(Blacklist.Entry, new TextInputFieldOptions
			{
				Name = Lang.Get("NAME_BLACKLIST"),
				TrimText = true,
				NumberOfLines = 10,
				RequiresRestart = false
			}));
			ConfigEntry<float> entry = 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(RequireInOrbit.Entry, new BoolCheckBoxOptions
			{
				Name = Lang.Get("NAME_REQUIRES_IN_ORBIT"),
				RequiresRestart = false
			}));
			ConfigEntry<int> entry2 = 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)new BoolCheckBoxConfigItem(ActAsSafe.Entry, new BoolCheckBoxOptions
			{
				Name = Lang.Get("NAME_AS_SAFE"),
				RequiresRestart = false
			}));
			ConfigEntry<int> entry3 = 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(PersistThroughFire.Entry, new BoolCheckBoxOptions
			{
				Name = Lang.Get("NAME_PERSIST_THROUGH_FIRE"),
				RequiresRestart = false
			}));
			LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(ShowConfirmation.Entry, new BoolCheckBoxOptions
			{
				Name = Lang.Get("NAME_SHOW_CONFIRMATION"),
				RequiresRestart = false
			}));
			LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(NoSteamID.Entry, new BoolCheckBoxOptions
			{
				Name = Lang.Get("NAME_NO_STEAM_ID"),
				RequiresRestart = false
			}));
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)new EnumDropDownConfigItem<OverrideMode>(OverrideTrigger.Entry, new EnumDropDownOptions
			{
				Name = Lang.Get("NAME_OVERRIDE_TRIGGER"),
				RequiresRestart = false
			}));
			LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(LetAsItem.Entry, new BoolCheckBoxOptions
			{
				Name = Lang.Get("NAME_LET_AS_ITEM"),
				RequiresRestart = true
			}));
			LethalConfigManager.AddConfigItem((BaseConfigItem)new TextInputFieldConfigItem(LangUsed, new TextInputFieldOptions
			{
				Description = "Language to use for the texts.\n\nThe translation has to be found next to the DLL.",
				RequiresRestart = true
			}));
			ConfigManager.Register<Config>((SyncedConfig2<Config>)(object)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.1")]
	[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);
			Config = new Config(((BaseUnityPlugin)this).Config);
			if (Bundle.LoadBundle("ShipInventory.Resources.si-bundle"))
			{
				LethalConfigManager.SetModIcon(Bundle.LoadAsset<Sprite>("icon"));
				LethalConfigManager.SetModDescription("Adds an inventory to the ship, allowing it to store items and retrieve them.");
				PrepareNetwork();
				Patch();
				InteractiveTerminalManager.RegisterApplication<ShipApplication>("ship", true);
				Logger.Info("ShipInventory v1.1.1 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>();
			VentProp ventProp = obj.AddComponent<VentProp>();
			Item val = ScriptableObject.CreateInstance<Item>();
			val.isScrap = true;
			val.lockedInDemo = true;
			val.itemName = "VENT_CHUTE";
			val.spawnPrefab = NetworkPrefabUtils.GetPrefab("VentChute");
			val.saveItemVariable = true;
			((GrabbableObject)ventProp).itemProperties = val;
			((GrabbableObject)ventProp).grabbable = false;
			((GrabbableObject)ventProp).grabbableToEnemies = false;
		}

		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);
			GrabbableObject component2 = vent.GetComponent<GrabbableObject>();
			if (Config.LetAsItem.Value)
			{
				component2.isInElevator = true;
				component2.isInShipRoom = true;
				component2.scrapPersistedThroughRounds = true;
				component2.OnHitGround();
			}
			else if ((Object)(object)component2 != (Object)null)
			{
				Object.Destroy((Object)(object)component2);
			}
			ItemManager.UpdateValue();
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "ShipInventory";

		public const string PLUGIN_NAME = "ShipInventory";

		public const string PLUGIN_VERSION = "1.1.1";
	}
}
namespace ShipInventory.Patches
{
	[HarmonyPatch(typeof(GameNetworkManager))]
	public class GameNetworkManager_Patches
	{
		[HarmonyTranspiler]
		[HarmonyPatch("SaveItemsInShip")]
		private static IEnumerable<CodeInstruction> RemoveChuteFromSelection(MethodBase original, IEnumerable<CodeInstruction> instructions)
		{
			IEnumerator<CodeInstruction> enumerator = instructions.GetEnumerator();
			while (enumerator.MoveNext())
			{
				CodeInstruction instruction = enumerator.Current;
				if (instruction == null)
				{
					break;
				}
				yield return instruction;
				if (!(instruction.opcode != OpCodes.Stloc_0))
				{
					yield return new CodeInstruction(OpCodes.Ldloca_S, (object)Convert.ToByte(0));
					yield return new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(VentProp), "RemoveChute", (Type[])null, (Type[])null));
				}
			}
			enumerator.Dispose();
		}

		[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(GrabbableObject))]
	public class GrabbableObject_Patches
	{
		[HarmonyPrefix]
		[HarmonyPatch("SetScrapValue")]
		private static bool PreventSubTextUpdate(GrabbableObject __instance, int setValueTo)
		{
			__instance.scrapValue = setValueTo;
			return !(__instance is VentProp);
		}
	}
	[HarmonyPatch(typeof(NetworkObject))]
	public class NetworkObject_Patches
	{
		[HarmonyPrefix]
		[HarmonyPatch("Despawn")]
		private static bool PreventChuteDespawn(NetworkObject __instance)
		{
			VentProp ventProp = default(VentProp);
			if (!((Component)__instance).TryGetComponent<VentProp>(ref ventProp))
			{
				return true;
			}
			if (ShipInventory.Config.ActAsSafe.Value)
			{
				return false;
			}
			Logger.Debug("Clearing the ship...");
			ItemManager.SetItems(Array.Empty<ItemData>(), updateAll: true);
			return false;
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	public class PlayerControllerB_Patches
	{
		[HarmonyPostfix]
		[HarmonyPatch("ConnectClientToPlayerObject")]
		private static void RequestOnConnect(PlayerControllerB __instance)
		{
			if (((NetworkBehaviour)__instance).IsClient && !((NetworkBehaviour)StartOfRound.Instance.localPlayerController).IsServer)
			{
				ChuteInteract.Instance?.RequestItems();
			}
		}
	}
	[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>());
			}
		}
	}
}
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 Transform spawnParent = null;

		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>();
			spawnParent = GameObject.Find("Environment/HangarShip").transform;
			((NetworkBehaviour)this).OnNetworkSpawn();
		}

		public void StoreHeldItem(PlayerControllerB player)
		{
			GrabbableObject currentlyHeldObjectServer = player.currentlyHeldObjectServer;
			if (currentlyHeldObjectServer == null)
			{
				Logger.Info("Player '" + player.playerUsername + "' is not holding any item.");
				return;
			}
			StoreItem(currentlyHeldObjectServer);
			Logger.Debug("Despawn held object...");
			player.DespawnHeldObject();
		}

		public void StoreItem(GrabbableObject item)
		{
			ItemData data = ItemManager.Save(item);
			item.OnBroughtToShip();
			Logger.Debug("Sending new item to server...");
			StoreItemServerRpc(data);
		}

		[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>();
				component.parentObject = itemRestorePoint;
				if (item.isScrap)
				{
					component.SetScrapValue(data.SCRAP_VALUE);
				}
				if (item.saveItemVariable)
				{
					component.LoadItemSaveData(data.SAVE_DATA);
				}
				component.isInShipRoom = true;
				component.isInElevator = true;
				component.OnHitGround();
				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 (item != null)
				{
					GameObject newItem = Object.Instantiate<GameObject>(item.spawnPrefab) ?? throw new NullReferenceException();
					newItem.transform.SetParent(spawnParent, false);
					GrabbableObject grabObj = newItem.GetComponent<GrabbableObject>();
					grabObj.Start();
					grabObj.PlayDropSFX();
					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;
		}

		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_0056: Unknown result type (might be due to invalid IL or missing references)
			if (NetworkManager.Singleton != null && Object.op_Implicit((Object)(object)_trigger))
			{
				PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController;
				if (val != null)
				{
					ItemManager.UpdateTrigger(_trigger, val);
					itemsInChute = Physics.OverlapSphere(itemRestorePoint.position, 0.2f, 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 ItemData()
		{
			ID = 0;
			SCRAP_VALUE = 0;
			SAVE_DATA = 0;
		}

		public Item? GetItem()
		{
			return ItemManager.GetItem(this);
		}

		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)
			((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));
		}
	}
	public class VentProp : GrabbableObject
	{
		public override void Start()
		{
			((GrabbableObject)this).Start();
			if ((Object)(object)base.radarIcon != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)base.radarIcon).gameObject);
			}
		}

		public override void Update()
		{
		}

		public static void RemoveChute(ref GrabbableObject[] list)
		{
			list = list.Where((GrabbableObject o) => !(o is VentProp)).ToArray();
		}

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

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "VentProp";
		}
	}
}
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>();

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

		private static List<Item> itemsAllowed => StartOfRound.Instance.allItemsList.itemsList;

		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>();
			}
			return storedItems.Where((ItemData d) => d.ID == data.ID).Take(count);
		}

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

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

		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 UpdateValue()
		{
			if (!((Object)(object)ChuteInteract.Instance == (Object)null))
			{
				GrabbableObject component = ((Component)ChuteInteract.Instance).GetComponent<GrabbableObject>();
				if (!((Object)(object)component == (Object)null))
				{
					component.scrapValue = GetTotalValue();
					component.OnHitGround();
				}
			}
		}

		public static ItemData Save(GrabbableObject item)
		{
			GrabbableObject item2 = item;
			ItemData result = default(ItemData);
			result.ID = itemsAllowed.FindIndex((Item i) => (Object)(object)i == (Object)(object)item2.itemProperties);
			if (item2.itemProperties.isScrap)
			{
				result.SCRAP_VALUE = item2.scrapValue;
			}
			if (item2.itemProperties.saveItemVariable)
			{
				result.SAVE_DATA = item2.GetItemDataToSave();
			}
			return result;
		}

		public static Item? GetItem(ItemData data)
		{
			return (itemsAllowed.Count > data.ID && data.ID >= 0) ? itemsAllowed[data.ID] : null;
		}

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

		public static bool IsItemAllowed(Item? item)
		{
			if (item == null)
			{
				return true;
			}
			return itemsAllowed.Contains(item) && !BLACKLIST.Contains(item.itemName.ToLower());
		}

		public static void UpdateTrigger(InteractTrigger trigger, PlayerControllerB local)
		{
			if (!local.isHoldingObject)
			{
				trigger.interactable = false;
				trigger.disabledHoverTip = Lang.Get("NOT_HOLDING_ITEM");
			}
			else if (ShipInventory.Config.OverrideTrigger.Value == Config.OverrideMode.NEVER)
			{
				trigger.interactable = false;
				trigger.disabledHoverTip = "Disabled by HOST";
			}
			else if (ShipInventory.Config.OverrideTrigger.Value == Config.OverrideMode.ALL)
			{
				trigger.interactable = true;
			}
			else if (!StartOfRound.Instance.inShipPhase && ShipInventory.Config.RequireInOrbit.Value)
			{
				trigger.interactable = false;
				trigger.disabledHoverTip = Lang.Get("NOT_IN_ORBIT");
			}
			else if (storedItems.Count() == ShipInventory.Config.MaxItemCount.Value)
			{
				trigger.interactable = false;
				trigger.disabledHoverTip = Lang.Get("INVENTORY_FULL");
			}
			else if (!IsItemAllowed(local.currentlyHeldObjectServer?.itemProperties))
			{
				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.Applications
{
	public class ShipApplication : InteractiveTerminalApplication
	{
		private readonly string CONFIRMATION_TITLE = Lang.Get("CONFIRMATION_TITLE");

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

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

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

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

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

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

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

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

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

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

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

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

		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");

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

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

		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_CAPACITY = Lang.Get("SHIP_INFO_CAPACITY");

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

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

		public override void Initialization()
		{
			Main();
		}

		private void Main()
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Expected O, but got Unknown
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Expected O, but got Unknown
			//IL_009f: 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)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Expected O, but got Unknown
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Expected O, but got Unknown
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Expected O, but got Unknown
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Expected O, but got Unknown
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Expected O, but got Unknown
			PlayerControllerB localPlayerController = StartOfRound.Instance.localPlayerController;
			int num = (ShipInventory.Config.NoSteamID.Value ? new Random((int)localPlayerController.playerSteamId).Next() : ((int)localPlayerController.playerSteamId));
			CursorMenu val = new CursorMenu();
			((BaseCursorMenu<CursorElement>)(object)val).cursorIndex = 0;
			((BaseCursorMenu<CursorElement>)(object)val).elements = (CursorElement[])(object)new CursorElement[5]
			{
				new CursorElement
				{
					Name = SINGLE_RETRIEVE,
					Active = (CursorElement _) => ItemManager.GetItems().Any(),
					Action = delegate
					{
						RetrieveSingle(0);
					}
				},
				new CursorElement
				{
					Name = TYPE_RETRIEVE,
					Active = (CursorElement _) => ItemManager.GetItems().Any(),
					Action = delegate
					{
						RetrieveType(0);
					}
				},
				new CursorElement
				{
					Name = RANDOM_RETRIEVE,
					Active = (CursorElement _) => ItemManager.GetItems().Any(),
					Action = RetrieveRandom
				},
				new CursorElement
				{
					Name = ALL_RETRIEVE,
					Active = (CursorElement _) => ItemManager.GetItems().Any(),
					Action = RetrieveAll
				},
				new CursorElement
				{
					Name = SHIP_INFO,
					Action = GetInfo
				}
			};
			CursorMenu val2 = val;
			BoxedScreen val3 = new BoxedScreen();
			val3.Title = TERMINAL_TITLE;
			val3.elements = (ITextElement[])(object)new ITextElement[7]
			{
				(ITextElement)TextElement.Create(string.Format(WELCOME_MESSAGE, HUDManager.Instance.playerLevels[localPlayerController.playerLevelNumber].levelName, num)),
				(ITextElement)TextElement.Create(" "),
				(ITextElement)TextElement.Create(HOME_MESSAGE),
				(ITextElement)TextElement.Create(" "),
				(ITextElement)val2,
				(ITextElement)TextElement.Create(" "),
				(ITextElement)TextElement.Create(TRADEMARK)
			};
			BoxedScreen val4 = val3;
			((BaseInteractiveApplication<CursorMenu, CursorElement>)(object)this).SwitchScreen((IScreen)(object)val4, val2, true);
		}

		private void Confirm(string message, Action? callback)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Expected O, but got Unknown
			//IL_007d: 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_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Expected O, but got Unknown
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Expected O, but got Unknown
			Action callback2 = callback;
			if (!ShipInventory.Config.ShowConfirmation.Value)
			{
				callback2?.Invoke();
				return;
			}
			CursorMenu val = new CursorMenu();
			((BaseCursorMenu<CursorElement>)(object)val).cursorIndex = 0;
			((BaseCursorMenu<CursorElement>)(object)val).elements = (CursorElement[])(object)new CursorElement[2]
			{
				new CursorElement
				{
					Name = NEGATIVE_ANSWER,
					Action = Main
				},
				new CursorElement
				{
					Name = POSITIVE_ANSWER,
					Action = delegate
					{
						callback2?.Invoke();
					}
				}
			};
			CursorMenu val2 = val;
			BoxedScreen val3 = new BoxedScreen();
			val3.Title = CONFIRMATION_TITLE;
			val3.elements = (ITextElement[])(object)new ITextElement[5]
			{
				(ITextElement)TextElement.Create(message),
				(ITextElement)TextElement.Create(" "),
				(ITextElement)TextElement.Create(CONFIRMATION_MESSAGE),
				(ITextElement)TextElement.Create(" "),
				(ITextElement)val2
			};
			BoxedScreen val4 = val3;
			((BaseInteractiveApplication<CursorMenu, CursorElement>)(object)this).SwitchScreen((IScreen)(object)val4, val2, true);
		}

		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);
			Confirm(tEXT_RANDOM_RETRIEVE, delegate
			{
				if (randomObj is ItemData)
				{
					ItemData data = (ItemData)randomObj;
					if (true)
					{
						ChuteInteract.Instance?.SpawnItemServerRpc(data);
					}
				}
				Object.Destroy((Object)(object)InteractiveTerminalManager.Instance);
			});
		}

		private void RetrieveAll()
		{
			Confirm(TEXT_ALL_RETRIEVE, delegate
			{
				foreach (IGrouping<int, ItemData> item in from i in ItemManager.GetItems()
					group i by i.ID)
				{
					ChuteInteract.Instance?.SpawnItemServerRpc(item.First(), item.Count());
				}
				Object.Destroy((Object)(object)InteractiveTerminalManager.Instance);
			});
		}

		private void RetrieveSingle(int index)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Expected O, but got Unknown
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Expected O, but got Unknown
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Expected O, but got Unknown
			//IL_00ec: Expected O, but got Unknown
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Expected O, but got Unknown
			//IL_00a7: 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_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Expected O, but got Unknown
			IEnumerable<ItemData> items = ItemManager.GetItems();
			List<CursorElement> list = new List<CursorElement>();
			if (index > 0)
			{
				list.Add(new CursorElement
				{
					Name = PREVIOUS,
					Action = delegate
					{
						RetrieveSingle(index - 1);
					}
				});
			}
			list.AddRange(items.Skip(index * 10).Take(10).Select((Func<ItemData, CursorElement>)delegate(ItemData item)
			{
				//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_007a: Unknown result type (might be due to invalid IL or missing references)
				//IL_008e: Expected O, but got Unknown
				Item item2 = item.GetItem();
				string name = UNKNOWN;
				if (item2 != null)
				{
					name = string.Format(SINGLE_ITEM_FORMAT, item2.itemName, item.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);
						Confirm(tEXT_SINGLE_RETRIEVE, delegate
						{
							ChuteInteract.Instance?.SpawnItemServerRpc(item);
							Object.Destroy((Object)(object)InteractiveTerminalManager.Instance);
						});
					}
				};
			}));
			if (items.Count() > 10 * (index + 1))
			{
				list.Add(new CursorElement
				{
					Name = NEXT,
					Action = delegate
					{
						RetrieveSingle(index + 1);
					}
				});
			}
			CursorMenu val = new CursorMenu();
			((BaseCursorMenu<CursorElement>)val).cursorIndex = 0;
			((BaseCursorMenu<CursorElement>)val).elements = list.ToArray();
			CursorMenu val2 = val;
			BoxedScreen val3 = new BoxedScreen();
			val3.Title = INVENTORY_TITLE;
			val3.elements = (ITextElement[])(object)new ITextElement[3]
			{
				(ITextElement)TextElement.Create(SINGLE_RETRIEVE_MESSAGE),
				(ITextElement)TextElement.Create(" "),
				(ITextElement)val2
			};
			BoxedScreen val4 = val3;
			((BaseInteractiveApplication<CursorMenu, CursorElement>)(object)this).SwitchScreen((IScreen)(object)val4, val2, true);
		}

		private void RetrieveType(int index)
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Expected O, but got Unknown
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Expected O, but got Unknown
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Expected O, but got Unknown
			//IL_0110: Expected O, but got Unknown
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Expected O, but got Unknown
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Expected O, but got Unknown
			IEnumerable<IGrouping<int, ItemData>> source = from i in ItemManager.GetItems()
				group i by i.ID;
			List<CursorElement> list = new List<CursorElement>();
			if (index > 0)
			{
				list.Add(new CursorElement
				{
					Name = PREVIOUS,
					Action = delegate
					{
						RetrieveType(index - 1);
					}
				});
			}
			list.AddRange(source.Skip(index * 10).Take(10).Select((Func<IGrouping<int, ItemData>, CursorElement>)delegate(IGrouping<int, ItemData> group)
			{
				//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b5: 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_00d2: Expected O, but got Unknown
				Item j = group.First().GetItem();
				int amount = group.Count();
				string name = UNKNOWN;
				if (j != null)
				{
					name = string.Format(TYPE_ITEM_FORMAT, j.itemName, amount, group.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, j?.itemName ?? UNKNOWN);
						Confirm(tEXT_TYPE_RETRIEVE, delegate
						{
							ChuteInteract.Instance?.SpawnItemServerRpc(group.First(), amount);
							Object.Destroy((Object)(object)InteractiveTerminalManager.Instance);
						});
					}
				};
			}));
			if (source.Count() > 10 * (index + 1))
			{
				list.Add(new CursorElement
				{
					Name = NEXT,
					Action = delegate
					{
						RetrieveType(index + 1);
					}
				});
			}
			CursorMenu val = new CursorMenu();
			((BaseCursorMenu<CursorElement>)val).cursorIndex = 0;
			((BaseCursorMenu<CursorElement>)val).elements = list.ToArray();
			CursorMenu val2 = val;
			BoxedScreen val3 = new BoxedScreen();
			val3.Title = INVENTORY_TITLE;
			val3.elements = (ITextElement[])(object)new ITextElement[3]
			{
				(ITextElement)TextElement.Create(TYPE_RETRIEVE_MESSAGE),
				(ITextElement)TextElement.Create(" "),
				(ITextElement)val2
			};
			BoxedScreen val4 = val3;
			((BaseInteractiveApplication<CursorMenu, CursorElement>)(object)this).SwitchScreen((IScreen)(object)val4, val2, true);
		}

		private void GetInfo()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			CursorMenu val = new CursorMenu();
			((BaseCursorMenu<CursorElement>)(object)val).cursorIndex = 0;
			((BaseCursorMenu<CursorElement>)(object)val).elements = (CursorElement[])(object)new CursorElement[1]
			{
				new CursorElement
				{
					Name = EXIT,
					Action = Main
				}
			};
			CursorMenu val2 = val;
			BoxedScreen val3 = new BoxedScreen();
			val3.Title = INVENTORY_TITLE;
			val3.elements = (ITextElement[])(object)new ITextElement[10]
			{
				(ITextElement)TextElement.Create(SHIP_INFO_HEADER),
				(ITextElement)TextElement.Create(" "),
				(ITextElement)TextElement.Create(string.Format(SHIP_INFO_TOTAL, ItemManager.GetTotalValue())),
				(ITextElement)TextElement.Create(string.Format(SHIP_INFO_COUNT, ItemManager.GetItems().Count())),
				(ITextElement)TextElement.Create(" "),
				(ITextElement)TextElement.Create(string.Format(SHIP_INFO_CAPACITY, ShipInventory.Config.MaxItemCount.Value)),
				(ITextElement)TextElement.Create(string.Format(SHIP_INFO_IS_SAFE, (ShipInventory.Config.ActAsSafe.Value ? ("<color=green>" + POSITIVE_ANSWER) : ("<color=red>" + NEGATIVE_ANSWER)) + "</color>")),
				(ITextElement)TextElement.Create(string.Format(SHIP_INFO_IN_ORBIT, ((!ShipInventory.Config.RequireInOrbit.Value) ? ("<color=green>" + POSITIVE_ANSWER) : ("<color=red>" + NEGATIVE_ANSWER)) + "</color>")),
				(ITextElement)TextElement.Create(" "),
				(ITextElement)val2
			};
			BoxedScreen val4 = val3;
			((BaseInteractiveApplication<CursorMenu, CursorElement>)(object)this).SwitchScreen((IScreen)(object)val4, val2, true);
		}
	}
}
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
	{
	}
}