using 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.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
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("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.Formats.Fbx.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Postprocessing.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[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.1.1.0")]
[assembly: AssemblyInformationalVersion("1.1.1+12d60b6c4e82b2dae0e0baf44523191736648ad8")]
[assembly: AssemblyProduct("AdvanceMyShop")]
[assembly: AssemblyTitle("AdvanceMyShop")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.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.0")]
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");
}
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);
}
public static bool Prefix(ItemAttributes __instance)
{
//IL_0060: 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_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: 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_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Expected I4, but got Unknown
if (GameManager.Multiplayer() && !PhotonNetwork.IsMasterClient)
{
return true;
}
float randomNumber = Utils.GetRandomNumber(__instance.itemValueMin, __instance.itemValueMax);
float num = __instance.value;
if (num == 0f)
{
num = (float)Math.Round(ShopManager.instance.itemValueMultiplier * randomNumber);
itemType itemType = __instance.itemType;
itemType val = itemType;
switch (val - 4)
{
case 1:
num += num * ShopManager.instance.crystalValueIncrease * (float)RunManager.instance.levelsCompleted;
break;
case 4:
num += num * ShopManager.instance.healthPackValueIncrease * (float)RunManager.instance.levelsCompleted;
break;
case 0:
num += num * ShopManager.instance.upgradeValueIncrease * (float)StatsManager.instance.GetItemsUpgradesPurchased(__instance.itemName);
break;
}
num *= PluginConfig.basePriceMultiplier.Value;
num *= PluginConfig.itemMultipliers.GetValueOrDefault(((object)(itemType)(ref __instance.itemType)).ToString())?.Value ?? 1f;
}
if (PluginConfig.individualApply.Value)
{
num = ApplyMultiplier(num, PluginConfig.NextAppliableMultiplier());
}
else if (ShopManagerPatch.shopWideDiscount != 0)
{
num = ApplyMultiplier(num, ShopManagerPatch.shopWideDiscount);
}
if (PluginConfig.WillBeItemFree())
{
num = 0f;
}
else if (PluginConfig.WillBeItemOverpriced())
{
num *= PluginConfig.overpricedItemMultiplier.Value;
}
__instance.value = Utils.NormalizePrice(num);
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 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_017c: Unknown result type (might be due to invalid IL or missing references)
//IL_0186: Expected O, but got Unknown
//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
//IL_01f5: 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>()));
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);
}
public static int NormalizePrice(float price)
{
return (int)Math.Round(price / 1000f);
}
}
}