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 MoreMonsterCredits v1.0.0
plugins/MoreMonsterCredits/MoreMonsterCredits.dll
Decompiled a day agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using LocalTweaks; using Microsoft.CodeAnalysis; using RiskOfOptions; using RiskOfOptions.OptionConfigs; using RiskOfOptions.Options; 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: AssemblyCompany("MoreMonsterCredits")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("MoreMonsterCredits")] [assembly: AssemblyTitle("MoreMonsterCredits")] [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 MoreMonsterCredits { [BepInPlugin("com.youssef.MoreMonsterCredits", "More Monster Credits", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class Plugin : BaseUnityPlugin { public const string Guid = "com.youssef.MoreMonsterCredits"; public const string Name = "More Monster Credits"; private static readonly ConfigEntry<int>[] bonuses = new ConfigEntry<int>[8]; private readonly Harmony harmony = new Harmony("com.youssef.MoreMonsterCredits"); private void Awake() { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Expected O, but got Unknown //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Expected O, but got Unknown for (int i = 3; i <= 10; i++) { bonuses[i - 3] = TweakSettings.Slider(((BaseUnityPlugin)this).Config, "Monster credits", $"Stage {i} bonus percent", 0, 0, 200, "Extra monster budget: 0 leaves it alone, 100 doubles it, 200 triples it. Ongoing income changes immediately; starting spawns change on the next stage entry. Hidden realms do not count.", "com.youssef.MoreMonsterCredits", "More Monster Credits"); } try { harmony.Patch((MethodBase)AccessTools.Method(typeof(CombatDirector), "FixedUpdate", (Type[])null, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "ChangeIncome", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)AccessTools.Method(typeof(SceneDirector), "PopulateScene", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Plugin), "ChangeStartingCredits", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Monster credit tweaks loaded."); } catch (Exception arg) { harmony.UnpatchSelf(); ((BaseUnityPlugin)this).Logger.LogError((object)$"Monster credit tweaks were not applied.\n{arg}"); } } private void OnDestroy() { harmony.UnpatchSelf(); } private static float Multiplier() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Invalid comparison between Unknown and I4 Run instance = Run.instance; SceneDef mostRecentSceneDef = SceneCatalog.mostRecentSceneDef; if (!NetworkServer.active || !Object.op_Implicit((Object)(object)instance) || !Object.op_Implicit((Object)(object)mostRecentSceneDef) || (int)mostRecentSceneDef.sceneType != 1 || mostRecentSceneDef.isFinalStage || !mostRecentSceneDef.validForRandomSelection) { return 1f; } int num = instance.stageClearCount - 2; if (num < 0 || num >= bonuses.Length) { return 1f; } return 1f + (float)bonuses[num].Value / 100f; } private static void ChangeStartingCredits(ref int ___monsterCredit) { ___monsterCredit = (int)Math.Min(2147483647.0, Math.Round((double)___monsterCredit * (double)Multiplier())); } private static float ScaleIncome(float credits, CombatDirector director) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 if ((int)director.teamIndex != 2) { return credits; } return credits * Multiplier(); } private static IEnumerable<CodeInstruction> ChangeIncome(IEnumerable<CodeInstruction> instructions) { //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Expected O, but got Unknown //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Expected O, but got Unknown List<CodeInstruction> list = instructions.ToList(); int num = 0; for (int i = 0; i < list.Count; i++) { if (list[i].operand is MethodInfo methodInfo && !(methodInfo.Name != "Update") && !(methodInfo.DeclaringType?.Name != "DirectorMoneyWave") && !(methodInfo.ReturnType != typeof(float))) { list.InsertRange(i + 1, (IEnumerable<CodeInstruction>)(object)new CodeInstruction[2] { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(Plugin), "ScaleIncome", (Type[])null, (Type[])null)) }); i += 2; num++; } } if (num != 1) { throw new InvalidOperationException($"Expected one director income update, found {num}."); } return list; } } } namespace LocalTweaks { internal static class PatchTools { internal static MethodInfo Method(string type, string name) { Type type2 = AccessTools.TypeByName(type); if (!(type2 == null)) { return AccessTools.DeclaredMethod(type2, name, (Type[])null, (Type[])null) ?? throw new MissingMethodException(type, name); } throw new TypeLoadException(type); } internal static IEnumerable<CodeInstruction> ReplaceFloat(IEnumerable<CodeInstruction> source, float value, MethodInfo replacement) { List<CodeInstruction> list = source.ToList(); List<CodeInstruction> list2 = list.Where((CodeInstruction x) => x.opcode == OpCodes.Ldc_R4 && x.operand is float num && Math.Abs(num - value) < 1E-06f).ToList(); if (list2.Count != 1) { throw new InvalidOperationException($"Expected one {value} constant, found {list2.Count}."); } list2[0].opcode = OpCodes.Call; list2[0].operand = replacement; return list; } } internal static class TweakSettings { internal static ConfigEntry<int> Slider(ConfigFile file, string section, string name, int value, int min, int max, string description, string guid, string modName) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown ConfigEntry<int> obj = file.Bind<int>(section, name, value, new ConfigDescription(description, (AcceptableValueBase)(object)new AcceptableValueRange<int>(min, max), Array.Empty<object>())); ModSettingsManager.AddOption((BaseOption)new IntSliderOption(obj, new IntSliderConfig { min = min, max = max }), guid, modName); return obj; } internal static ConfigEntry<bool> Checkbox(ConfigFile file, string section, string name, bool value, string description, string guid, string modName) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown ConfigEntry<bool> obj = file.Bind<bool>(section, name, value, description); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(obj), guid, modName); return obj; } } }