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 ConstantLunarShopRefresherPrice v1.0.0
plugins\ConstantLunarShopRefresherPrice\ConstantLunarShopRefresherPrice.dll
Decompiled 2 weeks agousing System; using System.Collections; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using RoR2; using UnityEngine; using UnityEngine.Networking; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyVersion("0.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [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 ConstantLunarShopRefresherPrice { [BepInPlugin("com.constantlunarshoprefresherprice.plugin", "ConstantLunarShopRefresherPrice", "1.0.0")] public sealed class Plugin : BaseUnityPlugin { public const string PluginGuid = "com.constantlunarshoprefresherprice.plugin"; public const string PluginName = "ConstantLunarShopRefresherPrice"; public const string PluginVersion = "1.0.0"; private const string LunarRecyclerNamePrefix = "LunarRecycler"; private Harmony _harmony; private ConfigEntry<int> _lunarPrice; private bool _normalizingConfig; internal static Plugin Instance { get; private set; } private void Awake() { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown Instance = this; _lunarPrice = ((BaseUnityPlugin)this).Config.Bind<int>("General", "LunarPrice", 1, "The fixed Lunar Coin price of the Lunar Shop Refresher. Negative values are changed to 0 (free)."); NormalizeLunarPrice(); _lunarPrice.SettingChanged += OnLunarPriceChanged; _harmony = new Harmony("com.constantlunarshoprefresherprice.plugin"); _harmony.PatchAll(typeof(Plugin).Assembly); ((BaseUnityPlugin)this).Logger.LogInfo((object)("ConstantLunarShopRefresherPrice loaded. Lunar Shop Refresher price: " + _lunarPrice.Value + ".")); } private void OnDestroy() { if (_lunarPrice != null) { _lunarPrice.SettingChanged -= OnLunarPriceChanged; } if (_harmony != null) { _harmony.UnpatchSelf(); _harmony = null; } if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } } private void OnLunarPriceChanged(object sender, EventArgs e) { if (!_normalizingConfig) { NormalizeLunarPrice(); ApplyPriceToExistingRecyclers(); } } private void NormalizeLunarPrice() { if (_lunarPrice == null || _lunarPrice.Value >= 0 || _normalizingConfig) { return; } _normalizingConfig = true; try { ((BaseUnityPlugin)this).Logger.LogWarning((object)"LunarPrice cannot be negative. Setting it to 0 (free)."); _lunarPrice.Value = 0; ((BaseUnityPlugin)this).Config.Save(); } finally { _normalizingConfig = false; } } internal void OnSceneDirectorStarted() { if (NetworkServer.active) { ((MonoBehaviour)this).StartCoroutine(ApplyPriceAfterSceneSetup()); } } private IEnumerator ApplyPriceAfterSceneSetup() { yield return (object)new WaitForSeconds(2f); ApplyPriceToExistingRecyclers(); } internal void OnRecyclerScaleCost(PurchaseInteraction purchaseInteraction) { if (NetworkServer.active && !((Object)(object)purchaseInteraction == (Object)null) && IsLunarRecycler(((Object)purchaseInteraction).name)) { ApplyPrice(purchaseInteraction); } } private void ApplyPriceToExistingRecyclers() { if (!NetworkServer.active) { return; } PurchaseInteraction[] array = Object.FindObjectsOfType<PurchaseInteraction>(); foreach (PurchaseInteraction val in array) { if ((Object)(object)val != (Object)null && IsLunarRecycler(((Object)val).name)) { ApplyPrice(val); } } } private void ApplyPrice(PurchaseInteraction purchaseInteraction) { purchaseInteraction.Networkcost = Math.Max(0, _lunarPrice.Value); } private static bool IsLunarRecycler(string objectName) { if (!string.IsNullOrEmpty(objectName)) { return objectName.StartsWith("LunarRecycler", StringComparison.OrdinalIgnoreCase); } return false; } } [HarmonyPatch(typeof(SceneDirector), "Start")] internal static class SceneDirectorStartPatch { [HarmonyPostfix] private static void Postfix() { if ((Object)(object)Plugin.Instance != (Object)null) { Plugin.Instance.OnSceneDirectorStarted(); } } } [HarmonyPatch(typeof(PurchaseInteraction), "ScaleCost")] internal static class PurchaseInteractionScaleCostPatch { [HarmonyPostfix] private static void Postfix(PurchaseInteraction __instance) { if ((Object)(object)Plugin.Instance != (Object)null) { Plugin.Instance.OnRecyclerScaleCost(__instance); } } } }