Decompiled source of ShipMaid v4.0.9
ShipMaid.dll
Decompiled 5 months ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using GameNetcodeStuff; using HarmonyLib; using LethalCompanyInputUtils.Api; using Microsoft.CodeAnalysis; using ShipMaid.Configuration; using ShipMaid.EntityHelpers; using ShipMaid.HelperFunctions; using ShipMaid.InputUtils; using ShipMaid.Networking; using ShipMaid.ObjectHelpers; using Unity.Collections; using Unity.Netcode; using UnityEngine; using UnityEngine.InputSystem; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("ShipMaid")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("On scan within the ship, items in the ship will be organized.")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+09d324c92056b5b6b8e025659c99cf02e6753edd")] [assembly: AssemblyProduct("ShipMaid")] [assembly: AssemblyTitle("ShipMaid")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace ShipMaid { [HarmonyPatch] internal static class Keybinds { public static PlayerControllerB localPlayerController; [HarmonyPatch(typeof(PlayerControllerB), "OnDisable")] [HarmonyPostfix] public static void OnDisable(PlayerControllerB __instance) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_0021: Expected O, but got Unknown //IL_0069: 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_007d: Expected O, but got Unknown //IL_007d: Expected O, but got Unknown //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Expected O, but got Unknown //IL_00d9: Expected O, but got Unknown if (ShipMaid.InputActionsInstance.ShipCleanupKey != null && !((Object)__instance != (Object)localPlayerController)) { ShipMaid.InputActionsInstance.ShipCleanupKey.performed -= OnShipMaidShipCleanupCalled; ShipMaid.InputActionsInstance.ShipCleanupKey.Disable(); } if (ShipMaid.InputActionsInstance.StorageCleanupKey != null && !((Object)__instance != (Object)localPlayerController)) { ShipMaid.InputActionsInstance.StorageCleanupKey.performed -= OnShipMaidClosetCleanupCalled; ShipMaid.InputActionsInstance.StorageCleanupKey.Disable(); } if (ShipMaid.InputActionsInstance.LocationOverrideKey != null && !((Object)__instance != (Object)localPlayerController)) { ShipMaid.InputActionsInstance.LocationOverrideKey.performed -= OnShipMaidDropAndSetObjectTypePositionCalled; ShipMaid.InputActionsInstance.LocationOverrideKey.Disable(); } } [HarmonyPatch(typeof(PlayerControllerB), "OnEnable")] [HarmonyPostfix] public static void OnEnable(PlayerControllerB __instance) { //IL_0001: 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_0015: Expected O, but got Unknown //IL_0015: Expected O, but got Unknown if ((Object)__instance == (Object)localPlayerController) { SubscribeToEvents(); } } [HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")] [HarmonyPostfix] public static void OnLocalPlayerConnect(PlayerControllerB __instance) { localPlayerController = __instance; ShipMaidFunctions.initItemLocations(); if (((Component)localPlayerController).gameObject.activeSelf) { SubscribeToEvents(); } ShipMaid.Log("Local Player Connect"); NetworkFunctions.NetworkingObjectManager.NetworkManagerInit(); ShipMaid.Log("Registering Manager"); } private static void OnShipMaidClosetCleanupCalled(CallbackContext context) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown if (!((Object)localPlayerController == (Object)null) && localPlayerController.isPlayerControlled && !localPlayerController.isTypingChat && !localPlayerController.inTerminalMenu && (!((NetworkBehaviour)localPlayerController).IsServer || localPlayerController.isHostPlayerObject) && !ConfigSettings.UseOnlyTerminal.Key.Value) { if (!StartOfRound.Instance.shipHasLanded && !StartOfRound.Instance.inShipPhase) { ShipMaid.Log("Ship Has Not Landed and Not In Ship Phase, do not cleanup"); return; } ShipMaid.Log("Cleanup Closet"); LootOrganizingFunctions.OrganizeStorageCloset(); } } private static void OnShipMaidDropAndSetObjectTypePositionCalled(CallbackContext context) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown if (!((Object)localPlayerController == (Object)null) && localPlayerController.isPlayerControlled && !localPlayerController.isTypingChat && !localPlayerController.inTerminalMenu && (!((NetworkBehaviour)localPlayerController).IsServer || localPlayerController.isHostPlayerObject)) { ShipMaid.Log("Set object cleanup position"); ShipMaidFunctions.DropAndSetObjectTypePosition(); } } private static void OnShipMaidShipCleanupCalled(CallbackContext context) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown if (!((Object)localPlayerController == (Object)null) && localPlayerController.isPlayerControlled && !localPlayerController.isTypingChat && !localPlayerController.inTerminalMenu && (!((NetworkBehaviour)localPlayerController).IsServer || localPlayerController.isHostPlayerObject) && !ConfigSettings.UseOnlyTerminal.Key.Value) { if (!StartOfRound.Instance.shipHasLanded && !StartOfRound.Instance.inShipPhase) { ShipMaid.Log("Ship Has Not Landed and Not In Ship Phase, do not cleanup"); return; } ShipMaid.Log("Cleanup Ship"); LootOrganizingFunctions.OrganizeShipLoot(); } } private static void SubscribeToEvents() { if (ShipMaid.InputActionsInstance.ShipCleanupKey != null) { ShipMaid.InputActionsInstance.ShipCleanupKey.Enable(); ShipMaid.InputActionsInstance.ShipCleanupKey.performed += OnShipMaidShipCleanupCalled; } if (ShipMaid.InputActionsInstance.StorageCleanupKey != null) { ShipMaid.InputActionsInstance.StorageCleanupKey.Enable(); ShipMaid.InputActionsInstance.StorageCleanupKey.performed += OnShipMaidClosetCleanupCalled; } if (ShipMaid.InputActionsInstance.LocationOverrideKey != null) { ShipMaid.InputActionsInstance.LocationOverrideKey.Enable(); ShipMaid.InputActionsInstance.LocationOverrideKey.performed += OnShipMaidDropAndSetObjectTypePositionCalled; } } } [BepInPlugin("ShipMaid", "ShipMaid", "4.0.9")] [BepInDependency(/*Could not decode attribute arguments.*/)] internal class ShipMaid : BaseUnityPlugin { public static ShipMaid instance; public static ShipMaidFunctions smf = new ShipMaidFunctions(); internal static InputUtilsKeybinds InputActionsInstance = new InputUtilsKeybinds(); private const string GUID = "ShipMaid"; private const string NAME = "ShipMaid"; private const string VERSION = "4.0.9"; public static void Log(string message) { ((BaseUnityPlugin)instance).Logger.LogInfo((object)message); } public static void LogError(string message) { ((BaseUnityPlugin)instance).Logger.LogError((object)message); } private void Awake() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) instance = this; ConfigSettings.BindConfigSettings(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin ShipMaid is loaded!"); new Harmony("ShipMaid").PatchAll(Assembly.GetExecutingAssembly()); } } [HarmonyPatch] internal class ShipMaidFunctions { public static List<GrabbableObjectPositionHelper> GrabbablesPositions = new List<GrabbableObjectPositionHelper>(); public static List<GrabbableObjectPositionHelperShotgun> GrabbablesPositionsShotgun = new List<GrabbableObjectPositionHelperShotgun>(); public static Vector3 OneHandedPosition = new Vector3(UnsetPosition.x, UnsetPosition.y, UnsetPosition.z); public static Vector3 TwoHandedPosition = new Vector3(UnsetPosition.x, UnsetPosition.y, UnsetPosition.z); public static Vector3 UnsetPosition = new Vector3(-9f, -9f, -9f); internal static void DropAndSetObjectTypePosition() { //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: 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_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: 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_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_02fa: Unknown result type (might be due to invalid IL or missing references) //IL_0300: Unknown result type (might be due to invalid IL or missing references) //IL_0306: Unknown result type (might be due to invalid IL or missing references) //IL_030b: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Unknown result type (might be due to invalid IL or missing references) GrabbableObject obj = GetCurrentlyHeldObject(); if ((Object)(object)obj != (Object)null) { string text = ((Object)obj).name; if (text.Contains("(Clone)")) { text = text.Substring(0, text.IndexOf("(Clone)")); } HUDManager.Instance.DisplayGlobalNotification("Setting object location for " + text); Vector3 position = ((Component)obj).gameObject.transform.position; ShotgunItem shotgun = default(ShotgunItem); ref ShotgunItem reference = ref shotgun; GrabbableObject obj2 = obj; reference = (ShotgunItem)(object)((obj2 is ShotgunItem) ? obj2 : null); if (shotgun != null && GrabbablesPositionsShotgun.Where((GrabbableObjectPositionHelperShotgun o) => o.objName == ((Object)obj).name && shotgun.shellsLoaded == o.AmmoQuantity).Any()) { GrabbablesPositionsShotgun.Where((GrabbableObjectPositionHelperShotgun o) => o.objName == ((Object)shotgun).name && shotgun.shellsLoaded == o.AmmoQuantity).First().PlacementPosition = new Vector3(position.x, position.y, position.z); GrabbableObjectPositionHelperShotgun shotgunPositionHelper = new GrabbableObjectPositionHelperShotgun(((Object)obj).name, position, shotgun.shellsLoaded); ConfigSettings.ShotgunPlacementOverrideLocation.AddOrUpdateObjectPositionSetting(shotgunPositionHelper); ((BaseUnityPlugin)ShipMaid.instance).Config.Save(); } else { GrabbableObject obj3 = obj; ShotgunItem val = (ShotgunItem)(object)((obj3 is ShotgunItem) ? obj3 : null); if (val != null) { GrabbablesPositionsShotgun.Add(new GrabbableObjectPositionHelperShotgun(((Object)obj).name, position, val.shellsLoaded)); GrabbableObjectPositionHelperShotgun shotgunPositionHelper2 = new GrabbableObjectPositionHelperShotgun(((Object)obj).name, position, val.shellsLoaded); ConfigSettings.ShotgunPlacementOverrideLocation.AddOrUpdateObjectPositionSetting(shotgunPositionHelper2); ((BaseUnityPlugin)ShipMaid.instance).Config.Save(); } } if (GrabbablesPositions.Where((GrabbableObjectPositionHelper o) => o.objName == ((Object)obj).name).Any()) { GrabbablesPositions.Where((GrabbableObjectPositionHelper o) => o.objName == ((Object)obj).name).First().PlacementPosition = new Vector3(position.x, position.y, position.z); GrabbableObjectPositionHelper objectPositionHelper = new GrabbableObjectPositionHelper(((Object)obj).name, position); ConfigSettings.ItemPlacementOverrideLocation.AddOrUpdateObjectPositionSetting(objectPositionHelper); ((BaseUnityPlugin)ShipMaid.instance).Config.Save(); } else { GrabbablesPositions.Add(new GrabbableObjectPositionHelper(((Object)obj).name, position)); GrabbableObjectPositionHelper objectPositionHelper2 = new GrabbableObjectPositionHelper(((Object)obj).name, position); ConfigSettings.ItemPlacementOverrideLocation.AddOrUpdateObjectPositionSetting(objectPositionHelper2); ((BaseUnityPlugin)ShipMaid.instance).Config.Save(); } if (obj.itemProperties.twoHanded) { TwoHandedPosition = new Vector3(position.x, position.y, position.z); ConfigSettings.TwoHandedItemPlacementOverrideLocation.SetVector3(TwoHandedPosition); ((BaseUnityPlugin)ShipMaid.instance).Config.Save(); } else { OneHandedPosition = new Vector3(position.x, position.y, position.z); ConfigSettings.OneHandedItemPlacementOverrideLocation.SetVector3(OneHandedPosition); ((BaseUnityPlugin)ShipMaid.instance).Config.Save(); } } else { ShipMaid.LogError("Failed to get held object"); } } internal static GrabbableObject GetCurrentlyHeldObject() { if ((Object)(object)Keybinds.localPlayerController != (Object)null) { for (int i = 0; i < Keybinds.localPlayerController.ItemSlots.Count(); i++) { if (Keybinds.localPlayerController.ItemSlots[i].isHeld && !Keybinds.localPlayerController.ItemSlots[i].isPocketed) { return Keybinds.localPlayerController.ItemSlots[i]; } } } return null; } internal static GrabbableObjectPositionHelper GetObjectPositionTarget(GrabbableObject obj) { if (GrabbablesPositions.Where((GrabbableObjectPositionHelper o) => o.objName == ((Object)obj).name).Any()) { return GrabbablesPositions.Where((GrabbableObjectPositionHelper o) => o.objName == ((Object)obj).name).First(); } return null; } internal static GrabbableObjectPositionHelperShotgun GetObjectPositionTargetShotgun(ShotgunItem obj) { if (GrabbablesPositionsShotgun.Where((GrabbableObjectPositionHelperShotgun o) => o.objName == ((Object)obj).name && obj.shellsLoaded == o.AmmoQuantity).Any()) { return GrabbablesPositionsShotgun.Where((GrabbableObjectPositionHelperShotgun o) => o.objName == ((Object)obj).name && obj.shellsLoaded == o.AmmoQuantity).First(); } return null; } internal static Vector3? GetOneHandedPositionTarget() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) if (OneHandedPosition != UnsetPosition) { return OneHandedPosition; } return null; } internal static Vector3? GetTwoHandedPositionTarget() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) if (TwoHandedPosition != UnsetPosition) { return TwoHandedPosition; } return null; } internal static void initItemLocations() { //IL_0385: Unknown result type (might be due to invalid IL or missing references) //IL_0387: Unknown result type (might be due to invalid IL or missing references) //IL_0453: Unknown result type (might be due to invalid IL or missing references) //IL_0455: Unknown result type (might be due to invalid IL or missing references) //IL_0329: Unknown result type (might be due to invalid IL or missing references) //IL_02fb: Unknown result type (might be due to invalid IL or missing references) //IL_0300: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_03dd: Unknown result type (might be due to invalid IL or missing references) //IL_03e2: Unknown result type (might be due to invalid IL or missing references) //IL_04a7: Unknown result type (might be due to invalid IL or missing references) //IL_04ac: Unknown result type (might be due to invalid IL or missing references) //IL_03ff: Unknown result type (might be due to invalid IL or missing references) //IL_0404: Unknown result type (might be due to invalid IL or missing references) //IL_04c9: Unknown result type (might be due to invalid IL or missing references) //IL_04ce: Unknown result type (might be due to invalid IL or missing references) List<string> strings = ConfigSettings.ClosetLocationOverride.GetStrings(ConfigSettings.ClosetLocationOverride.Key.Value); List<GrabbableObject> list = new HangarShipHelper().FindAllScrapShip(); if (ConfigSettings.OrganizeShotgunByAmmo.Key.Value) { List<GrabbableObjectPositionHelperShotgun> objectPositionList = ConfigSettings.ShotgunPlacementOverrideLocation.GetObjectPositionList(ConfigSettings.ShotgunPlacementOverrideLocation.Key.Value); if (objectPositionList.Count > 0 && objectPositionList.First().objName != "name") { foreach (GrabbableObjectPositionHelperShotgun item in objectPositionList) { GrabbablesPositionsShotgun.Add(item); } } else { ShotgunItem shotgun = default(ShotgunItem); foreach (GrabbableObject obj2 in list) { ref ShotgunItem reference = ref shotgun; GrabbableObject obj5 = obj2; reference = (ShotgunItem)(object)((obj5 is ShotgunItem) ? obj5 : null); if (shotgun == null || strings.Where((string ifsc) => ifsc.Equals(((Object)obj2).name)).Any()) { continue; } if (GrabbablesPositionsShotgun.Where((GrabbableObjectPositionHelperShotgun o) => o.objName == ((Object)shotgun).name && o.AmmoQuantity == shotgun.shellsLoaded).Any()) { GrabbablesPositionsShotgun.Where((GrabbableObjectPositionHelperShotgun o) => o.objName == ((Object)obj2).name && o.AmmoQuantity == shotgun.shellsLoaded).First().PlacementPosition = ((Component)obj2).gameObject.transform.position; } else { GrabbablesPositionsShotgun.Add(new GrabbableObjectPositionHelperShotgun(((Object)obj2).name, ((Component)obj2).gameObject.transform.position, shotgun.shellsLoaded)); } } } } if (ConfigSettings.UseItemTypePlacementOverrides.Key.Value) { List<GrabbableObjectPositionHelper> objectPositionList2 = ConfigSettings.ItemPlacementOverrideLocation.GetObjectPositionList(ConfigSettings.ItemPlacementOverrideLocation.Key.Value); if (objectPositionList2.Count > 0 && objectPositionList2.First().objName != "name") { foreach (GrabbableObjectPositionHelper item2 in objectPositionList2) { GrabbablesPositions.Add(item2); } } else { foreach (GrabbableObject obj3 in list) { if (strings.Where((string ifsc) => ifsc.Equals(((Object)obj3).name)).Any()) { continue; } if (GrabbablesPositions.Where((GrabbableObjectPositionHelper o) => o.objName == ((Object)obj3).name).Any()) { GrabbablesPositions.Where((GrabbableObjectPositionHelper o) => o.objName == ((Object)obj3).name).First().PlacementPosition = ((Component)obj3).gameObject.transform.position; } else { GrabbablesPositions.Add(new GrabbableObjectPositionHelper(((Object)obj3).name, ((Component)obj3).gameObject.transform.position)); } } } } if (ConfigSettings.UseOneHandedPlacementOverrides.Key.Value) { if (ConfigSettings.OneHandedItemPlacementOverrideLocation.GetVector3(ConfigSettings.OneHandedItemPlacementOverrideLocation.Key.Value, out var resultVector)) { OneHandedPosition = resultVector; } else { foreach (GrabbableObject obj4 in list) { if (!strings.Where((string ifsc) => ifsc.Equals(((Object)obj4).name)).Any() && !obj4.itemProperties.twoHanded && OneHandedPosition == UnsetPosition) { OneHandedPosition = ((Component)obj4).gameObject.transform.position; } } } } if (!ConfigSettings.UseTwoHandedPlacementOverrides.Key.Value) { return; } if (ConfigSettings.TwoHandedItemPlacementOverrideLocation.GetVector3(ConfigSettings.TwoHandedItemPlacementOverrideLocation.Key.Value, out var resultVector2)) { TwoHandedPosition = resultVector2; return; } foreach (GrabbableObject obj in list) { if (!strings.Where((string ifsc) => ifsc.Equals(((Object)obj).name)).Any() && obj.itemProperties.twoHanded && TwoHandedPosition == UnsetPosition) { TwoHandedPosition = ((Component)obj).gameObject.transform.position; break; } } } } public static class MyPluginInfo { public const string PLUGIN_GUID = "ShipMaid"; public const string PLUGIN_NAME = "ShipMaid"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace ShipMaid.Patchers { public class CommandInfo { public string Category { get; set; } public string Description { get; set; } public Func<string> DisplayTextSupplier { get; set; } public string Title { get; set; } public TerminalNode TriggerNode { get; set; } } public static class ShipMaidTerminalCommands { public static string PerformCleanup() { ShipMaid.Log("Perform Cleanup Called from terminal"); LootOrganizingFunctions.OrganizeShipLoot(); return "Cleaning Ship\n\n"; } public static string PerformStorageClosetCleanup() { ShipMaid.Log("Perform Storage Cleanup Called from terminal"); LootOrganizingFunctions.OrganizeStorageCloset(); return "Cleaning Storage\n\n"; } } public static class TerminalExtensions { public static T[] Add<T>(this T[] array, T newItem) { int num = array.Length + 1; Array.Resize(ref array, num); array[num - 1] = newItem; return array; } public static TerminalKeyword CreateTerminalKeyword(string word, bool isVerb = false, TerminalNode triggeringNode = null) { TerminalKeyword obj = ScriptableObject.CreateInstance<TerminalKeyword>(); obj.word = word.ToLower(); obj.isVerb = isVerb; obj.specialKeywordResult = triggeringNode; return obj; } public static TerminalNode CreateTerminalNode(string displayText, bool clearPreviousText = false, string terminalEvent = "") { TerminalNode obj = ScriptableObject.CreateInstance<TerminalNode>(); obj.displayText = displayText; obj.clearPreviousText = clearPreviousText; obj.terminalEvent = terminalEvent; return obj; } } [HarmonyPatch(typeof(Terminal))] internal class TerminalPatcher { public static List<CommandInfo> Commands = new List<CommandInfo> { new CommandInfo { Title = "cleanup", Category = "ShipMaid", TriggerNode = TerminalExtensions.CreateTerminalNode("cleanup", clearPreviousText: true), Description = "Ship Maid Ship Cleanup", DisplayTextSupplier = ShipMaidTerminalCommands.PerformCleanup }, new CommandInfo { Title = "cleanup storage", Category = "ShipMaid", TriggerNode = TerminalExtensions.CreateTerminalNode("cleanup storage", clearPreviousText: true), Description = "Ship Maid Storage Cleanup", DisplayTextSupplier = ShipMaidTerminalCommands.PerformStorageClosetCleanup } }; public static Terminal Terminal; [HarmonyPatch("Awake")] [HarmonyPostfix] public static void Awake(ref Terminal __instance) { Terminal = __instance; ShipMaid.Log("Adding Terminal Commands"); foreach (CommandInfo command in Commands) { Terminal.terminalNodes.allKeywords = Terminal.terminalNodes.allKeywords.Add(TerminalExtensions.CreateTerminalKeyword(command.Title, isVerb: false, command.TriggerNode)); } } [HarmonyPatch("BeginUsingTerminal")] [HarmonyPrefix] public static void OnBeginUsing(ref Terminal __instance) { } [HarmonyPatch("QuitTerminal")] [HarmonyPostfix] public static void OnQuitTerminal(ref Terminal __instance) { } [HarmonyPatch("TextChanged")] [HarmonyPostfix] public static void OnTextChanged(ref Terminal __instance, string newText) { if (newText.Trim().Length >= __instance.textAdded) { newText.Substring(newText.Length - __instance.textAdded); } } [HarmonyPatch("ParsePlayerSentence")] [HarmonyPostfix] public static void ParsePlayerSentence(ref Terminal __instance, TerminalNode __result) { CommandInfo commandInfo = Commands.FirstOrDefault((CommandInfo cI) => (Object)(object)cI.TriggerNode == (Object)(object)__result); if (commandInfo != null) { __result.displayText = commandInfo?.DisplayTextSupplier(); } __instance.screenText.text.Substring(__instance.screenText.text.Length - __instance.textAdded); } } } namespace ShipMaid.ObjectHelpers { public class GrabbableObjectPositionHelper { public string objName; public Vector3 PlacementPosition; public GrabbableObjectPositionHelper(string name, Vector3 pos) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) objName = name; PlacementPosition = pos; } public GrabbableObjectPositionHelper(string name, float xPos, float yPos, float zPos) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) objName = name; PlacementPosition = new Vector3(xPos, yPos, zPos); } } public class GrabbableObjectPositionHelperShotgun { public int AmmoQuantity; public string objName; public Vector3 PlacementPosition; public GrabbableObjectPositionHelperShotgun(string name, Vector3 pos, int ammoQuantity) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) objName = name; PlacementPosition = pos; AmmoQuantity = ammoQuantity; } public GrabbableObjectPositionHelperShotgun(string name, float xPos, float yPos, float zPos, int ammoQuantity) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) objName = name; PlacementPosition = new Vector3(xPos, yPos, zPos); AmmoQuantity = ammoQuantity; } } } namespace ShipMaid.Networking { internal class NetworkFunctions { public class NetworkingObjectManager : NetworkBehaviour { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static HandleNamedMessageDelegate <>9__3_0; internal void <NetworkManagerInit>b__3_0(ulong senderClientId, FastBufferReader reader) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: 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_0059: Unknown result type (might be due to invalid IL or missing references) if (senderClientId != Keybinds.localPlayerController.playerClientId) { NetworkObjectReference val = default(NetworkObjectReference); ((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref val, default(ForNetworkSerializable)); Vector3 placementPosition = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref placementPosition); Quaternion placementRotation = default(Quaternion); ((FastBufferReader)(ref reader)).ReadValueSafe(ref placementRotation); bool shipParent = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref shipParent, default(ForPrimitives)); NetworkObject val2 = default(NetworkObject); if (((NetworkObjectReference)(ref val)).TryGet(ref val2, (NetworkManager)null)) { MakeObjectFall(((Component)val2).GetComponent<GrabbableObject>(), placementPosition, placementRotation, shipParent); } } } } public static void MakeObjectFall(GrabbableObject obj, Vector3 placementPosition, Quaternion placementRotation, bool shipParent) { //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) GameObject val = GameObject.Find("/Environment/HangarShip"); GameObject val2 = GameObject.Find("/Environment/HangarShip/StorageCloset"); _ = string.Empty; if (shipParent) { if ((Object)(object)((Component)obj).gameObject.transform.GetParent() == (Object)null || ((Object)((Component)obj).gameObject.transform.GetParent()).name != "HangarShip") { ((Component)obj).gameObject.transform.SetParent(val.transform); } } else if ((Object)(object)((Component)obj).gameObject.transform.GetParent() == (Object)null || ((Object)((Component)obj).gameObject.transform.GetParent()).name != "StorageCloset") { ((Component)obj).gameObject.transform.SetParent(val2.transform); } ((Component)obj).gameObject.transform.SetPositionAndRotation(placementPosition, placementRotation); obj.hasHitGround = false; obj.startFallingPosition = placementPosition; obj.floorYRot = -1; if ((Object)(object)((Component)obj).transform.parent != (Object)null) { obj.startFallingPosition = ((Component)obj).transform.parent.InverseTransformPoint(obj.startFallingPosition); } obj.FallToGround(false); obj.floorYRot = -1; } [ClientRpc] public static void MakeObjectFallClientRpc(NetworkObjectReference obj, Vector3 placementPosition, Quaternion placementRotation, bool shipParent) { //IL_0026: 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_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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) NetworkManager singleton = NetworkManager.Singleton; if (singleton == null || !singleton.IsListening) { return; } FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(256, (Allocator)2, -1); ((FastBufferWriter)(ref val)).WriteValueSafe<NetworkObjectReference>(ref obj, default(ForNetworkSerializable)); ((FastBufferWriter)(ref val)).WriteValueSafe(ref placementPosition); ((FastBufferWriter)(ref val)).WriteValueSafe(ref placementRotation); ((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref shipParent, default(ForPrimitives)); NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll("MakeObjectFall", val, (NetworkDelivery)2); NetworkObject val2 = default(NetworkObject); if (!((NetworkObjectReference)(ref obj)).TryGet(ref val2, (NetworkManager)null)) { return; } GrabbableObject obj2 = default(GrabbableObject); if (((Component)val2).TryGetComponent<GrabbableObject>(ref obj2)) { if (!((NetworkBehaviour)Keybinds.localPlayerController).IsOwner) { MakeObjectFall(obj2, placementPosition, placementRotation, shipParent); } } else { ShipMaid.LogError("Failed to get grabbable object ref from network object - ClientRpc"); } } [ServerRpc] public static void MakeObjectFallServerRpc(NetworkObjectReference obj, Vector3 placementPosition, Quaternion placementRotation, bool shipParent) { //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008b: 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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Invalid comparison between Unknown and I4 //IL_00c0: 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 singleton = NetworkManager.Singleton; if (singleton == null) { ShipMaid.LogError("Network Manager == null"); return; } if (!singleton.IsListening) { ShipMaid.LogError("Network Manager not listening"); return; } if (((NetworkBehaviour)Keybinds.localPlayerController).OwnerClientId != singleton.LocalClientId) { if ((int)singleton.LogLevel <= 1) { ShipMaid.LogError("Only the owner can invoke a ServerRpc that requires ownership!"); } return; } FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(256, (Allocator)2, -1); ((FastBufferWriter)(ref val)).WriteValueSafe<NetworkObjectReference>(ref obj, default(ForNetworkSerializable)); ((FastBufferWriter)(ref val)).WriteValueSafe(ref placementPosition); ((FastBufferWriter)(ref val)).WriteValueSafe(ref placementRotation); ((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref shipParent, default(ForPrimitives)); NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll("MakeObjectFall", val, (NetworkDelivery)2); NetworkObject val2 = default(NetworkObject); if (((NetworkObjectReference)(ref obj)).TryGet(ref val2, (NetworkManager)null)) { GrabbableObject obj2 = default(GrabbableObject); if (((Component)val2).TryGetComponent<GrabbableObject>(ref obj2)) { MakeObjectFall(obj2, placementPosition, placementRotation, shipParent); } else { ShipMaid.LogError("Failed to get grabbable object ref from network object - ServerRpc"); } } } public static void NetworkManagerInit() { //IL_002d: 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_0038: Expected O, but got Unknown ShipMaid.Log("Registering named message"); CustomMessagingManager customMessagingManager = NetworkManager.Singleton.CustomMessagingManager; object obj = <>c.<>9__3_0; if (obj == null) { HandleNamedMessageDelegate val = delegate(ulong senderClientId, FastBufferReader reader) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: 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_0059: Unknown result type (might be due to invalid IL or missing references) if (senderClientId != Keybinds.localPlayerController.playerClientId) { NetworkObjectReference val2 = default(NetworkObjectReference); ((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref val2, default(ForNetworkSerializable)); Vector3 placementPosition = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref placementPosition); Quaternion placementRotation = default(Quaternion); ((FastBufferReader)(ref reader)).ReadValueSafe(ref placementRotation); bool shipParent = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref shipParent, default(ForPrimitives)); NetworkObject val3 = default(NetworkObject); if (((NetworkObjectReference)(ref val2)).TryGet(ref val3, (NetworkManager)null)) { MakeObjectFall(((Component)val3).GetComponent<GrabbableObject>(), placementPosition, placementRotation, shipParent); } } }; <>c.<>9__3_0 = val; obj = (object)val; } customMessagingManager.RegisterNamedMessageHandler("MakeObjectFall", (HandleNamedMessageDelegate)obj); } [ClientRpc] public static void RunClientRpc(NetworkObjectReference obj, Vector3 placementPosition, Quaternion placementRotation, bool shipParent) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) MakeObjectFallServerRpc(obj, placementPosition, placementRotation, shipParent); } } } } namespace ShipMaid.InputUtils { internal class InputUtilsKeybinds : LcInputActions { [InputAction("<Keyboard>/j", Name = "Set Location Override")] public InputAction LocationOverrideKey { get; set; } [InputAction("<Keyboard>/m", Name = "Cleanup Ship")] public InputAction ShipCleanupKey { get; set; } [InputAction("<Keyboard>/n", Name = "Cleanup Storage")] public InputAction StorageCleanupKey { get; set; } } } namespace ShipMaid.HelperFunctions { public class LootOrganizingFunctions { private static List<string> ItemsForStorageCloset = ConfigSettings.ClosetLocationOverride.GetStrings(ConfigSettings.ClosetLocationOverride.Key.Value); private static List<string> SortingBlacklist = ConfigSettings.SortingLocationBlacklist.GetStrings(ConfigSettings.SortingLocationBlacklist.Key.Value); public static void OrganizeShipLoot() { StorageClosetHelper storageClosetHelper = new StorageClosetHelper(); List<GrabbableObject> list = new HangarShipHelper().ObjectsInShip(); foreach (GrabbableObject item in storageClosetHelper.GetObjectsInStorageCloset()) { if (list.Contains(item)) { list.Remove(item); } } List<GrabbableObject> list2 = new List<GrabbableObject>(); List<GrabbableObject> list3 = new List<GrabbableObject>(); foreach (GrabbableObject item2 in list) { if (item2.itemProperties.twoHanded) { list2.Add(item2); } else { list3.Add(item2); } } OrganizeItems(storageClosetHelper, list3, twoHanded: false); OrganizeItems(storageClosetHelper, list2, twoHanded: true); } public static void OrganizeStorageCloset() { StorageClosetHelper storageClosetHelper = new StorageClosetHelper(); List<GrabbableObject> objectsInStorageCloset = storageClosetHelper.GetObjectsInStorageCloset(); List<string> list = new List<string>(); foreach (GrabbableObject item in objectsInStorageCloset) { if (!list.Contains(((Object)item).name)) { list.Add(((Object)item).name); } } foreach (string objectType in list) { List<GrabbableObject> list2 = objectsInStorageCloset.Where((GrabbableObject obj) => ((Object)obj).name.Contains(objectType)).ToList(); if ((Object)(object)((IEnumerable<GrabbableObject>)list2).FirstOrDefault((Func<GrabbableObject, bool>)((GrabbableObject obj) => !obj.isHeld)) != (Object)null) { storageClosetHelper.PlaceStorageObjectOnShelve(list2); } } } private static float GetXOffsetFromScrapValue(GrabbableObject obj, float highestScrapValue, float maxXOffset) { if (obj.scrapValue != 0 && highestScrapValue != 0f) { return (float)(obj.scrapValue - 10) / highestScrapValue * maxXOffset; } ShipMaid.Log($"Refraining from breaking math - HighestScrapValue {highestScrapValue} - obj.scrapValue {obj.scrapValue}"); return 0f; } private static void OrganizeItems(StorageClosetHelper sch, List<GrabbableObject> objects, bool twoHanded) { //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_02e2: Unknown result type (might be due to invalid IL or missing references) //IL_02f1: Unknown result type (might be due to invalid IL or missing references) //IL_0300: Unknown result type (might be due to invalid IL or missing references) //IL_0317: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Unknown result type (might be due to invalid IL or missing references) //IL_03a5: Unknown result type (might be due to invalid IL or missing references) //IL_03b0: Unknown result type (might be due to invalid IL or missing references) //IL_03bb: Unknown result type (might be due to invalid IL or missing references) //IL_0332: Unknown result type (might be due to invalid IL or missing references) //IL_0337: Unknown result type (might be due to invalid IL or missing references) //IL_0364: Unknown result type (might be due to invalid IL or missing references) //IL_0373: Unknown result type (might be due to invalid IL or missing references) //IL_0382: Unknown result type (might be due to invalid IL or missing references) //IL_0399: Unknown result type (might be due to invalid IL or missing references) //IL_039b: Unknown result type (might be due to invalid IL or missing references) //IL_0437: Unknown result type (might be due to invalid IL or missing references) //IL_071d: Unknown result type (might be due to invalid IL or missing references) //IL_0733: Unknown result type (might be due to invalid IL or missing references) //IL_0749: Unknown result type (might be due to invalid IL or missing references) //IL_075f: Unknown result type (might be due to invalid IL or missing references) //IL_054b: Unknown result type (might be due to invalid IL or missing references) //IL_0550: Unknown result type (might be due to invalid IL or missing references) //IL_07e9: Unknown result type (might be due to invalid IL or missing references) //IL_06cf: Unknown result type (might be due to invalid IL or missing references) //IL_06ea: Unknown result type (might be due to invalid IL or missing references) //IL_0705: Unknown result type (might be due to invalid IL or missing references) //IL_08d3: Unknown result type (might be due to invalid IL or missing references) //IL_08d8: Unknown result type (might be due to invalid IL or missing references) //IL_07f6: Unknown result type (might be due to invalid IL or missing references) //IL_07f8: Unknown result type (might be due to invalid IL or missing references) //IL_07fd: Unknown result type (might be due to invalid IL or missing references) //IL_0816: Unknown result type (might be due to invalid IL or missing references) //IL_0825: Unknown result type (might be due to invalid IL or missing references) //IL_0834: Unknown result type (might be due to invalid IL or missing references) //IL_084f: Unknown result type (might be due to invalid IL or missing references) //IL_0864: Unknown result type (might be due to invalid IL or missing references) //IL_086b: Unknown result type (might be due to invalid IL or missing references) //IL_0872: Unknown result type (might be due to invalid IL or missing references) //IL_0879: Unknown result type (might be due to invalid IL or missing references) //IL_087e: Unknown result type (might be due to invalid IL or missing references) //IL_0897: Unknown result type (might be due to invalid IL or missing references) //IL_08a6: Unknown result type (might be due to invalid IL or missing references) //IL_08b5: Unknown result type (might be due to invalid IL or missing references) //IL_07c5: Unknown result type (might be due to invalid IL or missing references) //IL_07dc: Unknown result type (might be due to invalid IL or missing references) //IL_07e1: Unknown result type (might be due to invalid IL or missing references) //IL_07e6: Unknown result type (might be due to invalid IL or missing references) //IL_08fb: Unknown result type (might be due to invalid IL or missing references) //IL_090a: Unknown result type (might be due to invalid IL or missing references) //IL_0919: Unknown result type (might be due to invalid IL or missing references) //IL_0937: Unknown result type (might be due to invalid IL or missing references) //IL_093c: Unknown result type (might be due to invalid IL or missing references) //IL_093e: Unknown result type (might be due to invalid IL or missing references) //IL_0607: Unknown result type (might be due to invalid IL or missing references) //IL_096d: Unknown result type (might be due to invalid IL or missing references) //IL_0617: Unknown result type (might be due to invalid IL or missing references) HangarShipHelper hangarShipHelper = new HangarShipHelper(); List<string> list = new List<string>(); foreach (GrabbableObject @object in objects) { if (!list.Contains(((Object)@object).name)) { list.Add(((Object)@object).name); } } float num = 0f; float num2 = 2.25f / (float)list.Count; float num3 = 0f; float num4 = 2.75f / (float)list.Count; float num5 = 7f; bool flag = false; float num6 = 0f; float num7 = 0f; if (twoHanded) { if (ConfigSettings.TwoHandedItemLocation.Key.Value == "Front") { num7 = num3; num6 = num2; flag = true; } else { num7 = num5; num6 = num4; } } else if (ConfigSettings.TwoHandedItemLocation.Key.Value == "Front") { num6 = num4; num7 = num5; } else { num7 = num3; num6 = num2; flag = true; } int num8 = 0; Vector3 val2 = default(Vector3); Vector3 valueOrDefault = default(Vector3); Quaternion val6 = default(Quaternion); foreach (string objectType in list) { List<GrabbableObject> list2 = objects.Where((GrabbableObject obj) => ((Object)obj).name.Contains(objectType)).ToList(); if (ItemsForStorageCloset.Where(objectType.Contains).Any()) { sch.PlaceStorageObjectOnShelve(list2); continue; } if (SortingBlacklist.Where(objectType.Contains).Any()) { continue; } GrabbableObject val = ((IEnumerable<GrabbableObject>)list2).FirstOrDefault((Func<GrabbableObject, bool>)((GrabbableObject obj) => !obj.isHeld)); if (!((Object)(object)val != (Object)null)) { continue; } List<float> list3 = new List<float>(); if (ConfigSettings.OrganizationTechnique.Key.Value == "Stack" && !ConfigSettings.UseItemTypePlacementOverrides.Key.Value && !ConfigSettings.UseOneHandedPlacementOverrides.Key.Value && !ConfigSettings.UseTwoHandedPlacementOverrides.Key.Value) { Random random = new Random(); num = (float)random.NextDouble() * (float)random.Next(-1, 2); if (ConfigSettings.ItemGrouping.Key.Value == "Loose") { num *= 2f; } } GrabbableObjectPositionHelper objectPositionTarget = ShipMaidFunctions.GetObjectPositionTarget(val); if (objectPositionTarget != null && objectPositionTarget != null && ConfigSettings.UseItemTypePlacementOverrides.Key.Value) { ShipMaid.Log("Setting position from memory for " + ((Object)val).name); val2 = objectPositionTarget.PlacementPosition; } else { Vector3? twoHandedPositionTarget = ShipMaidFunctions.GetTwoHandedPositionTarget(); int num9; if (twoHandedPositionTarget.HasValue) { valueOrDefault = twoHandedPositionTarget.GetValueOrDefault(); num9 = (ConfigSettings.UseTwoHandedPlacementOverrides.Key.Value ? 1 : 0); } else { num9 = 0; } if (((uint)num9 & (twoHanded ? 1u : 0u)) != 0) { ShipMaid.Log($"Setting Two Handed position from memory for {((Object)val).name} - {valueOrDefault.x},{valueOrDefault.y},{valueOrDefault.z}"); val2 = valueOrDefault; } else { twoHandedPositionTarget = ShipMaidFunctions.GetOneHandedPositionTarget(); if (twoHandedPositionTarget.HasValue) { Vector3 valueOrDefault2 = twoHandedPositionTarget.GetValueOrDefault(); if (ConfigSettings.UseOneHandedPlacementOverrides.Key.Value && !twoHanded) { ShipMaid.Log($"Setting One Handed position from memory for {((Object)val).name} - {valueOrDefault2.x},{valueOrDefault2.y},{valueOrDefault2.z}"); val2 = valueOrDefault2; goto IL_0449; } } ((Vector3)(ref val2))..ctor(hangarShipHelper.GetShipCenterLocation().x, hangarShipHelper.GetShipCenterLocation().y, hangarShipHelper.GetShipCenterLocation().z); if (ConfigSettings.ItemGrouping.Key.Value == "Loose") { val2.z -= num6 * (float)num8; } else { val2.z -= num6 * (float)num8 * 0.1f + num6 * 0.9f * (float)list.Count; } if (!flag) { val2.z += 0.5f; } val2.x = hangarShipHelper.GetShipCenterLocation().x + num7; } } goto IL_0449; IL_0449: foreach (GrabbableObject item in list2) { if (item.isHeld) { continue; } if (((Object)((Component)item).transform.parent).name.Contains("Wheelbarrow")) { ShipMaid.Log("Ignoring " + ((Object)item).name + " that appears to be located in a Wheelbarrow/Shopping Cart"); continue; } ShotgunItem val3 = (ShotgunItem)(object)((val is ShotgunItem) ? val : null); if (val3 != null) { ShipMaid.Log("Item is Shotgun - " + ((Object)val3).name); } ShotgunItem val4 = (ShotgunItem)(object)((val is ShotgunItem) ? val : null); if (val4 != null) { GrabbableObjectPositionHelperShotgun objectPositionTargetShotgun = ShipMaidFunctions.GetObjectPositionTargetShotgun(val4); if (objectPositionTargetShotgun != null && objectPositionTargetShotgun != null) { ShipMaid.Log("Item is Shotgun and target retrieved"); } } ShotgunItem val5 = (ShotgunItem)(object)((item is ShotgunItem) ? item : null); if (val5 != null) { GrabbableObjectPositionHelperShotgun objectPositionTargetShotgun2 = ShipMaidFunctions.GetObjectPositionTargetShotgun(val5); if (objectPositionTargetShotgun2 != null && objectPositionTargetShotgun2 != null && ConfigSettings.OrganizeShotgunByAmmo.Key.Value) { int shellsLoaded = val5.shellsLoaded; ShipMaid.Log($"Setting position from memory for {((Object)val).name} - Ammo capacity {shellsLoaded}"); val2 = objectPositionTargetShotgun2.PlacementPosition; } } if (ConfigSettings.OrganizationTechnique.Key.Value == "Value" && !ConfigSettings.UseItemTypePlacementOverrides.Key.Value && !ConfigSettings.UseOneHandedPlacementOverrides.Key.Value && !ConfigSettings.UseTwoHandedPlacementOverrides.Key.Value) { if (flag) { val2.x += GetXOffsetFromScrapValue(item, ScrapHelperFunctions.CalculateHighestScrapValue(hangarShipHelper.ObjectsInShip()), 2.5f); } else { val2.x += GetXOffsetFromScrapValue(item, ScrapHelperFunctions.CalculateHighestScrapValue(hangarShipHelper.ObjectsInShip()), 4f); } while (list3.Contains(val2.x)) { val2.x += 0.1f; } list3.Add(val2.x); } else if (!ConfigSettings.UseItemTypePlacementOverrides.Key.Value && !ConfigSettings.UseOneHandedPlacementOverrides.Key.Value && !ConfigSettings.UseTwoHandedPlacementOverrides.Key.Value) { val2.x += num; } if (ConfigSettings.ItemPlacementOverrideOffsetPosition.GetVector3(ConfigSettings.ItemPlacementOverrideOffsetPosition.Key.Value, out var resultVector) && (ConfigSettings.UseOneHandedPlacementOverrides.Key.Value || ConfigSettings.UseTwoHandedPlacementOverrides.Key.Value || ConfigSettings.UseItemTypePlacementOverrides.Key.Value)) { Random random2 = new Random(); val2.x += (float)random2.NextDouble() * resultVector.x; val2.y += (float)random2.NextDouble() * resultVector.y; val2.z += (float)random2.NextDouble() * resultVector.z; } ((Quaternion)(ref val6))..ctor(((Component)((NetworkBehaviour)item).NetworkObject).transform.rotation.x, ((Component)((NetworkBehaviour)item).NetworkObject).transform.rotation.y, ((Component)((NetworkBehaviour)item).NetworkObject).transform.rotation.z, ((Component)((NetworkBehaviour)item).NetworkObject).transform.rotation.w); if (ConfigSettings.ItemPlacementOverrideOffsetRotation.GetFloat(ConfigSettings.ItemPlacementOverrideOffsetRotation.Key.Value, out var resultFloat) && (ConfigSettings.UseOneHandedPlacementOverrides.Key.Value || ConfigSettings.UseTwoHandedPlacementOverrides.Key.Value || ConfigSettings.UseItemTypePlacementOverrides.Key.Value)) { Random random3 = new Random(); val6 *= Quaternion.Euler(0f, (float)random3.NextDouble() * resultFloat, 0f); } if (!hangarShipHelper.IsPositionWithinShip(val2)) { Vector3 val7 = hangarShipHelper.AdjustPositionWithinShip(val2); ShipMaid.Log($"Ship loot detected outside of ship - {((Object)item).name} - {val2.x},{val2.y},{val2.z} - ship bounds {HangarShipHelper.GetDebugLocationShip(((Component)item).gameObject.transform.position)}"); val2 = new Vector3(val7.x, val7.y, val7.z); ShipMaid.Log($"Corrected to- {((Object)item).name} - {val2.x},{val2.y},{val2.z}"); } if (!PositionHelperFunctions.SameLocation(((Component)item).transform.position, val2)) { ShipMaid.Log($"Moving item - {((Object)item).name} to {val2.x},{val2.y},{val2.z}"); NetworkFunctions.NetworkingObjectManager.RunClientRpc(NetworkObjectReference.op_Implicit(((NetworkBehaviour)item).NetworkObject), val2, val6, shipParent: true); if (!hangarShipHelper.IsObjectWithinShip(item)) { ShipMaid.Log("Found item outside of the ship - " + ((Object)item).name + " - where ship bounds are " + HangarShipHelper.GetDebugLocationShip(((Component)item).gameObject.transform.position)); } } } num8++; } } } public static class PositionHelperFunctions { public static Vector3 AdjustPositionWithinBounds(Vector3 targetPosition, Vector3 min, Vector3 max) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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_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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0057: 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_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008d: 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_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) if (targetPosition.x > max.x) { targetPosition.x = max.x; } if (targetPosition.y > max.y) { targetPosition.y = max.y; } if (targetPosition.z > max.z) { targetPosition.z = max.z; } if (targetPosition.x < min.x) { targetPosition.x = min.x; } if (targetPosition.y < min.y) { targetPosition.y = min.y; } if (targetPosition.z < min.z) { targetPosition.z = min.z; } return targetPosition; } public static string DebugQuaterion(Quaternion rot) { return rot.x + "," + rot.y + "," + rot.z + "," + rot.w; } public static string DebugVector3(Vector3 pos) { return pos.x + "," + pos.y + "," + pos.z; } public static bool IsPositionWithinBounds(Vector3 testPosition, Vector3 boundingPositionMin, Vector3 boundingPositionMax) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: 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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: 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_004c: Unknown result type (might be due to invalid IL or missing references) if (testPosition.x <= boundingPositionMax.x && testPosition.y <= boundingPositionMax.y && testPosition.z <= boundingPositionMax.z && testPosition.x >= boundingPositionMin.x && testPosition.y >= boundingPositionMin.y) { return testPosition.z >= boundingPositionMin.z; } return false; } public static bool NearLocation(float f1, float f2, float offset) { if (f1 < f2 + offset) { return f1 > f2 - offset; } return false; } public static bool SameLocation(Vector3 pos1, Vector3 pos2) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) if (NearLocation(pos1.x, pos2.x, 0.01f)) { return NearLocation(pos1.z, pos2.z, 0.01f); } return false; } } public static class ScrapHelperFunctions { private static void ReportScrapList(string where) { if (where == "ship") { CollectionExtensions.Do<GrabbableObject>((IEnumerable<GrabbableObject>)new HangarShipHelper().ObjectsInShip(), (Action<GrabbableObject>)delegate(GrabbableObject scrap) { ShipMaid.Log($"{((Object)scrap).name} - ${scrap.scrapValue} - ${scrap.targetFloorPosition.x}- ${scrap.targetFloorPosition.y}- ${scrap.targetFloorPosition.z}"); }); } else if (where == "closet") { CollectionExtensions.Do<GrabbableObject>((IEnumerable<GrabbableObject>)new StorageClosetHelper().GetObjectsInStorageCloset(), (Action<GrabbableObject>)delegate(GrabbableObject scrap) { ShipMaid.Log($"{((Object)scrap).name} - ${scrap.scrapValue} - ${scrap.targetFloorPosition.x}- ${scrap.targetFloorPosition.y}- ${scrap.targetFloorPosition.z}"); }); } } public static float CalculateHighestScrapValue(List<GrabbableObject> objects) { float num = 0f; foreach (GrabbableObject @object in objects) { if ((float)@object.scrapValue > num) { num = @object.scrapValue; } } return num; } internal static List<GrabbableObject> FindAllScrapOnMap() { List<GrabbableObject> list = new List<GrabbableObject>(); GrabbableObject[] array = Object.FindObjectsByType<GrabbableObject>((FindObjectsSortMode)0); foreach (GrabbableObject val in array) { if (!val.isInShipRoom) { list.Add(val); ShipMaid.Log("Found scrap: " + ((Object)val).name); } } return list; } } } namespace ShipMaid.EntityHelpers { public class HangarShipHelper { public static Vector3 ShipBoundsCenter; public static Vector3 ShipBoundsExtents; public static Vector3 ShipBoundsMaxBack; public static Vector3 ShipBoundsMaxFront; public static Vector3 ShipBoundsMinBack; public static Vector3 ShipBoundsMinFront; public static Vector3 ShipCenter; public static Vector3 ShipCenterForPlacement; public static Vector3 ShipCollider; public static Vector3 ShipExtends; public static GameObject ShipObject; public static float XLocationZChange = 4f; public HangarShipHelper() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: 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_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: 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_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: 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_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) ShipObject = GameObject.Find("/Environment/HangarShip"); ShipCenter = ShipObject.transform.position; MeshCollider componentInChildren = GameObject.Find("/Environment/HangarShip/ShipInside").GetComponentInChildren<MeshCollider>(); ShipBoundsCenter = ((Collider)componentInChildren).bounds.m_Center; ShipBoundsExtents = ((Collider)componentInChildren).bounds.m_Extents; ShipCenterForPlacement = new Vector3(ShipCenter.z - 6.25f, ShipCenter.x - 5.25f, ShipCenter.y + 1.66f); Bounds bounds = ((Collider)componentInChildren).bounds; float num = ((Bounds)(ref bounds)).min.x + 1.75f; bounds = ((Collider)componentInChildren).bounds; float y = ((Bounds)(ref bounds)).min.y; bounds = ((Collider)componentInChildren).bounds; ShipBoundsMinBack = new Vector3(num, y, ((Bounds)(ref bounds)).min.z + 0.5f); bounds = ((Collider)componentInChildren).bounds; float num2 = ((Bounds)(ref bounds)).max.x - 2f; bounds = ((Collider)componentInChildren).bounds; float y2 = ((Bounds)(ref bounds)).max.y; bounds = ((Collider)componentInChildren).bounds; ShipBoundsMaxBack = new Vector3(num2, y2, ((Bounds)(ref bounds)).max.z - 0.5f); bounds = ((Collider)componentInChildren).bounds; float num3 = ((Bounds)(ref bounds)).min.x + 1.75f; bounds = ((Collider)componentInChildren).bounds; float y3 = ((Bounds)(ref bounds)).min.y; bounds = ((Collider)componentInChildren).bounds; ShipBoundsMinFront = new Vector3(num3, y3, ((Bounds)(ref bounds)).min.z + 2f); bounds = ((Collider)componentInChildren).bounds; float num4 = ((Bounds)(ref bounds)).max.x - 2f; bounds = ((Collider)componentInChildren).bounds; float y4 = ((Bounds)(ref bounds)).max.y; bounds = ((Collider)componentInChildren).bounds; ShipBoundsMaxFront = new Vector3(num4, y4, ((Bounds)(ref bounds)).max.z - 1.75f); } public static string GetDebugLocationShip(Vector3 targetPosition) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) if (targetPosition.x > XLocationZChange) { return $"{ShipBoundsMinBack.x},{ShipBoundsMinBack.y},{ShipBoundsMinBack.z} to {ShipBoundsMaxBack.x},{ShipBoundsMaxBack.y},{ShipBoundsMaxBack.z}"; } return $"{ShipBoundsMinFront.x},{ShipBoundsMinFront.y},{ShipBoundsMinFront.z} to {ShipBoundsMaxFront.x},{ShipBoundsMaxFront.y},{ShipBoundsMaxFront.z}"; } public static NetworkObject GetShipNetworkObject() { return GameObject.Find("/Environment/HangarShip").gameObject.GetComponent<NetworkObject>(); } public static Transform GetShipTransform() { return GameObject.Find("/Environment/HangarShip").gameObject.transform; } public Vector3 AdjustPositionWithinShip(Vector3 targetPosition) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) if (targetPosition.x > XLocationZChange) { return PositionHelperFunctions.AdjustPositionWithinBounds(targetPosition, ShipBoundsMinBack, ShipBoundsMaxBack); } return PositionHelperFunctions.AdjustPositionWithinBounds(targetPosition, ShipBoundsMinFront, ShipBoundsMaxFront); } public List<GrabbableObject> FindAllScrapShip() { List<GrabbableObject> list = new List<GrabbableObject>(); GrabbableObject[] array = Object.FindObjectsByType<GrabbableObject>((FindObjectsSortMode)0); foreach (GrabbableObject val in array) { if (val.isInShipRoom) { list.Add(val); } } return list; } public Vector3 GetShipCenterLocation() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) Vector3 position = GameObject.Find("/Environment/HangarShip").transform.position; position.z += -6.25f; position.x += -5.25f; position.y += 1.66f; return position; } public bool IsObjectWithinShip(GrabbableObject obj) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0047: 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_0051: 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_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) if (((Component)obj).gameObject.transform.position.x > XLocationZChange) { return PositionHelperFunctions.IsPositionWithinBounds(((Component)obj).gameObject.transform.position, ShipBoundsMinBack, ShipBoundsMaxBack); } return PositionHelperFunctions.IsPositionWithinBounds(((Component)obj).gameObject.transform.position, ShipBoundsMinFront, ShipBoundsMaxFront); } public bool IsPositionWithinShip(Vector3 position) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (position.x > XLocationZChange) { return PositionHelperFunctions.IsPositionWithinBounds(position, ShipBoundsMinBack, ShipBoundsMaxBack); } return PositionHelperFunctions.IsPositionWithinBounds(position, ShipBoundsMinFront, ShipBoundsMaxFront); } public void MoveItemToShip(GrabbableObject obj) { //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) obj.hasBeenHeld = true; obj.isInFactory = false; obj.isInShipRoom = true; RoundManager instance = RoundManager.Instance; instance.scrapCollectedInLevel += obj.scrapValue; PlayerStats obj2 = StartOfRound.Instance.gameStats.allPlayerStats[Keybinds.localPlayerController.playerClientId]; obj2.profitable += obj.scrapValue; RoundManager.Instance.CollectNewScrapForThisRound(obj); ((Component)obj).transform.SetParent(ShipObject.transform); obj.OnBroughtToShip(); NetworkFunctions.NetworkingObjectManager.RunClientRpc(NetworkObjectReference.op_Implicit(((NetworkBehaviour)obj).NetworkObject), GetShipCenterLocation(), ((Component)obj).transform.rotation, shipParent: true); } public List<GrabbableObject> ObjectsInShip() { return (from obj in ShipObject.GetComponentsInChildren<GrabbableObject>() where ((Object)obj).name != "ClipboardManual" && ((Object)obj).name != "StickyNoteItem" select obj).ToList(); } } public class StorageClosetHelper { public static Vector3 ClosetBoundsMax; public static Vector3 ClosetBoundsMin; private const float StorageLocationXOffsetToShelve = 0.2f; private Vector3 ClosetRotation; private string LastItemPlaced = string.Empty; private float placementLocationAcrossOffset; private int shelveToPlaceOn = 1; private List<Vector3> ShevleListCenter = new List<Vector3>(); private GameObject StorageCloset; private Vector3 StorageLocationEnd; private Vector3 StorageLocationStart; private float StorageLocationXRange; private float StorageLocationXStepItem = 0.2f; private float StorageLocationXStepSize = 0.1f; private float StorageLocationZOffset = 0.2f; private float StorageLocationZRange; public StorageClosetHelper() { //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0079: 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_008a: 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_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: 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_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: 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_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_02f9: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: Unknown result type (might be due to invalid IL or missing references) //IL_030c: Unknown result type (might be due to invalid IL or missing references) StorageCloset = GameObject.Find("/Environment/HangarShip/StorageCloset"); MeshCollider componentInChildren = StorageCloset.GetComponentInChildren<MeshCollider>(); Quaternion rotation = StorageCloset.gameObject.transform.rotation; ClosetRotation = ((Quaternion)(ref rotation)).eulerAngles; Bounds bounds = ((Collider)componentInChildren).bounds; float num = ((Bounds)(ref bounds)).min.x + Mathf.Cos(0.0034906585f); bounds = ((Collider)componentInChildren).bounds; StorageLocationStart = new Vector3(num, 0f, ((Bounds)(ref bounds)).max.z - Mathf.Sin(0.0034906585f) - Mathf.Cos(0.0034906585f)); bounds = ((Collider)componentInChildren).bounds; float num2 = ((Bounds)(ref bounds)).max.x - Mathf.Cos(0.0034906585f); bounds = ((Collider)componentInChildren).bounds; StorageLocationEnd = new Vector3(num2, 0f, ((Bounds)(ref bounds)).min.z - Mathf.Cos(0.0034906585f)); bounds = ((Collider)componentInChildren).bounds; float num3 = ((Bounds)(ref bounds)).min.x + 0.2f; bounds = ((Collider)componentInChildren).bounds; float y = ((Bounds)(ref bounds)).min.y; bounds = ((Collider)componentInChildren).bounds; ClosetBoundsMin = new Vector3(num3, y, ((Bounds)(ref bounds)).min.z); bounds = ((Collider)componentInChildren).bounds; float num4 = ((Bounds)(ref bounds)).max.x - 0.2f; bounds = ((Collider)componentInChildren).bounds; float y2 = ((Bounds)(ref bounds)).max.y; bounds = ((Collider)componentInChildren).bounds; ClosetBoundsMax = new Vector3(num4, y2, ((Bounds)(ref bounds)).max.z); bounds = ((Collider)componentInChildren).bounds; float z = ((Bounds)(ref bounds)).max.z; bounds = ((Collider)componentInChildren).bounds; StorageLocationZRange = z - ((Bounds)(ref bounds)).min.z; bounds = ((Collider)componentInChildren).bounds; float x = ((Bounds)(ref bounds)).max.x; bounds = ((Collider)componentInChildren).bounds; StorageLocationXRange = x - ((Bounds)(ref bounds)).min.x; List<Vector3> shevleListCenter = ShevleListCenter; bounds = ((Collider)componentInChildren).bounds; float x2 = ((Bounds)(ref bounds)).center.x; bounds = ((Collider)componentInChildren).bounds; shevleListCenter.Add(new Vector3(x2, 0.75f, ((Bounds)(ref bounds)).min.z + 0.5f)); List<Vector3> shevleListCenter2 = ShevleListCenter; bounds = ((Collider)componentInChildren).bounds; float x3 = ((Bounds)(ref bounds)).center.x; bounds = ((Collider)componentInChildren).bounds; shevleListCenter2.Add(new Vector3(x3, 1.4f, ((Bounds)(ref bounds)).min.z + 0.5f)); List<Vector3> shevleListCenter3 = ShevleListCenter; bounds = ((Collider)componentInChildren).bounds; float x4 = ((Bounds)(ref bounds)).center.x; bounds = ((Collider)componentInChildren).bounds; shevleListCenter3.Add(new Vector3(x4, 2f, ((Bounds)(ref bounds)).min.z + 0.5f)); List<Vector3> shevleListCenter4 = ShevleListCenter; bounds = ((Collider)componentInChildren).bounds; float x5 = ((Bounds)(ref bounds)).center.x; bounds = ((Collider)componentInChildren).bounds; shevleListCenter4.Add(new Vector3(x5, 2.5f, ((Bounds)(ref bounds)).min.z + 0.5f)); } public static string GetDebugLocationCloset() { return $"{ClosetBoundsMin.x},{ClosetBoundsMin.y},{ClosetBoundsMin.z} to {ClosetBoundsMax.x},{ClosetBoundsMax.y},{ClosetBoundsMax.z}"; } public List<GrabbableObject> GetObjectsInStorageCloset() { return (from obj in StorageCloset.GetComponentsInChildren<GrabbableObject>() where ((Object)obj).name != "ClipboardManual" && ((Object)obj).name != "StickyNoteItem" select obj).ToList(); } public bool IsObjectWithinCloset(GrabbableObject obj) { //IL_000b: 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_0015: Unknown result type (might be due to invalid IL or missing references) return PositionHelperFunctions.IsPositionWithinBounds(((Component)obj).gameObject.transform.position, ClosetBoundsMin, ClosetBoundsMax); } public bool IsPositionWithinCloset(Vector3 placementPosition) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) return PositionHelperFunctions.IsPositionWithinBounds(placementPosition, ClosetBoundsMin, ClosetBoundsMax); } public void PlaceStorageObjectOnShelve(List<GrabbableObject> objectsOfType) { //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_0304: Unknown result type (might be due to invalid IL or missing references) //IL_0309: Unknown result type (might be due to invalid IL or missing references) //IL_0312: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: Unknown result type (might be due to invalid IL or missing references) string name = ((Object)objectsOfType.First()).name; if (!(name == "Key(Clone)")) { if (name == "WhoopieCushion(Clone)") { StorageLocationXStepSize = 0.2f; } else { StorageLocationXStepSize = 0.1f; } } else { StorageLocationXStepSize = 0.05f; } if (((Object)objectsOfType.First()).name != LastItemPlaced && LastItemPlaced != string.Empty) { if (placementLocationAcrossOffset + StorageLocationXStepItem + StorageLocationXStepSize * (float)objectsOfType.Count > 2.25f) { placementLocationAcrossOffset = 0f; if (shelveToPlaceOn < 4) { shelveToPlaceOn++; } } else { placementLocationAcrossOffset += StorageLocationXStepItem; } LastItemPlaced = ((Object)objectsOfType.First()).name; } else if (LastItemPlaced == string.Empty) { LastItemPlaced = ((Object)objectsOfType.First()).name; } int num = 2; bool flag = true; int num2 = 0; float num3 = 0.1f; float num4 = StorageLocationZOffset; Vector3 val2 = default(Vector3); Vector3 val5 = default(Vector3); for (int i = 0; i < objectsOfType.Count; i++) { GrabbableObject val = objectsOfType[i]; if (flag) { if (num2 < num) { num2++; } else { flag = false; } num4 += num3; } else { if (num2 >= 0) { num2--; } else { flag = true; } num4 -= num3; } ((Vector3)(ref val2))..ctor(placementLocationAcrossOffset, ShevleListCenter[shelveToPlaceOn - 1].y, num4); Vector3 val3 = Quaternion.Euler(0f, ClosetRotation.y, 0f) * val2; Vector3 val4 = Quaternion.Euler(0f, ClosetRotation.y, 0f) * new Vector3(-1.75f, 0f, -0.75f); ((Vector3)(ref val5))..ctor(val3.x + StorageCloset.gameObject.transform.position.x + val4.x, ShevleListCenter[shelveToPlaceOn - 1].y, val3.z + StorageCloset.gameObject.transform.position.z + val4.z); if (!IsPositionWithinCloset(val5)) { ShipMaid.Log("Fixed object location out of closet " + ((Object)val).name + " - Original Location " + PositionHelperFunctions.DebugVector3(val5) + " - Bounds are " + GetDebugLocationCloset()); val5 = PositionHelperFunctions.AdjustPositionWithinBounds(val5, ClosetBoundsMin, ClosetBoundsMax); } ShipMaid.Log($"Placing {((Object)val).name} [{i + 1} of {objectsOfType.Count}] on shelve {shelveToPlaceOn} at {PositionHelperFunctions.DebugVector3(val5)}"); NetworkFunctions.NetworkingObjectManager.RunClientRpc(NetworkObjectReference.op_Implicit(((NetworkBehaviour)val).NetworkObject), val5, ((Component)val).transform.rotation, shipParent: false); placementLocationAcrossOffset += StorageLocationXStepSize; } if (LastItemPlaced == "Key(Clone)") { StorageLocationXStepSize = 0.1f; } else { StorageLocationXStepSize = 0.1f; } } } } namespace ShipMaid.Configuration { public static class ConfigSettings { public static ConfigSetupList ClosetLocationOverride = new ConfigSetupList { pluginName = "ShipMaid", SettingName = "ClosetLocationOverride", SettingValue = "Whoopie,Key,Flashlight,StunGrenade", SettingDescription = "List of items separated by comma that will be automatically placed in the storage container on ship cleanup." }; public static Dictionary<string, ConfigEntryBase> currentConfigEntries = new Dictionary<string, ConfigEntryBase>(); public static ConfigSetupString ItemGrouping = new ConfigSetupString { pluginName = "ShipMaid", SettingName = "ItemGrouping", SettingValue = "Tight", SettingDescription = "[Loose] Spread items accross the ship from left to right -or- [Tight] Pack the items to the side of the ship with the suit rack." }; public static ConfigSetupGrabbableObjectPositions ItemPlacementOverrideLocation = new ConfigSetupGrabbableObjectPositions { pluginName = "ShipMaid", SettingName = "ItemPlacementOverrideLocation", SettingValue = "name,0.00,0.00,0.00", SettingDescription = "Name and location of the item location (if UseItemTypePlacementOverrides is enabled)" }; public static ConfigSetupVector3 ItemPlacementOverrideOffsetPosition = new ConfigSetupVector3 { pluginName = "ShipMaid", SettingName = "ItemPlacementOverrideOffsetPosition", SettingValue = "0.10,0.10,0.10", SettingDescription = "Vector3 variation of items within a stack of items (if UseOneHandedPlacementOverrides or UseTwoHandedPlacementOverrides is enabled)" }; public static ConfigSetupFloat ItemPlacementOverrideOffsetRotation = new ConfigSetupFloat { pluginName = "ShipMaid", SettingName = "ItemPlacementOverrideOffsetRotation", SettingValue = "10", SettingDescription = "Float rotation variation of items within a stack of items (if UseOneHandedPlacementOverrides or UseTwoHandedPlacementOverrides is enabled)" }; public static ConfigSetupVector3 OneHandedItemPlacementOverrideLocation = new ConfigSetupVector3 { pluginName = "ShipMaid", SettingName = "OneHandedItemPlacementOverrideLocation", SettingValue = "0.00,0.00,0.00", SettingDescription = "Vector3 location of the One-handed item location (if UseOneHandedPlacementOverrides is enabled)" }; public static ConfigSetupString OrganizationTechnique = new ConfigSetupString { pluginName = "ShipMaid", SettingName = "OrganizationMethod", SettingValue = "Value", SettingDescription = "Choose organization method, spread items of a type by [Value] or [Stack] perfectly by item type." }; public static ConfigSetupBool OrganizeShotgunByAmmo = new ConfigSetupBool { pluginName = "ShipMaid", SettingName = "OrganizeShotgunByAmmo", SettingValue = false, SettingDescription = "If [true], setting position overrides on shotguns will permit them to be organized by how much ammo is loaded" }; public static ConfigSetupShotgunPositions ShotgunPlacementOverrideLocation = new ConfigSetupShotgunPositions { pluginName = "ShipMaid", SettingName = "ShotgunPlacementOverrideLocation", SettingValue = "name,0.00,0.00,0.00,0", SettingDescription = "Name,locationX,locationY,locationZ,shellCount of the shotgun (if OrganizeShotgunByAmmo is enabled)" }; public static ConfigSetupList SortingLocationBlacklist = new ConfigSetupList { pluginName = "ShipMaid", SettingName = "SortingDisabledList", SettingValue = "", SettingDescription = "List of items separated by comma that will be ignored on sorting." }; public static ConfigSetupString TwoHandedItemLocation = new ConfigSetupString { pluginName = "ShipMaid", SettingName = "TwoHandedItemLocation", SettingValue = "Front", SettingDescription = "Choose location for two handed objects, [Front] of ship, or [Back] of ship. The opposite location will have the single handed items" }; public static ConfigSetupVector3 TwoHandedItemPlacementOverrideLocation = new ConfigSetupVector3 { pluginName = "ShipMaid", SettingName = "TwoHandedItemPlacementOverrideLocation", SettingValue = "0.00,0.00,0.00", SettingDescription = "Vector3 location of the Two-handed item location (if UseTwoHandedPlacementOverrides is enabled)" }; public static ConfigSetupBool UseItemTypePlacementOverrides = new ConfigSetupBool { pluginName = "ShipMaid", SettingName = "UseItemTypePlacementOverrides", SettingValue = false, SettingDescription = "If [true], pressing J (or what ever keybind from SetObjectTypePositionKey) will set an objects item type location for organization" }; public static ConfigSetupBool UseOneHandedPlacementOverrides = new ConfigSetupBool { pluginName = "ShipMaid", SettingName = "UseOneHandedPlacementOverrides", SettingValue = false, SettingDescription = "If [true], pressing J (or what ever keybind from SetObjectTypePositionKey) with a one handed object will set all one handed objects location for organization" }; public static ConfigSetupBool UseOnlyTerminal = new ConfigSetupBool { pluginName = "ShipMaid", SettingName = "UseOnlyTerminal", SettingValue = false, SettingDescription = "If [true], the keybinding will be disabled and only the terminal will be used for cleanup commands" }; public static ConfigSetupBool UseTwoHandedPlacementOverrides = new ConfigSetupBool { pluginName = "ShipMaid", SettingName = "UseTwoHandedPlacementOverrides", SettingValue = false, SettingDescription = "If [true], pressing J (or what ever keybind from SetObjectTypePositionKey) with a two handed object will set all two handed objects location for organization" }; public static void BindConfigSettings() { ShipMaid.Log("BindingConfigs"); MaybeMigrateConfigFile(); currentConfigEntries = UseOnlyTerminal.Bind(currentConfigEntries); currentConfigEntries = OrganizationTechnique.Bind(currentConfigEntries); currentConfigEntries = TwoHandedItemLocation.Bind(currentConfigEntries); currentConfigEntries = ItemGrouping.Bind(currentConfigEntries); currentConfigEntries = ClosetLocationOverride.Bind(currentConfigEntries); currentConfigEntries = SortingLocationBlacklist.Bind(currentConfigEntries); currentConfigEntries = UseItemTypePlacementOverrides.Bind(currentConfigEntries); currentConfigEntries = ItemPlacementOverrideLocation.Bind(currentConfigEntries); currentConfigEntries = UseOneHandedPlacementOverrides.Bind(currentConfigEntries); currentConfigEntries = OneHandedItemPlacementOverrideLocation.Bind(currentConfigEntries); currentConfigEntries = UseTwoHandedPlacementOverrides.Bind(currentConfigEntries); currentConfigEntries = TwoHandedItemPlacementOverrideLocation.Bind(currentConfigEntries); currentConfigEntries = ItemPlacementOverrideOffsetPosition.Bind(currentConfigEntries); currentConfigEntries = ItemPlacementOverrideOffsetRotation.Bind(currentConfigEntries); currentConfigEntries = OrganizeShotgunByAmmo.Bind(currentConfigEntries); currentConfigEntries = ShotgunPlacementOverrideLocation.Bind(currentConfigEntries); TryRemoveOldConfigSettings(); } public static void MaybeMigrateConfigFile() { try { ConfigFile config = ((BaseUnityPlugin)ShipMaid.instance).Config; string configFilePath = config.ConfigFilePath; if (!File.Exists(configFilePath)) { return; } string text = ""; string[] array = File.ReadAllLines(configFilePath); _ = array.Length; for (int i = 0; i < array.Length; i++) { if (array[i].Contains(" Enabled") || array[i].Contains(" Disabled")) { ShipMaid.Log("Found line to replace " + array[i]); array[i] = array[i].Replace("Enabled", "true"); array[i] = array[i].Replace("Disabled", "false"); if (i > 2 && array[i - 2].Contains("String"