Decompiled source of ShipInventoryUpdated v2.0.6
plugins/ShipInventoryUpdated.dll
Decompiled 2 weeks ago
The result has been truncated due to the large size, download it to view full contents!
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 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 ShipInventoryUpdated.Configurations; using ShipInventoryUpdated.Dependencies.InteractiveTerminalAPI; using ShipInventoryUpdated.Dependencies.LethalConfig; using ShipInventoryUpdated.Dependencies.LethalLib; using ShipInventoryUpdated.Dependencies.Newtonsoft; using ShipInventoryUpdated.Helpers; using ShipInventoryUpdated.Helpers.API; using ShipInventoryUpdated.NetcodePatcher; using ShipInventoryUpdated.Objects; using ShipInventoryUpdated.Patches; using ShipInventoryUpdated.Scripts; using Unity.Collections; using Unity.Netcode; using UnityEngine; using UnityEngine.Events; using UnityEngine.InputSystem; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyCompany("LethalCompanyModding")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Adds an inventory to the ship, allowing it to store items and retrieve them.")] [assembly: AssemblyFileVersion("2.0.6.0")] [assembly: AssemblyInformationalVersion("2.0.6+da57dc344ef1974e3a2ba0c9242759bae2f0cbf3")] [assembly: AssemblyProduct("ShipInventoryUpdated")] [assembly: AssemblyTitle("ShipInventoryUpdated")] [assembly: AssemblyMetadata("RepositoryUrl", "__PROJECT_URL__")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("2.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [module: NetcodePatchedAssembly] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace ShipInventoryUpdated { [BepInPlugin("org.lethalcompanymodding.shipinventoryupdated", "ShipInventoryUpdated", "2.0.6")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class ShipInventoryUpdated : BaseUnityPlugin { public const string SAVE_KEY = "shipInventoryItems"; internal static GameObject? INVENTORY_PREFAB; internal static GameObject? CHUTE_PREFAB; internal static TerminalNode? CHUTE_BUY_NODE; internal static TerminalNode? CHUTE_CONFIRM_NODE; private Harmony? _harmony; private void Awake() { Logger.SetLogger(((BaseUnityPlugin)this).Logger); if (LoadAssets("si-bundle") && PrepareRPCs()) { Configuration.Load(((BaseUnityPlugin)this).Config); global::ShipInventoryUpdated.Helpers.Dependencies.LoadDependencies(Configuration.Instance); Patch(); InteractionHelper.LoadConditions(); ItemConverter.LoadConversions(); Logger.Info("org.lethalcompanymodding.shipinventoryupdated v2.0.6 has loaded!"); } } private static bool LoadAssets(string name) { if (!Bundle.LoadBundle(name)) { return false; } INVENTORY_PREFAB = Bundle.LoadAsset<GameObject>("InventoryPrefab"); CHUTE_PREFAB = Bundle.LoadAsset<GameObject>("ChutePrefab"); CHUTE_BUY_NODE = Bundle.LoadAsset<TerminalNode>("ChuteBuy"); CHUTE_CONFIRM_NODE = Bundle.LoadAsset<TerminalNode>("ChuteConfirm"); return true; } private void Patch() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown _harmony = new Harmony("org.lethalcompanymodding.shipinventoryupdated"); _harmony.PatchAll(typeof(GameNetworkManager_Patches)); _harmony.PatchAll(typeof(StartOfRound_Patches)); _harmony.PatchAll(typeof(Terminal_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; } } public static class MyPluginInfo { public const string PLUGIN_GUID = "org.lethalcompanymodding.shipinventoryupdated"; public const string PLUGIN_NAME = "ShipInventoryUpdated"; public const string PLUGIN_VERSION = "2.0.6"; } } namespace ShipInventoryUpdated.Scripts { public class ChuteRetrieve : NetworkBehaviour { [CompilerGenerated] private sealed class <PlayDropSound>d__13 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public GrabbableObject item; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <PlayDropSound>d__13(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = null; <>1__state = 1; return true; case 1: <>1__state = -1; <>2__current = null; <>1__state = 2; return true; case 2: <>1__state = -1; item.PlayDropSFX(); item.OnHitGround(); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <SpawnCoroutine>d__14 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public ChuteRetrieve <>4__this; private float <spawnDelay>5__2; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <SpawnCoroutine>d__14(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown //IL_005e: Unknown result type (might be due to invalid IL or missing references) int num = <>1__state; ChuteRetrieve chuteRetrieve = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; <spawnDelay>5__2 = Configuration.Instance?.Inventory.RetrieveSpeed.Value ?? 0.5f; break; case 1: <>1__state = -1; break; } if (chuteRetrieve._spawnQueue.Count > 0) { ItemData data = chuteRetrieve._spawnQueue.Dequeue(); NetworkObject val = chuteRetrieve.SpawnItemServer(data); if (val != null) { chuteRetrieve.SpawnItemClientRpc(NetworkObjectReference.op_Implicit(val), data); } <>2__current = (object)new WaitForSeconds(<spawnDelay>5__2); <>1__state = 1; return true; } chuteRetrieve._spawnCoroutine = null; return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [SerializeField] private Transform? itemRestorePoint; [SerializeField] private Vector3 itemDetectionSize; [SerializeField] private InteractTrigger? trigger; [SerializeField] private ParticleSystem? spawnParticles; private int _layerIgnore = -1; private int _layerInteractable = -1; private int _layerProps = -1; private readonly Collider[] _buffer = (Collider[])(object)new Collider[1]; private readonly Queue<ItemData> _spawnQueue = new Queue<ItemData>(); private Coroutine? _spawnCoroutine; private void Awake() { _layerIgnore = LayerMask.NameToLayer("Ignore Raycast"); _layerInteractable = LayerMask.NameToLayer("InteractableObject"); _layerProps = LayerMask.NameToLayer("Props"); Inventory.OnRemoved = (Inventory.OnListChanged)Delegate.Combine(Inventory.OnRemoved, new Inventory.OnListChanged(RetrieveItemsServerRpc)); } private void FixedUpdate() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) if (itemRestorePoint != null && trigger != null) { int num = Physics.OverlapBoxNonAlloc(itemRestorePoint.position, itemDetectionSize / 2f, _buffer, itemRestorePoint.rotation, 1 << _layerProps); ((Component)trigger).gameObject.layer = ((num > 0) ? _layerIgnore : _layerInteractable); } } public override void OnNetworkDespawn() { Inventory.OnRemoved = (Inventory.OnListChanged)Delegate.Remove(Inventory.OnRemoved, new Inventory.OnListChanged(RetrieveItemsServerRpc)); } [IteratorStateMachine(typeof(<PlayDropSound>d__13))] private static IEnumerator PlayDropSound(GrabbableObject item) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <PlayDropSound>d__13(0) { item = item }; } [IteratorStateMachine(typeof(<SpawnCoroutine>d__14))] private IEnumerator SpawnCoroutine() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <SpawnCoroutine>d__14(0) { <>4__this = this }; } private NetworkObject? SpawnItemServer(ItemData data) { //IL_0011: 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) Item item = data.GetItem(); if (item == null) { Logger.Error($"Tried to spawn '{data.ID}', but no item could have been found for it."); return null; } if (item.spawnPrefab == 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 (val == 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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3930577943u, val, (RpcDelivery)0); ((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref networkObject, default(ForNetworkSerializable)); ((FastBufferWriter)(ref val2)).WriteValueSafe<ItemData>(ref data, default(ForNetworkSerializable)); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3930577943u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost)) { return; } base.__rpc_exec_stage = (__RpcExecStage)0; Item item = data.GetItem(); if ((Object)(object)item == (Object)null) { Logger.Error("Tried to spawn an item, but the original item was not found."); return; } if ((Object)(object)itemRestorePoint == (Object)null) { Logger.Error("Tried to spawn an item, but no restore point was defined."); return; } NetworkObject val3 = default(NetworkObject); if (!((NetworkObjectReference)(ref networkObject)).TryGet(ref val3, (NetworkManager)null)) { Logger.Error("Tried to spawn an item, but the original object was not found."); return; } ((Component)val3).transform.SetParent(StartOfRound.Instance?.elevatorTransform ?? itemRestorePoint, false); ((Component)val3).transform.position = itemRestorePoint.position; ((Component)val3).transform.rotation = itemRestorePoint.rotation; GrabbableObject val4 = default(GrabbableObject); if (((Component)val3).TryGetComponent<GrabbableObject>(ref val4)) { if (val4.itemProperties.itemSpawnsOnGround) { ((Component)val3).transform.localRotation = Quaternion.Euler(val4.itemProperties.restingRotation); } else { val4.OnHitGround(); } val4.scrapPersistedThroughRounds = data.PERSISTED_THROUGH_ROUNDS; if (item.isScrap) { val4.SetScrapValue(data.SCRAP_VALUE); } if (item.saveItemVariable) { val4.LoadItemSaveData(data.SAVE_DATA); } val4.isInShipRoom = true; val4.isInElevator = true; ((MonoBehaviour)val4).StartCoroutine(PlayDropSound(val4)); ParticleSystem? obj = spawnParticles; if (obj != null) { obj.Play(); } } } [ServerRpc(RequireOwnership = false)] private void RetrieveItemsServerRpc(ItemData[] items) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { ServerRpcParams val = default(ServerRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(4046261821u, val, (RpcDelivery)0); bool flag = items != null; ((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives)); if (flag) { ((FastBufferWriter)(ref val2)).WriteValueSafe<ItemData>(items, default(ForNetworkSerializable)); } ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 4046261821u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; foreach (ItemData item in items) { _spawnQueue.Enqueue(item); } if (_spawnCoroutine == null) { _spawnCoroutine = ((MonoBehaviour)this).StartCoroutine(SpawnCoroutine()); } } } private void OnDrawGizmosSelected() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)itemRestorePoint == (Object)null)) { Gizmos.matrix = itemRestorePoint.localToWorldMatrix; Gizmos.DrawCube(Vector3.zero, itemDetectionSize / 2f); } } protected override void __initializeVariables() { ((NetworkBehaviour)this).__initializeVariables(); } protected override void __initializeRpcs() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown ((NetworkBehaviour)this).__registerRpc(3930577943u, new RpcReceiveHandler(__rpc_handler_3930577943), "SpawnItemClientRpc"); ((NetworkBehaviour)this).__registerRpc(4046261821u, new RpcReceiveHandler(__rpc_handler_4046261821), "RetrieveItemsServerRpc"); ((NetworkBehaviour)this).__initializeRpcs(); } private static void __rpc_handler_3930577943(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { NetworkObjectReference networkObject = default(NetworkObjectReference); ((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref networkObject, default(ForNetworkSerializable)); ItemData data = default(ItemData); ((FastBufferReader)(ref reader)).ReadValueSafe<ItemData>(ref data, default(ForNetworkSerializable)); target.__rpc_exec_stage = (__RpcExecStage)1; ((ChuteRetrieve)(object)target).SpawnItemClientRpc(networkObject, data); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_4046261821(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives)); ItemData[] items = null; if (flag) { ((FastBufferReader)(ref reader)).ReadValueSafe<ItemData>(ref items, default(ForNetworkSerializable)); } target.__rpc_exec_stage = (__RpcExecStage)1; ((ChuteRetrieve)(object)target).RetrieveItemsServerRpc(items); target.__rpc_exec_stage = (__RpcExecStage)0; } } [MethodImpl(MethodImplOptions.NoInlining)] protected internal override string __getTypeName() { return "ChuteRetrieve"; } } public class ChuteStore : MonoBehaviour { [SerializeField] private InteractTrigger? trigger; private void Start() { float timeToHold = Configuration.Instance?.Chute.StoreSpeed.Value ?? 0.5f; if ((Object)(object)trigger != (Object)null) { ((UnityEvent<PlayerControllerB>)(object)trigger.onInteract).AddListener((UnityAction<PlayerControllerB>)StoreHeldItem); trigger.timeToHold = timeToHold; } } private static void StoreHeldItem(PlayerControllerB player) { GrabbableObject currentlyHeldObjectServer = player.currentlyHeldObjectServer; if ((Object)(object)currentlyHeldObjectServer == (Object)null) { Logger.Info("Player '" + player.playerUsername + "' is not holding any item."); return; } ItemData[] items = ItemConverter.Convert(currentlyHeldObjectServer); Inventory.Add(items); currentlyHeldObjectServer.isInShipRoom = false; currentlyHeldObjectServer.scrapPersistedThroughRounds = true; player.SetItemInElevator(true, true, currentlyHeldObjectServer); Logger.Debug("Despawn held object..."); player.DestroyItemInSlotAndSync(player.currentItemSlot); } } [RequireComponent(typeof(Collider))] public class ChuteTrigger : InteractTrigger { private void Start() { ((InteractTrigger)this).Start(); base.hoverTip = Localization.Get("tooltip.trigger.hover", new Dictionary<string, string> { ["key"] = "LMB" }); } private void Update() { ((InteractTrigger)this).Update(); PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController; if (val != null && val.isInHangarShipRoom) { InteractionHelper.SetTriggerStatus((InteractTrigger)(object)this, val); } } protected override void __initializeVariables() { ((InteractTrigger)this).__initializeVariables(); } protected override void __initializeRpcs() { ((InteractTrigger)this).__initializeRpcs(); } [MethodImpl(MethodImplOptions.NoInlining)] protected internal override string __getTypeName() { return "ChuteTrigger"; } } public class Inventory : NetworkBehaviour { public delegate void OnListChanged(ItemData[] value); private static Inventory? _instance; private readonly NetworkList<ItemData> _storedItems = new NetworkList<ItemData>((IEnumerable<ItemData>)null, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)1); public static OnListChanged? OnAdded; public static OnListChanged? OnRemoved; public static int Count => _instance?._storedItems.Count ?? 0; public static ItemData[] Items { get { if ((Object)(object)_instance == (Object)null) { return Array.Empty<ItemData>(); } ItemData[] array = new ItemData[Count]; for (int i = 0; i < array.Length; i++) { array[i] = _instance._storedItems[i]; } return array; } } public static void Add(ItemData[] items) { if ((Object)(object)_instance == (Object)null) { Logger.Warn("Tried to add an item to the inventory, but no instance was defined."); } else { _instance.AddServerRpc(items); } } public static void Remove(ItemData[] items) { if ((Object)(object)_instance == (Object)null) { Logger.Warn("Tried to remove an item to the inventory, but no instance was defined."); } else { _instance.RemoveServerRpc(items); } } public static void Clear() { if ((Object)(object)_instance == (Object)null) { Logger.Warn("Tried to remove an item to the inventory, but no instance was defined."); } else { _instance.ClearServerRpc(); } } public override void OnNetworkSpawn() { _instance = this; } public override void OnNetworkDespawn() { if ((Object)(object)_instance == (Object)(object)this) { _instance = null; } } [ServerRpc(RequireOwnership = false)] private void AddServerRpc(params ItemData[] items) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { ServerRpcParams val = default(ServerRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(21641584u, val, (RpcDelivery)0); bool flag = items != null; ((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives)); if (flag) { ((FastBufferWriter)(ref val2)).WriteValueSafe<ItemData>(items, default(ForNetworkSerializable)); } ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 21641584u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; foreach (ItemData itemData in items) { _storedItems.Add(itemData); } OnAdded?.Invoke(items); } } [ServerRpc(RequireOwnership = false)] private void RemoveServerRpc(params ItemData[] items) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { ServerRpcParams val = default(ServerRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(895173715u, val, (RpcDelivery)0); bool flag = items != null; ((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives)); if (flag) { ((FastBufferWriter)(ref val2)).WriteValueSafe<ItemData>(items, default(ForNetworkSerializable)); } ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 895173715u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; foreach (ItemData itemData in items) { _storedItems.Remove(itemData); } OnRemoved?.Invoke(items); } } [ServerRpc(RequireOwnership = false)] private void ClearServerRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { ServerRpcParams val = default(ServerRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1375891373u, val, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1375891373u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; _storedItems.Clear(); } } } protected override void __initializeVariables() { if (_storedItems == null) { throw new Exception("Inventory._storedItems cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)_storedItems).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)_storedItems, "_storedItems"); base.NetworkVariableFields.Add((NetworkVariableBase)(object)_storedItems); ((NetworkBehaviour)this).__initializeVariables(); } protected override void __initializeRpcs() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown ((NetworkBehaviour)this).__registerRpc(21641584u, new RpcReceiveHandler(__rpc_handler_21641584), "AddServerRpc"); ((NetworkBehaviour)this).__registerRpc(895173715u, new RpcReceiveHandler(__rpc_handler_895173715), "RemoveServerRpc"); ((NetworkBehaviour)this).__registerRpc(1375891373u, new RpcReceiveHandler(__rpc_handler_1375891373), "ClearServerRpc"); ((NetworkBehaviour)this).__initializeRpcs(); } private static void __rpc_handler_21641584(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives)); ItemData[] items = null; if (flag) { ((FastBufferReader)(ref reader)).ReadValueSafe<ItemData>(ref items, default(ForNetworkSerializable)); } target.__rpc_exec_stage = (__RpcExecStage)1; ((Inventory)(object)target).AddServerRpc(items); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_895173715(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives)); ItemData[] items = null; if (flag) { ((FastBufferReader)(ref reader)).ReadValueSafe<ItemData>(ref items, default(ForNetworkSerializable)); } target.__rpc_exec_stage = (__RpcExecStage)1; ((Inventory)(object)target).RemoveServerRpc(items); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_1375891373(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { target.__rpc_exec_stage = (__RpcExecStage)1; ((Inventory)(object)target).ClearServerRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } [MethodImpl(MethodImplOptions.NoInlining)] protected internal override string __getTypeName() { return "Inventory"; } } } namespace ShipInventoryUpdated.Patches { [HarmonyPatch(typeof(GameNetworkManager))] internal class GameNetworkManager_Patches { [HarmonyPatch("Start")] [HarmonyPostfix] private static void Start_Postfix() { if (!Object.op_Implicit((Object)(object)NetworkManager.Singleton)) { Logger.Error("Tried to add prefabs to the network, but 'Singleton' is not defined."); return; } if (ShipInventoryUpdated.CHUTE_PREFAB != null) { NetworkManager.Singleton.AddNetworkPrefab(ShipInventoryUpdated.CHUTE_PREFAB); } else { Logger.Error("Tried to add 'CHUTE_PREFAB' to the network, but it was not defined."); } if (ShipInventoryUpdated.INVENTORY_PREFAB != null) { NetworkManager.Singleton.AddNetworkPrefab(ShipInventoryUpdated.INVENTORY_PREFAB); } else { Logger.Error("Tried to add 'INVENTORY_PREFAB' to the network, but it was not defined."); } } [HarmonyPatch("SaveItemsInShip")] [HarmonyPrefix] private static void SaveItemsInShip_Prefix(GameNetworkManager __instance) { string currentSaveFileName = GameNetworkManager.Instance.currentSaveFileName; ES3.DeleteKey("shipGrabbableItemIDs", currentSaveFileName); ES3.DeleteKey("shipGrabbableItemPos", currentSaveFileName); ES3.DeleteKey("shipScrapValues", currentSaveFileName); ES3.DeleteKey("shipItemSaveData", currentSaveFileName); if (Inventory.Count == 0) { ES3.DeleteKey("shipInventoryItems", currentSaveFileName); } else { ES3.Save<string>("shipInventoryItems", JsonConvert.SerializeObject((object)Inventory.Items), currentSaveFileName); } } } [HarmonyPatch(typeof(StartOfRound))] internal class StartOfRound_Patches { [HarmonyPatch("Start")] [HarmonyPrefix] private static void Start_Prefix(StartOfRound __instance) { if (!((NetworkBehaviour)__instance).IsServer) { return; } if ((Object)(object)ShipInventoryUpdated.INVENTORY_PREFAB == (Object)null) { Logger.Error("Tried to spawn 'INVENTORY_PREFAB', but it was not defined."); return; } GameObject val = Object.Instantiate<GameObject>(ShipInventoryUpdated.INVENTORY_PREFAB); ((Object)val).name = "ShipInventoryUpdated-Inventory"; NetworkObject val2 = default(NetworkObject); if (val.TryGetComponent<NetworkObject>(ref val2)) { val2.Spawn(false); } } [HarmonyPatch("LoadUnlockables")] [HarmonyPostfix] private static void LoadUnlockables_Postfix(StartOfRound __instance) { Configuration instance = Configuration.Instance; if (instance == null || !instance.Unlock.IsChuteUnlocked.Value) { return; } int num = -1; for (int i = 0; i < __instance.unlockablesList.unlockables.Count; i++) { if (Terminal_Patches.IsChute(__instance.unlockablesList.unlockables[i])) { num = i; break; } } if (num == -1) { Logger.Error("Could not find the chute as an unlockable."); } else { __instance.UnlockShipObject(num); } } [HarmonyPatch("LoadShipGrabbableItems")] [HarmonyPrefix] private static void LoadShipGrabbableItems_Prefix() { string currentSaveFileName = GameNetworkManager.Instance.currentSaveFileName; Inventory.Clear(); if (ES3.KeyExists("shipInventoryItems", currentSaveFileName)) { string text = ES3.Load<string>("shipInventoryItems", currentSaveFileName); IEnumerable<ItemData> enumerable = JsonConvert.DeserializeObject<IEnumerable<ItemData>>(text); if (enumerable == null) { Logger.Error("Could not load items from the save file."); } else { Inventory.Add(enumerable.ToArray()); } } } [HarmonyPatch("GetValueOfAllScrap")] [HarmonyPostfix] private static void GetValueOfAllScrap_Postfix(ref int __result, bool onlyScrapCollected, bool onlyNewScrap) { ItemData[] items = Inventory.Items; for (int i = 0; i < items.Length; i++) { ItemData itemData = items[i]; if (!itemData.PERSISTED_THROUGH_ROUNDS) { Item item = itemData.GetItem(); if (!((Object)(object)item == (Object)null) && item.isScrap) { __result += itemData.SCRAP_VALUE; } } } } [HarmonyPatch("ResetShip")] [HarmonyPrefix] public static void ResetShip_Prefix() { Inventory.Clear(); } [HarmonyPatch("ReviveDeadPlayers")] [HarmonyPrefix] public static void ReviveDeadPlayers_Prefix(StartOfRound __instance) { if (__instance.allPlayersDead) { Configuration instance = Configuration.Instance; if (instance != null && instance.Inventory.ClearOnWipe.Value) { Inventory.Clear(); } } } } [HarmonyPatch(typeof(Terminal))] internal class Terminal_Patches { private static UnlockableItem? registeredUnlockable; private static TerminalKeyword? registeredKeyword; [HarmonyPatch("Awake")] [HarmonyPrefix] private static void Awake_Prefix(Terminal __instance) { ConfigEntry<string> val = Configuration.Instance?.Unlock.UnlockName; if (val == null) { Logger.Error("Tried to access the configuration for 'UnlockName', but it was not defined."); return; } RegisterUnlockable(val.Value); RegisterKeyword(__instance, val.Value); } private static void RegisterUnlockable(string command) { //IL_0067: 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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Expected O, but got Unknown if (registeredUnlockable != null) { return; } if ((Object)(object)StartOfRound.Instance == (Object)null) { Logger.Error("Tried to find 'Instance', but it was not defined."); return; } if ((Object)(object)ShipInventoryUpdated.CHUTE_BUY_NODE == (Object)null) { Logger.Error("Tried to add 'CHUTE_BUY_NODE' to the terminal, but it was not defined."); return; } if ((Object)(object)ShipInventoryUpdated.CHUTE_CONFIRM_NODE == (Object)null) { Logger.Error("Tried to add 'CHUTE_CONFIRM_NODE' to the terminal, but it was not defined."); return; } List<UnlockableItem> unlockables = StartOfRound.Instance.unlockablesList.unlockables; int count = unlockables.Count; UnlockableItem val = (registeredUnlockable = new UnlockableItem { unlockableName = command, prefabObject = ShipInventoryUpdated.CHUTE_PREFAB, unlockableType = 1, shopSelectionNode = null, alwaysInStock = true, IsPlaceable = true, canBeStored = true, maxNumber = 1, spawnPrefab = true }); unlockables.Add(val); GameObject prefabObject = val.prefabObject; PlaceableShipObject val2 = ((prefabObject != null) ? prefabObject.GetComponentInChildren<PlaceableShipObject>() : null); if ((Object)(object)val2 != (Object)null) { val2.unlockableID = count; } ShipInventoryUpdated.CHUTE_BUY_NODE.shipUnlockableID = count; ShipInventoryUpdated.CHUTE_BUY_NODE.displayText = Localization.Get("terminal.buy.main"); ShipInventoryUpdated.CHUTE_CONFIRM_NODE.shipUnlockableID = count; ShipInventoryUpdated.CHUTE_CONFIRM_NODE.displayText = Localization.Get("terminal.buy.confirm", new Dictionary<string, string> { ["command"] = command }); } private static void RegisterKeyword(Terminal __instance, string command) { //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Expected O, but got Unknown if ((Object)(object)registeredKeyword != (Object)null) { return; } TerminalKeyword val = null; TerminalKeyword val2 = ScriptableObject.CreateInstance<TerminalKeyword>(); ((Object)val2).name = (val2.word = command); registeredKeyword = val2; __instance.terminalNodes.allKeywords = CollectionExtensions.AddToArray<TerminalKeyword>(__instance.terminalNodes.allKeywords, val2); TerminalKeyword[] allKeywords = __instance.terminalNodes.allKeywords; foreach (TerminalKeyword val3 in allKeywords) { if (!(val3.word != "buy")) { val = val3; break; } } if ((Object)(object)val == (Object)null) { Logger.Error("Tried to add the noun to the keyword 'buy', but it was not found."); return; } val.compatibleNouns = CollectionExtensions.AddToArray<CompatibleNoun>(val.compatibleNouns, new CompatibleNoun { noun = val2, result = ShipInventoryUpdated.CHUTE_BUY_NODE }); val2.defaultVerb = val; } public static void AssignNewCommand(string command) { if (registeredUnlockable != null) { registeredUnlockable.unlockableName = command; } if ((Object)(object)registeredKeyword != (Object)null) { ((Object)registeredKeyword).name = (registeredKeyword.word = command); } if ((Object)(object)ShipInventoryUpdated.CHUTE_CONFIRM_NODE != (Object)null) { ShipInventoryUpdated.CHUTE_CONFIRM_NODE.displayText = Localization.Get("terminal.buy.confirm", new Dictionary<string, string> { ["command"] = command }); } } public static void AssignNewCost(int cost) { if ((Object)(object)ShipInventoryUpdated.CHUTE_BUY_NODE != (Object)null) { ShipInventoryUpdated.CHUTE_BUY_NODE.itemCost = cost; } if ((Object)(object)ShipInventoryUpdated.CHUTE_CONFIRM_NODE != (Object)null) { ShipInventoryUpdated.CHUTE_CONFIRM_NODE.itemCost = cost; } } public static bool IsChuteUnlocked() { return registeredUnlockable?.hasBeenUnlockedByPlayer ?? false; } public static bool IsChute(UnlockableItem item) { return registeredUnlockable == item; } } } namespace ShipInventoryUpdated.Objects { [Serializable] public struct ItemData : INetworkSerializable, IEquatable<ItemData> { [JsonConverter(typeof(FixedString32BytesJsonConverter))] public FixedString32Bytes ID; public int SCRAP_VALUE; public int SAVE_DATA; public bool PERSISTED_THROUGH_ROUNDS; public ItemData() : this(null) { } public ItemData(GrabbableObject? item) { //IL_0019: 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) SAVE_DATA = 0; ID = FixedString32Bytes.op_Implicit(ItemIdentifier.GetID(item?.itemProperties)); SCRAP_VALUE = item?.scrapValue ?? 0; if ((Object)(object)item?.itemProperties != (Object)null && item.itemProperties.saveItemVariable) { SAVE_DATA = item.GetItemDataToSave(); } PERSISTED_THROUGH_ROUNDS = item?.scrapPersistedThroughRounds ?? false; } public Item? GetItem() { return ItemIdentifier.GetItem(((FixedString32Bytes)(ref ID)).Value); } public unsafe void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) ((BufferSerializer<FixedString32Bytes>*)(&serializer))->SerializeValue<FixedString32Bytes>(ref ID, default(ForFixedStrings)); ((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 bool Equals(ItemData other) { if ((ref ID) != (ref other.ID)) { return false; } if (SCRAP_VALUE != other.SCRAP_VALUE) { return false; } if (SAVE_DATA != other.SAVE_DATA) { return false; } if (PERSISTED_THROUGH_ROUNDS != other.PERSISTED_THROUGH_ROUNDS) { return false; } return true; } } internal sealed class LanguagePackage { public readonly string Language; private readonly Dictionary<string, string> _loadedData; internal LanguagePackage(string language, JObject node) { Language = language; _loadedData = new Dictionary<string, string>(); ParseTree(node); } private void ParseTree(JObject root) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Invalid comparison between Unknown and I4 //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown Stack<(JToken, string)> stack = new Stack<(JToken, string)>(); stack.Push(((JToken)(object)root, "")); while (stack.Count > 0) { var (val, text) = stack.Pop(); if ((int)val.Type == 1) { JObject val2 = (JObject)val; if (!((JToken)val2).HasValues) { continue; } foreach (JProperty item2 in val2.Properties()) { string item = (string.IsNullOrEmpty(text) ? item2.Name : (text + "." + item2.Name)); stack.Push((item2.Value, item)); } } else if (!string.IsNullOrWhiteSpace(text)) { _loadedData[text] = ((object)val).ToString(); } } } public string? Get(string key) { if (!_loadedData.ContainsKey(key)) { return null; } return _loadedData[key]; } } } namespace ShipInventoryUpdated.Helpers { internal static class Bundle { private static AssetBundle? _loadedBundle; public static bool LoadBundle(string name) { string location = Assembly.GetExecutingAssembly().Location; location = Path.GetDirectoryName(location) ?? ""; location = Path.Combine(location, name); _loadedBundle = AssetBundle.LoadFromFile(location); if ((Object)(object)_loadedBundle == (Object)null) { Logger.Error("Failed to load the bundle '" + name + "'."); return false; } return true; } public static T? LoadAsset<T>(string name) where T : Object { if ((Object)(object)_loadedBundle == (Object)null) { Logger.Error("Tried to load '" + 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; } } internal static class Dependencies { private static readonly Dictionary<string, bool> CachedStatus = new Dictionary<string, bool>(); public static bool IsEnabled(string guid) { if (CachedStatus.TryGetValue(guid, out var value)) { return value; } value = Chainloader.PluginInfos.ContainsKey(guid); CachedStatus.Add(guid, value); return value; } public static void LoadDependencies(Configuration? config) { if (global::ShipInventoryUpdated.Dependencies.LethalConfig.Dependency.Enabled) { global::ShipInventoryUpdated.Dependencies.LethalConfig.Dependency.ApplyConfiguration(config); } if (global::ShipInventoryUpdated.Dependencies.InteractiveTerminalAPI.Dependency.Enabled) { global::ShipInventoryUpdated.Dependencies.InteractiveTerminalAPI.Dependency.RegisterApplication(); } } } internal static class Localization { private static LanguagePackage? _defaultLanguage; private static string? GetDirectory() { string codeBase = Assembly.GetExecutingAssembly().CodeBase; string directoryName = Path.GetDirectoryName(new Uri(codeBase).LocalPath); if (directoryName == null) { Logger.Error("Tried to find the location of the assembly, but it was not found."); return null; } return directoryName; } public static LanguagePackage? LoadLanguage(string languageCode) { string directory = GetDirectory(); if (directory == null) { return null; } string path = Path.Combine(directory, languageCode + ".json"); if (!File.Exists(path)) { Logger.Error("Tried to load the language package for '" + languageCode + "', but it was not found."); return null; } string text = File.ReadAllText(path); JObject val = JsonConvert.DeserializeObject<JObject>(text); if (val == null) { Logger.Error("Tried to load the language package for '" + languageCode + "', but it could not be parsed."); return null; } return new LanguagePackage(languageCode, val); } public static void SetAsDefault(LanguagePackage? languagePackage) { _defaultLanguage = languagePackage; } public static string Get(string key, Dictionary<string, string>? parameters = null) { string text = _defaultLanguage?.Get(key); if (text == null) { return key; } if (parameters != null) { foreach (KeyValuePair<string, string> parameter in parameters) { parameter.Deconstruct(out var key2, out var value); string text2 = key2; string newValue = value; text = text.Replace("{" + text2 + "}", newValue); } } return text; } } 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? log = _log; if (log != null) { log.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 ShipInventoryUpdated.Helpers.API { public static class InteractionHelper { private static readonly List<(Func<PlayerControllerB, bool>, string)> TriggerConditions = new List<(Func<PlayerControllerB, bool>, string)>(); public static void AddCondition(Func<PlayerControllerB, bool> condition, string error) { TriggerConditions.Add((condition, error)); } internal static void SetTriggerStatus(InteractTrigger trigger, PlayerControllerB player) { foreach (var (func, disabledHoverTip) in TriggerConditions) { if (!func(player)) { trigger.interactable = false; trigger.disabledHoverTip = disabledHoverTip; return; } } trigger.interactable = true; trigger.disabledHoverTip = ""; } internal static void LoadConditions() { AddCondition(IsHoldingObject, Localization.Get("tooltip.trigger.emptyHand")); AddCondition(HasEnoughSpace, Localization.Get("tooltip.trigger.notEnoughSpace")); AddCondition(IsAllowed, Localization.Get("tooltip.trigger.itemBlacklisted")); AddCondition(IsValid, Localization.Get("tooltip.trigger.invalidItem")); } private static bool IsHoldingObject(PlayerControllerB p) { if (p.isHoldingObject) { return (Object)(object)p.currentlyHeldObjectServer != (Object)null; } return false; } private static bool HasEnoughSpace(PlayerControllerB p) { Configuration instance = Configuration.Instance; if (instance == null) { return true; } GrabbableObject currentlyHeldObjectServer = p.currentlyHeldObjectServer; if ((Object)(object)currentlyHeldObjectServer == (Object)null) { return true; } ItemData[] array = ItemConverter.Convert(currentlyHeldObjectServer); return array.Length + Inventory.Count <= instance.Inventory.MaxItemCount.Value; } private static bool IsAllowed(PlayerControllerB p) { Configuration instance = Configuration.Instance; if (instance == null) { return true; } GrabbableObject currentlyHeldObjectServer = p.currentlyHeldObjectServer; if ((Object)(object)currentlyHeldObjectServer == (Object)null) { return true; } string input = currentlyHeldObjectServer.itemProperties.itemName.ToLower(); string[] array = instance.Chute.Blacklist.Value.Split(',', StringSplitOptions.RemoveEmptyEntries); foreach (string text in array) { if (text != null) { string pattern = "^" + text.Trim().ToLower() + "$"; if (Regex.IsMatch(input, pattern)) { return false; } } } return true; } 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; } } public static class ItemConverter { private static readonly List<Func<GrabbableObject, ItemData[]?>> Conversions = new List<Func<GrabbableObject, ItemData[]>>(); public static void AddConversion(Func<GrabbableObject, ItemData[]?> conversion) { Conversions.Add(conversion); } internal static ItemData[] Convert(GrabbableObject item) { foreach (Func<GrabbableObject, ItemData[]> conversion in Conversions) { ItemData[] array = conversion?.Invoke(item); if (array != null) { return array; } } return Array.Empty<ItemData>(); } internal static void LoadConversions() { AddConversion(BeltBagConversion); AddConversion(NormalConversion); } private static ItemData[] NormalConversion(GrabbableObject item) { return new ItemData[1] { new ItemData(item) }; } 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(Convert(val2)); } } list.Add(new ItemData((GrabbableObject?)(object)val)); return list.ToArray(); } } internal static class ItemIdentifier { private const string INVALID_ITEM_ID = "InvalidItem"; public static string GetID(Item? item) { if ((Object)(object)item == (Object)null) { return "InvalidItem"; } if (global::ShipInventoryUpdated.Dependencies.LethalLib.Dependency.Enabled) { string iD = global::ShipInventoryUpdated.Dependencies.LethalLib.Dependency.GetID(item); if (iD != null) { return iD; } } return "Vanilla/" + item.itemName; } public static Item? GetItem(string id) { if (id == "InvalidItem") { return null; } if (global::ShipInventoryUpdated.Dependencies.LethalLib.Dependency.Enabled) { Item item = global::ShipInventoryUpdated.Dependencies.LethalLib.Dependency.GetItem(id); if ((Object)(object)item != (Object)null) { return item; } } foreach (Item item2 in StartOfRound.Instance?.allItemsList?.itemsList ?? new List<Item>()) { string iD = GetID(item2); if (iD == id) { return item2; } } return null; } } } namespace ShipInventoryUpdated.Dependencies.Newtonsoft { internal class FixedString32BytesJsonConverter : JsonConverter<FixedString32Bytes> { public override void WriteJson(JsonWriter writer, FixedString32Bytes value, JsonSerializer serializer) { writer.WriteValue(((object)(FixedString32Bytes)(ref value)).ToString()); } public override FixedString32Bytes ReadJson(JsonReader reader, Type objectType, FixedString32Bytes existingValue, bool hasExistingValue, JsonSerializer serializer) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) string text = reader.Value as string; return new FixedString32Bytes(text ?? null); } } } namespace ShipInventoryUpdated.Dependencies.LethalLib { internal abstract class Dependency { private static Dictionary<string, Item>? _cachedModdedItems; public static bool Enabled => global::ShipInventoryUpdated.Helpers.Dependencies.IsEnabled("evaisa.lethallib"); private static void LoadModdedItems() { if (_cachedModdedItems != null) { return; } _cachedModdedItems = new Dictionary<string, Item>(); foreach (ScrapItem scrapItem in Items.scrapItems) { _cachedModdedItems.TryAdd(scrapItem.modName + "/" + scrapItem.item.itemName, scrapItem.item); } foreach (ShopItem shopItem in Items.shopItems) { _cachedModdedItems.TryAdd(shopItem.modName + "/" + shopItem.item.itemName, shopItem.item); } foreach (PlainItem plainItem in Items.plainItems) { _cachedModdedItems.TryAdd(plainItem.modName + "/" + plainItem.item.itemName, plainItem.item); } } public static string? GetID(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; } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static Item? GetItem(string id) { LoadModdedItems(); return _cachedModdedItems?.GetValueOrDefault(id); } } } namespace ShipInventoryUpdated.Dependencies.LethalConfig { internal static class Dependency { public static bool Enabled => global::ShipInventoryUpdated.Helpers.Dependencies.IsEnabled("ainavt.lc.lethalconfig"); [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void ApplyConfiguration(Configuration? configuration) { ApplyInformation(); if (configuration == null) { Logger.Info("Tried to load the configurations into 'LethalConfig', but none were given."); return; } LethalConfigManager.SkipAutoGen(); ApplyUnlockConfiguration(configuration.Unlock); ApplyChuteConfiguration(configuration.Chute); ApplyTerminalConfiguration(configuration.Terminal); ApplyInventoryConfiguration(configuration.Inventory); ApplyModConfiguration(configuration.Mod); } private static void ApplyInformation() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) Texture2D val = Bundle.LoadAsset<Texture2D>("mod-icon"); if ((Object)(object)val != (Object)null) { Sprite modIcon = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f)); LethalConfigManager.SetModIcon(modIcon); } LethalConfigManager.SetModDescription(Localization.Get("mod.description")); } private static void ApplyChuteConfiguration(ChuteConfig config) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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_0036: Expected O, but got Unknown //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown LethalConfigManager.AddConfigItem((BaseConfigItem)new TextInputFieldConfigItem(config.Blacklist, new TextInputFieldOptions { Name = Localization.Get("configuration.chute.blacklist.name"), NumberOfLines = 5, TrimText = true, RequiresRestart = false })); ConfigEntry<float> storeSpeed = config.StoreSpeed; FloatInputFieldOptions val = new FloatInputFieldOptions { Name = Localization.Get("configuration.chute.storeSpeed.name") }; ((BaseRangeOptions<float>)val).Min = 0f; ((BaseRangeOptions<float>)val).Max = float.MaxValue; ((BaseOptions)val).RequiresRestart = true; LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatInputFieldConfigItem(storeSpeed, val)); } private static void ApplyInventoryConfiguration(InventoryConfig config) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown //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_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: 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_0093: Expected O, but got Unknown //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Expected O, but got Unknown //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Expected O, but got Unknown //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Expected O, but got Unknown ConfigEntry<int> maxItemCount = config.MaxItemCount; IntInputFieldOptions val = new IntInputFieldOptions { Name = Localization.Get("configuration.inventory.maxItemCount.name") }; ((BaseRangeOptions<int>)val).Min = 1; ((BaseRangeOptions<int>)val).Max = int.MaxValue; ((BaseOptions)val).RequiresRestart = false; LethalConfigManager.AddConfigItem((BaseConfigItem)new IntInputFieldConfigItem(maxItemCount, val)); LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(config.ClearOnWipe, new BoolCheckBoxOptions { Name = Localization.Get("configuration.inventory.clearOnWipe.name"), RequiresRestart = false })); ConfigEntry<float> retrieveSpeed = config.RetrieveSpeed; FloatInputFieldOptions val2 = new FloatInputFieldOptions { Name = Localization.Get("configuration.inventory.retrieveSpeed.name") }; ((BaseRangeOptions<float>)val2).Min = 0f; ((BaseRangeOptions<float>)val2).Max = float.MaxValue; ((BaseOptions)val2).RequiresRestart = true; LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatInputFieldConfigItem(retrieveSpeed, val2)); } private static void ApplyModConfiguration(ModConfig config) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown LethalConfigManager.AddConfigItem((BaseConfigItem)new TextInputFieldConfigItem(config.Language, new TextInputFieldOptions { Name = "Language", NumberOfLines = 1, CharacterLimit = 16, TrimText = true, RequiresRestart = true })); } private static void ApplyUnlockConfiguration(UnlockConfig config) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Expected O, but got Unknown //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Expected O, but got Unknown //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Expected O, but got Unknown //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0082: 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_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Expected O, but got Unknown //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Expected O, but got Unknown LethalConfigManager.AddConfigItem((BaseConfigItem)new TextInputFieldConfigItem(config.UnlockName, new TextInputFieldOptions { Name = Localization.Get("configuration.unlock.unlockName.name"), NumberOfLines = 1, CharacterLimit = 64, TrimText = true, RequiresRestart = false })); ConfigEntry<int> unlockCost = config.UnlockCost; IntInputFieldOptions val = new IntInputFieldOptions { Name = Localization.Get("configuration.unlock.unlockCost.name") }; ((BaseRangeOptions<int>)val).Min = 0; ((BaseRangeOptions<int>)val).Max = 999999999; ((BaseOptions)val).RequiresRestart = false; LethalConfigManager.AddConfigItem((BaseConfigItem)new IntInputFieldConfigItem(unlockCost, val)); LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(config.IsChuteUnlocked, new BoolCheckBoxOptions { Name = Localization.Get("configuration.unlock.isUnlockable.name"), RequiresRestart = true })); } private static void ApplyTerminalConfiguration(TerminalConfig config) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Expected O, but got Unknown //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Expected O, but got Unknown //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Expected O, but got Unknown //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Expected O, but got Unknown //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Expected O, but got Unknown //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Expected O, but got Unknown //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Expected O, but got Unknown LethalConfigManager.AddConfigItem((BaseConfigItem)new TextInputFieldConfigItem(config.InventoryCommand, new TextInputFieldOptions { Name = Localization.Get("configuration.terminal.command.name"), NumberOfLines = 1, CharacterLimit = 64, TrimText = true, RequiresRestart = true })); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)new EnumDropDownConfigItem<TerminalConfig.SortOrder>(config.InventorySortOrder, new EnumDropDownOptions { Name = Localization.Get("configuration.terminal.inventorySortOrder.name"), RequiresRestart = false })); LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(config.AutomaticPositiveAnswer, new BoolCheckBoxOptions { Name = Localization.Get("configuration.terminal.automaticPositive.name", new Dictionary<string, string> { ["positiveAnswer"] = Localization.Get("application.answers.positive") }), RequiresRestart = false })); LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(config.ShowConfirmation, new BoolCheckBoxOptions { Name = Localization.Get("configuration.terminal.showConfirmation.name"), RequiresRestart = false })); LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(config.ShowTrademark, new BoolCheckBoxOptions { Name = Localization.Get("configuration.terminal.showTrademark.name"), RequiresRestart = false })); } } } namespace ShipInventoryUpdated.Dependencies.InteractiveTerminalAPI { internal static class Dependency { public static bool Enabled => global::ShipInventoryUpdated.Helpers.Dependencies.IsEnabled("WhiteSpike.InteractiveTerminalAPI"); [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void RegisterApplication() { ConfigEntry<string> val = Configuration.Instance?.Terminal.InventoryCommand; if (val == null) { Logger.Error("Tried to access the configuration for 'InventoryCommand', but it was not defined."); } else { InteractiveTerminalManager.RegisterApplication<ShipApplication>(val.Value, true); } } } public class ShipApplication : PageApplication { private Action<CallbackContext>? _lastExitPerformedAction; private Action? _confirmExitCallback; public override void Initialization() { if (!Terminal_Patches.IsChuteUnlocked()) { LockedScreen(); } else { MainScreen(); } } protected override int GetEntriesPerPage<T>(T[] entries) { return 10; } 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 static ItemData[] GetItems(bool applySortOrder) { ItemData[] items = Inventory.Items; if (!applySortOrder) { return items; } TerminalConfig.SortOrder sortOrder = Configuration.Instance?.Terminal.InventorySortOrder.Value ?? TerminalConfig.SortOrder.NONE; string defaultName = Localization.Get("application.answers.unknown"); return (sortOrder switch { TerminalConfig.SortOrder.NAME_ASC => items.OrderBy((ItemData i) => i.GetItem()?.itemName ?? defaultName), TerminalConfig.SortOrder.NAME_DESC => items.OrderByDescending((ItemData i) => i.GetItem()?.itemName ?? defaultName), TerminalConfig.SortOrder.VALUE_ASC => items.OrderBy((ItemData i) => i.SCRAP_VALUE), TerminalConfig.SortOrder.VALUE_DESC => items.OrderByDescending((ItemData i) => i.SCRAP_VALUE), _ => items, }).ToArray(); } private void CreateItemPages<T>(T[] items, int selectedIndex, string text, Func<T, (string, string, ItemData[])> render, Action<int> action) { //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Expected O, but got Unknown //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Expected O, but got Unknown //IL_0139: Expected O, but got Unknown //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Expected O, but got Unknown Action<int> action2 = action; int entriesPerPage = ((PageApplication)this).GetEntriesPerPage<int>(Array.Empty<int>()); int cursorCount = 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) { continue; } ref T reference = ref val; T val2 = default(T); if (val2 == null) { val2 = reference; reference = ref val2; } if (reference.Equals(default(T))) { continue; } (string, string, ItemData[]) result = render(val); int itemIndex = i * entriesPerPage + j; array[j] = new CursorElement { Name = result.Item1, Action = delegate { ConfirmElement(result.Item2, delegate { Inventory.Remove(result.Item3); if (cursorCount == 1) { MainScreen(); } else { action2(itemIndex); } }, delegate { action2(itemIndex); }); } }; } int num = i; CursorMenu val3 = new CursorMenu(); ((BaseCursorMenu<CursorElement>)val3).cursorIndex = 0; ((BaseCursorMenu<CursorElement>)val3).elements = array; item2[num] = val3; item3[i] = (IScreen)(object)CreateScreen(Localization.Get("application.titles.selection"), (ITextElement[])(object)new ITextElement[3] { (ITextElement)TextElement.Create(text), (ITextElement)TextElement.Create(" "), (ITextElement)item2[i] }); } selectedIndex = Math.Clamp(selectedIndex, 0, cursorCount - 1); int num2 = selectedIndex / entriesPerPage; int cursorIndex = selectedIndex % entriesPerPage; ((BaseCursorMenu<CursorElement>)(object)item2[num2]).cursorIndex = cursorIndex; base.currentPage = PageCursorElement.Create(num2, item3, item2); ((BaseInteractiveApplication<CursorMenu, CursorElement>)this).currentCursorMenu = base.currentPage.GetCurrentCursorMenu(); ((TerminalApplication)this).currentScreen = ((PageElement)base.currentPage).GetCurrentScreen(); RegisterExitAction(delegate { MainScreen(); }); } 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_002c: Unknown result type (might be due to invalid IL or missing references) //IL_003f: 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 = Localization.Get("application.answers.blocked"), 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(Localization.Get("application.titles.locked"), (ITextElement[])(object)new ITextElement[8] { (ITextElement)TextElement.Create(Localization.Get("application.screens.locked.message")), (ITextElement)TextElement.Create(" "), (ITextElement)TextElement.Create(Localization.Get("application.screens.locked.tip", new Dictionary<string, string> { ["command"] = Configuration.Instance?.Unlock.UnlockName.Value ?? "" })), (ITextElement)TextElement.Create(" "), (ITextElement)TextElement.Create(" "), (ITextElement)TextElement.Create(Localization.Get("application.screens.locked.offer")), (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 void MainScreen() { //IL_003f: 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_005a: Expected O, but got Unknown //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown //IL_0062: Expected O, but got Unknown PlayerControllerB localPlayerController = StartOfRound.Instance.localPlayerController; CursorElement[] array = (CursorElement[])(object)new CursorElement[5] { RetrieveSingleElement(), RetrieveTypeElement(), RetrieveRandomElement(), RetrieveAllElement(), InfoCursorElement() }; CursorMenu val = new CursorMenu(); ((BaseCursorMenu<CursorElement>)val).cursorIndex = ((Inventory.Count <= 0) ? (array.Length - 1) : 0); ((BaseCursorMenu<CursorElement>)val).elements = array; CursorMenu val2 = val; BoxedScreen val3 = CreateScreen(Localization.Get("application.titles.main"), (ITextElement[])(object)new ITextElement[5] { (ITextElement)TextElement.Create(Localization.Get("application.screens.main.welcome", new Dictionary<string, string> { ["level"] = HUDManager.Instance.playerLevels[localPlayerController.playerLevelNumber].levelName, ["username"] = localPlayerController.playerUsername })), (ITextElement)TextElement.Create(" "), (ITextElement)TextElement.Create(Localization.Get("application.screens.main.home")), (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 void ConfirmElement(string message, Action? confirmCallback, Action? declineCallback = null) { //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Expected O, but got Unknown //IL_00ba: 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_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Expected O, but got Unknown Action declineCallback2 = declineCallback; Action confirmCallback2 = confirmCallback; Configuration? instance = Configuration.Instance; if (instance != null && !instance.Terminal.ShowConfirmation.Value) { confirmCallback2?.Invoke(); return; } _confirmExitCallback = declineCallback2; bool flag = Configuration.Instance?.Terminal.AutomaticPositiveAnswer.Value ?? false; CursorMenu val = new CursorMenu(); ((BaseCursorMenu<CursorElement>)(object)val).cursorIndex = (flag ? 1 : 0); ((BaseCursorMenu<CursorElement>)(object)val).elements = (CursorElement[])(object)new CursorElement[2] { new CursorElement { Name = Localization.Get("application.answers.negative"), Action = delegate { if (declineCallback2 != null) { declineCallback2(); } else { MainScreen(); } } }, new CursorElement { Name = Localization.Get("application.answers.positive"), Action = delegate { confirmCallback2?.Invoke(); } } }; CursorMenu val2 = val; BoxedScreen val3 = CreateScreen(Localization.Get("application.titles.confirm"), (ITextElement[])(object)new ITextElement[7] { (ITextElement)TextElement.Create(message), (ITextElement)TextElement.Create(" "), (ITextElement)TextElement.Create(Localization.Get("application.screens.confirm.message")), (ITextElement)TextElement.Create(" "), (ITextElement)TextElement.Create(Localization.Get("application.screens.confirm.warning")), (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(delegate { _confirmExitCallback?.Invoke(); }); } private BoxedScreen CreateScreen(string title, ITextElement[] elements) { //IL_005a: 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_006e: Expected O, but got Unknown UnregisterExitAction(); Configuration? instance = Configuration.Instance; if (instance == null || instance.Terminal.ShowTrademark.Value) { List<ITextElement> list = new List<ITextElement>(elements) { (ITextElement)(object)TextElement.Create(" "), (ITextElement)(object)TextElement.Create(Localization.Get("application.footers.trademark")) }; elements = list.ToArray(); } return new BoxedScreen { Title = title, elements = elements }; } private CursorElement RetrieveSingleElement() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown return new CursorElement { Name = Localization.Get("application.titles.single"), Active = (CursorElement _) => Inventory.Count > 0, SelectInactive = false, Action = delegate { RetrieveSingle(); } }; } private static (string, string, ItemData[]) RenderSingle(ItemData itemData) { string value = itemData.GetItem()?.itemName ?? Localization.Get("application.answers.unknown"); string item = Localization.Get("application.screens.single.item", new Dictionary<string, string> { ["name"] = value, ["value"] = itemData.SCRAP_VALUE.ToString() }); string item2 = Localization.Get("application.screens.single.confirm", new Dictionary<string, string> { ["name"] = value }); return (item, item2, new ItemData[1] { itemData }); } private void RetrieveSingle(int selectedIndex = 0) { CreateItemPages(GetItems(applySortOrder: true), selectedIndex, Localization.Get("application.screens.single.message"), RenderSingle, RetrieveSingle); } private CursorElement RetrieveTypeElement() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown return new CursorElement { Name = Localization.Get("application.titles.type"), Active = (CursorElement _) => Inventory.Count > 0, SelectInactive = false, Action = delegate { RetrieveType(); } }; } private static (string, string, ItemData[]) RenderType(IGrouping<string, ItemData> group) { string value = group.Count().ToString(); string value2 = group.First().GetItem()?.itemName ?? Localization.Get("application.answers.unknown"); string item = Localization.Get("application.screens.type.item", new Dictionary<string, string> { ["name"] = value2, ["amount"] = value, ["total"] = group.Sum((ItemData d) => d.SCRAP_VALUE).ToString() }); string item2 = Localization.Get("application.screens.type.confirm", new Dictionary<string, string> { ["name"] = value2, ["amount"] = value }); return (item, item2, group.ToArray()); } private void RetrieveType(int selectedIndex = 0) { CreateItemPages((from i in GetItems(applySortOrder: true) group i by ((object)(FixedString32Bytes)(ref i.ID)).ToString()).ToArray(), selectedIndex, Localization.Get("application.screens.single.message"), RenderType, RetrieveType); } private CursorElement RetrieveRandomElement() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown return new CursorElement { Name = Localization.Get("application.titles.random"), Active = (CursorElement _) => Inventory.Count > 0, SelectInactive = false, Action = RetrieveRandom }; } private void RetrieveRandom() { ItemData data = Inventory.Items[Random.Range(0, Inventory.Count)]; string message = Localization.Get("application.screens.random.message", new Dictionary<string, string> { ["name"] = data.GetItem()?.itemName ?? Localization.Get("application.answers.unknown") }); ConfirmElement(message, delegate { Inventory.Remove(new ItemData[1] { data }); MainScreen(); }); RegisterExitAction(delegate { MainScreen(); }); } private CursorElement RetrieveAllElement() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown return new CursorElement { Name = Localization.Get("application.titles.all"), Active = (CursorElement _) => Inventory.Count > 0, SelectInactive = false, Action = RetrieveAll }; } private void RetrieveAll() { ItemData[] items = GetItems(applySortOrder: false); string message = Localization.Get("application.screens.all.message", new Dictionary<string, string> { ["amount"] = items.Length.ToString(), ["total"] = items.Sum((ItemData i) => i.SCRAP_VALUE).ToString() }); ConfirmElement(message, delegate { Inventory.Remove(items); MainScreen(); }); RegisterExitAction(delegate { MainScreen(); }); } 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_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown return new CursorElement { Name = Localization.Get("application.titles.information"), Action = GetInfo }; } private void GetInfo() { //IL_0022: 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_002e: Expected O, but got Unknown //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_003a: Expected O, but got Unknown int num = Configuration.Instance?.Inventory.MaxItemCount.Value ?? 1; ItemData[] items = Inventory.Items; CursorMenu val = new CursorMenu(); ((BaseCursorMenu<CursorElement>)val).cursorIndex = 0; ((BaseCursorMenu<CursorElement>)val).elements = Array.Empty<CursorElement>(); CursorMenu val2 = val; BoxedScreen val3 = CreateScreen(Localization.Get("application.titles.status"), (ITextElement[])(object)new ITextElement[2] { (ITextElement)TextElement.Create(Localization.Get("application.screens.information.total", new Dictionary<string, string> { ["total"] = items.Sum((ItemData i) => i.SCRAP_VALUE).ToString() })), (ITextElement)TextElement.Create(Localization.Get("application.screens.information.count", new Dictionary<string, string> { ["count"] = items.Length.ToString(), ["maxCount"] = num.ToString() })) }); 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(); }); } } } namespace ShipInventoryUpdated.Configurations { internal class ChuteConfig { private const string SECTION = "Chute"; public readonly ConfigEntry<string> Blacklist; public readonly ConfigEntry<float> StoreSpeed; public ChuteConfig(ConfigFile cfg) { //IL_0012: 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_0048: 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_006d: Expected O, but got Unknown //IL_006d: Expected O, but got Unknown Blacklist = cfg.Bind<string>(new ConfigDefinition("Chute", "ChuteBlacklist"), "", new ConfigDescription(Localization.Get("configuration.chute.blacklist.description"), (AcceptableValueBase)null, Array.Empty<object>())); StoreSpeed = cfg.Bind<float>(new ConfigDefinition("Chute", "TimeToStore"), 0.5f, new ConfigDescription(Localization.Get("configuration.chute.storeSpeed.description"), (AcceptableValueBase)null, Array.Empty<object>())); } } internal class Configuration { public readonly ChuteConfig Chute; public readonly UnlockConfig Unlock; public readonly TerminalConfig Terminal; public readonly InventoryConfig Inventory; public readonly ModConfig Mod; public static Configuration? Instance; private Configuration(ConfigFile cfg) { Mod = new ModConfig(cfg); string value = Mod.Language.Value; LanguagePackage asDefault = Localization.LoadLanguage(value); Localization.SetAsDefault(asDefault); Chute = new ChuteConfig(cfg); Unlock = new UnlockConfig(cfg); Terminal = new TerminalConfig(cfg); Inventory = new InventoryConfig(cfg); } public static void Load(ConfigFile cfg) { Instance = new Configuration(cfg); } } internal class InventoryConfig { private const string SECTION = "Inventory"; public readonly ConfigEntry<int> MaxItemCount; public readonly ConfigEntry<bool> ClearOnWipe; public readonly ConfigEntry<float> RetrieveSpeed; public InventoryConfig(ConfigFile cfg) { //IL_0012: 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_0048: 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 refe