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 BetterTumble.Patches;
using HarmonyLib;
using REPOConfig;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("BetterTumble")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BetterTumble")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("badd1d9d-fcf5-4063-9e9e-7230de898e99")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace BetterTumble
{
[BepInPlugin("prxphet.BetterTumble", "Better Tumble", "1.0")]
public class BetterTumbleBase : BaseUnityPlugin
{
private const string modGUID = "prxphet.BetterTumble";
private const string modName = "Better Tumble";
private const string modVersion = "1.0";
private readonly Harmony harmony = new Harmony("prxphet.BetterTumble");
private static BetterTumbleBase Instance;
internal static ManualLogSource mls;
[REPOConfigEntry("Disable self-damage")]
public static ConfigEntry<bool> NoSelfDamage;
[REPOConfigEntry("Damage scale", 1, 100, "", "")]
public static ConfigEntry<int> DamageScale;
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
mls = Logger.CreateLogSource("prxphet.BetterTumble");
mls.LogInfo((object)"BetterTumble is active");
NoSelfDamage = ((BaseUnityPlugin)this).Config.Bind<bool>("Gameplay", "Disable self-damage", true, (ConfigDescription)null);
DamageScale = ((BaseUnityPlugin)this).Config.Bind<int>("Gameplay", "Damage scale", 3, (ConfigDescription)null);
harmony.PatchAll(typeof(BetterTumbleBase));
harmony.PatchAll(typeof(PlayerTumblePatch));
harmony.PatchAll(typeof(HurtColliderPatch));
}
}
}
namespace BetterTumble.Patches
{
[HarmonyPatch(typeof(HurtCollider))]
internal class HurtColliderPatch
{
[HarmonyPatch("EnemyHurt")]
[HarmonyPrefix]
private static void EnemyHurtPrefix(HurtCollider __instance)
{
if (__instance.enemyDamage > 0 && Object.op_Implicit((Object)(object)((Component)__instance).GetComponentInParent<PlayerTumble>()))
{
__instance.enemyDamage *= BetterTumbleBase.DamageScale.Value;
}
}
}
[HarmonyPatch(typeof(PlayerTumble))]
internal class PlayerTumblePatch
{
[HarmonyPatch("HitEnemy")]
[HarmonyPrefix]
private static bool HitEnemyPrefix()
{
if (BetterTumbleBase.NoSelfDamage.Value)
{
return false;
}
return true;
}
}
}