Please disclose if any significant portion of your mod was created 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 SetSalesCrashFix v1.0.0
SetSalesCrashFix.dll
Decompiled 10 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("SetSalesCrashFix")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("SetSalesCrashFix")] [assembly: AssemblyCopyright("Copyright © 2025")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("81a34d1e-ccf9-4eca-be9a-6b396d0a4c0b")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] [BepInPlugin("com.yourname.fixitemsales", "FixItemSalesPatch", "1.0.0")] public class FixItemSalesPlugin : BaseUnityPlugin { private void Awake() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) new Harmony("com.yourname.fixitemsales").PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"FixItemSales patch applied!"); } } [HarmonyPatch(typeof(Terminal), "SetItemSales")] public class SetItemSalesPatch { private static bool Prefix(Terminal __instance) { if (__instance.itemSalesPercentages == null || __instance.itemSalesPercentages.Length == 0) { __instance.itemSalesPercentages = new int[__instance.buyableItemsList.Length + __instance.buyableVehicles.Length]; for (int i = 0; i < __instance.itemSalesPercentages.Length; i++) { __instance.itemSalesPercentages[i] = 100; } } Random random = new Random(StartOfRound.Instance.randomMapSeed + 90); DateTime dateTime = new DateTime(DateTime.Now.Year, 10, 23); bool num = DateTime.Today == dateTime; int minValue = (num ? (-2) : (-10)); int maxValue = (num ? 9 : 5); int num2 = Mathf.Max(random.Next(minValue, maxValue), 0); if (num2 <= 0) { return false; } List<int> list = new List<int>(); for (int j = 0; j < __instance.buyableItemsList.Length; j++) { list.Add(j); __instance.itemSalesPercentages[j] = 100; } for (int k = 0; k < __instance.buyableVehicles.Length; k++) { int num3 = k + __instance.buyableItemsList.Length; list.Add(num3); __instance.itemSalesPercentages[num3] = 100; } for (int l = 0; l < num2; l++) { if (list.Count <= 0) { break; } int index = random.Next(0, list.Count); int num4 = list[index]; int maxValue2 = ((num4 >= __instance.buyableItemsList.Length) ? 80 : Mathf.Clamp(__instance.buyableItemsList[num4].highestSalePercentage, 0, 90)); int num5 = 100 - random.Next(0, maxValue2); num5 = (int)Math.Round((double)num5 / 10.0) * 10; if (num4 < __instance.itemSalesPercentages.Length) { __instance.itemSalesPercentages[num4] = num5; } list.RemoveAt(index); } return false; } }