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 AdvanceMyShop v1.3.1
AdvanceMyShop.dll
Decompiled 4 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using MoreUpgrades.Classes; using Photon.Pun; using UnityEngine; [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: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("Autodesk.Fbx")] [assembly: IgnoresAccessChecksTo("Discord.Sdk")] [assembly: IgnoresAccessChecksTo("Domain_Reload")] [assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")] [assembly: IgnoresAccessChecksTo("FbxBuildTestAssets")] [assembly: IgnoresAccessChecksTo("Klattersynth")] [assembly: IgnoresAccessChecksTo("Photon3Unity3D")] [assembly: IgnoresAccessChecksTo("PhotonChat")] [assembly: IgnoresAccessChecksTo("PhotonRealtime")] [assembly: IgnoresAccessChecksTo("PhotonUnityNetworking")] [assembly: IgnoresAccessChecksTo("PhotonUnityNetworking.Utilities")] [assembly: IgnoresAccessChecksTo("PhotonVoice.API")] [assembly: IgnoresAccessChecksTo("PhotonVoice")] [assembly: IgnoresAccessChecksTo("PhotonVoice.PUN")] [assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime")] [assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime.Public")] [assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Attributes")] [assembly: IgnoresAccessChecksTo("Sirenix.Serialization.Config")] [assembly: IgnoresAccessChecksTo("Sirenix.Serialization")] [assembly: IgnoresAccessChecksTo("Sirenix.Utilities")] [assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")] [assembly: IgnoresAccessChecksTo("Unity.Burst")] [assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")] [assembly: IgnoresAccessChecksTo("Unity.Collections")] [assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")] [assembly: IgnoresAccessChecksTo("Unity.Formats.Fbx.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")] [assembly: IgnoresAccessChecksTo("Unity.Mathematics")] [assembly: IgnoresAccessChecksTo("Unity.MemoryProfiler")] [assembly: IgnoresAccessChecksTo("Unity.Postprocessing.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")] [assembly: IgnoresAccessChecksTo("Unity.Splines")] [assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")] [assembly: IgnoresAccessChecksTo("Unity.Timeline")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Antlr3.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Core")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Flow")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.State")] [assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.UI")] [assembly: IgnoresAccessChecksTo("websocket-sharp")] [assembly: AssemblyCompany("Dj_Haski")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.3.1.0")] [assembly: AssemblyInformationalVersion("1.3.1+fd97642d8da41e19053c26b4600e2fe47383522d")] [assembly: AssemblyProduct("AdvanceMyShop")] [assembly: AssemblyTitle("AdvanceMyShop")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.3.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 AdvanceMyShop { [BepInPlugin("Dj_Haski.AdvanceMyShop", "AdvanceMyShop", "1.3.1")] public class AdvanceMyShop : BaseUnityPlugin { internal static AdvanceMyShop Instance { get; private set; } internal static ManualLogSource Logger => Instance._logger; private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger; internal Harmony? Harmony { get; set; } private void Awake() { Instance = this; PluginConfig.Load(((BaseUnityPlugin)this).Config); ((Component)this).gameObject.transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; Patch(); Logger.LogInfo((object)$"v{((BaseUnityPlugin)this).Info.Metadata.Version} is now injected in the game. Have fun :3"); if (Chainloader.PluginInfos.ContainsKey("bulletbot.moreupgrades")) { Logger.LogInfo((object)"Found 'MoreUpgrades' mod. Compatibility layer is enabled."); } } internal void Patch() { //IL_001a: 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_0021: Expected O, but got Unknown //IL_0026: Expected O, but got Unknown if (Harmony == null) { Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID); Harmony val2 = val; Harmony = val; } Harmony.PatchAll(); } internal void Unpatch() { Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } } } [HarmonyPatch(typeof(ItemAttributes), "GetValue")] [HarmonyPriority(0)] public class ItemAttributesPatch { private static float ApplyMultiplier(float source, float multiplier) { if (multiplier == 0f) { return source; } return source * (1f - multiplier / 100f); } [MethodImpl(MethodImplOptions.NoInlining)] private static float GetMoreUpgradesItemValueMultiplier(Item item) { return MoreUpgradesAPI.ItemValueMultiplier(item); } private static float? GetModdedItemValueMultiplier(Item item) { if (Chainloader.PluginInfos.ContainsKey("bulletbot.moreupgrades")) { return GetMoreUpgradesItemValueMultiplier(item); } return null; } public static bool Prefix(ItemAttributes __instance) { //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_00b4: 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_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Invalid comparison between Unknown and I4 //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Invalid comparison between Unknown and I4 //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Invalid comparison between Unknown and I4 if (GameManager.Multiplayer() && !PhotonNetwork.IsMasterClient) { return true; } float num = Utils.GetRandomNumber(__instance.itemValueMin, __instance.itemValueMax); float? moddedItemValueMultiplier = GetModdedItemValueMultiplier(__instance.item); if (moddedItemValueMultiplier.HasValue) { num *= moddedItemValueMultiplier.Value; } else if (!PluginConfig.disableVanillaPriceMultiplier.Value) { num *= ShopManager.instance.itemValueMultiplier; } num = Mathf.Max(1000f, num); float num2 = __instance.value; if (num2 == 0f) { num2 = Mathf.Ceil(num / 1000f); itemType itemType = __instance.itemType; itemType val = itemType; if ((int)val != 3) { if ((int)val != 5) { if ((int)val == 8) { num2 = ShopManager.instance.HealthPackValueGet(num2); } } else { num2 = ShopManager.instance.CrystalValueGet(num2); } } else { num2 = ShopManager.instance.UpgradeValueGet(num2, __instance.item); } num2 *= PluginConfig.basePriceMultiplier.Value; num2 *= PluginConfig.itemMultipliers.GetValueOrDefault(((object)(itemType)(ref __instance.itemType)).ToString())?.Value ?? 1f; } if (PluginConfig.individualApply.Value) { num2 = ApplyMultiplier(num2, PluginConfig.NextAppliableMultiplier()); } else if (ShopManagerPatch.shopWideDiscount != 0) { num2 = ApplyMultiplier(num2, ShopManagerPatch.shopWideDiscount); } if (PluginConfig.WillBeItemFree()) { num2 = 0f; } else if (PluginConfig.WillBeItemOverpriced()) { num2 *= PluginConfig.overpricedItemMultiplier.Value; } __instance.value = (int)num2; if (GameManager.Multiplayer()) { __instance.photonView.RPC("GetValueRPC", (RpcTarget)1, new object[1] { __instance.value }); } return false; } } internal static class PluginConfig { public static ConfigEntry<float> basePriceMultiplier = null; public static ConfigEntry<int> discountChance = null; public static ConfigEntry<int> overpriceChance = null; public static ConfigEntry<float> overpriceMultiplier = null; public static ConfigEntry<bool> individualApply = null; private static ConfigEntry<string> percentages = null; public static ConfigEntry<float> freeItemChance = null; public static ConfigEntry<float> overpricedItemChance = null; public static ConfigEntry<float> overpricedItemMultiplier = null; public static float[] normalizedPercentages = null; public static ConfigEntry<bool> disableVanillaPriceMultiplier = null; public static Dictionary<string, ConfigEntry<float>> itemMultipliers = new Dictionary<string, ConfigEntry<float>>(); public static void Load(ConfigFile config) { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Expected O, but got Unknown //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Expected O, but got Unknown //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Expected O, but got Unknown //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Expected O, but got Unknown //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Expected O, but got Unknown discountChance = config.Bind<int>("General", "DiscountChance", 50, "Chance of a discount to occur. Works shop wide. Set to 0 to disable."); overpriceChance = config.Bind<int>("General", "OverpriceChance", 50, "Chance of an overprice to occur. Works shop wide. Set to 0 to disable."); overpriceMultiplier = config.Bind<float>("General", "OverpriceMultiplier", 1f, new ConfigDescription("This multiplier will be applied to the base generated percentage from 'Percentages'. Set to 1 to disable.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>())); individualApply = config.Bind<bool>("General", "IndividualApply", false, "If enabled, then each item will have a chance of being overpriced/discounted separately, rather than the whole shop."); percentages = config.Bind<string>("General", "Percentages", "0.5, 1, 2.5, 5, 10, 15, 20, 25, 30, 50", "List of percentages that will be used in the overpricing/discounts event."); freeItemChance = config.Bind<float>("General", "FreeItemChance", 0.5f, new ConfigDescription("Chance of a free item to occur. Works per item. Set to 0 to disable.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>())); overpricedItemChance = config.Bind<float>("General", "OverpricedItemChance", 0.5f, new ConfigDescription("Chance of an REALLY overpriced item to occur. Works per item. Set to 0 to disable.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>())); overpricedItemMultiplier = config.Bind<float>("General", "OverpricedItemMultiplier", 5f, new ConfigDescription("Multiplier applied to the overpriced item.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>())); disableVanillaPriceMultiplier = config.Bind<bool>("General", "DisableVanillaPriceMultiplier", false, "If enabled, mod will ignore vanilla game item value multiplier. This might be useful for easier playthrough."); basePriceMultiplier = config.Bind<float>("Multipliers", "BasePriceMultiplier", 1f, new ConfigDescription("Base price multiplier applied to all items (e.g. price * multiplier). Set to 1 to disable.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-10f, 10f), Array.Empty<object>())); foreach (object value in Enum.GetValues(typeof(itemType))) { itemMultipliers.Add(value.ToString(), config.Bind<float>("Multipliers", $"MultiplierFor_{value}", 1f, new ConfigDescription($"Multiplier applied to '{value}' items. Set to 1 to disable.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-10f, 10f), Array.Empty<object>()))); } normalizedPercentages = Array.ConvertAll(percentages.Value.Split(','), (string s) => Math.Clamp(float.Parse(s, CultureInfo.InvariantCulture), 0f, 100f)); } public static float NextAppliableMultiplier() { Random random = new Random(); if (Utils.GetRandomNumber(1f, 100f) <= (float)discountChance.Value) { return normalizedPercentages[random.Next(0, normalizedPercentages.Length - 1)]; } if (Utils.GetRandomNumber(1f, 100f) <= (float)overpriceChance.Value) { return -1f * normalizedPercentages[random.Next(0, normalizedPercentages.Length - 1)]; } return 0f; } public static bool WillBeItemFree() { return Utils.GetRandomNumber(1f, 100f) <= freeItemChance.Value; } public static bool WillBeItemOverpriced() { return Utils.GetRandomNumber(1f, 100f) <= overpricedItemChance.Value; } } [HarmonyPatch(typeof(ShopManager), "ShopInitialize")] internal class ShopManagerPatch { public static int shopWideDiscount; public static bool Prefix(ShopManager __instance) { if (!SemiFunc.RunIsShop() || !SemiFunc.IsMasterClientOrSingleplayer()) { return true; } if (!PluginConfig.individualApply.Value) { shopWideDiscount = (int)PluginConfig.NextAppliableMultiplier(); AdvanceMyShop.Logger.LogInfo((object)$"Rolled shop wide multiplier is: {shopWideDiscount}%"); } else { shopWideDiscount = 0; AdvanceMyShop.Logger.LogInfo((object)"No shop wide multiplier is rolled, individual discounts will be applied instead."); } return true; } } internal class Utils { public static float GetRandomNumber(float min, float max) { Random random = new Random(); return (float)(random.NextDouble() * (double)(max - min) + (double)min); } } }