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 RavagerNoSacrifice v1.0.0
plugins/RavagerNoSacrifice/RavagerNoSacrifice.dll
Decompiled 4 days 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; [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("RavagerNoSacrifice")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("RavagerNoSacrifice")] [assembly: AssemblyTitle("RavagerNoSacrifice")] [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 RavagerNoSacrifice { [BepInPlugin("com.youssef.RavagerNoSacrifice", "Ravager No Sacrifice", "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.RavagerNoSacrifice"; public const string Name = "Ravager No Sacrifice"; private static ConfigEntry<int> healthCost; private readonly Harmony harmony = new Harmony("com.youssef.RavagerNoSacrifice"); private void Awake() { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Expected O, but got Unknown healthCost = TweakSettings.Slider(((BaseUnityPlugin)this).Config, "Twisted Mutation", "Health cost percent", 0, 0, 10, "Maximum percent of full combined health spent on the charged aerial blink. Partial charge still costs proportionally less. Applies on the next blink.", "com.youssef.RavagerNoSacrifice", "Ravager No Sacrifice"); try { harmony.Patch((MethodBase)PatchTools.Method("RedGuyMod.SkillStates.Ravager.BlinkBig", "OnEnter"), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "ChangeHealthCost", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Twisted Mutation health-cost tweak loaded."); } catch (Exception arg) { harmony.UnpatchSelf(); ((BaseUnityPlugin)this).Logger.LogError((object)$"The Ravager tweak was not applied. The installed Ravager version may have changed.\n{arg}"); } } private void OnDestroy() { harmony.UnpatchSelf(); } private static float CostFraction() { return (float)healthCost.Value / 100f; } private static IEnumerable<CodeInstruction> ChangeHealthCost(IEnumerable<CodeInstruction> instructions) { return PatchTools.ReplaceFloat(instructions, 0.1f, AccessTools.Method(typeof(Plugin), "CostFraction", (Type[])null, (Type[])null)); } } } 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; } } }