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 Shop Duplicate Unlock v1.0.2
Matsu.ShopDuplicates.dll
Decompiled 2 weeks agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("Matsu.ShopDuplicates")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.2.0")] [assembly: AssemblyInformationalVersion("1.0.2")] [assembly: AssemblyProduct("Matsu.ShopDuplicates")] [assembly: AssemblyTitle("Matsu.ShopDuplicates")] [assembly: AssemblyVersion("1.0.2.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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] [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] [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 Matsu.ShopDuplicates { [BepInPlugin("com.matsu.shopduplicates", "Shop Duplicate Unlock", "1.0.2")] [BepInDependency("HeroHanex.NoItemSpawnLimit", "1.0.8")] public class Plugin : BaseUnityPlugin { public const string Guid = "com.matsu.shopduplicates"; public const string Name = "Shop Duplicate Unlock"; public const string Version = "1.0.2"; public static ManualLogSource Log; public static ConfigEntry<int> MaxCopiesPerItem; public static ConfigEntry<bool> IncludeConsumables; public static ConfigEntry<bool> IncludeHealthPacks; private void Awake() { //IL_0070: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; MaxCopiesPerItem = ((BaseUnityPlugin)this).Config.Bind<int>("Shop", "MaxCopiesPerItem", 5, "How many times each weapon/item/drone can appear in a single shop (vanilla usually caps them at 1). Higher = more duplicates possible. The shop still only fills its fixed number of slots, so this just removes the 'one of each' restriction."); IncludeConsumables = ((BaseUnityPlugin)this).Config.Bind<bool>("Shop", "IncludeConsumables", true, "Also allow duplicate power crystals / consumables."); IncludeHealthPacks = ((BaseUnityPlugin)this).Config.Bind<bool>("Shop", "IncludeHealthPacks", true, "Also allow duplicate health packs."); new Harmony("com.matsu.shopduplicates").PatchAll(); Log.LogInfo((object)string.Format("{0} {1} loaded (MaxCopiesPerItem={2}).", "Shop Duplicate Unlock", "1.0.2", MaxCopiesPerItem.Value)); } } [HarmonyPatch(typeof(ShopManager), "GetAllItemsFromStatsManager")] internal static class ShopDuplicatesPatch { private static void Postfix(ShopManager __instance) { try { int value = Plugin.MaxCopiesPerItem.Value; Plugin.Log.LogInfo((object)$"[ShopDuplicates] Postfix triggered. MaxCopiesPerItem={value}"); if (value > 1) { if (__instance.potentialItems != null) { int count = __instance.potentialItems.Count; TopUp(__instance.potentialItems, value, "potentialItems"); Plugin.Log.LogInfo((object)$"[ShopDuplicates] potentialItems: {count} → {__instance.potentialItems.Count}"); } if (Plugin.IncludeConsumables.Value && __instance.potentialItemConsumables != null) { int count2 = __instance.potentialItemConsumables.Count; TopUp(__instance.potentialItemConsumables, value, "potentialItemConsumables"); Plugin.Log.LogInfo((object)$"[ShopDuplicates] potentialItemConsumables: {count2} → {__instance.potentialItemConsumables.Count}"); } if (Plugin.IncludeHealthPacks.Value && __instance.potentialItemHealthPacks != null) { int count3 = __instance.potentialItemHealthPacks.Count; TopUp(__instance.potentialItemHealthPacks, value, "potentialItemHealthPacks"); Plugin.Log.LogInfo((object)$"[ShopDuplicates] potentialItemHealthPacks: {count3} → {__instance.potentialItemHealthPacks.Count}"); } } } catch (Exception arg) { Plugin.Log.LogError((object)$"[ShopDuplicates] error: {arg}"); } } private static void TopUp(List<Item>? list, int max, string listName) { if (list == null || list.Count == 0) { return; } HashSet<Item> hashSet = new HashSet<Item>(); foreach (Item item in list) { if ((Object)(object)item != (Object)null) { hashSet.Add(item); } } if (hashSet.Count == 0) { return; } Plugin.Log.LogInfo((object)$"[ShopDuplicates] '{listName}' has {hashSet.Count} distinct items, {list.Count} total before TopUp."); foreach (Item item2 in hashSet) { for (int i = 1; i < max; i++) { list.Add(item2); } } for (int num = list.Count - 1; num > 0; num--) { int num2 = Random.Range(0, num + 1); int index = num; int index2 = num2; Item value = list[num2]; Item value2 = list[num]; list[index] = value; list[index2] = value2; } } } }