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 StackedDifficulties v1.1.0
StackedDifficulties.dll
Decompiled 10 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using Microsoft.CodeAnalysis; using On.RoR2; using RiskOfOptions; using RiskOfOptions.Options; using RoR2; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("StackedDifficulties")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("StackedDifficulties")] [assembly: AssemblyTitle("StackedDifficulties")] [assembly: AssemblyVersion("1.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 StackedDifficulties { [BepInPlugin("com.rowan.StackedDifficulties", "StackedDifficulties", "1.1.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class StackedDifficultiesPlugin : BaseUnityPlugin { [CompilerGenerated] private static class <>O { public static hook_RecalculateDifficultyCoefficentInternal <0>__OnRecalc; public static Action<Run> <1>__OnRunStart; } public const string GUID = "com.rowan.StackedDifficulties"; public const string NAME = "StackedDifficulties"; public const string VERSION = "1.1.0"; internal static ConfigEntry<bool> Enabled; internal static ConfigEntry<string> StackedList; internal static ConfigEntry<bool> NormalizeToRainstorm; internal static ConfigEntry<bool> Announce; private static bool _loggedRecalcError; private static string _cacheKey; private static float _cachedFactor = 1f; public void Awake() { //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Expected O, but got Unknown Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Master switch for difficulty stacking."); StackedList = ((BaseUnityPlugin)this).Config.Bind<string>("General", "Stacked Difficulties", "", "Comma-separated names of ADDITIONAL difficulties to multiply on top of the lobby-selected one. Example: Monsoon, Typhoon. Case-insensitive; matches the difficulty name shown in the lobby."); NormalizeToRainstorm = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Normalize To Rainstorm", false, "If false (default), each stacked difficulty multiplies by its raw scaling value (Drizzle 1, Rainstorm 2, Monsoon 3...). If true, each stacked difficulty multiplies by (scaling / Rainstorm scaling), which is gentler."); Announce = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Announce In Chat", true, "Print the resulting difficulty multiplier in chat when a run starts."); object obj = <>O.<0>__OnRecalc; if (obj == null) { hook_RecalculateDifficultyCoefficentInternal val = OnRecalc; <>O.<0>__OnRecalc = val; obj = (object)val; } Run.RecalculateDifficultyCoefficentInternal += (hook_RecalculateDifficultyCoefficentInternal)obj; Run.onRunStartGlobal += OnRunStart; if (Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions")) { try { RiskOfOptionsCompat.Init(); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("RiskOfOptions integration failed: " + ex.Message)); } } ((BaseUnityPlugin)this).Logger.LogInfo((object)"StackedDifficulties loaded."); } private static void OnRecalc(orig_RecalculateDifficultyCoefficentInternal orig, Run self) { orig.Invoke(self); try { if ((Object)(object)self == (Object)null || Enabled == null || !Enabled.Value) { return; } float factor = GetFactor(); if (!(factor <= 0f) && !Mathf.Approximately(factor, 1f)) { self.difficultyCoefficient *= factor; self.compensatedDifficultyCoefficient *= factor; float compensatedDifficultyCoefficient = self.compensatedDifficultyCoefficient; if (compensatedDifficultyCoefficient > 0f) { self.oneOverCompensatedDifficultyCoefficientSquared = 1f / (compensatedDifficultyCoefficient * compensatedDifficultyCoefficient); } } } catch (Exception ex) { if (!_loggedRecalcError) { _loggedRecalcError = true; Debug.LogWarning((object)("[StackedDifficulties] recalc failed, stacking disabled for this run: " + ex.Message)); } } } private static void OnRunStart(Run run) { if (!Enabled.Value || !Announce.Value) { return; } List<string> unknown; List<DifficultyDef> list = ResolveStackedDefs(out unknown); if (list.Count == 0 && unknown.Count == 0) { return; } List<string> list2 = new List<string>(); foreach (DifficultyDef item in list) { list2.Add(Language.GetString(item.nameToken) + " (x" + PerDifficultyFactor(item).ToString("0.##") + ")"); } string text = "<style=cIsCombat>Stacked Difficulties:</style> total x" + GetFactor().ToString("0.##"); if (list2.Count > 0) { text = text + " [" + string.Join(", ", list2) + "]"; } if (unknown.Count > 0) { text = text + " <style=cDeath>(unknown: " + string.Join(", ", unknown) + ")</style>"; } Chat.AddMessage(text); } private static float PerDifficultyFactor(DifficultyDef def) { float num = Mathf.Max(def.scalingValue, 0.01f); if (NormalizeToRainstorm.Value) { DifficultyDef difficultyDef = DifficultyCatalog.GetDifficultyDef((DifficultyIndex)1); float num2 = ((difficultyDef != null) ? Mathf.Max(difficultyDef.scalingValue, 0.01f) : 2f); return num / num2; } return num; } internal static float GetFactor() { string text = ((StackedList != null) ? StackedList.Value : "") + "|" + (NormalizeToRainstorm != null && NormalizeToRainstorm.Value); if (text == _cacheKey) { return _cachedFactor; } float num = 1f; try { List<string> unknown; foreach (DifficultyDef item in ResolveStackedDefs(out unknown)) { num *= PerDifficultyFactor(item); } } catch { num = 1f; } _cacheKey = text; _cachedFactor = num; return num; } private static List<DifficultyDef> ResolveStackedDefs(out List<string> unknown) { List<DifficultyDef> list = new List<DifficultyDef>(); unknown = new List<string>(); string value = StackedList.Value; if (string.IsNullOrWhiteSpace(value)) { return list; } string[] array = value.Split(','); for (int i = 0; i < array.Length; i++) { string text = array[i].Trim(); if (text.Length != 0) { DifficultyDef val = FindDifficulty(text); if (val != null) { list.Add(val); } else { unknown.Add(text); } } } return list; } private static DifficultyDef FindDifficulty(string name) { string text = name.ToUpperInvariant(); for (int i = 0; i < 64; i++) { DifficultyDef difficultyDef; try { difficultyDef = DifficultyCatalog.GetDifficultyDef((DifficultyIndex)i); } catch { break; } if (difficultyDef != null) { string text2 = difficultyDef.nameToken ?? ""; string text3 = ""; try { text3 = Language.GetString(text2) ?? ""; } catch { } if (text3.ToUpperInvariant() == text || text2.ToUpperInvariant() == text || text2.ToUpperInvariant().Contains(text)) { return difficultyDef; } } } return null; } } internal static class RiskOfOptionsCompat { [MethodImpl(MethodImplOptions.NoInlining)] public static void Init() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown ModSettingsManager.SetModDescription("Multiply several difficulties together. Pick your base difficulty in the lobby, then list extra difficulties to stack on top."); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(StackedDifficultiesPlugin.Enabled)); ModSettingsManager.AddOption((BaseOption)new StringInputFieldOption(StackedDifficultiesPlugin.StackedList)); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(StackedDifficultiesPlugin.NormalizeToRainstorm)); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(StackedDifficultiesPlugin.Announce)); } } }