Please disclose if your mod was created primarily using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of ItemWeights v1.2.1
DarthLilo.ItemWeights.dll
Decompiled 2 years agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using ItemWeights.Helpers; using LethalCompanyInputUtils.Api; using LethalConfig; using LethalConfig.ConfigItems; using Microsoft.CodeAnalysis; using Unity.Mathematics; using UnityEngine; using UnityEngine.InputSystem; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("DarthLilo.ItemWeights")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.2.1.0")] [assembly: AssemblyInformationalVersion("1.2.1+7762e7a9e06079e03f1748f85d2fa7402872ce06")] [assembly: AssemblyProduct("ItemWeights")] [assembly: AssemblyTitle("DarthLilo.ItemWeights")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.2.1.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace ItemWeights { [BepInPlugin("DarthLilo.ItemWeights", "ItemWeights", "1.2.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class ItemWeights : BaseUnityPlugin { public static ConfigFile Config_Data; public static bool logTerminalNodes; internal static ItemWeightsKeybindHelper InputActionsInstance; public static ItemWeights Instance { get; private set; } internal static ManualLogSource Logger { get; private set; } internal static Harmony? Harmony { get; set; } private void Awake() { Logger = ((BaseUnityPlugin)this).Logger; Instance = this; Config_Data = ((BaseUnityPlugin)this).Config; ItemWeightsConfigHelper.SetLethalConfig(Config_Data); InputActionsInstance = new ItemWeightsKeybindHelper(); logTerminalNodes = ItemWeightsConfigHelper.LogTerminalNodes.Value; ItemWeightsCallbacks.StartKeybindCallbacks(); Patch(); Logger.LogInfo((object)"DarthLilo.ItemWeights v1.2.1 has loaded!"); } internal static void Patch() { //IL_000d: 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_0018: Expected O, but got Unknown if (Harmony == null) { Harmony = new Harmony("DarthLilo.ItemWeights"); } Logger.LogDebug((object)"Patching..."); Harmony.PatchAll(); Logger.LogDebug((object)"Finished patching!"); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "DarthLilo.ItemWeights"; public const string PLUGIN_NAME = "ItemWeights"; public const string PLUGIN_VERSION = "1.2.1"; } } namespace ItemWeights.Patches { [HarmonyPatch(typeof(GrabbableObject))] public class GrabbableObject_patches { [HarmonyPatch("Start")] [HarmonyPostfix] public static void ChangeItemData(GrabbableObject __instance) { ItemPatch.UpdateItemWeight(__instance); } } public class ItemPatch { public static Dictionary<string, float> WeightsDict() { Dictionary<string, float> dictionary = new Dictionary<string, float>(); string value = ItemWeightsConfigHelper.Weights.Value; List<string> list = value.Split(',').ToList(); foreach (string item in list) { if (!(item == "")) { string[] array = item.Split(':'); string key = array[0]; string s = array[1]; dictionary[key] = float.Parse(s); } } return dictionary; } public static Dictionary<string, List<int>> SellPricesDict() { Dictionary<string, List<int>> dictionary = new Dictionary<string, List<int>>(); string value = ItemWeightsConfigHelper.SellPrices.Value; List<string> list = value.Split(',').ToList(); foreach (string item in list) { if (!(item == "")) { string[] array = item.Split(':'); string[] array2 = array[1].Split("-"); string key = array[0]; List<int> list2 = new List<int>(); list2.Add(int.Parse(array2[0])); list2.Add(int.Parse(array2[1])); dictionary[key] = list2; } } return dictionary; } public static void UpdateItemWeight(GrabbableObject item) { string name = ((Object)item.itemProperties).name; Dictionary<string, float> dictionary = WeightsDict(); if ((Object)(object)item == (Object)null) { ItemWeights.Logger.LogInfo((object)(name + " is null, skipping!")); } else if (dictionary.ContainsKey(name)) { float num = dictionary[name] / 100f + 1f; ItemWeights.Logger.LogInfo((object)$"Updating weights for [{name}] to [{num}]"); item.itemProperties.weight = num; } } public static void UpdateItemPrice(Item item) { string name = ((Object)item).name; Dictionary<string, List<int>> dictionary = SellPricesDict(); if ((Object)(object)item == (Object)null) { ItemWeights.Logger.LogInfo((object)(name + " is null, skipping!")); } else if (dictionary.ContainsKey(name)) { int num = (int)Math.Round((double)dictionary[name][0] * 2.5); int num2 = (int)Math.Round((double)dictionary[name][1] * 2.5); ItemWeights.Logger.LogInfo((object)$"Updating sell prices for [{name}] to [{num} - {num2}]"); item.minValue = num; item.maxValue = num2; } } } [HarmonyPatch(typeof(RoundManager))] public class RoundManagerPatch { [HarmonyPatch("SpawnScrapInLevel")] [HarmonyPrefix] public static void SpawnScrapInLevelPatch(RoundManager __instance) { if (__instance == null) { ItemWeights.Logger.LogWarning((object)"RoundManager __instance is null, cancelling!"); return; } foreach (SpawnableItemWithRarity item in __instance.currentLevel.spawnableScrap) { ItemPatch.UpdateItemPrice(item.spawnableItem); } } } [HarmonyPatch(typeof(Terminal))] public class TerminalPatch { public static List<string> removedShopItems = new List<string>(); public static Dictionary<string, int> shipDecorItems = new Dictionary<string, int>(); public static Dictionary<string, int> shipDecorItems2 = new Dictionary<string, int>(); public static Dictionary<string, string> shipDecorConfirms = new Dictionary<string, string>(); public static int newSignalTranslatorPrice = 255; public static Dictionary<string, int> PriceDict() { Dictionary<string, int> dictionary = new Dictionary<string, int>(); string value = ItemWeightsConfigHelper.TerminalPrices.Value; List<string> list = value.Split(",").ToList(); foreach (string item in list) { if (!(item == "")) { string[] array = item.Split(":"); string key = array[0]; int value2 = int.Parse(array[1]); dictionary[key] = value2; } } return dictionary; } public static Dictionary<string, string> TerminalKeywordsDict() { Dictionary<string, string> dictionary = new Dictionary<string, string>(); string value = ItemWeightsConfigHelper.TerminalKeywords.Value; List<string> list = value.Split(",").ToList(); foreach (string item in list) { if (!(item == "")) { string[] array = item.Split(":"); string key = array[0]; string value2 = array[1]; dictionary[key] = value2; } } return dictionary; } public static Dictionary<string, string> TerminalKeywordsConfirmDict() { Dictionary<string, string> dictionary = new Dictionary<string, string>(); string value = ItemWeightsConfigHelper.TerminalKeywordsConfirm.Value; List<string> list = value.Split(",").ToList(); foreach (string item in list) { if (!(item == "")) { string[] array = item.Split(":"); string key = array[0]; string value2 = array[1]; dictionary[key] = value2; } } return dictionary; } [HarmonyPatch("Start")] [HarmonyPrefix] public static void UpdateTerminalPrices(Terminal __instance) { ItemWeights.Config_Data.Reload(); Dictionary<string, int> dictionary = PriceDict(); Dictionary<string, string> dictionary2 = TerminalKeywordsDict(); Dictionary<string, string> dictionary3 = TerminalKeywordsConfirmDict(); List<Item> list = new List<Item>(); int num = 0; Item[] buyableItemsList = __instance.buyableItemsList; foreach (Item val in buyableItemsList) { Item val2 = __instance.buyableItemsList[num]; if (dictionary.ContainsKey(((Object)val2).name)) { int num2 = dictionary[((Object)val2).name]; if (num2 <= -1) { if (dictionary2.ContainsKey(((Object)val2).name)) { removedShopItems.Add(dictionary2[((Object)val2).name]); num++; continue; } } else { val2.creditsWorth = num2; } } if (((Object)val2).name == "SignalTranslatorBuy") { newSignalTranslatorPrice = val2.creditsWorth; } list.Add(val2); num++; } __instance.buyableItemsList = list.ToArray(); int num3 = 0; foreach (TerminalNode item in __instance.ShipDecorSelection) { TerminalNode val3 = __instance.ShipDecorSelection[num3]; if (dictionary.ContainsKey(((Object)val3).name)) { int num4 = dictionary[((Object)val3).name]; if (num4 >= 0) { val3.itemCost = num4; if (dictionary2.ContainsKey(((Object)val3).name) && dictionary3.ContainsKey(((Object)val3).name)) { shipDecorItems[((Object)val3).name] = num4; shipDecorItems2[dictionary3[((Object)val3).name]] = num4; shipDecorConfirms[((Object)val3).name] = dictionary3[((Object)val3).name]; } } } num3++; } BuyableVehicle[] buyableVehicles = __instance.buyableVehicles; foreach (BuyableVehicle val4 in buyableVehicles) { if (val4.vehicleDisplayName == "Cruiser") { val4.creditsWorth = ItemWeightsConfigHelper.CruiserPrice.Value; } } } [HarmonyPatch("LoadNewNodeIfAffordable")] [HarmonyPrefix] public static void LoadNewNodePatch(Terminal __instance, ref TerminalNode node) { if (ItemWeights.logTerminalNodes) { ItemWeights.Logger.LogInfo((object)("Accessing node " + ((Object)node).name)); } if (((Object)node).name == "buyCruiser" || ((Object)node).name == "buyCruiser2") { node.itemCost = ItemWeightsConfigHelper.CruiserPrice.Value; return; } if (((Object)node).name == "TeleporterBuy1" || ((Object)node).name == "TeleporterBuyConfirm") { node.itemCost = ItemWeightsConfigHelper.TeleporterPrice.Value; return; } if (((Object)node).name == "InverseTeleporterBuy" || ((Object)node).name == "InverseTeleporterBuyConfirm") { node.itemCost = ItemWeightsConfigHelper.InverseTeleporterPrice.Value; return; } if (((Object)node).name == "LoudHornBuy1" || ((Object)node).name == "LoudHornBuyConfirm") { node.itemCost = ItemWeightsConfigHelper.LoudHornPrice.Value; return; } foreach (KeyValuePair<string, string> shipDecorConfirm in shipDecorConfirms) { if (((Object)node).name == shipDecorConfirm.Key) { node.itemCost = shipDecorItems[((Object)node).name]; break; } if (((Object)node).name == shipDecorConfirm.Value) { node.itemCost = shipDecorItems2[((Object)node).name]; break; } } } [HarmonyPatch("ParseWord")] [HarmonyPostfix] public static void ParsewordPatch(Terminal __instance, ref TerminalKeyword __result) { if ((Object)(object)__result != (Object)null && removedShopItems.Contains(((Object)__result).name)) { __result = null; } } [HarmonyPatch("TextPostProcess")] [HarmonyPostfix] public static void TextPostProcessPatch(Terminal __instance, ref string __result) { if (__result != null) { string text = __result; if (text.Contains("* Loud horn // Price: $100")) { text = text.Replace("* Loud horn // Price: $100", $"* Loud horn // Price: ${ItemWeightsConfigHelper.LoudHornPrice.Value}"); } if (text.Contains("* Signal Translator // Price: $255")) { text = text.Replace("* Signal Translator // Price: $255", $"* Signal Translator // Price: ${newSignalTranslatorPrice}"); } if (text.Contains("* Teleporter // Price: $375")) { text = text.Replace("* Teleporter // Price: $375", $"* Teleporter // Price: ${ItemWeightsConfigHelper.TeleporterPrice.Value}"); } if (text.Contains("* Inverse Teleporter // Price: $425")) { text = text.Replace("* Inverse Teleporter // Price: $425", $"* Inverse Teleporter // Price: ${ItemWeightsConfigHelper.InverseTeleporterPrice.Value}"); } __result = text; } } } } namespace ItemWeights.Helpers { public static class ItemWeightsConfigHelper { public static ConfigEntry<string> Weights; public static ConfigEntry<string> SellPrices; public static ConfigEntry<string> TerminalPrices; public static ConfigEntry<string> TerminalKeywords; public static ConfigEntry<string> TerminalKeywordsConfirm; public static ConfigEntry<bool> LogTerminalNodes; public static ConfigEntry<int> CruiserPrice; public static ConfigEntry<int> TeleporterPrice; public static ConfigEntry<int> InverseTeleporterPrice; public static ConfigEntry<int> LoudHornPrice; public static void SetLethalConfig(ConfigFile config) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Expected O, but got Unknown //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Expected O, but got Unknown //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Expected O, but got Unknown //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Expected O, but got Unknown //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Expected O, but got Unknown //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Expected O, but got Unknown //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Expected O, but got Unknown //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Expected O, but got Unknown Weights = config.Bind<string>("Item Config", "ItemWeights", "", "Create an entry in this format \"ITEMID:WEIGHT\", for example to make a shovel weigh 4 pounds you would put \"Shovel:4\". Enter values manually or use the keybind in-game!"); TextInputFieldConfigItem val = new TextInputFieldConfigItem(Weights, true); SellPrices = config.Bind<string>("Item Config", "SellPrices", "", "Changes the min and max value per scrap item, register new items using the in-game keybind! Note, this will not affect items spawned in using mods such as imperium and will not affect tools or keys! Manual Format: ITEMID:MIN-MAX"); TextInputFieldConfigItem val2 = new TextInputFieldConfigItem(SellPrices, true); TerminalPrices = config.Bind<string>("Item Config", "TerminalPrices", "WalkieTalkie:12,Flashlight:15,Shovel:30,LockPicker:20,ProFlashlight:25,StunGrenade:30,Boombox:60,TZPInhalant:120,ZapGun:400,Jetpack:900,ExtensionLadder:60,RadarBooster:60,SprayPaint:50,WeedKillerBottle:40,GreenSuitBuy1:60,HazardSuitBuy1:90,PajamaSuitBuy1:900,CozyLightsBuy1:140,TelevisionBuy1:130,ToiletBuy1:150,ShowerBuy1:180,RecordPlayerBuy:120,TableBuy1:70,RomTableBuy1:120,SignalTranslatorBuy:255,JackOLanternBuy:50,WelcomeMatBuy:40,FishBowlBuy:50,PlushiePajamaManBuy:100,PurpleSuitBuy1:70,BeeSuitBuy:110,BunnySuitBuy:200,DiscoBallBuy:150", "Changes the prices of items and decorations in the shop, to add more items to this list use the in-game keybind which will add all currently available items in the shop to this list."); TextInputFieldConfigItem val3 = new TextInputFieldConfigItem(TerminalPrices, true); CruiserPrice = config.Bind<int>("Item Config", "CruiserPrice", 400, "The price of the Company Cruiser"); IntInputFieldConfigItem val4 = new IntInputFieldConfigItem(CruiserPrice, true); TeleporterPrice = config.Bind<int>("Item Config", "TeleporterPrice", 375, "The price of the Teleporter"); IntInputFieldConfigItem val5 = new IntInputFieldConfigItem(TeleporterPrice, true); InverseTeleporterPrice = config.Bind<int>("Item Config", "InverseTeleporterPrice", 425, "The price of the Inverse Teleporter"); IntInputFieldConfigItem val6 = new IntInputFieldConfigItem(InverseTeleporterPrice, true); LoudHornPrice = config.Bind<int>("Item Config", "LoudHornPrice", 375, "The price of the Loud Horn"); IntInputFieldConfigItem val7 = new IntInputFieldConfigItem(LoudHornPrice, true); TerminalKeywords = config.Bind<string>("Advanced Config", "TerminalKeywords", "WalkieTalkie:WalkieTalkie,Flashlight:Flashlight,Shovel:Shovel,LockPicker:Lockpicker,ProFlashlight:ProFlashlight,StunGrenade:StunGrenade,Boombox:BoomBox,TZPInhalant:TZPInhalant,ZapGun:ZapGun,Jetpack:Jetpack,ExtensionLadder:ExtensionLadder,RadarBooster:RadarBooster,SprayPaint:Spray paint,WeedKillerBottle:Weed killer,GreenSuitBuy1:GreenSuit,HazardSuitBuy1:HazardSuit,PajamaSuitBuy1:PajamaSuit,CozyLightsBuy1:CozyLights,TelevisionBuy1:Television,ToiletBuy1:Toilet,ShowerBuy1:Shower,RecordPlayerBuy:RecordPlayer,TableBuy1:Table,SignalTranslatorBuy:SignalTranslator,JackOLanternBuy:JackOLantern,:WelcomeMatBuy:WelcomeMat,FishBowlBuy:Goldfish,PlushiePajamaManBuy:PlushiePajamaMan,PurpleSuitBuy1:PurpleSuit,BeeSuitBuy:BeeSuit,BunnySuitBuy:BunnySuit,DiscoBallBuy:Disco ball", "This is a config setting used to determine terminal keyword to item matching, it is NOT reccomended to touch this unless you know what you are doing!"); TextInputFieldConfigItem val8 = new TextInputFieldConfigItem(TerminalKeywords, true); TerminalKeywordsConfirm = config.Bind<string>("Advanced Config", "TerminalKeywordsConfirm", "GreenSuitBuy1:GreenSuitBuyConfirm,HazardSuitBuy1:HazardSuitBuyConfirm,PajamaSuitBuy1:PajamaSuitBuyConfirm,CozyLightsBuy1:CozyLightsBuyConfirm,TelevisionBuy1:TelevisionBuyConfirm,ToiletBuy1:ToiletBuyConfirm,ShowerBuy1:ShowerBuyConfirm,RecordPlayerBuy:RecordPlayerBuyConfirm,TableBuy1:TableBuyConfirm,SignalTranslatorBuy:SignalTranslatorBuyConfirm,JackOLanternBuy:JackOLanternBuyConfirm,:WelcomeMatBuy:WelcomeMatBuyConfirm,FishBowlBuy:FishBowlBuyConfirm,PlushiePajamaManBuy:PlushiePajamaManBuyConfirm,PurpleSuitBuy1:PurpleSuitBuyConfirm,BeeSuitBuy:BeeSuitBuyConfirm,BunnySuitBuy:BunnySuitBuyConfirm,DiscoBallBuy:DiscoBallBuyConfirm", "This is a config setting used to determine terminal keyword to item matching, it is NOT reccomended to touch this unless you know what you are doing!"); TextInputFieldConfigItem val9 = new TextInputFieldConfigItem(TerminalKeywordsConfirm, true); LogTerminalNodes = config.Bind<bool>("Advanced Config", "LogTerminalNodes", false, "Logs accessed terminal nodes in the output"); BoolCheckBoxConfigItem val10 = new BoolCheckBoxConfigItem(LogTerminalNodes, true); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val2); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val3); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val4); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val5); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val6); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val7); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val10); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val8); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val9); LethalConfigManager.SetModDescription("A mod for configuring weights of individual items."); } } public class ItemWeightsKeybindHelper : LcInputActions { [InputAction(/*Could not decode attribute arguments.*/)] public InputAction RegisterItem { get; set; } [InputAction(/*Could not decode attribute arguments.*/)] public InputAction RegisterTerminalStore { get; set; } [InputAction(/*Could not decode attribute arguments.*/)] public InputAction PrintTerminalKeywords { get; set; } } public static class ItemWeightsCallbacks { public static void StartKeybindCallbacks() { ItemWeights.InputActionsInstance.RegisterItem.performed += OnRegisterItemPressed; ItemWeights.InputActionsInstance.RegisterTerminalStore.performed += OnRegisterTerminalStorePressed; ItemWeights.InputActionsInstance.PrintTerminalKeywords.performed += OnPrintTerminalKeywordsPressed; } public static void OnRegisterItemPressed(CallbackContext registerContext) { if (!((CallbackContext)(ref registerContext)).performed) { return; } GrabbableObject currentlyHeldObjectServer = GameNetworkManager.Instance.localPlayerController.currentlyHeldObjectServer; if (!Object.op_Implicit((Object)(object)currentlyHeldObjectServer)) { return; } string name = ((Object)currentlyHeldObjectServer.itemProperties).name; float num = (currentlyHeldObjectServer.itemProperties.weight - 1f) * 100f; float num2 = math.round(num); int num3 = (int)math.round((double)currentlyHeldObjectServer.itemProperties.minValue / 2.5); int num4 = (int)math.round((double)currentlyHeldObjectServer.itemProperties.maxValue / 2.5); string value = ItemWeightsConfigHelper.Weights.Value; string[] array = value.Split(","); string[] source = (from x in value.Split(",") select x.Split(":")[0]).ToArray(); string value2 = ItemWeightsConfigHelper.SellPrices.Value; string[] array2 = value2.Split(","); string[] source2 = (from x in value2.Split(",") select x.Split(":")[0]).ToArray(); int num5 = 0; if (!source.Contains(name)) { num5 = 1; if (value == "") { ItemWeightsConfigHelper.Weights.Value = $"{name}:{num2}"; } else { ItemWeightsConfigHelper.Weights.Value = $"{value},{name}:{num2}"; } } if (!source2.Contains(name)) { num5 = 1; if (value2 == "") { ItemWeightsConfigHelper.SellPrices.Value = $"{name}:{num3}-{num4}"; } else { ItemWeightsConfigHelper.SellPrices.Value = $"{value2},{name}:{num3}-{num4}"; } } if (num5 > 0) { HUDManager.Instance.DisplayTip("ItemWeights", $"[{name}] has been added to the config! [{num2}lb] [{num3}-{num4}]", false, false, "LC_Tip1"); } else { HUDManager.Instance.DisplayTip("ItemWeights", "[" + name + "] is already in the config!", false, false, "LC_Tip1"); } } public static void OnRegisterTerminalStorePressed(CallbackContext storeContext) { if (!((CallbackContext)(ref storeContext)).performed) { return; } string terminalPricesString = ItemWeightsConfigHelper.TerminalPrices.Value; string[] array = terminalPricesString.Split(","); string[] source = (from x in terminalPricesString.Split(",") select x.Split(":")[0]).ToArray(); Terminal val = Object.FindObjectOfType<Terminal>(); Item[] buyableItemsList = val.buyableItemsList; List<TerminalNode> shipDecorSelection = val.ShipDecorSelection; List<UnlockableItem> unlockables = StartOfRound.Instance.unlockablesList.unlockables; Item[] array2 = buyableItemsList; foreach (Item val2 in array2) { if (!source.Contains(((Object)val2).name)) { addEntry(((Object)val2).name, val2.creditsWorth); } } foreach (TerminalNode item in shipDecorSelection) { if (!source.Contains(((Object)item).name)) { addEntry(((Object)item).name, item.itemCost); } } ItemWeightsConfigHelper.TerminalPrices.Value = terminalPricesString; HUDManager.Instance.DisplayTip("ItemWeights", "Updated terminal prices string, you can now edit it in the config!", false, false, "LC_Tip1"); void addEntry(string name, int value) { if (terminalPricesString == "") { terminalPricesString += $"{name}:{value}"; } else { terminalPricesString += $",{name}:{value}"; } } } public static void OnPrintTerminalKeywordsPressed(CallbackContext keywordContext) { if (((CallbackContext)(ref keywordContext)).performed) { ItemWeightsConfigHelper.LogTerminalNodes.Value = !ItemWeightsConfigHelper.LogTerminalNodes.Value; ItemWeights.logTerminalNodes = ItemWeightsConfigHelper.LogTerminalNodes.Value; HUDManager.Instance.DisplayTip("ItemWeights", $"Set terminal node logging to {ItemWeightsConfigHelper.LogTerminalNodes.Value}!", false, false, "LC_Tip1"); } } } }