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 E8BarrierAdjustment v1.0.1
plugins/E8BarrierAdjustment/E8BarrierAdjustment.dll
Decompiled 3 months agousing 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.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using E8BarrierAdjustment.Configuration; using IL.RoR2; using Microsoft.CodeAnalysis; using Mono.Cecil; using Mono.Cecil.Cil; using MonoMod.Cil; using R2API.Utils; using RiskOfOptions; using RiskOfOptions.OptionConfigs; using RiskOfOptions.Options; using RoR2; using Sandswept.Items.Greens; 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("E8BarrierAdjustment")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+97805441232e8c940e5824f6c9b63e966852611d")] [assembly: AssemblyProduct("E8BarrierAdjustment")] [assembly: AssemblyTitle("E8BarrierAdjustment")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.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 E8BarrierAdjustment { public class Compat { private static bool? _sandswept; private static bool? _riskOfOptions; public static bool Sandswept { get { if (!_sandswept.HasValue) { _sandswept = Chainloader.PluginInfos.ContainsKey("com.TeamSandswept.Sandswept"); } return _sandswept.Value; } } public static bool RiskOfOptions { get { if (!_riskOfOptions.HasValue) { _riskOfOptions = Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions"); } return _riskOfOptions.Value; } } } internal static class Log { private static ManualLogSource _logSource; internal static void Init(ManualLogSource logSource) { _logSource = logSource; } internal static void Debug(object data) { _logSource.LogDebug(data); } internal static void Error(object data) { _logSource.LogError(data); } internal static void Fatal(object data) { _logSource.LogFatal(data); } internal static void Info(object data) { _logSource.LogInfo(data); } internal static void Message(object data) { _logSource.LogMessage(data); } internal static void Warning(object data) { _logSource.LogWarning(data); } } [BepInPlugin("com.Hex3.E8BarrierAdjustment", "E8BarrierAdjustment", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public class Main : BaseUnityPlugin { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static Func<Instruction, bool> <>9__5_1; public static Func<Instruction, bool> <>9__5_2; public static Func<Instruction, bool> <>9__5_3; public static Func<Instruction, bool> <>9__5_4; public static Func<Instruction, bool> <>9__5_5; public static Func<HealthComponent, float> <>9__5_6; public static Manipulator <>9__5_0; internal void <Awake>b__5_0(ILContext il) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); val.TryGotoNext(new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(Buffs), "PermanentCurse") }); MethodReference val2 = default(MethodReference); float num = default(float); if (val.TryGotoPrev(new Func<Instruction, bool>[4] { (Instruction x) => ILPatternMatchingExt.MatchCall(x, ref val2), (Instruction x) => ILPatternMatchingExt.MatchDiv(x), (Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, ref num), (Instruction x) => ILPatternMatchingExt.MatchMul(x) })) { val.Index += 4; val.Emit(OpCodes.Ldarg, 0); val.EmitDelegate<Func<HealthComponent, float>>((Func<HealthComponent, float>)((HealthComponent hc) => SubtractOverhealth(hc))); val.Emit(OpCodes.Sub); } else { Log.Error("IL hook failed for barrier decay adjustment."); } } internal bool <Awake>b__5_1(Instruction x) { return ILPatternMatchingExt.MatchLdsfld(x, typeof(Buffs), "PermanentCurse"); } internal bool <Awake>b__5_2(Instruction x) { MethodReference val = default(MethodReference); return ILPatternMatchingExt.MatchCall(x, ref val); } internal bool <Awake>b__5_3(Instruction x) { return ILPatternMatchingExt.MatchDiv(x); } internal bool <Awake>b__5_4(Instruction x) { float num = default(float); return ILPatternMatchingExt.MatchLdcR4(x, ref num); } internal bool <Awake>b__5_5(Instruction x) { return ILPatternMatchingExt.MatchMul(x); } internal float <Awake>b__5_6(HealthComponent hc) { return SubtractOverhealth(hc); } } public const string E8BARRIERADJUSTMENT_GUID = "com.Hex3.E8BarrierAdjustment"; public const string E8BARRIERADJUSTMENT_NAME = "E8BarrierAdjustment"; public const string E8BARRIERADJUSTMENT_VER = "1.0.0"; public static Main Instance; public static ConfigOptions configOptions; public void Awake() { //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown Log.Init(((BaseUnityPlugin)this).Logger); Log.Info("Init E8BarrierAdjustment 1.0.0"); Instance = this; Log.Info("Creating config..."); configOptions = new ConfigOptions(); if (Compat.RiskOfOptions) { Log.Info("Detected RiskOfOptions"); ModSettingsManager.SetModDescription("Prevents Eclipse 8 curse when damage is blocked by temporary barrier. Includes support for Sandswept's temporary plating."); } Log.Info("Creating hooks..."); object obj = <>c.<>9__5_0; if (obj == null) { Manipulator val = delegate(ILContext il) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) ILCursor val2 = new ILCursor(il); val2.TryGotoNext(new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(Buffs), "PermanentCurse") }); MethodReference val3 = default(MethodReference); float num = default(float); if (val2.TryGotoPrev(new Func<Instruction, bool>[4] { (Instruction x) => ILPatternMatchingExt.MatchCall(x, ref val3), (Instruction x) => ILPatternMatchingExt.MatchDiv(x), (Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, ref num), (Instruction x) => ILPatternMatchingExt.MatchMul(x) })) { val2.Index += 4; val2.Emit(OpCodes.Ldarg, 0); val2.EmitDelegate<Func<HealthComponent, float>>((Func<HealthComponent, float>)((HealthComponent hc) => SubtractOverhealth(hc))); val2.Emit(OpCodes.Sub); } else { Log.Error("IL hook failed for barrier decay adjustment."); } }; <>c.<>9__5_0 = val; obj = (object)val; } HealthComponent.TakeDamageProcess += (Manipulator)obj; Log.Info("Done"); } public static float SubtractOverhealth(HealthComponent healthComponent) { float num = 0f; if (configOptions.Barrier_Enabled.Value) { num += healthComponent.barrier; } if (configOptions.Plating_Enabled.Value && Compat.Sandswept && Object.op_Implicit((Object)(object)healthComponent.body) && Object.op_Implicit((Object)(object)healthComponent.body.master) && Object.op_Implicit((Object)(object)healthComponent.body.master.bodyInstanceObject)) { CharacterMaster master = healthComponent.body.master; PlatingManager component = master.bodyInstanceObject.GetComponent<PlatingManager>(); if (Object.op_Implicit((Object)(object)component)) { num += component.CurrentPlating; } } return num; } } } namespace E8BarrierAdjustment.Configuration { public class ConfigItem<T> { private ConfigEntry<T> configEntry; private readonly string header; private readonly string name; private readonly string desc; private readonly T defaultValue; private readonly float minValue; private readonly float maxValue; private readonly float increment; public T Value => configEntry.Value; public Type Type => typeof(T); public ConfigItem(string _header, string _name, string _desc, T _defaultValue, float _minValue = float.MinValue, float _maxValue = float.MinValue, float _increment = float.MinValue) { header = _header; name = _name; desc = _desc; defaultValue = _defaultValue; minValue = _minValue; maxValue = _maxValue; increment = _increment; InitConfigItem(); } public void InitConfigItem() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_0039: Expected O, but got Unknown //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Expected O, but got Unknown //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Expected O, but got Unknown //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Expected O, but got Unknown //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Expected O, but got Unknown //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Expected O, but got Unknown configEntry = ((BaseUnityPlugin)Main.Instance).Config.Bind<T>(new ConfigDefinition(header, name), defaultValue, new ConfigDescription(desc, (AcceptableValueBase)null, Array.Empty<object>())); if (Compat.RiskOfOptions) { if (Type == typeof(bool)) { ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(configEntry as ConfigEntry<bool>, true)); } else if (Type == typeof(string)) { ModSettingsManager.AddOption((BaseOption)new StringInputFieldOption(configEntry as ConfigEntry<string>, true)); } else if (Type == typeof(int)) { int num = Convert.ToInt32(defaultValue); float num2 = ((minValue == float.MinValue) ? 0f : minValue); float num3 = ((maxValue == float.MinValue) ? ((float)num * 10f) : maxValue); ModSettingsManager.AddOption((BaseOption)new IntSliderOption(configEntry as ConfigEntry<int>, new IntSliderConfig { min = (int)num2, max = (int)num3, restartRequired = true })); } else if (Type == typeof(float)) { float num4 = Convert.ToSingle(defaultValue); float min = ((minValue == float.MinValue) ? 0f : minValue); float max = ((maxValue == float.MinValue) ? (num4 * 10f) : maxValue); float num5 = ((increment == float.MinValue) ? (num4 / 10f) : increment); ModSettingsManager.AddOption((BaseOption)new StepSliderOption(configEntry as ConfigEntry<float>, new StepSliderConfig { min = min, max = max, increment = num5, restartRequired = true })); } } } } public class ConfigOptions { public ConfigItem<bool> Barrier_Enabled = new ConfigItem<bool>("Enable mechanics", "Barrier curse prevention", "Taking hits to temporary barrier no longer inflicts Eclipse 8 curse.", _defaultValue: true); public ConfigItem<bool> Plating_Enabled = new ConfigItem<bool>("Enable mechanics", "Sandswept: Plating curse prevention", "Taking hits to Makeshift Plating's temporary health no longer inflicts Eclipse 8 curse.", _defaultValue: true); } }