using System;
using System.Collections.Generic;
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 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.5")]
public class BetterTumbleBase : BaseUnityPlugin
{
private const string modGUID = "prxphet.BetterTumble";
private const string modName = "Better Tumble";
private const string modVersion = "1.0.5";
private readonly Harmony harmony = new Harmony("prxphet.BetterTumble");
private static BetterTumbleBase Instance;
internal static ManualLogSource mls;
public static ConfigEntry<bool> NoSelfDamage;
public static ConfigEntry<int> DamageScale;
public static List<HurtCollider> PatchedColliders = new List<HurtCollider>();
private void Awake()
{
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Expected O, but got Unknown
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, new ConfigDescription("", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 100), Array.Empty<object>()));
harmony.PatchAll(typeof(BetterTumbleBase));
harmony.PatchAll(typeof(GameManagerPatch));
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 && !BetterTumbleBase.PatchedColliders.Contains(__instance) && Object.op_Implicit((Object)(object)((Component)__instance).GetComponentInParent<PlayerTumble>()))
{
__instance.enemyDamage *= BetterTumbleBase.DamageScale.Value;
BetterTumbleBase.PatchedColliders.Add(__instance);
}
}
}
[HarmonyPatch(typeof(PlayerTumble))]
internal class PlayerTumblePatch
{
[HarmonyPatch("HitEnemy")]
[HarmonyPrefix]
private static bool HitEnemyPrefix()
{
if (BetterTumbleBase.NoSelfDamage.Value)
{
return false;
}
return true;
}
}
[HarmonyPatch(typeof(GameManager))]
internal class GameManagerPatch
{
[HarmonyPatch("Awake")]
[HarmonyPrefix]
private static void Awake()
{
BetterTumbleBase.PatchedColliders.Clear();
}
}
}