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 DamageReduction v1.0.0
DamageReduction.dll
Decompiled 10 months agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("SkyLevelCooldown")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("SkyLevelCooldown")] [assembly: AssemblyCopyright("Copyright © 2025")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("74eb5aae-2b80-4e14-b616-24649964c125")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] [BepInPlugin("com.sky.silksong.damageoverride", "Silksong Damage Override", "1.0.0")] public class DamageReductionPlugin : BaseUnityPlugin { public const string PluginGUID = "com.sky.silksong.damageoverride"; public const string PluginName = "Silksong Damage Override"; public const string PluginVersion = "1.0.0"; private Harmony _harmony; internal static ConfigEntry<bool> Enabled; internal static ConfigEntry<int> DamageValue; internal static ConfigEntry<bool> OnlyPositive; internal static ManualLogSource Log; private void Awake() { //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Enable the damage override patch."); DamageValue = ((BaseUnityPlugin)this).Config.Bind<int>("General", "DamageValue", 1, "Damage value to force for all incoming damage (set to 1 to force every hit to do 1)."); OnlyPositive = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "OnlyWhenAmountPositive", true, "Only overwrite when incoming amount > 0 (prevents interfering with healing or zero-damage calls)."); _harmony = new Harmony("com.sky.silksong.damageoverride"); if (Enabled.Value) { try { _harmony.PatchAll(Assembly.GetExecutingAssembly()); Log.LogInfo((object)"Silksong Damage Override v1.0.0 - patches applied."); return; } catch (Exception arg) { Log.LogError((object)string.Format("{0} - PatchAll failed: {1}", "Silksong Damage Override", arg)); return; } } Log.LogInfo((object)"Silksong Damage Override is disabled via config."); } private void OnDestroy() { if (_harmony != null) { try { _harmony.UnpatchSelf(); Log.LogInfo((object)"Silksong Damage Override - patches removed."); } catch (Exception arg) { Log.LogWarning((object)string.Format("{0} - UnpatchSelf failed: {1}", "Silksong Damage Override", arg)); } } } } [HarmonyPatch] internal static class PlayerData_TakeHealth_Patch { private static MethodBase TargetMethod() { Type type = AccessTools.TypeByName("PlayerData"); if (type == null) { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { type = assembly.GetType("PlayerData"); if (type != null) { break; } } } if (type == null) { throw new Exception("PlayerData type not found. Make sure the game assembly has been loaded and the type is named 'PlayerData'."); } return AccessTools.Method(type, "TakeHealth", new Type[3] { typeof(int), typeof(bool), typeof(bool) }, (Type[])null); } private static bool Prefix(ref int amount) { try { if (DamageReductionPlugin.Enabled.Value && (!DamageReductionPlugin.OnlyPositive.Value || amount > 0)) { amount = DamageReductionPlugin.DamageValue.Value; DamageReductionPlugin.Log.LogDebug((object)$"[DamageOverride] Damage set to {DamageReductionPlugin.DamageValue.Value}."); } } catch (Exception arg) { DamageReductionPlugin.Log.LogError((object)$"[DamageOverride] Exception in Prefix: {arg}"); } return true; } }