using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using FullHPSprint.Patches;
using GameNetcodeStuff;
using HarmonyLib;
using Unity.Netcode;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("FullHPSprint")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("FullHPSprint")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("0881498b-da41-4e5e-9cdb-ca173ed6881f")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
[HarmonyPatch(typeof(NetworkManager))]
internal static class NetworkPrefabPatch2
{
private static readonly string MOD_GUID = "EventhorizonHeve.FullHPSprint";
[HarmonyPostfix]
[HarmonyPatch("SetSingleton")]
private static void RegisterPrefab()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Expected O, but got Unknown
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject(MOD_GUID + " Prefab");
((Object)val).hideFlags = (HideFlags)(((Object)val).hideFlags | 0x3D);
Object.DontDestroyOnLoad((Object)(object)val);
NetworkObject obj = val.AddComponent<NetworkObject>();
FieldInfo field = typeof(NetworkObject).GetField("GlobalObjectIdHash", BindingFlags.Instance | BindingFlags.NonPublic);
field.SetValue(obj, GetHash(MOD_GUID));
NetworkManager.Singleton.PrefabHandler.AddNetworkPrefab(val);
static uint GetHash(string value)
{
return value?.Aggregate(17u, (uint current, char c) => (current * 31) ^ c) ?? 0;
}
}
}
namespace FullHPSprint
{
[BepInPlugin("EventhorizonHeve.FullHPSprint", "FullHPSprint", "1.1.9")]
public class FullHPSprintModBase : BaseUnityPlugin
{
public const string modGUID = "EventhorizonHeve.FullHPSprint";
private const string modName = "FullHPSprint";
private const string modVersion = "1.1.9";
private readonly Harmony harmony = new Harmony("EventhorizonHeve.FullHPSprint");
private static FullHPSprintModBase Instance;
internal ManualLogSource mls;
public static ConfigEntry<bool> InfiniteSprint { get; set; }
public static ConfigEntry<float> SprintMultiplier { get; set; }
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
mls = Logger.CreateLogSource("EventhorizonHeve.FullHPSprint");
mls.LogInfo((object)"Useless awake log from: FullHPSprint");
_bind_config();
harmony.PatchAll(typeof(FullHPSprintModBase));
harmony.PatchAll(typeof(PlayerControllerBPatch));
harmony.PatchAll(typeof(NetworkPrefabPatch2));
}
private void _bind_config()
{
InfiniteSprint = ((BaseUnityPlugin)this).Config.Bind<bool>("Sprint Settings", "Infinite Sprint", true, "Gives Infinite Sprint when on Full HP. Overrides the other setting!");
SprintMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Sprint Settings", "Sprint Multiplier", 0.001f, "How many times FASTER the sprint will drain when on full HP! There is a limit to how slow it can drain, not sure what to do against that :/");
}
}
}
namespace FullHPSprint.Patches
{
[HarmonyPatch(typeof(PlayerControllerB))]
internal class PlayerControllerBPatch
{
private static float newStaminaMeter;
[HarmonyPatch("Update")]
[HarmonyPrefix]
private static void UpdatePrefix(ref float ___sprintMeter)
{
newStaminaMeter = ___sprintMeter;
}
[HarmonyPatch("Update")]
[HarmonyPostfix]
private static void UpdatePatch(PlayerControllerB __instance, ref float ___sprintMeter, ref int ___health, ref float ___sprintTime, ref float ___carryWeight, ref bool ___isSprinting, ref float ___drunkness)
{
if (!((NetworkBehaviour)__instance).IsOwner)
{
return;
}
if (___isSprinting && ___health >= 100 && !FullHPSprintModBase.InfiniteSprint.Value)
{
float num = 1f;
if (___drunkness > 0.02f && (Object)(object)StartOfRound.Instance != (Object)null && StartOfRound.Instance.drunknessSpeedEffect != null)
{
num *= Mathf.Abs(StartOfRound.Instance.drunknessSpeedEffect.Evaluate(___drunkness) - 1.25f);
}
newStaminaMeter = Mathf.Clamp(newStaminaMeter - Time.deltaTime / ___sprintTime * ___carryWeight * num * FullHPSprintModBase.SprintMultiplier.Value, 0f, 1f);
___sprintMeter = newStaminaMeter;
}
else if (FullHPSprintModBase.InfiniteSprint.Value && ___health >= 100)
{
___sprintMeter = 1f;
}
}
}
}