Decompiled source of Ship Customizer v0.9.3
VoidCrewShipCustomizer.dll
Decompiled 3 days 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.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Text; using System.Text.RegularExpressions; using System.Threading; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using CG; using CG.Client; using CG.Client.Utils; using CG.Game; using CG.Game.Configuration; using CG.Game.SpaceObjects.Controllers; using CG.Network; using CG.Objects; using CG.Profile; using CG.Ship.Hull; using CG.Ship.Modules; using CG.Ship.Modules.Shield; using CG.Ship.Object; using CG.Space; using CG.UI.MainMenu; using Client.Player.Interactions; using Code.Gameplay.Carryables; using ExitGames.Client.Photon; using Gameplay.Chat; using Gameplay.CompositeWeapons; using Gameplay.Hub; using Gameplay.Power; using Gameplay.Utilities; using HarmonyLib; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Photon.Pun; using Photon.Realtime; using ResourceAssets; using UI; using UI.Core; using UI.Core.Audio; using UI.PowerTerminal; using UI.ShipLoadoutTerminal; using UnityEngine; using UnityEngine.Localization; using UnityEngine.UIElements; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("Void Crew Ship Customizer")] [assembly: AssemblyDescription("BepInEx plugin that adds a Custom ship loadout to Void Crew's ship loadout terminal")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("CaptainChunck")] [assembly: AssemblyProduct("VoidCrewShipCustomizer")] [assembly: AssemblyCopyright("Copyright © CaptainChunck 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("6c0b5e1a-3d2f-4b8e-9c47-5a1e0f2d7b93")] [assembly: AssemblyFileVersion("0.9.3.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("0.9.3.0")] namespace VoidCrewShipCustomizer; internal enum OptionKind { Module, Weapon, Item, WeaponCrate } internal sealed class Option { public string Code; public OptionKind Kind; public GUIDUnion Guid; public GUIDUnion PrefabGuid; public string Name; public ContextInfo Context; public Sprite Icon; public RarityType Rarity; public string Category; public int CategoryOrder; public string RuleCategory = "OTHER"; public bool HasSize; public BuildSize Size; public bool SingleInstance; public Type ModuleType; public string Blessing; public int PowerUse; public int PowerMade; } internal sealed class ContentSlot { public int Index; public CarryablesSocket Socket; public readonly Dictionary<string, bool> AcceptCache = new Dictionary<string, bool>(); public string Kind; } internal sealed class SocketInfo { public int Index; public BuildSize Size; public Vector3[] Cells = (Vector3[])(object)new Vector3[0]; public readonly List<int> Overlaps = new List<int>(); public int Group; } internal sealed class ShelfInfo { public int CoreIndex; public GUIDUnion ModuleGuid; public string Name; public List<CarryablesSocket> Slots = new List<CarryablesSocket>(); public readonly Dictionary<string, bool> AcceptCache = new Dictionary<string, bool>(); } internal sealed class HullInfo { public GUIDUnion ShipGuid; public string Name; public ShipLoadoutDataDef BasePreset; public readonly List<ShipLoadoutDataDef> Presets = new List<ShipLoadoutDataDef>(); public readonly List<ShipLoadoutDataDef> RegularPresets = new List<ShipLoadoutDataDef>(); public readonly List<SocketInfo> Sockets = new List<SocketInfo>(); public readonly List<ShelfInfo> Shelves = new List<ShelfInfo>(); public int GroupCount; public int BasePower; } internal static class Catalog { private static readonly Dictionary<GUIDUnion, HullInfo> Hulls = new Dictionary<GUIDUnion, HullInfo>(); private static readonly HashSet<GUIDUnion> FailedHulls = new HashSet<GUIDUnion>(); private static readonly Dictionary<string, Option> ByCode = new Dictionary<string, Option>(); private static readonly Dictionary<GUIDUnion, JObject> PresetContents = new Dictionary<GUIDUnion, JObject>(); private static List<Option> _slotOptions; private static List<Option> _itemOptions; private static List<Option> _homunculusOptions; private static bool _presetContentsRead; private static GUIDUnion _weaponCrate; private static bool _weaponCrateRead; private static HashSet<GUIDUnion> _batteryPayloads; private static int _batteryPayloadsFrom = -1; private static readonly Dictionary<string, List<ContentSlot>> ContentSlotsByCode = new Dictionary<string, List<ContentSlot>>(); private static readonly FieldInfo CompareMethodField = AccessTools.Field(typeof(CsObjectReference), "compareMethod"); private static readonly FieldInfo PrefabRuleField = AccessTools.Field(typeof(CsObjectReference), "orbitObjectRef"); public static List<Option> SlotOptions { get { if (_slotOptions != null) { return _slotOptions; } Stopwatch stopwatch = Stopwatch.StartNew(); List<Option> list = new List<Option>(); AddWeaponOptions(list); AddModuleOptions(list); _slotOptions = (from o in EachCodeOnce(list) orderby o.CategoryOrder, ((int)o.Rarity != 0) ? ((int)o.Rarity) : 0 select o).ThenBy<Option, string>((Option o) => o.Name, StringComparer.OrdinalIgnoreCase).ToList(); foreach (Option slotOption in _slotOptions) { ByCode[slotOption.Code] = slotOption; } Log.Info($"Found {_slotOptions.Count((Option o) => o.Kind == OptionKind.Weapon)} weapons and {_slotOptions.Count((Option o) => o.Kind == OptionKind.Module)} modules that fit in hardpoints ({stopwatch.ElapsedMilliseconds} ms)."); return _slotOptions; } } public static List<Option> ItemOptions { get { if (_itemOptions != null) { return _itemOptions; } Stopwatch stopwatch = Stopwatch.StartNew(); List<Option> list = new List<Option>(); AddItemOptions(list); _itemOptions = (from o in EachCodeOnce(list) orderby o.CategoryOrder, ((int)o.Rarity != 0) ? ((int)o.Rarity) : 0 select o).ThenBy<Option, string>((Option o) => o.Name, StringComparer.OrdinalIgnoreCase).ToList(); foreach (Option itemOption in _itemOptions) { ByCode[itemOption.Code] = itemOption; } Log.Info($"Found {_itemOptions.Count} items for the storage racks ({stopwatch.ElapsedMilliseconds} ms)."); return _itemOptions; } } public static List<Option> HomunculusOptions { get { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) if (_homunculusOptions != null) { return _homunculusOptions; } HashSet<GUIDUnion> hashSet = new HashSet<GUIDUnion>(); List<Option> list = new List<Option>(); foreach (ShipLoadoutDataDef assetDescription in ((ResourceAssetContainer<ShipLoadoutDataContainer, ShipLoadoutData, ShipLoadoutDataDef>)(object)ResourceAssetContainer<ShipLoadoutDataContainer, ShipLoadoutData, ShipLoadoutDataDef>.Instance).AssetDescriptions) { try { CarryableRef homunculusOverride = ((ResourceAssetDef<ShipLoadoutData>)(object)assetDescription).Asset.ShipLoadout.HomunculusOverride; if (!((ResourceAssetRef)(object)homunculusOverride == (ResourceAssetRef)null) && !((ResourceAssetRef)homunculusOverride).IsNull && hashSet.Add(((ResourceAssetRef)homunculusOverride).AssetGuid)) { Option option = ItemOption(((ResourceAssetRef)homunculusOverride).AssetGuid, "HOMUNCULUS", 0); if (option != null) { list.Add(option); } } } catch (Exception ex) { Log.Verbose("Skipped a loadout's homunculus: " + ex.Message); } } _homunculusOptions = list.OrderBy<Option, string>((Option o) => o.Name, StringComparer.OrdinalIgnoreCase).ToList(); foreach (Option homunculusOption in _homunculusOptions) { ByCode[homunculusOption.Code] = homunculusOption; } return _homunculusOptions; } } public static GUIDUnion WeaponCrateGuid { get { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) if (_weaponCrateRead) { return _weaponCrate; } _weaponCrateRead = true; try { _weaponCrate = ((ResourceAssetDef<CarryableObject>)(object)ResourceAssetContainer<CarryableContainer, CarryableObject, CarryableDef>.Instance.WeaponBuildBox).AssetGuid; } catch (Exception ex) { Log.Warn("Could not find the game's weapon crate, so weapons can't be put on storage racks: " + ex.Message); } return _weaponCrate; } } public static List<GUIDUnion> ShipGuids() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) List<GUIDUnion> list = new List<GUIDUnion>(); foreach (MonoBehaviourRef ship in ResourceAssetContainer<ShipLoadoutDataContainer, ShipLoadoutData, ShipLoadoutDataDef>.Instance.Ships) { if ((ResourceAssetRef)(object)ship != (ResourceAssetRef)null && !((ResourceAssetRef)ship).IsNull) { list.Add(((ResourceAssetRef)ship).AssetGuid); } } return list; } public unsafe static bool TryGetHull(GUIDUnion shipGuid, out HullInfo hull) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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_003c: Unknown result type (might be due to invalid IL or missing references) if (Hulls.TryGetValue(shipGuid, out hull)) { return true; } if (((GUIDUnion)(ref shipGuid)).IsNull || FailedHulls.Contains(shipGuid)) { return false; } try { Stopwatch stopwatch = Stopwatch.StartNew(); hull = BuildHull(shipGuid); Hulls[shipGuid] = hull; Log.Info($"Read the {hull.Name}: {hull.Sockets.Count} hardpoint positions in {hull.GroupCount} hardpoints, {hull.Shelves.Count} storage racks, {hull.Presets.Count} loadouts ({stopwatch.ElapsedMilliseconds} ms)."); return true; } catch (Exception ex) { FailedHulls.Add(shipGuid); GUIDUnion val = shipGuid; Log.Error("Could not read ship " + ((object)(*(GUIDUnion*)(&val))/*cast due to .constrained prefix*/).ToString() + ", so it gets no CUSTOM loadout: " + ex); hull = null; return false; } } private static HullInfo BuildHull(GUIDUnion shipGuid) { //IL_000c: 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_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: 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_03a4: Unknown result type (might be due to invalid IL or missing references) //IL_03a9: Unknown result type (might be due to invalid IL or missing references) HullInfo hullInfo = new HullInfo { ShipGuid = shipGuid, Name = HeaderOf(ContextOf(shipGuid), "SHIP") }; List<ShipLoadoutDataDef> list = new List<ShipLoadoutDataDef>(); foreach (ShipLoadoutDataDef assetDescription in ((ResourceAssetContainer<ShipLoadoutDataContainer, ShipLoadoutData, ShipLoadoutDataDef>)(object)ResourceAssetContainer<ShipLoadoutDataContainer, ShipLoadoutData, ShipLoadoutDataDef>.Instance).AssetDescriptions) { try { if (assetDescription != null && !((ResourceAssetDef<ShipLoadoutData>)(object)assetDescription).IsNull && (Object)(object)((ResourceAssetDef<ShipLoadoutData>)(object)assetDescription).Asset != (Object)null && ((ResourceAssetDef<ShipLoadoutData>)(object)assetDescription).Asset.ShipLoadout != null && assetDescription.ShipGuid == shipGuid) { list.Add(assetDescription); } } catch (Exception ex) { Log.Verbose("Skipped a loadout while reading " + hullInfo.Name + ": " + ex.Message); } } if (list.Count == 0) { throw new InvalidOperationException("the game has no loadouts for this ship"); } ShipLoadoutDataContainer instance = ResourceAssetContainer<ShipLoadoutDataContainer, ShipLoadoutData, ShipLoadoutDataDef>.Instance; List<ShipLoadoutDataDef> listed = new List<ShipLoadoutDataDef>(); try { listed.AddRange(instance.GetUnlockedShipDefinitionsFromHighestRankPlayer()); listed.AddRange(instance.GetLockedShipDefinitionsFromHighestRankPlayer()); } catch (Exception ex2) { Log.Warn("Could not read which loadouts the terminal lists: " + ex2.Message); } hullInfo.RegularPresets.AddRange(list.Where(listed.Contains).OrderBy(RankRequirement)); hullInfo.Presets.AddRange(hullInfo.RegularPresets); hullInfo.Presets.AddRange(list.Where((ShipLoadoutDataDef p) => !listed.Contains(p))); ShipLoadoutDataDef val = null; try { val = ((DefaultableResourceAssetContainer<ShipLoadoutDataContainer, ShipLoadoutData, ShipLoadoutDataDef>)(object)instance).GetDefault(); } catch { } hullInfo.BasePreset = (ShipLoadoutDataDef)((val != null && list.Contains(val)) ? ((object)val) : ((object)(hullInfo.RegularPresets.FirstOrDefault() ?? list[0]))); MonoBehaviour asset = ((ResourceAssetRef<MonoBehaviourContainer, MonoBehaviour, MonoBehaviourDef>)(object)((ResourceAssetDef<ShipLoadoutData>)(object)hullInfo.BasePreset).Asset.ShipLoadout.ReferenceShip).Asset; if ((Object)(object)asset == (Object)null) { throw new InvalidOperationException("the ship prefab could not be loaded"); } BuildSocketController component = ((Component)asset).GetComponent<BuildSocketController>(); List<BuildSocket> list2 = (((Object)(object)component != (Object)null && component.Sockets != null && component.Sockets.Count > 0) ? component.Sockets : new List<BuildSocket>(((Component)asset).GetComponentsInChildren<BuildSocket>(true))); for (int num = 0; num < list2.Count; num++) { SocketInfo socketInfo = new SocketInfo { Index = num }; if ((Object)(object)list2[num] != (Object)null) { socketInfo.Size = list2[num].Size; socketInfo.Cells = CellsOf(list2[num]); } hullInfo.Sockets.Add(socketInfo); } hullInfo.GroupCount = Hardpoints.LinkOverlaps(hullInfo.Sockets); try { hullInfo.BasePower = (from p in ((Component)asset).GetComponentsInChildren<PowerProvider>(true) where (Object)(object)p != (Object)null && p.PowerProvided != null select p).Sum((PowerProvider p) => ((ModifiablePrimitive<int, IntModifier>)(object)p.PowerProvided).BaseValue); } catch (Exception ex3) { Log.Verbose("Could not read the " + hullInfo.Name + "'s own power: " + ex3.Message); } PlayerControlledShip component2 = ((Component)asset).GetComponent<PlayerControlledShip>(); CellModule[] array = (((Object)(object)component2 != (Object)null) ? component2.CoreSystems : null); if (array != null) { for (int num2 = 0; num2 < array.Length; num2++) { CarryablesShelf val2 = (((Object)(object)array[num2] != (Object)null) ? ((Component)array[num2]).GetComponent<CarryablesShelf>() : null); if (!((Object)(object)val2 == (Object)null)) { ShelfInfo shelfInfo = new ShelfInfo { CoreIndex = num2, ModuleGuid = ((AbstractCloneStarObject)val2).assetGuid }; shelfInfo.Slots.AddRange(((CellModule)val2).CarryablesSockets.Where((CarryablesSocket s) => (Object)(object)s != (Object)null)); shelfInfo.Name = "STORAGE RACK " + (hullInfo.Shelves.Count + 1); hullInfo.Shelves.Add(shelfInfo); } } } return hullInfo; } private static Vector3[] CellsOf(BuildSocket socket) { //IL_0008: 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_001a: Unknown result type (might be due to invalid IL or missing references) Transform transform = ((Component)socket).transform; return Hardpoints.CellsFor(socket.Size, transform.position, transform.right, transform.forward); } private static int RankRequirement(ShipLoadoutDataDef def) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) try { UnlockItemDef assetDefById = ((ResourceAssetContainer<UnlockContainer, Object, UnlockItemDef>)(object)ResourceAssetContainer<UnlockContainer, Object, UnlockItemDef>.Instance).GetAssetDefById(((ResourceAssetDef<ShipLoadoutData>)(object)def).AssetGuid, false); return (assetDefById != null) ? assetDefById.UnlockOptions.RankRequirement : int.MaxValue; } catch { return int.MaxValue; } } private static IEnumerable<Option> EachCodeOnce(List<Option> options) { HashSet<string> codes = new HashSet<string>(); foreach (Option option in options) { if (codes.Add(option.Code)) { yield return option; continue; } Log.InfoOnce("listed twice " + option.Code, "Listed " + RichText.Plain(option.Name) + " (" + option.Code + ") once: the game's list has it twice."); } } public static string VariantNote(Option option) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0013: 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_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) if (option == null) { return null; } GUIDUnion guid = option.Guid; try { RuntimeAssetsRegister instance = RuntimeAssetsRegister.Instance; if (instance.HasAsset(guid)) { RuntimeAssetInfo val = default(RuntimeAssetInfo); string text = ((!instance.TryGetAssetInfo(guid, ref val) || val == null) ? null : (string.IsNullOrEmpty(val.DisplayName) ? val.Name : val.DisplayName)); if (string.IsNullOrEmpty(text) || text == RichText.Plain(option.Name)) { Object asset = instance.GetAsset(guid); text = ((asset != (Object)null) ? asset.name : null); } return "from a mod" + (string.IsNullOrEmpty(text) ? "" : (": " + Readable(text))); } ResourcePaths instance2 = ResourcePaths.Instance; string text2 = default(string); if ((Object)(object)instance2 != (Object)null && instance2.TryGetPath(guid, ref text2) && !string.IsNullOrEmpty(text2)) { string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(text2); if (!string.IsNullOrEmpty(fileNameWithoutExtension)) { return "in the game as " + Readable(fileNameWithoutExtension); } } } catch (Exception ex) { Log.Verbose("Could not tell where " + option.Name + " comes from: " + ex.Message); } return "id " + ((GUIDUnion)(ref guid)).AsHex().Substring(0, 8); } internal static string Readable(string name) { return string.Join(" ", (name ?? "").Split(new char[2] { '_', ' ' }, StringSplitOptions.RemoveEmptyEntries)); } public static bool IsHomunculus(string code) { if (!string.IsNullOrEmpty(code)) { return HomunculusOptions.Any((Option o) => o.Code == code); } return false; } public static string BlessingOf(Option option) { if (option == null || (Object)(object)option.Context == (Object)null) { return null; } if (option.Blessing == null) { try { option.Blessing = RichText.LastSection(option.Context.BodyText) ?? ""; } catch (Exception ex) { option.Blessing = ""; Log.Verbose("Could not read the blessing of " + option.Name + ": " + ex.Message); } } if (option.Blessing.Length <= 0) { return null; } return option.Blessing; } public static bool TryGetOption(string code, out Option option) { //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) option = null; if (string.IsNullOrEmpty(code)) { return false; } if (ByCode.TryGetValue(code, out option)) { return true; } if (code.StartsWith("m:") || code.StartsWith("w:")) { _ = SlotOptions; } else { _ = ItemOptions; } if (ByCode.TryGetValue(code, out option)) { return true; } if (code.Length > 2 && GUIDUnion.IsValidString(code.Substring(2))) { GUIDUnion guid = default(GUIDUnion); ((GUIDUnion)(ref guid))..ctor(code.Substring(2)); if (code.StartsWith("m:")) { option = RawModuleOption(guid); } else if (code.StartsWith("i:") && IsCarryable(guid)) { option = ItemOption(guid, "OTHER", 99); } if (option != null) { ByCode[code] = option; } } return option != null; } public static bool TryGetHardpointOption(string code, out Option option) { if (TryGetOption(code, out option) && (option.Kind == OptionKind.Module || option.Kind == OptionKind.Weapon)) { return option.HasSize; } return false; } public static bool TryGetRackOption(string code, out Option option) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) if (!TryGetOption(code, out option)) { return false; } if (option.Kind == OptionKind.WeaponCrate) { return true; } if (option.Kind == OptionKind.Item) { return IsCarryable(option.Guid); } return false; } public static bool IsCarryable(GUIDUnion guid) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) try { return !((GUIDUnion)(ref guid)).IsNull && ((ResourceAssetContainer<CarryableContainer, CarryableObject, CarryableDef>)(object)ResourceAssetContainer<CarryableContainer, CarryableObject, CarryableDef>.Instance).HasItem(guid); } catch { return false; } } public static bool CanSpawn(GUIDUnion guid) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) if (!((GUIDUnion)(ref guid)).IsNull) { return ((ResourceAssetContainer<CloneStarObjectContainer, AbstractCloneStarObject, CloneStarObjectDef>)(object)ResourceAssetContainer<CloneStarObjectContainer, AbstractCloneStarObject, CloneStarObjectDef>.Instance).HasItem(guid); } return false; } private static bool IsBatteryPayload(GUIDUnion guid) { //IL_0116: 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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) RuntimeAssetsRegister instance = RuntimeAssetsRegister.Instance; List<GUIDUnion> allIds = instance.GetAllIds(); if (_batteryPayloads == null || allIds.Count != _batteryPayloadsFrom) { _batteryPayloadsFrom = allIds.Count; _batteryPayloads = new HashSet<GUIDUnion>(); Object val = default(Object); foreach (GUIDUnion item in allIds) { GUIDUnion current = item; try { if (instance.TryGetAsset(current, ref val)) { GameObject val2 = (GameObject)(object)((val is GameObject) ? val : null); if ((Object)(object)val2 == (Object)null && val is Component) { val2 = ((Component)val).gameObject; } PayloadBattery val3 = (((Object)(object)val2 != (Object)null) ? val2.GetComponent<PayloadBattery>() : null); if ((Object)(object)val3 != (Object)null && (Object)(object)val3.Payload != (Object)null) { _batteryPayloads.Add(((AbstractCloneStarObject)val3.Payload).assetGuid); } } } catch (Exception ex) { Log.Verbose("Could not read mod asset " + ((GUIDUnion)(ref current)).AsHex() + ": " + ex.Message); } } } return _batteryPayloads.Contains(guid); } private static Option RawModuleOption(GUIDUnion guid) { //IL_0000: 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_0017: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: 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_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) if (!CanSpawn(guid) || !((ResourceAssetContainer<ModuleContainer, CellModule, ModuleDef>)(object)ResourceAssetContainer<ModuleContainer, CellModule, ModuleDef>.Instance).HasItem(guid)) { return null; } if (IsWeaponCore(guid)) { Log.InfoOnce("weapon core " + ((GUIDUnion)(ref guid)).AsHex(), "Left out a weapon's core named as a module (m:" + ((GUIDUnion)(ref guid)).AsHex() + "): weapons are fitted as weapons."); return null; } ContextInfo val = ContextOf(guid); Option option = new Option { Code = "m:" + ((GUIDUnion)(ref guid)).AsHex(), Kind = OptionKind.Module, Guid = guid, PrefabGuid = guid, Name = HeaderOf(val, "Module"), Context = val, Icon = (((Object)(object)val != (Object)null) ? val.Icon : null), Rarity = RarityOf(guid), Category = "OTHER", CategoryOrder = 9 }; try { CellModule val2 = ((ResourceAssetDef<CellModule>)(object)((ResourceAssetContainer<ModuleContainer, CellModule, ModuleDef>)(object)ResourceAssetContainer<ModuleContainer, CellModule, ModuleDef>.Instance).GetAssetDefById(guid, false))?.Asset; if ((Object)(object)val2 != (Object)null && TryGetSize(val2.BuildingConstraints, out var size)) { option.HasSize = true; option.Size = size; option.SingleInstance = val2.BuildingConstraints.AllowOnlySingleInstance; option.ModuleType = ((object)val2).GetType(); ReadPower(option, val2); } } catch (Exception ex) { Log.Verbose("Could not read the size of module " + option.Name + ": " + ex.Message); } return option; } private static bool IsWeaponCore(GUIDUnion guid) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) try { ModuleDef assetDefById = ((ResourceAssetContainer<ModuleContainer, CellModule, ModuleDef>)(object)ResourceAssetContainer<ModuleContainer, CellModule, ModuleDef>.Instance).GetAssetDefById(guid, false); return assetDefById != null && ((ResourceAssetDef<CellModule>)(object)assetDefById).Asset is CompositeWeaponModule; } catch (Exception ex) { Log.Verbose("Could not tell whether module " + ((GUIDUnion)(ref guid)).AsHex() + " is a weapon: " + ex.Message); return false; } } private static void AddWeaponOptions(List<Option> list) { //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) foreach (CompositeWeaponDataDef assetDescription in ((ResourceAssetContainer<CompositeWeaponDataContainer, CompositeWeaponData, CompositeWeaponDataDef>)(object)ResourceAssetContainer<CompositeWeaponDataContainer, CompositeWeaponData, CompositeWeaponDataDef>.Instance).AssetDescriptions) { try { if (assetDescription == null || ((ResourceAssetDef<CompositeWeaponData>)(object)assetDescription).IsNull) { continue; } CompositeWeaponData asset = ((ResourceAssetDef<CompositeWeaponData>)(object)assetDescription).Asset; if ((Object)(object)asset == (Object)null || asset.Data == null || (ResourceAssetRef)(object)asset.Data.CoreElement == (ResourceAssetRef)null || ((ResourceAssetRef)asset.Data.CoreElement).IsNull || !CanSpawn(((ResourceAssetRef)asset.Data.CoreElement).AssetGuid)) { continue; } CompositeWeaponModule asset2 = ((ResourceAssetRef<WeaponCoreContainer, CompositeWeaponModule, WeaponCoreDef>)(object)asset.Data.CoreElement).Asset; if (!((Object)(object)asset2 == (Object)null) && TryGetSize(((CellModule)asset2).BuildingConstraints, out var size)) { IResourceAssetContextInfo contextInfo = ((PurchasableResourceAssetDef<CompositeWeaponData>)(object)assetDescription).ContextInfo; ContextInfo val = (ContextInfo)(object)((contextInfo is ContextInfo) ? contextInfo : null); if (!IsMissing(val)) { CoreStatDescriptor val2 = (CoreStatDescriptor)(((ResourceAssetRef)(object)asset.Data.CoreStats != (ResourceAssetRef)null && !((ResourceAssetRef)asset.Data.CoreStats).IsNull) ? /*isinst with value type is only supported in some contexts*/: null); Option obj = new Option { PowerUse = (((Object)(object)val2 != (Object)null) ? val2.PowerRequirement : 0) }; GUIDUnion assetGuid = ((ResourceAssetDef<CompositeWeaponData>)(object)assetDescription).AssetGuid; obj.Code = "w:" + ((GUIDUnion)(ref assetGuid)).AsHex(); obj.Kind = OptionKind.Weapon; obj.Guid = ((ResourceAssetDef<CompositeWeaponData>)(object)assetDescription).AssetGuid; obj.PrefabGuid = ((ResourceAssetRef)asset.Data.CoreElement).AssetGuid; obj.Name = HeaderOf(val, ((Object)asset).name); obj.Context = val; obj.Icon = val.Icon; obj.Rarity = RarityOf(((ResourceAssetDef<CompositeWeaponData>)(object)assetDescription).AssetGuid); obj.Category = CategoryName((ECategory)1); obj.CategoryOrder = 1; obj.RuleCategory = "WEAPONS"; obj.HasSize = true; obj.Size = size; obj.SingleInstance = ((CellModule)asset2).BuildingConstraints.AllowOnlySingleInstance; obj.ModuleType = ((object)asset2).GetType(); list.Add(obj); } } } catch (Exception ex) { Log.Verbose("Skipped weapon " + ((assetDescription != null) ? ((ResourceAssetDef<CompositeWeaponData>)(object)assetDescription).Path : "?") + ": " + ex.Message); } } } private static void AddModuleOptions(List<Option> list) { //IL_0029: 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) //IL_0082: 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_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Expected I4, but got Unknown //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) foreach (ModuleDef assetDescription in ((ResourceAssetContainer<ModuleContainer, CellModule, ModuleDef>)(object)ResourceAssetContainer<ModuleContainer, CellModule, ModuleDef>.Instance).AssetDescriptions) { try { if (assetDescription == null || ((ResourceAssetDef<CellModule>)(object)assetDescription).IsNull || (int)assetDescription.Category == 0 || !CanSpawn(((ResourceAssetDef<CellModule>)(object)assetDescription).AssetGuid)) { continue; } CellModule asset = ((ResourceAssetDef<CellModule>)(object)assetDescription).Asset; if (!((Object)(object)asset == (Object)null) && !(asset is CompositeWeaponModule) && !((Object)(object)((Component)asset).GetComponent<CarryablesShelf>() != (Object)null) && TryGetSize(asset.BuildingConstraints, out var size)) { ContextInfo val = ContextOf(((ResourceAssetDef<CellModule>)(object)assetDescription).AssetGuid); if (!IsMissing(val)) { Option option = new Option(); GUIDUnion assetGuid = ((ResourceAssetDef<CellModule>)(object)assetDescription).AssetGuid; option.Code = "m:" + ((GUIDUnion)(ref assetGuid)).AsHex(); option.Kind = OptionKind.Module; option.Guid = ((ResourceAssetDef<CellModule>)(object)assetDescription).AssetGuid; option.PrefabGuid = ((ResourceAssetDef<CellModule>)(object)assetDescription).AssetGuid; option.Name = HeaderOf(val, ((Object)asset).name); option.Context = val; option.Icon = val.Icon; option.Rarity = RarityOf(((ResourceAssetDef<CellModule>)(object)assetDescription).AssetGuid); option.Category = CategoryName(assetDescription.Category); option.CategoryOrder = (int)assetDescription.Category; option.RuleCategory = ModuleRuleCategory(assetDescription.Category); option.HasSize = true; option.Size = size; option.SingleInstance = asset.BuildingConstraints.AllowOnlySingleInstance; option.ModuleType = ((object)asset).GetType(); Option option2 = option; ReadPower(option2, asset); list.Add(option2); } } } catch (Exception ex) { Log.Verbose("Skipped module " + ((assetDescription != null) ? ((ResourceAssetDef<CellModule>)(object)assetDescription).Path : "?") + ": " + ex.Message); } } } private static void ReadPower(Option option, CellModule prefab) { try { PowerDrain componentInChildren = ((Component)prefab).GetComponentInChildren<PowerDrain>(true); option.PowerUse = (((Object)(object)componentInChildren != (Object)null && componentInChildren.PowerWanted != null) ? ((ModifiablePrimitive<int, IntModifier>)(object)componentInChildren.PowerWanted).BaseValue : 0); PowerProvider componentInChildren2 = ((Component)prefab).GetComponentInChildren<PowerProvider>(true); option.PowerMade = (((Object)(object)componentInChildren2 != (Object)null && componentInChildren2.PowerProvided != null) ? ((ModifiablePrimitive<int, IntModifier>)(object)componentInChildren2.PowerProvided).BaseValue : 0); } catch (Exception ex) { Log.Verbose("Could not read the power of " + option.Name + ": " + ex.Message); } } private static void AddItemOptions(List<Option> list) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: 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_012f: 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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Invalid comparison between Unknown and I4 //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) CarryableContainer instance = ResourceAssetContainer<CarryableContainer, CarryableObject, CarryableDef>.Instance; GUIDUnion weaponCrateGuid = WeaponCrateGuid; foreach (CarryableDef assetDescription in ((ResourceAssetContainer<CarryableContainer, CarryableObject, CarryableDef>)(object)instance).AssetDescriptions) { try { if (assetDescription != null && !((ResourceAssetDef<CarryableObject>)(object)assetDescription).IsNull && !(((ResourceAssetDef<CarryableObject>)(object)assetDescription).AssetGuid == weaponCrateGuid) && ((int)((PurchasableResourceAssetDef<CarryableObject>)(object)assetDescription).Category != 65 || Settings.ShowQuestItems.Value)) { Option option = ItemOption(((ResourceAssetDef<CarryableObject>)(object)assetDescription).AssetGuid, ItemCategoryName(((PurchasableResourceAssetDef<CarryableObject>)(object)assetDescription).Category), ItemCategoryOrder(((PurchasableResourceAssetDef<CarryableObject>)(object)assetDescription).Category)); if (option != null) { list.Add(option); } } } catch (Exception ex) { Log.Verbose("Skipped item " + ((assetDescription != null) ? ((ResourceAssetDef<CarryableObject>)(object)assetDescription).Path : "?") + ": " + ex.Message); } } if (((GUIDUnion)(ref weaponCrateGuid)).IsNull || !CanSpawn(weaponCrateGuid)) { return; } foreach (Option item in SlotOptions.Where((Option o) => o.Kind == OptionKind.Weapon)) { Sprite icon = item.Icon; try { icon = ((ResourceAssetContainer<CompositeWeaponDataContainer, CompositeWeaponData, CompositeWeaponDataDef>)(object)ResourceAssetContainer<CompositeWeaponDataContainer, CompositeWeaponData, CompositeWeaponDataDef>.Instance).GetAssetDefById(item.Guid, true).BuildBoxIcon; } catch { } list.Add(new Option { Code = "c:" + ((GUIDUnion)(ref item.Guid)).AsHex(), Kind = OptionKind.WeaponCrate, Guid = item.Guid, PrefabGuid = weaponCrateGuid, Name = item.Name, Context = item.Context, Icon = icon, Rarity = item.Rarity, Category = "WEAPON CRATES", CategoryOrder = 5, RuleCategory = "WEAPON CRATES" }); } } private static Option ItemOption(GUIDUnion guid, string category, int order) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000a: 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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009b: 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_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) if (!CanSpawn(guid)) { return null; } ContextInfo val = ContextOf(guid); if (IsMissing(val)) { return null; } if (IsBatteryPayload(guid)) { Log.InfoOnce("battery payload " + ((GUIDUnion)(ref guid)).AsHex(), "Left out " + HeaderOf(val, "Item") + " (" + ((GUIDUnion)(ref guid)).AsHex() + "): it is the payload inside a mod's payload battery, not an item a rack can start with."); return null; } return new Option { Code = "i:" + ((GUIDUnion)(ref guid)).AsHex(), Kind = OptionKind.Item, Guid = guid, PrefabGuid = guid, Name = HeaderOf(val, "Item"), Context = val, Icon = val.Icon, Rarity = RarityOf(guid), Category = category, CategoryOrder = order, RuleCategory = ((category == "SUPPORT") ? "SUPPORT ITEMS" : category) }; } private static string ModuleRuleCategory(ECategory category) { //IL_0000: 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) //IL_0014: Expected I4, but got Unknown return (category - 1) switch { 0 => "WEAPONS", 1 => "DEFENSE", 2 => "SUPPORT MODULES", _ => "OTHER", }; } private static string ItemCategoryName(PurchasableItemSubCategory category) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Invalid comparison between Unknown and I4 //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Invalid comparison between Unknown and I4 //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Invalid comparison between Unknown and I4 //IL_000c: 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) //IL_0021: Expected I4, but got Unknown //IL_002d: 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_0032: Invalid comparison between Unknown and I4 if ((int)category <= 35) { if (category - 17 <= 3) { return "ANIMUS CRATES"; } switch (category - 33) { case 0: return "AMMO & POWER"; case 1: return "SUPPORT"; case 2: return "MATERIALS"; } } else { if ((int)category == 49) { return "WEAPON MODS"; } if ((int)category == 50) { return "RELICS"; } if (category - 65 <= 1) { return "SPECIAL"; } } return "OTHER"; } private static int ItemCategoryOrder(PurchasableItemSubCategory category) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return ItemCategoryName(category) switch { "AMMO & POWER" => 1, "SUPPORT" => 2, "MATERIALS" => 3, "ANIMUS CRATES" => 4, "WEAPON MODS" => 6, "RELICS" => 7, "SPECIAL" => 8, _ => 9, }; } private unsafe static string CategoryName(ECategory category) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) try { string text = ECategoryExtension.ToStringLocalized(category); if (!string.IsNullOrEmpty(text)) { return text.ToUpperInvariant(); } } catch { } return ((object)(*(ECategory*)(&category))/*cast due to .constrained prefix*/).ToString().ToUpperInvariant(); } public static bool ShelfAccepts(ShelfInfo shelf, Option item) { if (shelf.Slots.Count == 0) { return true; } return SocketAccepts(shelf.Slots[0], item, shelf.AcceptCache, whenUnsure: true, shelf.Name); } public static bool SocketAccepts(CarryablesSocket slot, Option item, Dictionary<string, bool> cache, bool whenUnsure, string what) { //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)slot == (Object)null || item == null) { return whenUnsure; } string key = ((item.Kind == OptionKind.WeaponCrate) ? "crate" : item.Code); if (cache != null && cache.TryGetValue(key, out var value)) { return value; } value = true; try { bool flag = false; if (slot.rejectedList != null) { CsObjectReference[] rejectedList = slot.rejectedList; for (int i = 0; i < rejectedList.Length; i++) { bool? flag2 = QuickMatch(rejectedList[i], item.PrefabGuid); if (flag2 == true) { value = false; } if (!flag2.HasValue) { flag = true; } } } if (value) { bool? flag3 = QuickMatch(slot.accepted, item.PrefabGuid); if (flag3 == false) { value = false; } if (!flag3.HasValue) { flag = true; } } if (value && flag) { ISelfReferencingResourceAsset asset = (ISelfReferencingResourceAsset)(object)((ResourceAssetDef<CarryableObject>)(object)((ResourceAssetContainer<CarryableContainer, CarryableObject, CarryableDef>)(object)ResourceAssetContainer<CarryableContainer, CarryableObject, CarryableDef>.Instance).GetAssetDefById(item.PrefabGuid, false))?.Asset; if (asset != null) { if (slot.rejectedList != null && slot.rejectedList.Any((CsObjectReference r) => r != null && r.IsInstanceOf(asset))) { value = false; } else if (slot.accepted != null) { value = slot.accepted.IsInstanceOf(asset); } } } } catch (Exception ex) { Log.Verbose("Could not check whether " + what + " takes " + item.Name + ": " + ex.Message); value = whenUnsure; } if (cache != null) { cache[key] = value; } return value; } public static List<ContentSlot> ContentSlotsOf(Option option) { if (option == null || (option.Kind != OptionKind.Module && option.Kind != OptionKind.Weapon)) { return new List<ContentSlot>(); } if (ContentSlotsByCode.TryGetValue(option.Code, out var value)) { return value; } value = new List<ContentSlot>(); try { foreach (CarryablesSocket item in PrefabSockets(option)) { value.Add(new ContentSlot { Index = value.Count, Socket = item }); } } catch (Exception ex) { Log.Verbose("Could not read the item slots of " + option.Name + ": " + ex.Message); value = new List<ContentSlot>(); } ContentSlotsByCode[option.Code] = value; return value; } private static List<CarryablesSocket> PrefabSockets(Option option) { //IL_011a: 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) List<CarryablesSocket> list = new List<CarryablesSocket>(); if (option.Kind == OptionKind.Weapon) { CompositeWeaponDataDef assetDefById = ((ResourceAssetContainer<CompositeWeaponDataContainer, CompositeWeaponData, CompositeWeaponDataDef>)(object)ResourceAssetContainer<CompositeWeaponDataContainer, CompositeWeaponData, CompositeWeaponDataDef>.Instance).GetAssetDefById(option.Guid, false); CompositeWeapon val = ((assetDefById != null && (Object)(object)((ResourceAssetDef<CompositeWeaponData>)(object)assetDefById).Asset != (Object)null) ? ((ResourceAssetDef<CompositeWeaponData>)(object)assetDefById).Asset.Data : null); if (val == null) { return list; } if ((ResourceAssetRef)(object)val.CoreElement != (ResourceAssetRef)null && !((ResourceAssetRef)val.CoreElement).IsNull) { AddProviderSockets(list, (Component)(object)((ResourceAssetRef<WeaponCoreContainer, CompositeWeaponModule, WeaponCoreDef>)(object)val.CoreElement).Asset); } if ((ResourceAssetRef)(object)val.MagazineElement != (ResourceAssetRef)null && !((ResourceAssetRef)val.MagazineElement).IsNull) { AddProviderSockets(list, (Component)(object)((ResourceAssetRef<WeaponMagazineContainer, WeaponMagazine, WeaponMagazineDef>)(object)val.MagazineElement).Asset); } if ((ResourceAssetRef)(object)val.ModRackElement != (ResourceAssetRef)null && !((ResourceAssetRef)val.ModRackElement).IsNull) { WeaponModRack asset = ((ResourceAssetRef<WeaponModRackContainer, WeaponModRack, WeaponModRackDef>)(object)val.ModRackElement).Asset; if ((Object)(object)asset != (Object)null && asset.ModSockets != null) { ModSocket[] modSockets = asset.ModSockets; foreach (ModSocket socket in modSockets) { AddSocket(list, (CarryablesSocket)(object)socket); } } } return list; } CellModule val2 = ((ResourceAssetDef<CellModule>)(object)((ResourceAssetContainer<ModuleContainer, CellModule, ModuleDef>)(object)ResourceAssetContainer<ModuleContainer, CellModule, ModuleDef>.Instance).GetAssetDefById(option.Guid, false))?.Asset; if ((Object)(object)val2 == (Object)null) { return list; } AddProviderSockets(list, (Component)(object)val2); ShieldBatteryLoader[] componentsInChildren = ((Component)val2).GetComponentsInChildren<ShieldBatteryLoader>(true); foreach (ShieldBatteryLoader owner in componentsInChildren) { AddProviderSockets(list, (Component)(object)owner); } return list; } private static void AddProviderSockets(List<CarryablesSocket> list, Component owner) { CarryablesSocketProvider val = (((Object)(object)owner != (Object)null) ? owner.GetComponent<CarryablesSocketProvider>() : null); if ((Object)(object)val == (Object)null || val.Sockets == null) { return; } foreach (CarryablesSocket socket in val.Sockets) { AddSocket(list, socket); } } private static void AddSocket(List<CarryablesSocket> list, CarryablesSocket socket) { if ((Object)(object)socket != (Object)null && !list.Contains(socket)) { list.Add(socket); } } public static bool ContentSlotAccepts(ContentSlot slot, Option item) { if (item != null && item.Kind == OptionKind.Item) { return SocketAccepts(slot.Socket, item, slot.AcceptCache, whenUnsure: false, "an item slot"); } return false; } public static string KindOf(ContentSlot slot) { if (slot.Kind != null) { return slot.Kind; } switch ((from c in (from o in ItemOptions where o.Kind == OptionKind.Item && ContentSlotAccepts(slot, o) select o.RuleCategory).ToList() group c by c into g orderby g.Count() descending select g.Key).FirstOrDefault()) { case "WEAPON MODS": slot.Kind = "MOD"; break; case "AMMO & POWER": slot.Kind = "AMMO"; break; case "SUPPORT ITEMS": slot.Kind = "POWER"; break; default: slot.Kind = "ITEM"; break; } return slot.Kind; } public static List<string> UsualContents(Option option) { //IL_0016: 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) List<string> list = new List<string>(); if (option == null || !Settings.CopyPresetModuleContents.Value || !TryGetPresetContents(option.Guid, out var entry)) { return list; } try { ShipSocketEntry val = ((JToken)entry).ToObject<ShipSocketEntry>(); if (val.Upgrades == null) { return list; } ShipAssetRef[] upgrades = val.Upgrades; foreach (ShipAssetRef val2 in upgrades) { list.Add((val2 != null && !val2.IsNull && CanSpawn(val2.AssetGuid) && IsDefaultContent(val2)) ? CodeFor(val2) : ""); } } catch (Exception ex) { Log.Verbose("Could not read the usual contents of " + option.Name + ": " + ex.Message); } return list; } private static bool? QuickMatch(CsObjectReference rule, GUIDUnion item) { //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) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Invalid comparison between Unknown and I4 //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Invalid comparison between Unknown and I4 //IL_0080: 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) if (rule == null) { return false; } if (CompareMethodField == null) { return null; } Comparison val = (Comparison)CompareMethodField.GetValue(rule); if ((int)val != 0) { if ((int)val != 2) { if ((int)val == 5) { return true; } return null; } ResourceAssetRef val2 = (ResourceAssetRef)((PrefabRuleField != null) ? /*isinst with value type is only supported in some contexts*/: null); return val2 != (ResourceAssetRef)null && !val2.IsNull && val2.AssetGuid == item; } return false; } public static Option OptionFor(ShipSocketEntry entry) { //IL_0026: 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) if (entry == null || (ResourceAssetRef)(object)entry.Module == (ResourceAssetRef)null || ((ResourceAssetRef)entry.Module).IsNull) { return null; } GUIDUnion val = WeaponGuidOf(entry.ExtraData); if (!((GUIDUnion)(ref val)).IsNull && TryGetOption("w:" + ((GUIDUnion)(ref val)).AsHex(), out var option)) { return option; } if (TryGetOption("m:" + ((GUIDUnion)(ref ((ResourceAssetRef)entry.Module).AssetGuid)).AsHex(), out option)) { return option; } return null; } public static string CodeFor(ShipAssetRef item) { //IL_0025: 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_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) if (item == null || item.AssetRef == (ResourceAssetRef)null || item.IsNull) { return ""; } GUIDUnion val = WeaponGuidOf(item.ExtraData); if (!((GUIDUnion)(ref val)).IsNull) { return "c:" + ((GUIDUnion)(ref val)).AsHex(); } GUIDUnion assetGuid = item.AssetGuid; return "i:" + ((GUIDUnion)(ref assetGuid)).AsHex(); } public static GUIDUnion WeaponGuidOf(JObject extraData) { //IL_0012: 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_0038: 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) JToken val = default(JToken); if (extraData == null || !extraData.TryGetValue("AssetGuid", ref val)) { return GUIDUnion.Empty(); } GUIDUnion val2 = default(GUIDUnion); ((GUIDUnion)(ref val2))..ctor(((object)val).ToString()); if (!((ResourceAssetContainer<CompositeWeaponDataContainer, CompositeWeaponData, CompositeWeaponDataDef>)(object)ResourceAssetContainer<CompositeWeaponDataContainer, CompositeWeaponData, CompositeWeaponDataDef>.Instance).HasItem(val2)) { return GUIDUnion.Empty(); } return val2; } public static bool TryGetPresetContents(GUIDUnion moduleOrWeapon, out JObject entry) { //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: 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_00f2: 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) if (!_presetContentsRead) { _presetContentsRead = true; HashSet<ShipLoadoutDataDef> hashSet = ListedLoadouts(); foreach (ShipLoadoutDataDef assetDescription in ((ResourceAssetContainer<ShipLoadoutDataContainer, ShipLoadoutData, ShipLoadoutDataDef>)(object)ResourceAssetContainer<ShipLoadoutDataContainer, ShipLoadoutData, ShipLoadoutDataDef>.Instance).AssetDescriptions) { try { if (!hashSet.Contains(assetDescription)) { continue; } foreach (ShipSocketEntry socket in ((ResourceAssetDef<ShipLoadoutData>)(object)assetDescription).Asset.ShipLoadout.Sockets) { if (socket != null && !((ResourceAssetRef)(object)socket.Module == (ResourceAssetRef)null) && !((ResourceAssetRef)socket.Module).IsNull) { GUIDUnion key = WeaponGuidOf(socket.ExtraData); if (((GUIDUnion)(ref key)).IsNull) { key = ((ResourceAssetRef)socket.Module).AssetGuid; } bool flag = socket.Upgrades != null && socket.Upgrades.Any((ShipAssetRef u) => u != null && !u.IsNull); if (!PresetContents.TryGetValue(key, out var value) || (flag && !HasContents(value))) { PresetContents[key] = JObject.FromObject((object)socket); } } } } catch (Exception ex) { Log.Verbose("Skipped a loadout while reading module contents: " + ex.Message); } } } return PresetContents.TryGetValue(moduleOrWeapon, out entry); } private static HashSet<ShipLoadoutDataDef> ListedLoadouts() { HashSet<ShipLoadoutDataDef> hashSet = new HashSet<ShipLoadoutDataDef>(); try { ShipLoadoutDataContainer instance = ResourceAssetContainer<ShipLoadoutDataContainer, ShipLoadoutData, ShipLoadoutDataDef>.Instance; foreach (ShipLoadoutDataDef item in instance.GetUnlockedShipDefinitionsFromHighestRankPlayer()) { hashSet.Add(item); } foreach (ShipLoadoutDataDef item2 in instance.GetLockedShipDefinitionsFromHighestRankPlayer()) { hashSet.Add(item2); } } catch (Exception ex) { Log.Warn("Could not read which loadouts the terminal lists: " + ex.Message); } return hashSet; } public static bool IsDefaultContent(ShipAssetRef item) { if (!TryGetOption(CodeFor(item), out var option)) { return false; } if (option.RuleCategory != "WEAPON MODS" && option.RuleCategory != "RELICS") { return option.RuleCategory != "SPECIAL"; } return false; } private static bool HasContents(JObject entry) { JToken obj = entry["Upgrades"]; return ((IEnumerable<JToken>)((obj is JArray) ? obj : null))?.Any(delegate(JToken u) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) if (u is JObject && u[(object)"AssetRef"] is JObject) { GUIDUnion val = new GUIDUnion(((object)((JObject)u[(object)"AssetRef"])["AssetGuid"])?.ToString()); return !((GUIDUnion)(ref val)).IsNull; } return false; }) ?? false; } public static ContextInfo ContextOf(GUIDUnion guid) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) if (((GUIDUnion)(ref guid)).IsNull) { return null; } IResourceAssetContextInfo context = ResourceAssetContainer<CloneStarObjectContainer, AbstractCloneStarObject, CloneStarObjectDef>.Instance.GetContext(guid); return (ContextInfo)(object)((context is ContextInfo) ? context : null); } public static string HeaderOf(ContextInfo context, string fallback) { try { string text = (((Object)(object)context != (Object)null) ? context.HeaderText : null); return string.IsNullOrEmpty(text) ? fallback : text; } catch { return fallback; } } private static bool IsMissing(ContextInfo context) { if ((Object)(object)context == (Object)null) { return true; } try { return (Object)(object)context == (Object)(object)DataTable<DefaultAssetTable>.Instance.MissingContextInfo; } catch { return false; } } public static RarityType RarityOf(GUIDUnion guid) { //IL_0005: 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_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_0013: Unknown result type (might be due to invalid IL or missing references) try { return ResourceAssetContainer<UnlockContainer, Object, UnlockItemDef>.Instance.GetRarity(guid); } catch { return (RarityType)0; } } private static bool TryGetSize(BuildingConstraints constraints, out BuildSize size) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected I4, but got Unknown size = (BuildSize)0; if (constraints == null) { return false; } try { size = (BuildSize)(int)BuildSizeExtensions.GetSize(constraints.Width, constraints.Height, constraints.Depth); return true; } catch { return false; } } public static string SizeName(BuildSize size) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Invalid comparison between Unknown and I4 if ((int)size != 0) { if ((int)size == 1) { return "2x1"; } return "2x2"; } return "1x1"; } } internal static class CustomLoadouts { private sealed class Entry { public HullInfo Hull; public GUIDUnion Guid; public ShipLoadoutDataDef Def; public ShipLoadoutData Data; public bool Stale = true; } private sealed class ShipPlan { public string Hull; public string Which; public ShipLoadout Loadout; public string Json; public HashSet<int> Racks; public int FabricatorLevel; public Dictionary<int, List<string>> Contents; public int Spawns; } private sealed class PendingLevel { public PlayerControlledShip Ship; public int Level; public Dictionary<int, List<string>> Contents; public string Which; public float Since = -1f; } public const string Header = "CUSTOM"; public const int MaxShips = 6; private static readonly Dictionary<GUIDUnion, Entry> ByShip = new Dictionary<GUIDUnion, Entry>(); private static readonly Dictionary<GUIDUnion, Entry> ByGuid = new Dictionary<GUIDUnion, Entry>(); private static readonly Dictionary<GUIDUnion, JObject> BaseLoadouts = new Dictionary<GUIDUnion, JObject>(); private static readonly FieldInfo HeaderTextField = AccessTools.Field(typeof(ContextInfo), "headerTextDefaultable"); private static readonly FieldInfo BodyTextField = AccessTools.Field(typeof(ContextInfo), "bodyTextDefaultable"); public static bool Available; private static readonly GUIDUnion[] ActiveShips = Enumerable.Repeat<GUIDUnion>(GUIDUnion.Empty(), 7).ToArray(); private static readonly HullConfig[] RemoteConfigs = new HullConfig[7]; public static GUIDUnion ResumeShip = GUIDUnion.Empty(); private static int _terminalShip = 1; private static bool _otherShipCustomRun; private static bool _missionIsSavedRun; private static readonly Dictionary<GUIDUnion, HullConfig>[] HostLayouts = PerShip(); private static readonly Dictionary<GUIDUnion, HullConfig>[] ConfirmedLayouts = PerShip(); private static readonly Dictionary<string, string> PartEditors = new Dictionary<string, string>(); private static readonly Dictionary<string, int> PartEditorActors = new Dictionary<string, int>(); private static readonly Dictionary<string, string> LayoutEditors = new Dictionary<string, string>(); private static readonly Dictionary<string, float> LastChangeToast = new Dictionary<string, float>(); private const int MaxContentSlots = 16; private static readonly List<ShipPlan> ShipPlans = new List<ShipPlan>(); private static readonly List<PendingLevel> PendingLevels = new List<PendingLevel>(); public static GUIDUnion ActiveShip => ActiveShips[1]; public static int TerminalShip { get { if (_terminalShip <= 1 || FleetLink.Running) { return _terminalShip; } return 1; } } public static bool IsActive { get { //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) GUIDUnion activeShip = ActiveShip; return !((GUIDUnion)(ref activeShip)).IsNull; } } private static Dictionary<GUIDUnion, HullConfig>[] PerShip() { return (from i in Enumerable.Range(0, 7) select new Dictionary<GUIDUnion, HullConfig>()).ToArray(); } public static GUIDUnion ActiveShipOf(int ship) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (!ValidShip(ship)) { return GUIDUnion.Empty(); } return ActiveShips[ship]; } public static bool ValidShip(int ship) { if (ship >= 1) { return ship <= 6; } return false; } public static void SetRemoteChoice(int ship, GUIDUnion hullGuid, HullConfig config) { //IL_000f: 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) if (ValidShip(ship)) { ActiveShips[ship] = hullGuid; RemoteConfigs[ship] = config; } } public static bool IsCustom(ShipLoadoutDataDef def) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) if (def != null) { return ByGuid.ContainsKey(((ResourceAssetDef<ShipLoadoutData>)(object)def).AssetGuid); } return false; } public static bool TryGetHullOfCustomGuid(GUIDUnion guid, out HullInfo hull) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) hull = (ByGuid.TryGetValue(guid, out var value) ? value.Hull : null); return hull != null; } public static bool TryGetDefOfCustomGuid(GUIDUnion guid, out ShipLoadoutDataDef def) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: 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_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) def = null; if (ByGuid.TryGetValue(guid, out var value)) { def = value.Def; return true; } if (!Available || ((GUIDUnion)(ref guid)).IsNull) { return false; } GUIDUnion val = CustomGuidFor(guid); if (!Catalog.ShipGuids().Contains(val)) { return false; } if (TryGetDef(val, out def)) { return ((ResourceAssetDef<ShipLoadoutData>)(object)def).AssetGuid == guid; } return false; } public static bool TryGetHull(ShipLoadoutDataDef customDef, out HullInfo hull) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) hull = null; if (customDef != null) { return TryGetHullOfCustomGuid(((ResourceAssetDef<ShipLoadoutData>)(object)customDef).AssetGuid, out hull); } return false; } public static bool TryGetDef(GUIDUnion shipGuid, out ShipLoadoutDataDef def) { //IL_001a: 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_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) def = null; if (!Available || ((GUIDUnion)(ref shipGuid)).IsNull) { return false; } if (!ByShip.TryGetValue(shipGuid, out var value)) { if (!Catalog.TryGetHull(shipGuid, out var hull)) { return false; } try { value = Create(hull); } catch (Exception ex) { Log.Error("Could not create the CUSTOM loadout for the " + hull.Name + ": " + ex); return false; } ByShip[shipGuid] = value; ByGuid[value.Guid] = value; } def = value.Def; return true; } private static Entry Create(HullInfo hull) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Expected O, but got Unknown //IL_00d8: 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_005f: Unknown result type (might be due to invalid IL or missing references) GUIDUnion val = CustomGuidFor(hull.ShipGuid); ShipLoadoutData val2 = ScriptableObject.CreateInstance<ShipLoadoutData>(); ((Object)val2).name = "ShipCustomizer " + hull.Name; ((Object)val2).hideFlags = (HideFlags)32; ((SelfReferencingScriptableObject)val2).ContainerGuid = val; val2.ShipLoadout = ((ResourceAssetDef<ShipLoadoutData>)(object)hull.BasePreset).Asset.ShipLoadout; if (!RuntimeAssetsRegister.Instance.HasAsset(val)) { RuntimeAssetsRegister.Instance.RegisterAsset(val, (Object)(object)val2, (SessionModificationEffect)0, (RuntimeAssetInfo)null); } ShipLoadoutDataDef val3 = new ShipLoadoutDataDef(val, ""); ((ResourceAssetDef<ShipLoadoutData>)(object)val3).Ref.IsRuntime = true; val3.LoadoutContextInfo = MakeContext(hull); Log.Info("Added a CUSTOM loadout for the " + hull.Name + " (shown to other players as " + LoadoutStore.PresetName(hull.BasePreset) + ")."); return new Entry { Hull = hull, Guid = val, Def = val3, Data = val2 }; } public static bool LooksCustom(GUIDUnion guid) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) if (((GUIDUnion)(ref guid)).IsNull) { return false; } try { return Catalog.ShipGuids().Contains(CustomGuidFor(guid)); } catch { return false; } } private static GUIDUnion CustomGuidFor(GUIDUnion ship) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000c: 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_0024: 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) return new GUIDUnion(ship.m_Value0 ^ 0x50494853, ship.m_Value1 ^ 0x54535543, ship.m_Value2 ^ 0x5A494D4F, ship.m_Value3 ^ 0x21215245); } private static ShipLoadoutContextInfo MakeContext(HullInfo hull) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Expected O, but got Unknown //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Expected O, but got Unknown ShipLoadoutContextInfo val = Object.Instantiate<ShipLoadoutContextInfo>(hull.BasePreset.LoadoutContextInfo); ((Object)val).name = "ShipCustomizer CUSTOM " + hull.Name; ((Object)val).hideFlags = (HideFlags)32; if (HeaderTextField != null) { HeaderTextField.SetValue(val, (object?)new DefaultableLocalizedString("CUSTOM", (LocalizedString)null)); } if (BodyTextField != null) { BodyTextField.SetValue(val, (object?)new DefaultableLocalizedString("<b>Custom Loadout</b>", (LocalizedString)null)); } return val; } private static string Description(HullInfo hull, HullConfig config) { List<string> list = new List<string> { PowerLine(hull, config) }; if (config.Alloys >= 0) { list.Add(config.Alloys + " alloys"); } if (config.FabricatorLevel > 0) { list.Add("fabricator " + FabricatorLevelName(config.FabricatorLevel)); } return "<b>Custom Loadout</b>\n<i>Click a hardpoint on the ship, or use HARDPOINTS, to fit any module or weapon.</i>\n" + string.Join(" · ", list.ToArray()) + "\nMissions flown with it are marked modded and earn no XP or rewards."; } public static string PowerLine(HullInfo hull, HullConfig config) { int num = 0; int num2 = hull.BasePower; foreach (string value in config.Slots.Values) { if (Catalog.TryGetOption(value, out var option)) { num += option.PowerUse; num2 += option.PowerMade; } } string text = "Power: " + num + " of " + num2 + " made"; if (num <= num2) { return text; } return text + " (not everything can be on at once)"; } public static HullConfig ConfigToShow(HullInfo hull) { int terminalShip = TerminalShip; if (!PhotonNetwork.IsMasterClient) { HullConfig hullConfig = HostLayout(hull, terminalShip); if (hullConfig != null) { return hullConfig; } HullConfig hullConfig2 = RemoteConfigs[terminalShip]; if (hullConfig2 != null && RoomUses(hull)) { return hullConfig2; } if (RoomSync.HostSharesLayouts()) { return LoadoutStore.Default(hull); } } return LoadoutStore.Get(hull, terminalShip); } public static bool CanEdit(HullInfo hull) { if (!TeamMayEdit() || !HostKnowsTerminalShip() || WaitingForHost(hull)) { return false; } if (!PhotonNetwork.IsMasterClient && !EditsGoToHost(hull) && RemoteConfigs[TerminalShip] != null) { return !RoomUses(hull); } return true; } public static bool WaitingForHost(HullInfo hull) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) if (!PhotonNetwork.IsMasterClient && RoomSync.HostSharesLayouts()) { return !HostLayouts[1].ContainsKey(hull.ShipGuid); } return false; } public static bool TeamMayEdit() { Player localPlayer = PhotonNetwork.LocalPlayer; if (localPlayer != null) { return FleetLink.CanEditShip(localPlayer.ActorNumber, TerminalShip); } return true; } private static bool HostKnowsTerminalShip() { if (TerminalShip >= 3 && PhotonNetwork.InRoom) { return RoomSync.HostKnowsManyShips(); } return true; } public static string WhyNotEditable() { if (!TeamMayEdit()) { string text = FleetLink.TeamNameOfShip(TerminalShip); if (text == null) { return "Only this ship's team can change it."; } return "This is the " + text + " team's ship: only its players can change it."; } if (!HostKnowsTerminalShip()) { return "The host's Ship Customizer is older than 0.9.0, so ships 3 to 6 can't use CUSTOM."; } if (RoomSync.HostSharesLayouts()) { return "The host's CUSTOM loadout of this ship is still on its way. Try again in a moment."; } return "This is the host's CUSTOM loadout, and the host's Ship Customizer is older than 0.5.0, so only the host can change it."; } public static bool EditsGoToHost(HullInfo hull) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) if (!PhotonNetwork.IsMasterClient && HostLayouts[1].ContainsKey(hull.ShipGuid)) { return RoomSync.HostSharesLayouts(); } return false; } public static HullConfig HostLayout(HullInfo hull, int ship) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) if (!ValidShip(ship)) { return null; } if (ship >= 2 && HostLayouts[ship].TryGetValue(hull.ShipGuid, out var value)) { return value; } if (!HostLayouts[1].TryGetValue(hull.ShipGuid, out value)) { return null; } if (ship < 2 || !FleetLink.IsTeamMatch) { return value; } return LoadoutStore.Default(hull); } public static HullConfig LayoutOf(HullInfo hull, int ship) { if (!EditsGoToHost(hull)) { return LoadoutStore.Get(hull, ship); } return HostLayout(hull, ship); } public static bool FollowsShip1(HullInfo hull, int ship) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) if (ship < 2 || !ValidShip(ship)) { return false; } if (!EditsGoToHost(hull)) { return !LoadoutStore.HasOwn(hull, ship); } return !HostLayouts[ship].ContainsKey(hull.ShipGuid); } public static void SetConfirmedLayout(int ship, GUIDUnion hullGuid, HullConfig config) { //IL_0022: 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 (ValidShip(ship)) { if (config == null) { ConfirmedLayouts[ship].Remove(hullGuid); } else { ConfirmedLayouts[ship][hullGuid] = Normalize(config.Clone()); } } } private static HullConfig ConfirmedLayout(HullInfo hull, int ship) { //IL_000c: 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) if (ship >= 2 && ConfirmedLayouts[ship].TryGetValue(hull.ShipGuid, out var value)) { return value; } if (ship >= 2 && FleetLink.IsTeamMatch) { return LoadoutStore.Default(hull); } if (ConfirmedLayouts[1].TryGetValue(hull.ShipGuid, out value)) { return value; } return HostLayout(hull, ship); } public static void SetHostLayout(int ship, GUIDUnion hullGuid, HullConfig config) { //IL_0023: 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_0034: 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) if (ValidShip(ship)) { if (config == null) { HostLayouts[ship].Remove(hullGuid); } else { HostLayouts[ship][hullGuid] = Normalize(config); } if (ByShip.ContainsKey(hullGuid) && Catalog.TryGetHull(hullGuid, out var hull)) { Refresh(hull); } } } public static void ForgetHostLayouts() { Dictionary<GUIDUnion, HullConfig>[] hostLayouts = HostLayouts; for (int i = 0; i < hostLayouts.Length; i++) { hostLayouts[i].Clear(); } hostLayouts = ConfirmedLayouts; for (int i = 0; i < hostLayouts.Length; i++) { hostLayouts[i].Clear(); } LayoutEditors.Clear(); RefreshAll(); } public static bool SendEditToHost(HullInfo hull, int ship, HullConfig config, bool followShip1) { //IL_004b: 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) if (!ValidShip(ship)) { return false; } if (!RoomSync.SendEdit(hull, ship, config, followShip1, ConfirmedLayout(hull, ship)?.Clone())) { return false; } if (followShip1) { HostLayouts[ship].Remove(hull.ShipGuid); } else { HostLayouts[ship][hull.ShipGuid] = config; } Refresh(hull); return true; } public static void ApplyEditAsHost(string who, int actor, RoomSync.RoomEdit edit) { //IL_006e: 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) if (edit == null || string.IsNullOrEmpty(edit.Hull) || !ValidShip(edit.Ship) || (edit.Ship >= 2 && !FleetLink.Running)) { return; } GUIDUnion val = default(GUIDUnion); ((GUIDUnion)(ref val))..ctor(edit.Hull); if (!Catalog.ShipGuids().Contains(val) || !Catalog.TryGetHull(val, out var hull)) { return; } if (edit.FollowShip1) { if (edit.Ship < 2) { return; } FollowShip1AsHost(hull, edit.Ship); } List<string> list = null; if (!edit.FollowShip1) { if (edit.Config == null) { return; } HullConfig hullConfig = Sanitize(hull, edit.Config); HullConfig forEdit = LoadoutStore.GetForEdit(hull, edit.Ship); List<string> list2 = new List<string>(); List<string> list3 = new List<string>(); HullConfig hullConfig2; if (edit.Base != null) { hullConfig2 = LayoutMerge.Merge(forEdit, edit.Base, edit.Config, hullConfig, hull.Sockets, RackSlots(hull), (string part) => LastEditorActor(hull, edit.Ship, part) == actor, list2, list3); } else { list2.AddRange(LayoutMerge.Changed(forEdit, hullConfig, hull.Sockets, RackSlots(hull))); hullConfig2 = hullConfig; } Dictionary<string, string> reasons = list3.ToDictionary((string p) => p, (string p) => EditorOf(hull, edit.Ship, p)); List<KeyValuePair<string, string>> list4 = DoubledSingles(hull, hullConfig2, list2); while (list4.Count > 0) { foreach (KeyValuePair<string, string> item in list4) { LayoutMerge.Copy(forEdit, hullConfig2, hull.Sockets, item.Key); list2.Remove(item.Key); list3.Add(item.Key); reasons[item.Key] = "one " + item.Value + " per ship"; } list4 = DoubledSingles(hull, hullConfig2, list2); } list = list3.Select((string p) => PartName(hull, p) + " (" + reasons[p] + ")").ToList(); if (list3.Count > 0) { Log.Info("Kept what others changed first, instead of " + who + "'s change: " + string.Join(", ", list.ToArray()) + "."); } if (list2.Count == 0) { OnEdited(hull, actor, edit.N, edit.Ship, list); return; } LoadoutStore.Set(hull, hullConfig2, edit.Ship); NoteEditors(hull, edit.Ship, list2, who, actor); } OnEdited(hull, actor, edit.N, edit.Ship, list); TerminalUi.OnLoadoutChangedRemotely(); string text = Whose(edit.Ship) + "CUSTOM " + hull.Name; Log.Info(who + " changed " + text + "."); ToastChange(who, text); } public static string Whose(int ship) { if (ship >= 2 || FleetLink.IsTeamMatch) { return FleetLink.ShipName(ship) + "'s "; } return ""; } public static void RefuseEditAsHost(int actor, RoomSync.RoomEdit edit, string why) { //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) if (edit != null && !string.IsNullOrEmpty(edit.Hull) && ValidShip(edit.Ship)) { GUIDUnion val = default(GUIDUnion); ((GUIDUnion)(ref val))..ctor(edit.Hull); if (Catalog.ShipGuids().Contains(val) && Catalog.TryGetHull(val, out var hull)) { RoomSync.PublishLayouts(hull, actor, edit.N, edit.Ship, new List<string> { "your change, because " + why }); } } } public static Dictionary<int, int> RackSlots(HullInfo hull) { return hull.Shelves.ToDictionary((ShelfInfo s) => s.CoreIndex, (ShelfInfo s) => s.Slots.Count); } private static void NoteEditors(HullInfo hull, int ship, IEnumerable<string> parts, string who, int actor) { foreach (string part in parts) { string key = ((GUIDUnion)(ref hull.ShipGuid)).AsHex() + "/" + ship + "/" + part; PartEditors[key] = who; PartEditorActors[key] = actor; } } private static string EditorOf(HullInfo hull, int ship, string part) { if (!PartEditors.TryGetValue(((GUIDUnion)(ref hull.ShipGuid)).AsHex() + "/" + ship + "/" + part, out var value)) { return "someone"; } return value; } public static void FollowShip1AsHost(HullInfo hull, int ship) { LoadoutStore.Forget(hull, ship); string prefix = ((GUIDUnion)(ref hull.ShipGuid)).AsHex() + "/" + ship + "/"; foreach (string item in PartEditors.Keys.Where((string k) => k.StartsWith(prefix, StringComparison.Ordinal)).ToList()) { PartEditors.Remove(item); } foreach (string item2 in PartEditorActors.Keys.Where((string k) => k.StartsWith(prefix, StringComparison.Ordinal)).ToList()) { PartEditorActors.Remove(item2); } } private static int LastEditorActor(HullInfo hull, int ship, string part) { if (!PartEditorActors.TryGetValue(((GUIDUnion)(ref hull.ShipGuid)).AsHex() + "/" + ship + "/" + part, out var value)) { return -1; } return value; } private static List<KeyValuePair<string, string>> DoubledSingles(HullInfo hull, HullConfig result, ICollection<string> applied) { List<KeyValuePair<string, string>> list = new List<KeyValuePair<string, string>>(); Dictionary<Type, List<string>> dictionary = new Dictionary<Type, List<string>>(); Dictionary<Type, string> dictionary2 = new Dictionary<Type, string>(); foreach (KeyValuePair<int, string> slot in result.Slots) { if (slot.Key >= 0 && slot.Key < hull.Sockets.Count && Catalog.TryGetHardpointOption(slot.Value, out var option) && option.SingleInstance && !(option.ModuleType == null)) { if (!dictionary.TryGetValue(option.ModuleType, out var value)) { value = (dictionary[option.ModuleType] = new List<string>()); } string item = LayoutMerge.HardpointPart(hull.Sockets[slot.Key].Group); if (!value.Contains(item)) { value.Add(item); } dictionary2[option.ModuleType] = RichText.Plain(option.Name); } } foreach (KeyValuePair<Type, List<string>> item2 in dictionary.Where((KeyValuePair<Type, List<string>> t) => t.Value.Count > 1)) { List<string> list3 = item2.Value.Where(applied.Contains).ToList(); IEnumerable<string> enumerable; if (list3.Count >= item2.Value.Count) { enumerable = list3.Skip(1); } else { IEnumerable<string> enumerable2 = list3; enumerable = enumerable2; } foreach (string item3 in enumerable) { list.Add(new KeyValuePair<string, string>(item3, dictionary2[item2.Key])); } } return list; } public static void NoteHostChange(HullInfo hull, int ship, HullConfig before, HullConfig after) { if (before != null && after != null) { Player localPlayer = PhotonNetwork.LocalPlayer; string who = ((localPlayer != null && !string.IsNullOrEmpty(localPlayer.NickName)) ? localPlayer.NickName : "the host"); NoteEditors(hull, ship, LayoutMerge.Changed(before, after, hull.Sockets, RackSlots(hull)), who, (localPlayer != null) ? localPlayer.ActorNumber : 0); } } public static string LastEditorOf(HullInfo hull, string part) { if (PhotonNetwork.IsMasterClient) { return EditorOf(hull, TerminalShip, part); } if (!LayoutEditors.TryGetValue(((GUIDUnion)(ref hull.ShipGuid)).AsHex() + "/" + TerminalShip, out var value)) { return "someone"; } return value; } public static void OnChangedByOther(string who, int ship, GUIDUnion hullGuid) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) LayoutEditors[((GUIDUnion)(ref hullGuid)).AsHex() + "/" + ship] = who; if (Catalog.TryGetHull(hullGuid, out var hull)) { ToastChange(who, Whose(ship) + "CUSTOM " + hull.Name); } } private static void ToastChange(string who, string what) { if (!LastChangeToast.TryGetValue(who, out var value) || !(Time.unscaledTime - value <= 8f)) { LastChangeToast[who] = Time.unscaledTime; TerminalUi.ShowToast(who + " changed " + what + "."); } } public static string PartName(HullInfo hull, string part) { switch (part) { case "homunculus": return "the homunculus"; case "alloys": return "the starting alloys"; case "fabricator": return "the fabricator level"; default: if (part.StartsWith("hp:")) { return "HARDPOINT " + (int.Parse(part.Substring(3)) + 1); } if (part.StartsWith("rack:")) { string[] array = part.Split(new char[1] { ':' }); int rack = int.Parse(array[1]); ShelfInfo shelfInfo = hull.Shelves.FirstOrDefault((ShelfInfo s) => s.CoreIndex == rack); return ((shelfInfo != null) ? shelfInfo.Name : "a storage rack") + " slot " + (int.Parse(array[2]) + 1); } return part; } } public static HullConfig Sanitize(HullInfo hull, HullConfig config) { return CheckCodes(hull, Shape(hull, config)); } internal static HullConfig Shape(HullInfo hull, HullConfig config) { HullConfig hullConfig = new HullConfig { CopiedFrom = ((config.CopiedFrom != null && config.CopiedFrom.Length <= 100) ? config.CopiedFrom : ""), Homunculus = Code(config.Homunculus), Alloys = config.Alloys, FabricatorLevel = config.FabricatorLevel }; if (config.Slots != null) { foreach (KeyValuePair<int, string> slot in config.Slots) { if (slot.Key >= 0 && slot.Key < hull.Sockets.Count && Code(slot.Value).Length > 0) { hullConfig.Slots[slot.Key] = slot.Value; } } } if (config.Storage != null) { foreach (ShelfInfo shelf in hull.Shelves) { if (config.Storage.TryGetValue(shelf.CoreIndex, out var value) && value != null) { hullConfig.Storage[shelf.CoreIndex] = value.Take(shelf.Slots.Count).Select(Code).ToList(); } } } if (config.Contents != null) { foreach (KeyValuePair<int, List<string>> content in config.Contents) { if (content.Value != null && hullConfig.Slots.ContainsKey(content.Key)) { hullConfig.Contents[content.Key] = content.Value.Take(16).Select(Code).ToList(); } } } return hullConfig.Normalized(); } private static HullConfig CheckCodes(HullInfo hull, HullConfig shaped) { //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) HullConfig hullConfig = new HullConfig { CopiedFrom = shaped.CopiedFrom, Homunculus = ((shaped.Homunculus.Length > 0 && Catalog.IsHomunculus(shaped.Homunculus)) ? shaped.Homunculus : ""), Alloys = shaped.Alloys, FabricatorLevel = shaped.FabricatorLevel }; HashSet<Type> hashSet = new HashSet<Type>(); foreach (KeyValuePair<int, string> slot in shaped.Slots) { if (Catalog.TryGetHardpointOption(slot.Value, out var option)) { SocketInfo socketInfo = hull.Sockets[slot.Key]; if ((Settings.AllowAnySize.Value || option.Size == socketInfo.Size) && !socketInfo.Overlaps.Any(hullConfig.Slots.ContainsKey) && (!option.SingleInstance || !(option.ModuleType != null) || hashSet.Add(option.ModuleType))) { hullConfig.Slots[slot.Key] = option.Code; } } } foreach (ShelfInfo shelf in hull.Shelves) { if (shaped.Storage.TryGetValue(shelf.CoreIndex, out var value)) { hullConfig.Storage[shelf.CoreIndex] = value.Select((string code) => RackCode(shelf, code)).ToList(); } } foreach (KeyValuePair<int, List<string>> content in shaped.Contents) { if (!hullConfig.Slots.TryGetValue(content.Key, out var value2) || !Catalog.TryGetHardpointOption(value2, out var option2)) { continue; } List<ContentSlot> slots = Catalog.ContentSlotsOf(option2); if (slots.Count != 0) { hullConfig.Contents[content.Key] = content.Value.Take(slots.Count).Select((string c, int j) => ContentCode(slots[j], c)).ToList(); } } return hullConfig.Normalized(); } private static string ContentCode(ContentSlot slot, string code) { if (code.Length == 0 || !Catalog.TryGetRackOption(code, out var option) || !Catalog.ContentSlotAccepts(slot, option)) { return ""; } return option.Code; } private static string RackCode(ShelfInfo shelf, string code) { if (code.Length == 0 || !Catalog.TryGetRackOption(code, out var option)) { return ""; } if (!Settings.AnyItemOnAnyRack.Value && !Catalog.ShelfAccepts(shelf, option)) { return ""; } return option.Code; } private static string Code(string code) { if (code == null || code.Length > 80) { return ""; } return code; } private static HullConfig Normalize(HullConfig config) { return config.Normalized(); } public static bool RoomUses(HullInfo hull) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) return ActiveShips[TerminalShip] == hull.ShipGuid; } public static ShipLoadoutDataDef RoomChoice(int ship) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) if (ship <= 1) { HubShipManager instance = HubShipManager.Instance; if (!((Object)(object)instance != (Object)null)) { return null; } return instance.CurrentShipSelected; } if (!ValidShip(ship) || ((GUIDUnion)(ref ActiveShips[ship])).IsNull || !TryGetDef(ActiveShips[ship], out var def)) { return null; } return def; } public static bool IsStandInFor(ShipLoadoutDataDef shown, ShipLoadoutDataDef custom) { //IL_0016: 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) if (shown != null && TryGetHull(custom, out var hull) && hull.BasePreset != null) { return ((ResourceAssetDef<ShipLoadoutData>)(object)shown).AssetGuid == ((ResourceAssetDef<ShipLoadoutData>)(object)hull.BasePreset).AssetGuid; } return false; } public static void SetTerminalShip(int ship) { TerminalUi.ExpectChoiceShown(); if (!ValidShip(ship)) { ship = 1; } if (ship >= 2 && !FleetLink.Running) { Log.WarnOnce("ship " + ship + " without fleet", "Ignored a request to set up ship " + ship + ": Void Crew Fleet isn't running here and on the host."); ship = 1; } if (_terminalShip != ship) { _terminalShip = ship; RefreshAll(); TerminalUi.OnTerminalShipChanged(); } } public static void ResetTerminalShip() { if (_terminalShip != 1) { _terminalShip = 1; RefreshAll(); } } public static void OnFleetRunningChanged(bool running) { if (!running) { _terminalShip = 1; } RefreshAll(); TerminalUi.OnTerminalShipChanged(); } public static void OnShipsChanged() { bool num = _terminalShip > FleetLink.ShipCount; if (num) { _terminalShip = 1; } RefreshAll(); if (num) { TerminalUi.OnTerminalShipChanged(); } else { TerminalUi.OnLoadoutChangedRemotely(); } } public static string HullName(GUIDUnion shipGuid) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) if (((GUIDUnion)(ref shipGuid)).IsNull || !Catalog.ShipGuids().Contains(shipGuid) || !Catalog.TryGetHull(shipGuid, out var hull)) { return "different ship"; } return hull.Name; } public static string WrongType(int ship, HullInfo hull) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) GUIDUnion val = FleetLink.HullOfShip(ship); if (((GUIDUnion)(ref val)).IsNull || val == hull.ShipGuid) { return null; } return FleetLink.ShipName(ship) + " must be a " + HullName(val) + " in this match, so it can't use the CUSTOM " + hull.Name + "."; } public static void Refresh(HullInfo hull) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) if (ByShip.TryGetValue(hull.ShipGuid, out var value)) { value.Stale = true; } } public static void RefreshAll() { foreach (Entry value in ByShip.Values) { value.Stale = true; } } public static void EnsureBuilt(ShipLoadoutDataDef def) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown if (def == null || !ByGuid.TryGetValue(((ResourceAssetDef<ShipLoadoutData>)(object)def).AssetGuid, out var value) || !value.Stale) { return; } HullInfo hull = value.Hull; try { HullConfig config = ConfigToShow(hull); value.Data.ShipLoadout = Build(hull, config); if (BodyTextField != null) { BodyTextField.SetValue(value.Def.LoadoutContextInfo, (object?)new DefaultableLocalizedString(Description(hull, config), (LocalizedString)null)); } value.Stale = false; } catch (Exception e) { Log.Failure("Building the CUSTOM loadout of the " + hull.Name, e); } } public unsafe static ShipLoadout Build(HullInfo hull, HullConfig config) { //IL_0006: 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_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_032f: Unknown result type (might be due to invalid IL or missing references) //IL_033e: Unknown result type (might be due to invalid IL or missing references) //IL_0343: Unknown result type (might be due to invalid IL or missing references) //IL_0355: Unknown result type (might be due to invalid IL or missing references) //IL_035d: Unknown result type (might be due to invalid IL or missing references) //IL_0363: Unknown result type (might be due to invalid IL or missing references) //IL_036d: Expected O, but got Unknown //IL_0368: Unknown result type (might be due to invalid IL or missing references) //IL_0372: Expected O, but got Unknown //IL_0372: 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_037d: Expected O, but got Unknown //IL_037d: Unknown result type (might be due to invalid IL or missing references) //IL_038b: Expected O, but got Unknown //IL_0413: Unknown result type (might be due to invalid IL or missing references) //IL_041d: Expected O, but got Unknown //IL_043b: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_0449: Unknown result type (might be due to invalid IL or missing references) //IL_0458: Unknown result type (might be due to invalid IL or missing references) //IL_045d: Unknown result type (might be due to invalid IL or missing references) //IL_0467: Expected O, but got Unknown if (!BaseLoadouts.TryGetValue(hull.ShipGuid, out var value)) { value = ((ResourceAssetDef<ShipLoadoutData>)(object)hull.BasePreset).Asset.ShipLoadout.AsJObject(); BaseLoadouts[hull.ShipGuid] = value; } ShipLoadout val = ShipLoadout.FromJObject(value); val.Sockets = new List<ShipSocketEntry>(); HashSet<int> hashSet = new HashSet<int>(); HashSet<Type> hashSet2 = new HashSet<Type>(); foreach (KeyValuePair<int, string> slot in config.Slots) { if (slot.Key < 0 || slot.Key >= hull.Sockets.Count) { continue; } Option option; if (hull.Sockets[slot.Key].Overlaps.Any(hashSet.Contains)) { GUIDUnion shipGuid = hull.ShipGuid; Log.WarnOnce("overlap " + ((object)(*(GUIDUnion*)(&shipGuid))/*cast due to .constrained prefix*/).ToString() + slot.Key, "Hardpoint position " + slot.Key + " of the " + hull.Name + " overlaps a module that is already fitted, so it is left empty."); } else if (!Catalog.TryGetHardpointOption(slot.Value, out option) || !Catalog.CanSpawn(option.PrefabGuid)) { Log.WarnOnce("unknown " + slot.Value, "The CUSTOM " + hull.Name + " has a module the game no longer has (" + slot.Value + "); that hardpoint is left empty."); } else if (option.SingleInstance && option.ModuleType != null && !hashSet2.Add(option.ModuleType)) { GUIDUnion shipGuid = hull.ShipGuid; Log.WarnOnce("single " + ((object)(*(GUIDUnion*)(&shipGuid))/*cast due to .constrained prefix*/).ToString() + slot.Key, "The CUSTOM " + hull.Name + " has a second " + RichText.Plain(option.Name) + " (one per ship), so hardpoint position " + slot.Key + " is left empty."); } else { ShipSoc