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.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using CSync.Extensions;
using CSync.Lib;
using CustomItemBehaviourLibrary.AbstractItems;
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 LethalLib.Modules;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using OpenMonitors.Monitors;
using ShipInventory.Applications;
using ShipInventory.Compatibility;
using ShipInventory.Extensions;
using ShipInventory.Helpers;
using ShipInventory.Items;
using ShipInventory.Objects;
using ShipInventory.Patches;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.InputSystem;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("OpenMonitors")]
[assembly: AssemblyCompany("LethalCompanyModding")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Adds an inventory to the ship, allowing it to store items and retrieve them.")]
[assembly: AssemblyFileVersion("1.2.13.0")]
[assembly: AssemblyInformationalVersion("1.2.13+18c758bc5a4ffeb9bc845599812851559c4a612c")]
[assembly: AssemblyProduct("ShipInventoryUpdated")]
[assembly: AssemblyTitle("ShipInventoryUpdated")]
[assembly: AssemblyMetadata("RepositoryUrl", "__PROJECT_URL__")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.13.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
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;
}
}
}
internal static class LCMPluginInfo
{
public const string PLUGIN_GUID = "ShipInventoryUpdated";
public const string PLUGIN_NAME = "ShipInventoryUpdated";
public const string PLUGIN_VERSION = "1.2.13";
}
namespace ShipInventory
{
public class Configuration : SyncedConfig2<Configuration>
{
public enum PermissionLevel
{
HOST_ONLY,
CLIENTS_ONLY,
EVERYONE,
NO_ONE
}
public enum SortOrder
{
NONE,
NAME_ASC,
NAME_DESC,
VALUE_ASC,
VALUE_DESC
}
public readonly ConfigEntry<string> LangUsed;
[SyncedEntryField]
public SyncedEntry<PermissionLevel> ChutePermission;
[SyncedEntryField]
public SyncedEntry<bool> RequireInOrbit;
[SyncedEntryField]
public SyncedEntry<float> TimeToStore;
[SyncedEntryField]
public SyncedEntry<float> TimeToRetrieve;
[SyncedEntryField]
public SyncedEntry<int> StopAfter;
[SyncedEntryField]
public SyncedEntry<string> Blacklist;
[SyncedEntryField]
public SyncedEntry<PermissionLevel> InventoryPermission;
[SyncedEntryField]
public SyncedEntry<bool> ActAsSafe;
[SyncedEntryField]
public SyncedEntry<bool> PersistThroughFire;
[SyncedEntryField]
public SyncedEntry<int> MaxItemCount;
[SyncedEntryField]
public SyncedEntry<float> KeepRate;
public ConfigEntry<SortOrder> InventorySortOrder;
[SyncedEntryField]
public SyncedEntry<bool> KeepRemoveAll;
public ConfigEntry<string> InventoryCommand;
public ConfigEntry<bool> YesPlease;
public ConfigEntry<bool> ShowConfirmation;
public ConfigEntry<bool> ShowTrademark;
[SyncedEntryField]
public SyncedEntry<float> InventoryRefreshRate;
[SyncedEntryField]
public SyncedEntry<bool> InventoryUpdateCheckSilencer;
[SyncedEntryField]
public SyncedEntry<bool> ForceUpdateUponAdding;
[SyncedEntryField]
public SyncedEntry<bool> ForceUpdateUponRemoving;
[SyncedEntryField]
public SyncedEntry<bool> ChuteIsUnlock;
[SyncedEntryField]
public SyncedEntry<int> ChuteUnlockCost;
[SyncedEntryField]
public SyncedEntry<int> ChuteUnlockID;
[SyncedEntryField]
public SyncedEntry<string> ChuteUnlockName;
public Configuration(ConfigFile cfg)
: base("ShipInventoryUpdated")
{
LangUsed = cfg.Bind<string>("Language", "Language", "en", (ConfigDescription)null);
Lang.LoadLang(LangUsed.Value);
LoadChuteConfig(cfg);
LoadInventoryConfig(cfg);
LoadTerminalConfig(cfg);
LoadNetworkConfig(cfg);
LoadUnlockConfig(cfg);
if (LethalConfig.Enabled)
{
LethalConfig.AddConfigs(this);
}
}
private void LoadChuteConfig(ConfigFile cfg)
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Expected O, but got Unknown
//IL_0033: Expected O, but got Unknown
//IL_0040: 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_0060: Expected O, but got Unknown
//IL_0060: Expected O, but got Unknown
//IL_006d: 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_0091: Expected O, but got Unknown
//IL_0091: Expected O, but got Unknown
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Expected O, but got Unknown
//IL_00c2: Expected O, but got Unknown
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Expected O, but got Unknown
//IL_00f0: Expected O, but got Unknown
//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: Unknown result type (might be due to invalid IL or missing references)
//IL_0121: Expected O, but got Unknown
//IL_0121: Expected O, but got Unknown
string text = Lang.Get("CHUTE_SECTION");
ChutePermission = SyncedBindingExtensions.BindSyncedEntry<PermissionLevel>(cfg, new ConfigDefinition(text, "ChutePermission"), PermissionLevel.EVERYONE, new ConfigDescription(Lang.Get("DESCRIPTION_CHUTE_PERMISSION"), (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>()));
TimeToStore = SyncedBindingExtensions.BindSyncedEntry<float>(cfg, new ConfigDefinition(text, "TimeToStore"), 0.5f, new ConfigDescription(Lang.Get("DESCRIPTION_TIME_TO_STORE"), (AcceptableValueBase)null, Array.Empty<object>()));
TimeToRetrieve = SyncedBindingExtensions.BindSyncedEntry<float>(cfg, new ConfigDefinition(text, "ChuteDelay"), 0.5f, new ConfigDescription(Lang.Get("DESCRIPTION_TIME_TO_RETRIEVE"), (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>()));
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);
}
private void LoadInventoryConfig(ConfigFile cfg)
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Expected O, but got Unknown
//IL_0033: Expected O, but got Unknown
//IL_0040: 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_0060: Expected O, but got Unknown
//IL_0060: Expected O, but got Unknown
//IL_006d: 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_008d: Expected O, but got Unknown
//IL_008d: Expected O, but got Unknown
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Expected O, but got Unknown
//IL_00be: Expected O, but got Unknown
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Expected O, but got Unknown
//IL_00ef: Expected O, but got Unknown
//IL_00fc: 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_011c: Expected O, but got Unknown
//IL_011c: Expected O, but got Unknown
//IL_0129: 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: Expected O, but got Unknown
//IL_0149: Expected O, but got Unknown
string text = Lang.Get("INVENTORY_SECTION");
InventoryPermission = SyncedBindingExtensions.BindSyncedEntry<PermissionLevel>(cfg, new ConfigDefinition(text, "InventoryPermission"), PermissionLevel.EVERYONE, new ConfigDescription(Lang.Get("DESCRIPTION_INVENTORY_PERMISSION"), (AcceptableValueBase)null, Array.Empty<object>()));
ActAsSafe = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, new ConfigDefinition(text, "ChuteSafe"), false, new ConfigDescription(Lang.Get("DESCRIPTION_AS_SAFE"), (AcceptableValueBase)null, Array.Empty<object>()));
PersistThroughFire = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, new ConfigDefinition(text, "PersistThroughFire"), false, new ConfigDescription(Lang.Get("DESCRIPTION_PERSIST_THROUGH_FIRE"), (AcceptableValueBase)null, Array.Empty<object>()));
MaxItemCount = SyncedBindingExtensions.BindSyncedEntry<int>(cfg, new ConfigDefinition(text, "MaxItemCount"), 5000, new ConfigDescription(Lang.Get("DESCRIPTION_MAX_ITEM_COUNT"), (AcceptableValueBase)null, Array.Empty<object>()));
KeepRate = SyncedBindingExtensions.BindSyncedEntry<float>(cfg, new ConfigDefinition(text, "KeepRate"), 0f, new ConfigDescription(Lang.Get("DESCRIPTION_KEEP_RATE"), (AcceptableValueBase)null, Array.Empty<object>()));
InventorySortOrder = cfg.Bind<SortOrder>(new ConfigDefinition(text, "InventorySortOrder"), SortOrder.NAME_ASC, new ConfigDescription(Lang.Get("DESCRIPTION_INVENTORY_SORT_ORDER"), (AcceptableValueBase)null, Array.Empty<object>()));
KeepRemoveAll = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, new ConfigDefinition(text, "KeepRemoveAll"), true, new ConfigDescription(Lang.Get("DESCRIPTION_KEEP_REMOVE_ALL"), (AcceptableValueBase)null, Array.Empty<object>()));
}
private void LoadTerminalConfig(ConfigFile cfg)
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Expected O, but got Unknown
//IL_0037: Expected O, but got Unknown
//IL_0044: 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_0064: Expected O, but got Unknown
//IL_0064: Expected O, but got Unknown
//IL_0071: 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_0091: Expected O, but got Unknown
//IL_0091: Expected O, but got Unknown
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Expected O, but got Unknown
//IL_00be: Expected O, but got Unknown
string text = Lang.Get("TERMINAL_SECTION");
InventoryCommand = cfg.Bind<string>(new ConfigDefinition(text, "InventoryCommand"), "ship", new ConfigDescription(Lang.Get("DESCRIPTION_INVENTORY_COMMAND"), (AcceptableValueBase)null, Array.Empty<object>()));
YesPlease = cfg.Bind<bool>(new ConfigDefinition(text, "YesPlease"), false, new ConfigDescription(Lang.Get("DESCRIPTION_YES_PLEASE"), (AcceptableValueBase)null, Array.Empty<object>()));
ShowConfirmation = cfg.Bind<bool>(new ConfigDefinition(text, "ShowConfirmation"), true, new ConfigDescription(Lang.Get("DESCRIPTION_SHOW_CONFIRMATION"), (AcceptableValueBase)null, Array.Empty<object>()));
ShowTrademark = cfg.Bind<bool>(new ConfigDefinition(text, "ShowTrademark"), true, new ConfigDescription(Lang.Get("DESCRIPTION_SHOW_TRADEMARK"), (AcceptableValueBase)null, Array.Empty<object>()));
}
private void LoadNetworkConfig(ConfigFile cfg)
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Expected O, but got Unknown
//IL_0037: Expected O, but got Unknown
//IL_0044: 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_0064: Expected O, but got Unknown
//IL_0064: Expected O, but got Unknown
//IL_009b: 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_00bb: Expected O, but got Unknown
//IL_00bb: Expected O, but got Unknown
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Expected O, but got Unknown
//IL_00e8: Expected O, but got Unknown
string text = Lang.Get("NETWORK_SECTION");
InventoryRefreshRate = SyncedBindingExtensions.BindSyncedEntry<float>(cfg, new ConfigDefinition(text, "InventoryRefreshRate"), 15f, new ConfigDescription(Lang.Get("DESCRIPTION_INVENTORY_REFRESH_RATE"), (AcceptableValueBase)null, Array.Empty<object>()));
InventoryUpdateCheckSilencer = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, new ConfigDefinition(text, "InventoryUpdateCheckSilencer"), false, new ConfigDescription(Lang.Get("DESCRIPTION_INVENTORY_UPDATE_CHECK_SILENCER"), (AcceptableValueBase)null, Array.Empty<object>()));
InventoryUpdateCheckSilencer.Changed += delegate(object _, SyncedSettingChangedEventArgs<bool> e)
{
if (!e.OldValue && e.NewValue)
{
Logger.Debug("Inventory Update Check has been silenced.");
}
};
ForceUpdateUponAdding = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, new ConfigDefinition(text, "ForceUpdateUponAdding"), true, new ConfigDescription(Lang.Get("DESCRIPTION_FORCE_UPDATE_UPON_ADDING"), (AcceptableValueBase)null, Array.Empty<object>()));
ForceUpdateUponRemoving = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, new ConfigDefinition(text, "ForceUpdateUponRemoving"), true, new ConfigDescription(Lang.Get("DESCRIPTION_FORCE_UPDATE_UPON_REMOVING"), (AcceptableValueBase)null, Array.Empty<object>()));
}
private void LoadUnlockConfig(ConfigFile cfg)
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Expected O, but got Unknown
//IL_0033: Expected O, but got Unknown
//IL_0040: 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_0064: Expected O, but got Unknown
//IL_0064: Expected O, but got Unknown
//IL_0071: 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_0092: Expected O, but got Unknown
//IL_0092: Expected O, but got Unknown
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: Expected O, but got Unknown
//IL_00ed: Expected O, but got Unknown
string text = Lang.Get("UNLOCK_SECTION");
ChuteIsUnlock = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, new ConfigDefinition(text, "ChuteIsUnlock"), true, new ConfigDescription(Lang.Get("DESCRIPTION_CHUTE_IS_UNLOCK"), (AcceptableValueBase)null, Array.Empty<object>()));
ChuteUnlockID = SyncedBindingExtensions.BindSyncedEntry<int>(cfg, new ConfigDefinition(text, "ChuteUnlockID"), 901, new ConfigDescription(Lang.Get("DESCRIPTION_UNLOCK_ID"), (AcceptableValueBase)null, Array.Empty<object>()));
ChuteUnlockCost = SyncedBindingExtensions.BindSyncedEntry<int>(cfg, new ConfigDefinition(text, "ChuteUnlockCost"), 60, new ConfigDescription(Lang.Get("DESCRIPTION_UNLOCK_COST"), (AcceptableValueBase)null, Array.Empty<object>()));
ChuteUnlockCost.Changed += delegate(object _, SyncedSettingChangedEventArgs<int> e)
{
if (ChuteInteract.UnlockableItem != null)
{
Unlockables.UpdateUnlockablePrice(ChuteInteract.UnlockableItem, e.NewValue);
}
};
ChuteUnlockName = SyncedBindingExtensions.BindSyncedEntry<string>(cfg, new ConfigDefinition(text, "ChuteUnlockName"), "ship inventory", new ConfigDescription(Lang.Get("DESCRIPTION_UNLOCK_NAME"), (AcceptableValueBase)null, Array.Empty<object>()));
}
}
public static class Constants
{
public const string DROP_NODE_PATH = "DropNode";
public const string STORED_ITEMS = "shipInventoryItems";
public const string BAD_ITEM_KEYS = "shipInventoryMissingKeys";
public const string CHUTE_PREFAB = "ChutePrefab";
public const string MOD_ICON = "icon.png";
public const string ERROR_ITEM_ASSET = "ErrorItem";
public const string INVENTORY_BUY_TERMINAL_NODE = "InventoryBuy";
public const string BUNDLE_MAIN = "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("ShipInventoryUpdated", "ShipInventoryUpdated", "1.2.13")]
[BepInDependency("WhiteSpike.InteractiveTerminalAPI", "1.2.0")]
[BepInDependency("com.sigurd.csync", "5.0.1")]
[BepInDependency("evaisa.lethallib", "0.16.2")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class ShipInventory : BaseUnityPlugin
{
public static Configuration Configuration;
private Harmony? _harmony;
private void Awake()
{
Logger.SetLogger(((BaseUnityPlugin)this).Logger);
if (Bundle.LoadBundle("ShipInventory.Resources.si-bundle"))
{
Configuration = new Configuration(((BaseUnityPlugin)this).Config);
if (LoadFallbackItem() && PrepareRPCs())
{
ApplyPatches();
InteractiveTerminalManager.RegisterApplication<ShipApplication>(Configuration.InventoryCommand.Value, true);
Logger.Info("ShipInventoryUpdated v1.2.13 has loaded!");
}
}
}
private void ApplyPatches()
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected O, but got Unknown
Logger.Debug("Applying patches...");
if (_harmony == null)
{
_harmony = new Harmony("ShipInventoryUpdated");
}
_harmony.PatchAll(typeof(GameNetworkManager_Patches));
_harmony.PatchAll(typeof(RoundManager_Patches));
_harmony.PatchAll(typeof(StartOfRound_Patches));
if (OpenMonitors.Enabled)
{
OpenMonitors.PatchAll(_harmony);
}
Logger.Debug("Finished applying patches!");
}
private void RemovePatches()
{
Logger.Debug("Removing patches...");
Harmony? harmony = _harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
Logger.Debug("Finished removing patches!");
}
private static bool PrepareRPCs()
{
try
{
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);
}
}
}
}
catch (Exception ex)
{
Logger.Error("Error while preparing RPCs: '" + ex.Message + "'");
return false;
}
return true;
}
private static bool LoadFallbackItem()
{
Item val = Bundle.LoadAsset<Item>("ErrorItem");
if ((Object)(object)val == (Object)null)
{
return false;
}
BadItem badItem = val.spawnPrefab.AddComponent<BadItem>();
((GrabbableObject)badItem).itemProperties = val;
NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
Items.RegisterItem(val);
ItemManager.FALLBACK_ITEM = val;
return true;
}
internal static bool LoadChute(out GameObject? prefab)
{
prefab = null;
GameObject val = Bundle.LoadAsset<GameObject>("ChutePrefab");
if ((Object)(object)val == (Object)null)
{
return false;
}
val.AddComponent<ChuteInteract>();
AutoParentToShip component = val.GetComponent<AutoParentToShip>();
ChuteInteract.SetOffsets(component);
component.overrideOffset = true;
NetworkManager.Singleton.AddNetworkPrefab(val);
prefab = val;
return true;
}
internal static bool LoadTerminalNode(GameObject prefab)
{
//IL_0045: 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_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: 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_0089: 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_0098: Expected O, but got Unknown
TerminalNode val = Bundle.LoadAsset<TerminalNode>("InventoryBuy");
val.shipUnlockableID = Configuration.ChuteUnlockID.Value;
Logger.Info($"Unlock ID: {val.shipUnlockableID}");
if ((Object)(object)val == (Object)null)
{
return false;
}
UnlockableItem val2 = new UnlockableItem
{
unlockableName = Configuration.ChuteUnlockName.Value,
prefabObject = prefab,
unlockableType = 1,
shopSelectionNode = null,
alwaysInStock = true,
IsPlaceable = true,
canBeStored = true,
maxNumber = 1,
spawnPrefab = true
};
Unlockables.RegisterUnlockable(val2, (StoreType)1, (TerminalNode)null, (TerminalNode)null, val, Configuration.ChuteUnlockCost.Value);
ChuteInteract.UnlockableItem = val2;
return true;
}
}
}
namespace ShipInventory.Patches
{
[HarmonyPatch(typeof(GameNetworkManager))]
public class GameNetworkManager_Patches
{
[HarmonyPostfix]
[HarmonyPatch("Start")]
private static void LoadRequiredAssets(GameNetworkManager __instance)
{
if (ShipInventory.LoadChute(out GameObject prefab) && !((Object)(object)prefab == (Object)null))
{
ShipInventory.LoadTerminalNode(prefab);
}
}
[HarmonyPrefix]
[HarmonyPatch("SaveItemsInShip")]
private static void SaveChuteItems(GameNetworkManager __instance)
{
string currentSaveFileName = GameNetworkManager.Instance.currentSaveFileName;
ES3.DeleteKey("shipGrabbableItemIDs", currentSaveFileName);
ES3.DeleteKey("shipGrabbableItemPos", currentSaveFileName);
ES3.DeleteKey("shipScrapValues", currentSaveFileName);
ES3.DeleteKey("shipItemSaveData", currentSaveFileName);
ItemsIO.SaveStoredItems(currentSaveFileName);
ItemsIO.SaveKeys(currentSaveFileName);
}
}
[HarmonyPatch(typeof(LootMonitor))]
public class OpenMonitors_Patches
{
[HarmonyPostfix]
[HarmonyPatch("Calculate")]
private static void AddToLootMonitor(ref float __result)
{
__result += ItemManager.GetTotalValue(onlyScraps: false, onlyFromRound: false);
}
}
[HarmonyPatch(typeof(RoundManager))]
public class RoundManager_Patches
{
[HarmonyPostfix]
[HarmonyPatch("DespawnPropsAtEndOfRound")]
private static void ClearInventory(RoundManager __instance)
{
if (!((NetworkBehaviour)__instance).IsServer)
{
return;
}
ItemManager.SetAllPersisted();
if (!StartOfRound.Instance.allPlayersDead)
{
return;
}
List<ItemData> list = ItemManager.GetItems().ToList();
float num = (ShipInventory.Configuration.ActAsSafe.Value ? 1f : (ShipInventory.Configuration.KeepRate.Value / 100f));
for (int num2 = list.Count - 1; num2 >= 0; num2--)
{
if (Random.value <= num)
{
list.RemoveAt(num2);
}
}
ItemManager.RemoveItems(list.ToArray());
}
}
[HarmonyPatch(typeof(StartOfRound))]
internal class StartOfRound_Patches
{
[HarmonyPrefix]
[HarmonyPatch("LoadShipGrabbableItems")]
private static void LoadStoredItems()
{
string currentSaveFileName = GameNetworkManager.Instance.currentSaveFileName;
ItemsIO.LoadStoredItems(currentSaveFileName);
ItemsIO.LoadKeys(currentSaveFileName);
}
[HarmonyPostfix]
[HarmonyPatch("ResetShip")]
private static void ResetInventory()
{
if (!ShipInventory.Configuration.PersistThroughFire.Value)
{
ItemManager.ClearCache();
}
}
[HarmonyPostfix]
[HarmonyPatch("GetValueOfAllScrap")]
private static void GetValueOfAllScrap(ref int __result, bool onlyScrapCollected, bool onlyNewScrap)
{
__result += ItemManager.GetTotalValue(onlyScraps: true, onlyFromRound: true);
}
[HarmonyPostfix]
[HarmonyPatch("LoadUnlockables")]
private static void UnlockChute(StartOfRound __instance)
{
if (SyncedEntry<bool>.op_Implicit(ShipInventory.Configuration.ChuteIsUnlock))
{
return;
}
int num = -1;
for (int i = 0; i < __instance.unlockablesList.unlockables.Count; i++)
{
if (__instance.unlockablesList.unlockables[i] == ChuteInteract.UnlockableItem)
{
num = i;
break;
}
}
if (num == -1)
{
Logger.Error("Could not find the chute as an unlockable.");
}
else
{
__instance.UnlockShipObject(num);
}
}
[HarmonyPostfix]
[HarmonyPatch("ResetShip")]
private static void UnlockChuteBack(StartOfRound __instance)
{
if (((NetworkBehaviour)__instance).IsServer)
{
UnlockChute(__instance);
}
}
}
}
namespace ShipInventory.Objects
{
public class BadItem : PhysicsProp
{
public string? ID;
private ItemData? _data;
internal int _index;
public override void Start()
{
((GrabbableObject)this).grabbable = true;
((GrabbableObject)this).grabbableToEnemies = true;
((GrabbableObject)this).isInFactory = true;
((GrabbableObject)this).Start();
CheckForItem();
}
public override int GetItemDataToSave()
{
return _index;
}
public override void LoadItemSaveData(int saveData)
{
_index = saveData;
if (ItemsIO.GetItemKey(saveData, out _data) && _data.HasValue)
{
ID = _data.Value.ID;
}
}
private void CheckForItem()
{
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
if (!_data.HasValue)
{
return;
}
Item item = LethalLib.GetItem(_data.Value.ID);
if (!((Object)(object)item == (Object)null))
{
Logger.Debug("The item '" + ID + "' was found! Replacing the bad item with it...");
GrabbableObject component = Object.Instantiate<GameObject>(item.spawnPrefab, ((Component)this).transform.position, Quaternion.identity, ((Component)this).transform.parent).GetComponent<GrabbableObject>();
component.fallTime = 1f;
component.hasHitGround = true;
component.scrapPersistedThroughRounds = true;
component.isInElevator = true;
component.isInShipRoom = true;
if (item.isScrap)
{
component.SetScrapValue(_data.Value.SCRAP_VALUE);
}
if (item.saveItemVariable)
{
component.LoadItemSaveData(_data.Value.SAVE_DATA);
}
((NetworkBehaviour)component).NetworkObject.Spawn(false);
((NetworkBehaviour)this).NetworkObject.Despawn(true);
Logger.Debug("The replacement was spawned and the bad item was despawned!");
}
}
}
public class ChuteInteract : NetworkBehaviour
{
public static ChuteInteract? Instance;
private Transform itemRestorePoint;
private ParticleSystem? spawnParticles;
private Transform dropShipTransform;
private readonly Queue<ItemData> spawnQueue = new Queue<ItemData>();
private Coroutine? spawnCoroutine;
private string? updateKey;
private Collider[] itemsInChute = Array.Empty<Collider>();
private InteractTrigger _trigger;
public static UnlockableItem? UnlockableItem;
private Coroutine? updateCoroutine;
private int LAYER_IGNORE = -1;
private int LAYER_INTERACTABLE = -1;
private int LAYER_PROPS = -1;
private void StoreHeldItem(PlayerControllerB player)
{
GrabbableObject currentlyHeldObjectServer = player.currentlyHeldObjectServer;
if (currentlyHeldObjectServer == null)
{
Logger.Info("Player '" + player.playerUsername + "' is not holding any item.");
return;
}
StoreItem(currentlyHeldObjectServer);
currentlyHeldObjectServer.isInShipRoom = false;
currentlyHeldObjectServer.scrapPersistedThroughRounds = true;
player.SetItemInElevator(true, true, currentlyHeldObjectServer);
Logger.Debug("Despawn held object...");
player.DestroyItemInSlotAndSync(player.currentItemSlot);
}
private void StoreItem(GrabbableObject item)
{
ItemData[] items = ConvertItemHelper.ConvertItem(item);
StoreItems(items);
}
public void StoreItems(params ItemData[] items)
{
Logger.Debug($"Sending {items.Length} new items...");
StoreItemsServerRpc(items, GetClientID());
if (OpenMonitors.Enabled)
{
OpenMonitors.UpdateMonitor();
}
}
public void RetrieveItems(params ItemData[] items)
{
RetrieveItemsServerRpc(items, GetClientID());
}
private IEnumerator SpawnCoroutine()
{
while (spawnQueue.Count > 0)
{
if (itemsInChute.Length >= ShipInventory.Configuration.StopAfter.Value)
{
yield return (object)new WaitForEndOfFrame();
continue;
}
ItemData data = spawnQueue.Dequeue();
NetworkObject val = SpawnItemServer(data);
if ((Object)(object)val != (Object)null)
{
SpawnItemClientRpc(NetworkObjectReference.op_Implicit(val), data);
}
yield return (object)new WaitForSeconds(ShipInventory.Configuration.TimeToRetrieve.Value);
}
spawnCoroutine = null;
}
private NetworkObject? SpawnItemServer(ItemData data)
{
Item item = data.GetItem();
if ((Object)(object)item == (Object)null)
{
Logger.Debug("Tried to spawn '" + data.ID + "', but no item could have been found for it.");
return null;
}
if ((Object)(object)item.spawnPrefab == (Object)null)
{
Logger.Debug("Cannot spawn '" + data.ID + "', because no prefab is assigned to it.");
return null;
}
GameObject val = Object.Instantiate<GameObject>(item.spawnPrefab, itemRestorePoint, false);
if ((Object)(object)val == (Object)null)
{
return null;
}
NetworkBehaviour val2 = default(NetworkBehaviour);
if (!val.TryGetComponent<NetworkBehaviour>(ref val2))
{
return null;
}
NetworkObject networkObject = val2.NetworkObject;
networkObject.Spawn(false);
return networkObject;
}
[ClientRpc]
private void SpawnItemClientRpc(NetworkObjectReference networkObject, ItemData data)
{
//IL_004d: 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_0091: 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)
NetworkObject val = default(NetworkObject);
if (!((NetworkObjectReference)(ref networkObject)).TryGet(ref val, (NetworkManager)null))
{
return;
}
try
{
((Component)val).transform.SetParent(dropShipTransform, false);
}
catch
{
Logger.Warn("Failed to parent the object to the Drop Ship's transform.");
((Component)val).transform.SetParent(itemRestorePoint, false);
}
((Component)val).transform.position = itemRestorePoint.position;
((Component)val).transform.rotation = itemRestorePoint.rotation;
GrabbableObject val2 = default(GrabbableObject);
if (((Component)val).TryGetComponent<GrabbableObject>(ref val2))
{
if (val2.itemProperties.itemSpawnsOnGround)
{
((Component)val).transform.localRotation = Quaternion.Euler(val2.itemProperties.restingRotation);
}
else
{
val2.OnHitGround();
}
val2.scrapPersistedThroughRounds = data.PERSISTED_THROUGH_ROUNDS;
if (val2 is BadItem badItem)
{
badItem.ID = data.ID;
}
Item item = data.GetItem();
if (item.isScrap)
{
val2.SetScrapValue(data.SCRAP_VALUE);
}
if (item.saveItemVariable)
{
val2.LoadItemSaveData(data.SAVE_DATA);
}
val2.isInShipRoom = true;
val2.isInElevator = true;
((MonoBehaviour)val2).StartCoroutine(PlayDropSound(val2));
ParticleSystem? obj2 = spawnParticles;
if (obj2 != null)
{
obj2.Play();
}
}
}
private static IEnumerator PlayDropSound(GrabbableObject grabbable)
{
yield return null;
yield return null;
grabbable.PlayDropSFX();
grabbable.OnHitGround();
}
[ServerRpc(RequireOwnership = false)]
private void CheckInventoryServerRpc(string? _updateKey, string? key, params ulong[] ids)
{
//IL_0002: 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_002c: Unknown result type (might be due to invalid IL or missing references)
ClientRpcParams routing = default(ClientRpcParams);
routing.Send.TargetClientIds = ids;
string key2 = ItemManager.GetKey();
if (key2 != key)
{
UpdateInventoryClientRpc(_updateKey, key2, ItemManager.GetItems(), routing);
}
else
{
InventoryUpToDateClientRpc(_updateKey, routing);
}
}
[ServerRpc(RequireOwnership = false)]
private void StoreItemsServerRpc(ItemData[] items, params ulong[] ids)
{
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: 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_0064: 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)
Logger.Debug($"Adding {items.Length} new items...");
ItemManager.AddItems(items);
Logger.Debug("The inventory has been updated: '" + ItemManager.GetKey() + "'.");
if (ShipInventory.Configuration.ForceUpdateUponAdding.Value)
{
ForceUpdateClientRpc(new ClientRpcParams
{
Send = new ClientRpcSendParams
{
TargetClientIds = ids
}
});
}
}
[ServerRpc(RequireOwnership = false)]
private void RetrieveItemsServerRpc(ItemData[] items, params ulong[] ids)
{
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: 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_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
ItemData[] array = ItemManager.FilterExtras(items);
if (array.Length != items.Length)
{
Logger.Debug("Tried to retrieve an item that is not in the inventory anymore.");
}
if (array.Length != 0)
{
Logger.Debug($"Removing '{array.Length}' items...");
ItemManager.RemoveItems(array);
ItemData[] array2 = array;
foreach (ItemData item in array2)
{
spawnQueue.Enqueue(item);
}
if (spawnCoroutine == null)
{
spawnCoroutine = ((MonoBehaviour)this).StartCoroutine(SpawnCoroutine());
}
Logger.Debug($"{array.Length} items enqueued!");
if (ShipInventory.Configuration.ForceUpdateUponRemoving.Value)
{
ForceUpdateClientRpc(new ClientRpcParams
{
Send = new ClientRpcSendParams
{
TargetClientIds = ids
}
});
}
}
}
private static ulong GetClientID(PlayerControllerB? player = null)
{
return (player ?? GameNetworkManager.Instance.localPlayerController).actualClientId;
}
[ClientRpc]
private void UpdateInventoryClientRpc(string? _updateKey, string? key, ItemData[] data, ClientRpcParams routing = default(ClientRpcParams))
{
if (updateKey != _updateKey)
{
Logger.Debug("Received an update that was not the one expected.");
return;
}
Logger.Debug("Updating the cache with: '" + (key ?? "null") + "'");
ItemManager.UpdateCache(key, data.ToList());
Logger.Debug("Cached updated!");
updateKey = null;
}
[ClientRpc]
private void InventoryUpToDateClientRpc(string? _updateKey, ClientRpcParams routing = default(ClientRpcParams))
{
if (updateKey != _updateKey)
{
Logger.Debug("Received an inventory check that was not the one expected.");
return;
}
updateKey = null;
if (!ShipInventory.Configuration.InventoryUpdateCheckSilencer.Value)
{
Logger.Debug("The inventory is up to date! (" + ItemManager.GetKey() + ")");
}
}
[ClientRpc]
private void ForceUpdateClientRpc(ClientRpcParams routing = default(ClientRpcParams))
{
StartNewCheck();
}
private void UpdateTrigger()
{
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: 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: 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)
{
_trigger.UpdateChuteTrigger(localPlayerController);
itemsInChute = Physics.OverlapBox(itemRestorePoint.position, new Vector3(1f, 0.25f, 1.25f) / 2f, itemRestorePoint.rotation, 1 << LAYER_PROPS);
((Component)this).gameObject.layer = ((itemsInChute.Length != 0) ? LAYER_IGNORE : LAYER_INTERACTABLE);
}
}
}
public static void SetOffsets(AutoParentToShip autoParent)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: 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_002f: Unknown result type (might be due to invalid IL or missing references)
autoParent.positionOffset = new Vector3(1.9f, 1f, -4.5f);
autoParent.rotationOffset = new Vector3(35f, 0f, 0f);
}
private void StartNewCheck()
{
if (updateCoroutine != null)
{
((MonoBehaviour)this).StopCoroutine(updateCoroutine);
updateCoroutine = null;
}
updateCoroutine = ((MonoBehaviour)this).StartCoroutine(UpdateInventory());
}
private IEnumerator UpdateInventory()
{
PlayerControllerB player;
do
{
player = GameNetworkManager.Instance?.localPlayerController;
yield return null;
}
while ((Object)(object)player == (Object)null);
if (((NetworkBehaviour)player).IsHost)
{
yield break;
}
while (true)
{
updateKey = Guid.NewGuid().ToString();
CheckInventoryServerRpc(updateKey, ItemManager.GetKey(), GetClientID(player));
yield return (object)new WaitForSeconds(ShipInventory.Configuration.InventoryRefreshRate.Value);
}
}
private void Start()
{
LAYER_IGNORE = LayerMask.NameToLayer("Ignore Raycast");
LAYER_INTERACTABLE = LayerMask.NameToLayer("InteractableObject");
LAYER_PROPS = LayerMask.NameToLayer("Props");
_trigger = ((Component)this).GetComponent<InteractTrigger>();
((UnityEvent<PlayerControllerB>)(object)_trigger.onInteract).AddListener((UnityAction<PlayerControllerB>)StoreHeldItem);
_trigger.timeToHold = ShipInventory.Configuration.TimeToStore.Value;
itemRestorePoint = ((Component)this).transform.Find("DropNode");
spawnParticles = ((Component)this).GetComponentInChildren<ParticleSystem>();
dropShipTransform = GameObject.Find("/Environment/HangarShip").transform;
Logger.Info("CHUTE CREATED");
Instance = this;
StartNewCheck();
}
private void Update()
{
UpdateTrigger();
}
public override void OnDestroy()
{
((NetworkBehaviour)this).OnDestroy();
if ((Object)(object)Instance == (Object)(object)this)
{
Instance = null;
}
if (StartOfRound.Instance.firingPlayersCutsceneRunning && !ShipInventory.Configuration.PersistThroughFire.Value)
{
Logger.Debug("Clearing cache from fire!");
ItemManager.ClearCache();
}
}
}
}
namespace ShipInventory.Items
{
[Serializable]
public struct ItemData : INetworkSerializable
{
public string 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 = LethalLib.GetID(item.itemProperties);
if (item.itemProperties.isScrap)
{
SCRAP_VALUE = item.scrapValue;
}
if (item.itemProperties.saveItemVariable)
{
SAVE_DATA = item.GetItemDataToSave();
}
PERSISTED_THROUGH_ROUNDS = item.scrapPersistedThroughRounds;
}
public unsafe void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: 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_004a: Unknown result type (might be due to invalid IL or missing references)
serializer.SerializeValue(ref ID, false);
((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));
}
}
public static class ItemManager
{
public static Item? FALLBACK_ITEM;
private static List<ItemData> cachedItems = new List<ItemData>();
private static string? cacheKey;
private static readonly HashSet<string> BLACKLIST = new HashSet<string>();
public static IEnumerable<ItemData> GetInstances(ItemData data, int count)
{
if (count == 1)
{
return cachedItems.Where((ItemData d) => d.Equals(data)).Take(1);
}
return cachedItems.Where((ItemData d) => d.ID == data.ID).Take(count);
}
public static ItemData[] GetItems()
{
return cachedItems.ToArray();
}
internal static void UpdateCache(string? key, List<ItemData> items)
{
cacheKey = key;
cachedItems = items;
}
internal static void ClearCache()
{
UpdateCache(null, new List<ItemData>());
}
internal static ItemData[] FilterExtras(params ItemData[] items)
{
return items.Where((ItemData item) => cachedItems.Contains(item)).ToArray();
}
internal static void AddItems(params ItemData[] items)
{
cachedItems.AddRange(items);
NewKey();
}
internal static void RemoveItems(params ItemData[] items)
{
foreach (ItemData item in items)
{
cachedItems.Remove(item);
}
NewKey();
}
internal static void SetAllPersisted()
{
for (int i = 0; i < cachedItems.Count; i++)
{
ItemData value = cachedItems[i];
value.PERSISTED_THROUGH_ROUNDS = true;
cachedItems[i] = value;
}
NewKey();
}
public static int GetCount()
{
return cachedItems.Count;
}
public static bool HasItems()
{
return cachedItems.Count > 0;
}
public static int GetTotalValue(bool onlyScraps, bool onlyFromRound)
{
int num = 0;
foreach (ItemData cachedItem in cachedItems)
{
if (!onlyFromRound || !cachedItem.PERSISTED_THROUGH_ROUNDS)
{
Item item = cachedItem.GetItem();
if (!((Object)(object)item == (Object)null) && (!onlyScraps || item.isScrap))
{
num += cachedItem.SCRAP_VALUE;
}
}
}
return num;
}
public static string? GetKey()
{
return cacheKey;
}
private static void NewKey()
{
cacheKey = Guid.NewGuid().ToString();
}
internal static void UpdateBlacklist(string blacklistString)
{
BLACKLIST.Clear();
string[] array = blacklistString.Split(',', StringSplitOptions.RemoveEmptyEntries);
foreach (string text in array)
{
if (text != null)
{
BLACKLIST.Add("^" + text.Trim().ToLower() + "$");
}
}
}
public static bool IsBlacklisted(Item item)
{
string name = item.itemName.ToLower();
return BLACKLIST.Any((string s) => Regex.IsMatch(name, s));
}
}
internal static class ItemsIO
{
private static ItemData[]? loadedKeys;
public static void SaveStoredItems(string saveFileName)
{
if (!ItemManager.HasItems())
{
ES3.DeleteKey("shipInventoryItems", saveFileName);
Logger.Debug("Stored items cleared!");
return;
}
ItemData[] items = ItemManager.GetItems();
Logger.Debug("Saving stored items...");
ES3.Save<string>("shipInventoryItems", JsonConvert.SerializeObject((object)items), saveFileName);
Logger.Debug($"Successfully saved {ItemManager.GetCount()} items!");
}
public static void LoadStoredItems(string saveFileName)
{
ItemManager.ClearCache();
if (!ES3.KeyExists("shipInventoryItems", saveFileName))
{
Logger.Debug("No items found.");
return;
}
Logger.Debug("Loading stored items...");
string text = ES3.Load<string>("shipInventoryItems", saveFileName);
IEnumerable<ItemData> enumerable = JsonConvert.DeserializeObject<IEnumerable<ItemData>>(text);
if (enumerable == null)
{
Logger.Error("Could not load items from the save file.");
return;
}
ItemManager.AddItems(enumerable.ToArray());
Logger.Debug("Loaded stored items!");
}
public static void SaveKeys(string saveFileName)
{
BadItem[] array = Object.FindObjectsByType<BadItem>((FindObjectsInactive)0, (FindObjectsSortMode)1);
List<ItemData> list = new List<ItemData>();
BadItem[] array2 = array;
foreach (BadItem badItem in array2)
{
if (badItem.ID != null)
{
badItem._index = list.Count;
list.Add(new ItemData((GrabbableObject)(object)badItem)
{
ID = badItem.ID
});
}
}
if (list.Count == 0)
{
ES3.DeleteKey("shipInventoryMissingKeys", saveFileName);
Logger.Debug("Bad item keys cleared!");
}
else
{
Logger.Debug("Saving bad item keys...");
ES3.Save<string>("shipInventoryMissingKeys", JsonConvert.SerializeObject((object)list), saveFileName);
Logger.Debug($"Successfully saved {list.Count} keys!");
}
}
public static void LoadKeys(string saveFileName)
{
loadedKeys = null;
if (!ES3.KeyExists("shipInventoryMissingKeys", saveFileName))
{
Logger.Debug("No bad item keys found.");
return;
}
Logger.Debug("Loading bad item keys...");
string text = ES3.Load<string>("shipInventoryMissingKeys", saveFileName);
ItemData[] array = JsonConvert.DeserializeObject<ItemData[]>(text);
if (array == null)
{
Logger.Error("Could not load the bad item keys from the save file.");
return;
}
loadedKeys = array;
Logger.Debug($"Successfully loaded {array.Length} keys!");
}
public static bool GetItemKey(int index, out ItemData? data)
{
data = null;
if (loadedKeys == null)
{
return false;
}
if (index < 0 || loadedKeys.Length >= index)
{
return false;
}
data = loadedKeys[index];
return true;
}
}
}
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;
}
AssetBundle val = AssetBundle.LoadFromStream(manifestResourceStream);
if ((Object)(object)val == (Object)null)
{
Logger.Error("Failed to load the bundle '" + name + "'.");
return false;
}
loadedBundle = val;
return true;
}
public static T? LoadAsset<T>(string name) where T : Object
{
if ((Object)(object)loadedBundle == (Object)null)
{
Logger.Error("Tried to load '" + name + "', but the bundle was not loaded.");
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 ConvertItemHelper
{
private static readonly List<Func<GrabbableObject, ItemData[]?>> conversions;
static ConvertItemHelper()
{
conversions = new List<Func<GrabbableObject, ItemData[]>>();
AddConversion(CustomItemBehaviourLibrary.ConvertContainer);
AddConversion(BeltBagConversion);
AddConversion(NormalConversion, appendToStart: false);
}
public static ItemData[] ConvertItem(GrabbableObject item)
{
ItemData[] array = null;
foreach (Func<GrabbableObject, ItemData[]> conversion in conversions)
{
if (conversion != null)
{
array = conversion(item);
if (array != null)
{
break;
}
}
}
return array ?? Array.Empty<ItemData>();
}
public static void AddConversion(Func<GrabbableObject, ItemData[]?> conversion, bool appendToStart = true)
{
int index = ((!appendToStart) ? conversions.Count : 0);
conversions.Insert(index, conversion);
}
private static ItemData[]? BeltBagConversion(GrabbableObject item)
{
BeltBagItem val = (BeltBagItem)(object)((item is BeltBagItem) ? item : null);
if (val == null)
{
return null;
}
List<ItemData> list = new List<ItemData>();
for (int num = val.objectsInBag.Count - 1; num >= 0; num--)
{
GrabbableObject val2 = val.objectsInBag[num];
if (!((Object)(object)val2 == (Object)null))
{
list.AddRange(ConvertItem(val2));
}
}
list.Add(new ItemData((GrabbableObject)(object)val));
return list.ToArray();
}
private static ItemData[] NormalConversion(GrabbableObject item)
{
return new ItemData[1]
{
new ItemData(item)
};
}
}
public static class InteractionHelper
{
private static readonly List<(Func<PlayerControllerB, bool>, string)> triggerConditions;
static InteractionHelper()
{
triggerConditions = new List<(Func<PlayerControllerB, bool>, string)>();
AddCondition(IsHoldingObject, Lang.Get("NOT_HOLDING_ITEM"));
AddCondition(HasPermission, Lang.Get("CHUTE_PERMISSION_MISSING"));
AddCondition(RequireInOrbit, Lang.Get("NOT_IN_ORBIT"));
AddCondition(HasFreeSpace, Lang.Get("INVENTORY_FULL"));
AddCondition(IsAllowed, Lang.Get("ITEM_BLACKLISTED"));
AddCondition(IsValid, Lang.Get("ITEM_NOT_ALLOWED"));
}
public static void UpdateChuteTrigger(this InteractTrigger trigger, PlayerControllerB local)
{
foreach (var (func, disabledHoverTip) in triggerConditions)
{
if (!func(local))
{
trigger.interactable = false;
trigger.disabledHoverTip = disabledHoverTip;
return;
}
}
trigger.interactable = true;
trigger.disabledHoverTip = "";
}
public static void AddCondition(Func<PlayerControllerB, bool> condition, string error, bool appendToStart = false)
{
int index = ((!appendToStart) ? triggerConditions.Count : 0);
triggerConditions.Insert(index, (condition, error));
}
private static bool IsHoldingObject(PlayerControllerB p)
{
if (p.isHoldingObject)
{
return (Object)(object)p.currentlyHeldObjectServer != (Object)null;
}
return false;
}
private static bool HasPermission(PlayerControllerB p)
{
switch (ShipInventory.Configuration.ChutePermission.Value)
{
case Configuration.PermissionLevel.HOST_ONLY:
if (((NetworkBehaviour)p).IsHost)
{
break;
}
goto case Configuration.PermissionLevel.NO_ONE;
case Configuration.PermissionLevel.CLIENTS_ONLY:
if (!((NetworkBehaviour)p).IsHost)
{
break;
}
goto case Configuration.PermissionLevel.NO_ONE;
case Configuration.PermissionLevel.NO_ONE:
return false;
}
return true;
}
private static bool RequireInOrbit(PlayerControllerB p)
{
if (ShipInventory.Configuration.RequireInOrbit.Value)
{
return StartOfRound.Instance.inShipPhase;
}
return true;
}
private static bool HasFreeSpace(PlayerControllerB p)
{
return ItemManager.GetCount() < ShipInventory.Configuration.MaxItemCount.Value;
}
private static bool IsAllowed(PlayerControllerB p)
{
return !ItemManager.IsBlacklisted(p.currentlyHeldObjectServer.itemProperties);
}
private static bool IsValid(PlayerControllerB p)
{
GrabbableObject currentlyHeldObjectServer = p.currentlyHeldObjectServer;
if (currentlyHeldObjectServer.itemUsedUp)
{
return false;
}
Item itemProperties = currentlyHeldObjectServer.itemProperties;
if ((Object)(object)itemProperties.spawnPrefab == (Object)null)
{
return false;
}
RagdollGrabbableObject val = default(RagdollGrabbableObject);
if (itemProperties.spawnPrefab.TryGetComponent<RagdollGrabbableObject>(ref val))
{
return false;
}
return true;
}
}
internal static class Lang
{
public const string DEFAULT_LANG = "en";
private static readonly Dictionary<string, string> tokens = new Dictionary<string, string>();
public static bool LoadLang(string lang)
{
string codeBase = Assembly.GetExecutingAssembly().CodeBase;
UriBuilder uriBuilder = new UriBuilder(codeBase);
string directoryName = Path.GetDirectoryName(Uri.UnescapeDataString(uriBuilder.Path));
if (directoryName == null)
{
return false;
}
string text = Path.Combine(directoryName, "lang-" + lang + ".json");
if (!File.Exists(text))
{
Logger.Error("Could not find the file '" + text + "'.");
if (lang != "en")
{
return LoadLang("en");
}
return false;
}
JObject val = JObject.Parse(File.ReadAllText(text));
tokens.Clear();
foreach (var (text3, val3) in val)
{
tokens[text3] = ((object)val3)?.ToString() ?? text3;
}
Logger.Info("Language '" + lang + "' loaded!");
return true;
}
public static string Get(string id)
{
return tokens.GetValueOrDefault(id, 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_000a: 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 Trace(object? content)
{
Log((LogLevel)8, content);
}
public static void Debug(object? content)
{
Log((LogLevel)32, content);
}
public static void Info(object? content)
{
Log((LogLevel)16, content);
}
public static void Warn(object? content)
{
Log((LogLevel)4, content);
}
public static void Error(object? content)
{
Log((LogLevel)2, content);
}
}
}
namespace ShipInventory.Extensions
{
internal static class ItemDataExtensions
{
public static Item GetItem(this ItemData data)
{
Item val = LethalLib.GetItem(data.ID) ?? ItemManager.FALLBACK_ITEM;
if ((Object)(object)val != (Object)null)
{
return val;
}
throw new NullReferenceException();
}
public static string GetItemName(this ItemData data)
{
return data.GetItem().itemName;
}
}
}
namespace ShipInventory.Compatibility
{
internal static class CustomItemBehaviourLibrary
{
public const string GUID = "com.github.WhiteSpike.CustomItemBehaviourLibrary";
private static bool? _enabled;
public static bool Enabled
{
get
{
bool valueOrDefault = _enabled.GetValueOrDefault();
if (!_enabled.HasValue)
{
valueOrDefault = Chainloader.PluginInfos.ContainsKey("com.github.WhiteSpike.CustomItemBehaviourLibrary");
_enabled = valueOrDefault;
}
return _enabled.Value;
}
}
public static ItemData[]? ConvertContainer(GrabbableObject item)
{
if (!Enabled)
{
return null;
}
return HandleContainer(item);
}
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
public static ItemData[]? HandleContainer(GrabbableObject item)
{
ContainerBehaviour val = (ContainerBehaviour)(object)((item is ContainerBehaviour) ? item : null);
if (val == null)
{
return null;
}
((Behaviour)val).enabled = false;
List<ItemData> list = new List<ItemData>();
GrabbableObject[] componentsInChildren = ((Component)val).GetComponentsInChildren<GrabbableObject>();
for (int num = componentsInChildren.Length - 1; num >= 0; num--)
{
GrabbableObject val2 = componentsInChildren[num];
if (!((Object)(object)val2 == (Object)null) && !((Object)(object)val2 == (Object)(object)val))
{
list.AddRange(ConvertItemHelper.ConvertItem(val2));
}
}
list.Add(new ItemData((GrabbableObject)(object)val));
return list.ToArray();
}
}
internal static class LethalConfig
{
public const string GUID = "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(Configuration config)
{
//IL_0024: 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_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Expected O, but got Unknown
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Expected O, but got Unknown
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Expected O, but got Unknown
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: 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_00d9: Expected O, but got Unknown
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Expected O, but got Unknown
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Expected O, but got Unknown
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_00f5: Expected O, but got Unknown
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_0105: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_0120: Expected O, but got Unknown
//IL_0120: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: Expected O, but got Unknown
//IL_012b: Unknown result type (might be due to invalid IL or missing references)
//IL_0137: Expected O, but got Unknown
//IL_0132: Unknown result type (might be due to invalid IL or missing references)
//IL_013c: Expected O, but got Unknown
//IL_0147: Unknown result type (might be due to invalid IL or missing references)
//IL_014c: 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_0163: Expected O, but got Unknown
//IL_0163: Unknown result type (might be due to invalid IL or missing references)
//IL_016e: Expected O, but got Unknown
//IL_016e: Unknown result type (might be due to invalid IL or missing references)
//IL_017a: Expected O, but got Unknown
//IL_0175: Unknown result type (might be due to invalid IL or missing references)
//IL_017f: Expected O, but got Unknown
//IL_018a: Unknown result type (might be due to invalid IL or missing references)
//IL_018f: Unknown result type (might be due to invalid IL or missing references)
//IL_019f: Unknown result type (might be due to invalid IL or missing references)
//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
//IL_01ba: Expected O, but got Unknown
//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
//IL_01bf: Expected O, but got Unknown
//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
//IL_01cf: 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_01eb: Expected O, but got Unknown
//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0200: Unknown result type (might be due to invalid IL or missing references)
//IL_0210: Unknown result type (might be due to invalid IL or missing references)
//IL_021c: Expected O, but got Unknown
//IL_0217: Unknown result type (might be due to invalid IL or missing references)
//IL_0221: Expected O, but got Unknown
//IL_022c: Unknown result type (might be due to invalid IL or missing references)
//IL_0231: Unknown result type (might be due to invalid IL or missing references)
//IL_0241: Unknown result type (might be due to invalid IL or missing references)
//IL_024d: Expected O, but got Unknown
//IL_0248: Unknown result type (might be due to invalid IL or missing references)
//IL_0252: Expected O, but got Unknown
//IL_025d: Unknown result type (might be due to invalid IL or missing references)
//IL_0262: Unknown result type (might be due to invalid IL or missing references)
//IL_0272: Unknown result type (might be due to invalid IL or missing references)
//IL_0279: Expected O, but got Unknown
//IL_0279: Unknown result type (might be due to invalid IL or missing references)
//IL_0284: Expected O, but got Unknown
//IL_0284: Unknown result type (might be due to invalid IL or missing references)
//IL_0290: Expected O, but got Unknown
//IL_028b: Unknown result type (might be due to invalid IL or missing references)
//IL_0295: Expected O, but got Unknown
//IL_02a0: 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_02b5: Unknown result type (might be due to invalid IL or missing references)
//IL_02c0: Expected O, but got Unknown
//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
//IL_02cb: Expected O, but got Unknown
//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
//IL_02d7: Expected O, but got Unknown
//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
//IL_02dc: Expected O, but got Unknown
//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
//IL_0303: Expected O, but got Unknown
//IL_0313: Unknown result type (might be due to invalid IL or missing references)
//IL_0318: Unknown result type (might be due to invalid IL or missing references)
//IL_0328: Unknown result type (might be due to invalid IL or missing references)
//IL_0334: Expected O, but got Unknown
//IL_032f: Unknown result type (might be due to invalid IL or missing references)
//IL_0339: Expected O, but got Unknown
//IL_033f: Unknown result type (might be due to invalid IL or missing references)
//IL_0344: Unknown result type (might be due to invalid IL or missing references)
//IL_0354: Unknown result type (might be due to invalid IL or missing references)
//IL_035b: Unknown result type (might be due to invalid IL or missing references)
//IL_0362: Unknown result type (might be due to invalid IL or missing references)
//IL_036e: Expected O, but got Unknown
//IL_0369: Unknown result type (might be due to invalid IL or missing references)
//IL_0373: Expected O, but got Unknown
//IL_0379: Unknown result type (might be due to invalid IL or missing references)
//IL_037e: Unknown result type (might be due to invalid IL or missing references)
//IL_038e: Unknown result type (might be due to invalid IL or missing references)
//IL_039a: Expected O, but got Unknown
//IL_0395: Unknown result type (might be due to invalid IL or missing references)
//IL_039f: Expected O, but got Unknown
//IL_03a5: Unknown result type (might be due to invalid IL or missing references)
//IL_03aa: Unknown result type (might be due to invalid IL or missing references)
//IL_03ba: Unknown result type (might be due to invalid IL or missing references)
//IL_03c6: Expected O, but got Unknown
//IL_03c1: Unknown result type (might be due to invalid IL or missing references)
//IL_03cb: Expected O, but got Unknown
//IL_03d1: Unknown result type (might be due to invalid IL or missing references)
//IL_03d6: Unknown result type (might be due to invalid IL or missing references)
//IL_03e6: Unknown result type (might be due to invalid IL or missing references)
//IL_03f2: Expected O, but got Unknown
//IL_03ed: Unknown result type (might be due to invalid IL or missing references)
//IL_03f7: Expected O, but got Unknown
//IL_0402: Unknown result type (might be due to invalid IL or missing references)
//IL_0407: Unknown result type (might be due to invalid IL or missing references)
//IL_0417: Unknown result type (might be due to invalid IL or missing references)
//IL_0422: Unknown result type (might be due to invalid IL or missing references)
//IL_042d: Expected O, but got Unknown
//IL_042d: Unknown result type (might be due to invalid IL or missing references)
//IL_0438: Expected O, but got Unknown
//IL_0438: Unknown result type (might be due to invalid IL or missing references)
//IL_0444: Expected O, but got Unknown
//IL_043f: Unknown result type (might be due to invalid IL or missing references)
//IL_0449: Expected O, but got Unknown
//IL_0454: Unknown result type (might be due to invalid IL or missing references)
//IL_0459: Unknown result type (might be due to invalid IL or missing references)
//IL_0469: Unknown result type (might be due to invalid IL or missing references)
//IL_0475: Expected O, but got Unknown
//IL_0470: Unknown result type (might be due to invalid IL or missing references)
//IL_047a: Expected O, but got Unknown
//IL_0485: Unknown result type (might be due to invalid IL or missing references)
//IL_048a: Unknown result type (might be due to invalid IL or missing references)
//IL_049a: Unknown result type (might be due to invalid IL or missing references)
//IL_04a6: Expected O, but got Unknown
//IL_04a1: Unknown result type (might be due to invalid IL or missing references)
//IL_04ab: Expected O, but got Unknown
//IL_04b6: Unknown result type (might be due to invalid IL or missing references)
//IL_04bb: Unknown result type (might be due to invalid IL or missing references)
//IL_04cb: Unknown result type (might be due to invalid IL or missing references)
//IL_04d7: Expected O, but got Unknown
//IL_04d2: Unknown result type (might be due to invalid IL or missing references)
//IL_04dc: Expected O, but got Unknown
//IL_04e7: Unknown result type (might be due to invalid IL or missing references)
//IL_04ec: Unknown result type (might be due to invalid IL or missing references)
//IL_04fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0508: Expected O, but got Unknown
//IL_0503: Unknown result type (might be due to invalid IL or missing references)
//IL_050d: Expected O, but got Unknown
//IL_0518: Unknown result type (might be due to invalid IL or missing references)
//IL_051d: Unknown result type (might be due to invalid IL or missing references)
//IL_052d: Unknown result type (might be due to invalid IL or missing references)
//IL_0534: Expected O, but got Unknown
//IL_0534: Unknown result type (might be due to invalid IL or missing references)
//IL_053f: Expected O, but got Unknown
//IL_053f: Unknown result type (might be due to invalid IL or missing references)
//IL_054b: Expected O, but got Unknown
//IL_0546: Unknown result type (might be due to invalid IL or missing references)
//IL_0550: Expected O, but got Unknown
//IL_055b: Unknown result type (might be due to invalid IL or missing references)
//IL_0560: Unknown result type (might be due to invalid IL or missing references)
//IL_0570: Unknown result type (might be due to invalid IL or missing references)
//IL_0577: Unknown result type (might be due to invalid IL or missing references)
//IL_057e: Unknown result type (might be due to invalid IL or missing references)
//IL_058a: Expected O, but got Unknown
//IL_0585: Unknown result type (might be due to invalid IL or missing references)
//IL_058f: Expected O, but got Unknown
Texture2D val = Bundle.LoadAsset<Texture2D>("icon.png");
LethalConfigManager.SetModIcon(Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f)));
LethalConfigManager.SetModDescription("Adds an inventory to the ship, allowing it to store items and retrieve them.");
LethalConfigManager.AddConfigItem((BaseConfigItem)(object)new EnumDropDownConfigItem<Configuration.PermissionLevel>(config.ChutePermission.Entry, new EnumDropDownOptions
{
Name = Lang.Get("NAME_CHUTE_PERMISSION"),
RequiresRestart = false
}));
LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(config.RequireInOrbit.Entry, new BoolCheckBoxOptions
{
Name = Lang.Get("NAME_REQUIRES_IN_ORBIT"),
RequiresRestart = false
}));
ConfigEntry<float> entry = config.TimeToStore.Entry;
FloatInputFieldOptions val2 = new FloatInputFieldOptions
{
Name = Lang.Get("NAME_TIME_TO_STORE")
};
((BaseRangeOptions<float>)val2).Min = 0f;
((BaseRangeOptions<float>)val2).Max = float.MaxValue;
((BaseOptions)val2).RequiresRestart = true;
LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatInputFieldConfigItem(entry, val2));
ConfigEntry<float> entry2 = config.TimeToRetrieve.Entry;
FloatInputFieldOptions val3 = new FloatInputFieldOptions
{
Name = Lang.Get("NAME_TIME_TO_RETRIEVE")
};
((BaseRangeOptions<float>)val3).Min = 0f;
((BaseRangeOptions<float>)val3).Max = float.MaxValue;
((BaseOptions)val3).RequiresRestart = false;
LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatInputFieldConfigItem(entry2, val3));
ConfigEntry<int> entry3 = config.StopAfter.Entry;
IntSliderOptions val4 = new IntSliderOptions
{
Name = Lang.Get("NAME_STOP_AFTER")
};
((BaseRangeOptions<int>)val4).Min = 1;
((BaseRangeOptions<int>)val4).Max = 1000;
((BaseOptions)val4).RequiresRestart = false;
LethalConfigManager.AddConfigItem((BaseConfigItem)new IntSliderConfigItem(entry3, val4));
LethalConfigManager.AddConfigItem((BaseConfigItem)new TextInputFieldConfigItem(config.Blacklist.Entry, new TextInputFieldOptions
{
Name = Lang.Get("NAME_BLACKLIST"),
TrimText = true,
NumberOfLines = 10,
RequiresRestart = false
}));
LethalConfigManager.AddConfigItem((BaseConfigItem)(object)new EnumDropDownConfigItem<Configuration.PermissionLevel>(config.InventoryPermission.Entry, new EnumDropDownOptions
{
Name = Lang.Get("NAME_INVENTORY_PERMISSION"),
RequiresRestart = false
}));
LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(config.ActAsSafe.Entry, new BoolCheckBoxOptions
{
Name = Lang.Get("NAME_AS_SAFE"),
RequiresRestart = false
}));
LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(config.PersistThroughFire.Entry, new BoolCheckBoxOptions
{
Name = Lang.Get("NAME_PERSIST_THROUGH_FIRE"),
RequiresRestart = false
}));
ConfigEntry<int> entry4 = config.MaxItemCount.Entry;
IntSliderOptions val5 = new IntSliderOptions
{
Name = Lang.Get("NAME_MAX_ITEM_COUNT")
};
((BaseRangeOptions<int>)val5).Min = 1;
((BaseRangeOptions<int>)val5).Max = 10000;
((BaseOptions)val5).RequiresRestart = false;
LethalConfigManager.AddConfigItem((BaseConfigItem)new IntSliderConfigItem(entry4, val5));
ConfigEntry<float> entry5 = config.KeepRate.Entry;
FloatSliderOptions val6 = new FloatSliderOptions
{
Name = Lang.Get("NAME_KEEP_RATE")
};
((BaseRangeOptions<float>)val6).Min = 0f;
((BaseRangeOptions<float>)val6).Max = 100f;
((BaseOptions)val6).RequiresRestart = false;
LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatSliderConfigItem(entry5, val6));
LethalConfigManager.AddConfigItem((BaseConfigItem)(object)new EnumDropDownConfigItem<Configuration.SortOrder>(config.InventorySortOrder, new EnumDropDownOptions
{
Name = Lang.Get("NAME_INVENTORY_SORT_ORDER"),
RequiresRestart = false
}));
LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(config.KeepRemoveAll.Entry, new BoolCheckBoxOptions
{
Name = Lang.Get("NAME_KEEP_REMOVE_ALL"),
RequiresRestart = false
}));
LethalConfigManager.AddConfigItem((BaseConfigItem)new TextInputFieldConfigItem(config.InventoryCommand, new TextInputFieldOptions
{
Name = Lang.Get("NAME_INVENTORY_COMMAND"),
TrimText = true,
NumberOfLines = 1,
RequiresRestart = true
}));
LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(config.YesPlease, new BoolCheckBoxOptions
{
Name = Lang.Get("NAME_YES_PLEASE"),
RequiresRestart = false
}));
LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(config.ShowConfirmation, new BoolCheckBoxOptions
{
Name = Lang.Get("NAME_SHOW_CONFIRMATION"),
RequiresRestart = false
}));
LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(config.ShowTrademark, new BoolCheckBoxOptions
{
Name = Lang.Get("NAME_SHOW_TRADEMARK"),
RequiresRestart = false
}));
ConfigEntry<float> entry6 = config.InventoryRefreshRate.Entry;
FloatStepSliderOptions val7 = new FloatStepSliderOptions
{
Name = Lang.Get("NAME_INVENTORY_REFRESH_RATE"),
Step = 0.2f
};
((BaseRangeOptions<float>)val7).Min = 0.2f;
((BaseRangeOptions<float>)val7).Max = 60f;
((BaseOptions)val7).RequiresRestart = false;
LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatStepSliderConfigItem(entry6, val7));
LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(config.InventoryUpdateCheckSilencer.Entry, new BoolCheckBoxOptions
{
Name = Lang.Get("NAME_INVENTORY_UPDATE_CHECK_SILENCER"),
RequiresRestart = false
}));
LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(config.ForceUpdateUponAdding.Entry, new BoolCheckBoxOptions
{
Name = Lang.Get("NAME_FORCE_UPDATE_UPON_ADDING"),
RequiresRestart = false
}));
LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(config.ForceUpdateUponRemoving.Entry, new BoolCheckBoxOptions
{
Name = Lang.Get("NAME_FORCE_UPDATE_UPON_REMOVING"),
RequiresRestart = false
}));
LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(config.ChuteIsUnlock.Entry, new BoolCheckBoxOptions
{
Name = Lang.Get("NAME_CHUTE_IS_UNLOCK"),
RequiresRestart = false
}));
ConfigEntry<int> entry7 = config.ChuteUnlockCost.Entry;
IntSliderOptions val8 = new IntSliderOptions
{
Name = Lang.Get("NAME_UNLOCK_COST")
};
((BaseRangeOptions<int>)val8).Min = 1;
((BaseRangeOptions<int>)val8).Max = 5000;
((BaseOptions)val8).RequiresRestart = false;
LethalConfigManager.AddConfigItem((BaseConfigItem)new IntSliderConfigItem(entry7, val8));
LethalConfigManager.AddConfigItem((BaseConfigItem)new TextInputFieldConfigItem(config.ChuteUnlockName.Entry, new TextInputFieldOptions
{
Name = Lang.Get("NAME_UNLOCK_NAME"),
TrimText = true,
NumberOfLines = 1,
RequiresRestart = true
}));
LethalConfigManager.SkipAutoGenFor((ConfigEntryBase)(object)config.LangUsed);
ConfigManager.Register<Configuration>((SyncedConfig2<Configuration>)(object)config);
}
}
public static class LethalLib
{
private const string ID_FORMAT = "{0}/{1}";
private const string BAD_ITEM = "ShipInventory/BadItem";
private const string VANILLA_ITEM_MOD = "Vanilla";
private static Dictionary<string, Item>? _cachedModdedItems;
private static string ID(this Item item, string mod = "Vanilla")
{
return $"{mod}/{item.itemName}";
}
private static (string mod, string name) Extract(string id)
{
string[] array = id.Split('/', StringSplitOptions.RemoveEmptyEntries);
if (array == null || array.Length < 2)
{
Logger.Error("The item with the ID '" + id + "' is invalid.");
return ("Vanilla", id);
}
return (array[0], array[1]);
}
public static string GetID(Item item)
{
if ((Object)(object)item == (Object)(object)ItemManager.FALLBACK_ITEM)
{
return "ShipInventory/BadItem";
}
return GetModdedID(item) ?? item.ID();
}
public static Item? GetItem(string ID)
{
if (ID == "ShipInventory/BadItem")
{
return ItemManager.FALLBACK_ITEM;
}
var (text, name) = Extract(ID);
if (!(text == "Vanilla"))
{
return GetModdedItem(ID);
}
return GetVanillaItem(name);
}
private static Item? GetVanillaItem(string name)
{
string name2 = name;
return ((IEnumerable<Item>)StartOfRound.Instance.allItemsList.itemsList).FirstOrDefault((Func<Item, bool>)((Item item) => item.itemName == name2));
}
private static void LoadModdedItems()
{
if (_cachedModdedItems != null)
{
return;
}
_cachedModdedItems = new Dictionary<string, Item>();
foreach (ScrapItem scrapItem in Items.scrapItems)
{
_cachedModdedItems.TryAdd(scrapItem.item.ID(scrapItem.modName), scrapItem.item);
}
foreach (ShopItem shopItem in Items.shopItems)
{
_cachedModdedItems.TryAdd(shopItem.item.ID(shopItem.modName), shopItem.item);
}
foreach (PlainItem plainItem in Items.plainItems)
{
_cachedModdedItems.TryAdd(plainItem.item.ID(plainItem.modName), plainItem.item);
}
}
private static Item? GetModdedItem(string id)
{
LoadModdedItems();
return _cachedModdedItems.GetValueOrDefault(id);
}
private static string? GetModdedID(Item item)
{
LoadModdedItems();
if (_cachedModdedItems == null)
{
return null;
}
foreach (var (result, val2) in _cachedModdedItems)
{
if (!((Object)(object)val2 != (Object)(object)item))
{
return result;
}
}
return null;
}
}
internal static class OpenMonitors
{
public const string GUID = "xxxstoner420bongmasterxxx.open_monitors";
private static bool? _enabled;
public static bool Enabled
{
get
{
bool valueOrDefault = _enabled.GetValueOrDefault();
if (!_enabled.HasValue)
{
valueOrDefault = Chainloader.PluginInfos.ContainsKey("xxxstoner420bongmasterxxx.open_monitors");
_enabled = valueOrDefault;
}
return _enabled.Value;
}
}
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
public static void PatchAll(Harmony harmony)
{
try
{
harmony.PatchAll(typeof(OpenMonitors_Patches));
}
catch (Exception arg)
{
Logger.Error($"Failed to apply OpenMonitors patches. {arg}");
}
}
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
public static void UpdateMonitor()
{
LootMonitor.Instance.UpdateMonitor();
}
}
}
namespace ShipInventory.Applications
{
public class ShipApplication : PageApplication
{
private readonly string INVENTORY_TITLE = Lang.Get("INVENTORY_TITLE");
private readonly string TRADEMARK = Lang.Get("TRADEMARK");
private readonly string HOME_MESSAGE = Lang.Get("HOME_MESSAGE");
private readonly string WELCOME_MESSAGE = Lang.Get("WELCOME_MESSAGE");
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 int getInfoIndex = -1;
private readonly string LOCKED_MESSAGE = Lang.Get("LOCKED_MESSAGE");
private readonly string LOCKED_SUB_MESSAGE = Lang.Get("LOCKED_SUB_MESSAGE");
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 int retrieveSingleIndex = -1;
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 int retrieveTypeIndex = -1;
private readonly string RANDOM_RETRIEVE = Lang.Get("RANDOM_RETRIEVE");
private readonly string TEXT_RANDOM_RETRIEVE = Lang.Get("TEXT_RANDOM_RETRIEVE");
private int retrieveRandomIndex = -1;
private readonly string ALL_RETRIEVE = Lang.Get("ALL_RETRIEVE");
private readonly string TEXT_ALL_RETRIEVE = Lang.Get("TEXT_ALL_RETRIEVE");
private int retrieveAllIndex = -1;
public override void Initialization()
{
if ((Object)(object)ChuteInteract.Instance == (Object)null)
{
LockedScreen();
}
else
{
MainScreen(0);
}
}
protected override int GetEntriesPerPage<T>(T[] entries)
{
return 10;
}
private void MainScreen(int selectedIndex)
{
//IL_0062: 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_007c: Expected O, but got Unknown
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Expected O, but got Unknown
//IL_0084: Expected O, but got Unknown
PlayerControllerB localPlayerController = StartOfRound.Instance.localPlayerController;
CursorElement[] array = (CursorElement[])(object)new CursorElement[5]
{
RetrieveSingleElement(),
RetrieveTypeElement(),
RetrieveRandomElement(),
RetrieveAllElement(),
InfoCursorElement()
};
retrieveSingleIndex = 0;
retrieveTypeIndex = 1;
retrieveRandomIndex = 2;
retrieveAllIndex = 3;
getInfoIndex = 4;
CursorMenu val = new CursorMenu();
((BaseCursorMenu<CursorElement>)val).cursorIndex = (ItemManager.HasItems() ? 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)
{
if (!value)
{
return "<color=red>" + NEGATIVE_ANSWER + "</color>";
}
return "<color=green>" + POSITIVE_ANSWER + "</color>";
}
private static bool CanRetrieve()
{
PlayerControllerB localPlayerController = StartOfRound.Instance.localPlayerController;
switch (ShipInventory.Configuration.InventoryPermission.Value)
{
case Configuration.PermissionLevel.HOST_ONLY:
if (((NetworkBehaviour)localPlayerController).IsHost)
{
break;
}
goto case Configuration.PermissionLevel.NO_ONE;
case Configuration.PermissionLevel.CLIENTS_ONLY:
if (!((NetworkBehaviour)localPlayerController).IsHost)
{
break;
}
goto case Configuration.PermissionLevel.NO_ONE;
case Configuration.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_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
UnregisterExitAction();
BoxedScreen val = new BoxedScreen();
val.Title = title;
ITextElement[] array = (ITextElement[])((!ShipInventory.Configuration.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_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Expected O, but got Unknown
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Expected O, but got Unknown
//IL_0082: 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_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Expected O, but got Unknown
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_00f5: Expected O, but got Unknown
//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
//IL_00fc: Expected O, but got Unknown
//IL_00fe: Expected O, but got Unknown
Action declineCallback2 = declineCallback;
Action confirmCallback2 = confirmCallback;
if (!ShipInventory.Configuration.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.Configuration.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 void CreateItemPages<T>(T[] items, int selectedIndex, string text, Func<T, int, bool, CursorElement> render, int returnIndex)
{
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Expected O, but got Unknown
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Expected O, but got Unknown
//IL_00ea: Expected O, but got Unknown
int entriesPerPage = ((PageApplication)this).GetEntriesPerPage<int>(Array.Empty<int>());
int num = items.Length;
ValueTuple<T[][], CursorMenu[], IScreen[]> pageEntries = ((PageApplication)this).GetPageEntries<T>(items);
T[][] 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++)
{
T val = item[i][j];
if (val != null)
{
ref T reference = ref val;
T val2 = default(T);
if (val2 == null)
{
val2 = reference;
reference = ref val2;
}
if (!reference.Equals(default(T)))
{
array[j] = render(val, i * entriesPerPage + j, num == 1);
}
}
}
int num2 = i;
CursorMenu val3 = new CursorMenu();
((BaseCursorMenu<CursorElement>)val3).cursorIndex = 0;
((BaseCursorMenu<CursorElement>)val3).elements = array;
item2[num2] = val3;
item3[i] = (IScreen)(object)CreateScreen(INVENTORY_TITLE, (ITextElement[])(object)new ITextElement[3]
{
(ITextElement)TextElement.Create(text),
(ITextElement)TextElement.Create(" "),
(ITextElement)item2[i]
});
}
selectedIndex = Math.Clamp(selectedIndex, 0, 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(delegate
{
MainScreen(returnIndex);
});
}
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_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Expected O, but got Unknown
return new CursorElement
{
Name = SHIP_INFO,
Action = GetInfo
};
}
private void GetInfo()
{
//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_000c: Expected O, but got Unknown
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
//IL_0018: 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(onlyScraps: false, onlyFromRound: false))),
(ITextElement)TextElement.Create(string.Format(SHIP_INFO_COUNT, ItemManager.GetItems().Count(), ShipInventory.Configuration.MaxItemCount.Value)),
(ITextElement)TextElement.Create(" "),
(ITextElement)TextElement.Create(string.Format(SHIP_INFO_IN_ORBIT, BoolToString(!ShipInventory.Configuration.RequireInOrbit.Value))),
(ITextElement)TextElement.Create(" "),
(ITextElement)TextElement.Create(SHIP_INFO_KEEP_HEADER),
(ITextElement)TextElement.Create(string.Format(SHIP_INFO_KEEP_ON_WIPE, BoolToString(ShipInventory.Configuration.ActAsSafe.Value))),
(ITextElement)TextElement.Create(string.Format(SHIP_INFO_KEEP_ON_FIRE, BoolToString(ShipInventory.Configuration.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(delegate
{
MainScreen(getInfoIndex);
});
}
private void LockedScreen()
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Expected O, but got Unknown
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: 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 = BLOCKED_ANSWER,
Action = delegate
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
((TerminalApplication)this).OnScreenExit(default(CallbackContext));
}
}
};
CursorMenu val2 = val;
BoxedScreen val3 = CreateScreen(INVENTORY_TITLE, (ITextElement[])(object)new ITextElement[5]
{
(ITextElement)TextElement.Create(LOCKED_MESSAGE),
(ITextElement)TextElement.Create(" "),
(ITextElement)TextElement.Create(string.Format(LOCKED_SUB_MESSAGE, ShipInventory.Configuration.ChuteUnlockName.Value)),
(ITextElement)TextElement.Create(" "),
(ITextElement)val2
});
base.currentPage = PageCursorElement.Create(0, (IScreen[])(object)new IScreen[1] { (IScreen)val3 }, (