using System; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("FistDamage")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Azumatt")] [assembly: AssemblyProduct("FistDamage")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("61A0A78C-E8A5-47D1-8DBE-E60D3D698B4C")] [assembly: AssemblyFileVersion("1.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.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 FistDamage { [BepInPlugin("Azumatt.FistDamage", "FistDamage", "1.0.0")] public class FistDamagePlugin : BaseUnityPlugin { public enum Toggle { On = 1, Off = 0 } internal const string ModName = "FistDamage"; internal const string ModVersion = "1.0.0"; internal const string Author = "Azumatt"; internal const string ModGUID = "Azumatt.FistDamage"; private const string ConfigFileName = "Azumatt.FistDamage.cfg"; private static readonly string ConfigFileFullPath; internal static readonly ManualLogSource FistDamageLogger; private readonly Harmony harmony = new Harmony("Azumatt.FistDamage"); internal static ConfigEntry modEnabled; internal static ConfigEntry fistDamage; internal static ConfigEntry fistRange; internal static ConfigEntry fistHitRadius; internal static ConfigEntry fistForce; internal static ConfigEntry fistHitOffsetDist; internal static bool IsEnabled { get { ConfigEntry val = modEnabled; if (val != null) { return val.Value == Toggle.On; } return false; } } public void Awake() { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Expected O, but got Unknown //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Expected O, but got Unknown //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Expected O, but got Unknown bool saveOnConfigSet = ((BaseUnityPlugin)this).Config.SaveOnConfigSet; ((BaseUnityPlugin)this).Config.SaveOnConfigSet = false; modEnabled = config("1 - General", "Enabled", Toggle.On, "Turn the whole mod off without unloading it."); fistDamage = config("2 - Fists", "Damage", 3, new ConfigDescription("Damage a punch deals. Vanilla is 3.", (AcceptableValueBase)(object)new AcceptableValueRange(0, 99999), Array.Empty())); fistRange = config("2 - Fists", "Range", 1.5f, new ConfigDescription("How far a punch reaches. Vanilla is 1.5.", (AcceptableValueBase)(object)new AcceptableValueRange(0.1f, 20f), Array.Empty())); fistHitRadius = config("2 - Fists", "Hit Radius", 0.5f, new ConfigDescription("Spherecast radius used to find an item to punch. Vanilla is 0.5.", (AcceptableValueBase)(object)new AcceptableValueRange(0.01f, 5f), Array.Empty())); fistForce = config("2 - Fists", "Force", 100f, new ConfigDescription("Push applied to a punched item. Vanilla is 100.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 5000f), Array.Empty())); fistHitOffsetDist = config("2 - Fists", "Hit Offset Distance", 0.15f, new ConfigDescription("Pulls the hit point back toward you to keep the fist out of whatever it hit. Vanilla is 0.15.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 2f), Array.Empty())); Assembly executingAssembly = Assembly.GetExecutingAssembly(); harmony.PatchAll(executingAssembly); SetupWatcher(); if (saveOnConfigSet) { ((BaseUnityPlugin)this).Config.SaveOnConfigSet = saveOnConfigSet; ((BaseUnityPlugin)this).Config.Save(); } } private void OnDestroy() { ((BaseUnityPlugin)this).Config.Save(); } private void SetupWatcher() { FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(Paths.ConfigPath, "Azumatt.FistDamage.cfg"); fileSystemWatcher.Changed += ReadConfigValues; fileSystemWatcher.Created += ReadConfigValues; fileSystemWatcher.Renamed += ReadConfigValues; fileSystemWatcher.IncludeSubdirectories = true; fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject; fileSystemWatcher.EnableRaisingEvents = true; } private void ReadConfigValues(object sender, FileSystemEventArgs e) { if (!File.Exists(ConfigFileFullPath)) { return; } try { ((BaseUnityPlugin)this).Config.Reload(); } catch { FistDamageLogger.LogError((object)"There was an issue loading your Azumatt.FistDamage.cfg"); FistDamageLogger.LogError((object)"Please check your config entries for spelling and format!"); } } private ConfigEntry config(string group, string name, T value, ConfigDescription description) { return ((BaseUnityPlugin)this).Config.Bind(group, name, value, description); } private ConfigEntry config(string group, string name, T value, string description) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown return config(group, name, value, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty())); } static FistDamagePlugin() { string configPath = Paths.ConfigPath; char directorySeparatorChar = Path.DirectorySeparatorChar; ConfigFileFullPath = configPath + directorySeparatorChar + "Azumatt.FistDamage.cfg"; FistDamageLogger = Logger.CreateLogSource("FistDamage"); modEnabled = null; fistDamage = null; fistRange = null; fistHitRadius = null; fistForce = null; fistHitOffsetDist = null; } } public static class Patches { [HarmonyPatch(typeof(PlayerPunching), "FindPunchTarget")] private static class OverridePunchingValues { private static void Prefix(PlayerPunching __instance) { if (!vanillaCached) { vanillaDamage = __instance._damage; vanillaRange = __instance._range; vanillaHitRadius = __instance._hitRadius; vanillaForce = __instance._force; vanillaHitOffsetDist = __instance._hitOffsetDist; vanillaCached = true; } if (!FistDamagePlugin.IsEnabled) { __instance._damage = vanillaDamage; __instance._range = vanillaRange; __instance._hitRadius = vanillaHitRadius; __instance._force = vanillaForce; __instance._hitOffsetDist = vanillaHitOffsetDist; } else { __instance._damage = FistDamagePlugin.fistDamage.Value; __instance._range = FistDamagePlugin.fistRange.Value; __instance._hitRadius = FistDamagePlugin.fistHitRadius.Value; __instance._force = FistDamagePlugin.fistForce.Value; __instance._hitOffsetDist = FistDamagePlugin.fistHitOffsetDist.Value; } } } private static bool vanillaCached; private static int vanillaDamage; private static float vanillaRange; private static float vanillaHitRadius; private static float vanillaForce; private static float vanillaHitOffsetDist; } }