using System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using GlobalSettings; using HarmonyLib; using Microsoft.CodeAnalysis; 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: AssemblyCompany("MonorReaperBalance")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("0.1.0.0")] [assembly: AssemblyInformationalVersion("0.1.0+93295ff80c4a3bb6df071368aa0d09774ebf6d34")] [assembly: AssemblyProduct("MonorReaperBalance")] [assembly: AssemblyTitle("MonorReaperBalance")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/FabulatorK/MonorReaperBalance")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.1.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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] [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] [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 BepInEx { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] internal sealed class BepInAutoPluginAttribute : Attribute { public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace BepInEx.Preloader.Core.Patching { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] internal sealed class PatcherAutoPluginAttribute : Attribute { public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace MonorReaperBalance { [BepInPlugin("io.github.fabulatork.monorreaperbalance", "MonorReaperBalance", "0.1.0")] public class MonorReaperBalancePlugin : BaseUnityPlugin { public static ConfigEntry ModeDuration; public static ConfigEntry PersistThroughHits; public static ConfigEntry HitPenaltySeconds; public static ConfigEntry MinOrbsPerHit; internal static FieldRef? ReaperStateRef; public const string Id = "io.github.fabulatork.monorreaperbalance"; public static string Name => "MonorReaperBalance"; public static string Version => "0.1.0"; private void Awake() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown BindConfig(); Harmony harmony = new Harmony("io.github.fabulatork.monorreaperbalance"); TryPatch("Gameplay.ReaperModeDuration getter", delegate { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown harmony.Patch((MethodBase)(AccessTools.PropertyGetter(typeof(Gameplay), "ReaperModeDuration") ?? throw new MissingMemberException("getter not found")), (HarmonyMethod)null, new HarmonyMethod(typeof(ReaperPatches), "DurationPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); }); TryPatch("HeroController.GetReaperPayout", delegate { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown harmony.Patch((MethodBase)(AccessTools.Method(typeof(HeroController), "GetReaperPayout", (Type[])null, (Type[])null) ?? throw new MissingMemberException("method not found")), (HarmonyMethod)null, new HarmonyMethod(typeof(ReaperPatches), "PayoutPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); }); TryPatch("HeroController.ResetReaperCrestState", delegate { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown ReaperStateRef = AccessTools.FieldRefAccess("reaperState"); harmony.Patch((MethodBase)(AccessTools.Method(typeof(HeroController), "ResetReaperCrestState", (Type[])null, (Type[])null) ?? throw new MissingMemberException("method not found")), new HarmonyMethod(typeof(ReaperPatches), "ResetReaperPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); }); int damageOverloadsPatched = 0; MethodInfo[] methods = typeof(HeroController).GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (MethodInfo method in methods) { if (!(method.Name != "TakeDamage")) { TryPatch($"HeroController.TakeDamage ({method})", delegate { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown //IL_0044: Expected O, but got Unknown harmony.Patch((MethodBase)method, new HarmonyMethod(typeof(ReaperPatches), "DamagePrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(ReaperPatches), "DamageFinalizer", (Type[])null), (HarmonyMethod)null); int num2 = damageOverloadsPatched; damageOverloadsPatched = num2 + 1; }); } } if (damageOverloadsPatched == 0) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"No HeroController.TakeDamage overload found - PersistThroughHits is inactive."); } ((BaseUnityPlugin)this).Logger.LogInfo((object)("Plugin " + Name + " (io.github.fabulatork.monorreaperbalance) has loaded!")); } private void BindConfig() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Expected O, but got Unknown //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Expected O, but got Unknown ModeDuration = ((BaseUnityPlugin)this).Config.Bind("Reaper", "ModeDurationSeconds", 7.5f, new ConfigDescription("Reaper mode length in seconds (mod default: 7.5, vanilla: 10). Values snap to 0.1s steps.", (AcceptableValueBase)(object)new AcceptableValueRange(2.5f, 15f), Array.Empty())); ModeDuration.SettingChanged += delegate { SnapModeDuration(); }; SnapModeDuration(); PersistThroughHits = ((BaseUnityPlugin)this).Config.Bind("Reaper", "PersistThroughHits", true, "Taking a hit no longer ends Reaper mode."); HitPenaltySeconds = ((BaseUnityPlugin)this).Config.Bind("Reaper", "HitDurationPenalty", 0f, new ConfigDescription("Seconds removed from remaining Reaper time per hit taken (Warrior-rage style). 0 = no penalty. Only applies while PersistThroughHits is on.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 5f), Array.Empty())); MinOrbsPerHit = ((BaseUnityPlugin)this).Config.Bind("Reaper", "MinOrbsPerHit", 2, new ConfigDescription("Minimum silk bundles per hit while in Reaper mode (vanilla rolls 1-3).", (AcceptableValueBase)(object)new AcceptableValueRange(1, 3), Array.Empty())); } private static void SnapModeDuration() { float num = Mathf.Round(ModeDuration.Value * 10f) / 10f; if (!Mathf.Approximately(num, ModeDuration.Value)) { ModeDuration.Value = num; } } private void TryPatch(string target, Action apply) { try { apply(); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Patch failed, feature disabled (" + target + "): " + ex.Message)); } } } internal static class ReaperPatches { private static bool insideDamageCall; public static void DamagePrefix() { insideDamageCall = true; } public static void DamageFinalizer() { insideDamageCall = false; } public static void DurationPostfix(ref float __result) { __result = MonorReaperBalancePlugin.ModeDuration.Value; } public static void PayoutPostfix(ref int __result) { int value = MonorReaperBalancePlugin.MinOrbsPerHit.Value; if (__result > 0 && __result < value) { __result = value; } } public static bool ResetReaperPrefix(HeroController __instance) { if (insideDamageCall && MonorReaperBalancePlugin.PersistThroughHits.Value) { FieldRef reaperStateRef = MonorReaperBalancePlugin.ReaperStateRef; if (reaperStateRef != null) { ref ReaperCrestStateInfo reference = ref reaperStateRef.Invoke(__instance); if (!reference.IsInReaperMode) { return true; } float value = MonorReaperBalancePlugin.HitPenaltySeconds.Value; if (value > 0f) { reference.ReaperModeDurationLeft -= value; if (reference.ReaperModeDurationLeft <= 0f) { return true; } } return false; } } return true; } } }