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 HarmonyLib;
using ScalingTumbleLaunch.Patches;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("ScalingTumbleLaunch")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ScalingTumbleLaunch")]
[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 ScalingTumbleLaunch
{
[BepInPlugin("sirinfinity.ScalingTumbleLaunch", "Scaling Tumble Launch", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class ScalingTumbleLaunchBase : BaseUnityPlugin
{
private const string modGUID = "sirinfinity.ScalingTumbleLaunch";
private const string modName = "Better Tumble";
private const string modVersion = "1.0.5";
private readonly Harmony harmony = new Harmony("sirinfinity.ScalingTumbleLaunch");
private static ScalingTumbleLaunchBase Instance;
internal static ManualLogSource mls;
public static ConfigEntry<bool> NoSelfDamage;
public static ConfigEntry<float> DamageScale;
public static List<HurtCollider> PatchedColliders = new List<HurtCollider>();
private void Awake()
{
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Expected O, but got Unknown
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
mls = Logger.CreateLogSource("sirinfinity.ScalingTumbleLaunch");
mls.LogInfo((object)"ScalingTumbleLaunch is active");
NoSelfDamage = ((BaseUnityPlugin)this).Config.Bind<bool>("Gameplay", "Disable self-damage", true, (ConfigDescription)null);
DamageScale = ((BaseUnityPlugin)this).Config.Bind<float>("Gameplay", "Damage scale", 1.2f, new ConfigDescription("Adjusts the damage scaling factor", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 10f), Array.Empty<object>()));
harmony.PatchAll(typeof(ScalingTumbleLaunchBase));
harmony.PatchAll(typeof(PlayerTumblePatch));
harmony.PatchAll(typeof(HurtColliderPatch));
}
}
}
namespace ScalingTumbleLaunch.Patches
{
[HarmonyPatch(typeof(HurtCollider))]
internal class HurtColliderPatch
{
public class ModifiedDamage : MonoBehaviour
{
public int baseDamage;
}
[HarmonyPatch("EnemyHurt")]
[HarmonyPrefix]
private static void EnemyHurtPrefix(HurtCollider __instance)
{
int num = 0;
PlayerTumble componentInParent = ((Component)__instance).GetComponentInParent<PlayerTumble>();
if ((Object)(object)componentInParent != (Object)null)
{
PlayerAvatar playerAvatar = componentInParent.playerAvatar;
if ((Object)(object)playerAvatar != (Object)null)
{
string key = SemiFunc.PlayerGetSteamID(playerAvatar);
if ((Object)(object)StatsManager.instance != (Object)null && StatsManager.instance.playerUpgradeLaunch != null && StatsManager.instance.playerUpgradeLaunch.TryGetValue(key, out var value))
{
num = value;
}
}
}
ModifiedDamage modifiedDamage = default(ModifiedDamage);
if (!((Component)__instance).TryGetComponent<ModifiedDamage>(ref modifiedDamage))
{
modifiedDamage = ((Component)__instance).gameObject.AddComponent<ModifiedDamage>();
modifiedDamage.baseDamage = __instance.enemyDamage;
}
if (__instance.enemyDamage > 0 && Object.op_Implicit((Object)(object)((Component)__instance).GetComponentInParent<PlayerTumble>()))
{
__instance.enemyDamage = Mathf.RoundToInt((float)modifiedDamage.baseDamage * ScalingTumbleLaunchBase.DamageScale.Value * (float)((num <= 0) ? 1 : num));
ScalingTumbleLaunchBase.PatchedColliders.Add(__instance);
}
}
}
[HarmonyPatch(typeof(PlayerTumble))]
internal class PlayerTumblePatch
{
[HarmonyPatch("HitEnemy")]
[HarmonyPrefix]
private static bool HitEnemyPrefix()
{
if (ScalingTumbleLaunchBase.NoSelfDamage.Value)
{
return false;
}
return true;
}
}
}