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 GameNetcodeStuff;
using HarmonyLib;
using Patch;
using RunForYourLife;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyDescription("When you use more stamina than you have, you lose life instead.")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e279d7a9-7f26-4825-af0f-1b827a9f7ab5")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace RunForYourLife
{
internal class RFYLConfig
{
public static ConfigEntry<float> baseStamina;
public static ConfigEntry<int> damageMagnitude;
public static ConfigEntry<float> damageInterval;
public static ConfigEntry<bool> isFatal;
public static void Setup()
{
baseStamina = Plugin.Instance.Config.Bind<float>("Stamina", "BaseStamina", 1f, "How much stamina the player has before taking damage.");
damageMagnitude = Plugin.Instance.Config.Bind<int>("Damage", "DamageMagnitude", 10, "The amount of damage taken per tick of damage.");
damageInterval = Plugin.Instance.Config.Bind<float>("Damage", "DamageFrequency", 0.1f, "How much stamina taken to cause one tick of damage.");
isFatal = Plugin.Instance.Config.Bind<bool>("Damage", "IsFatal", true, "Whether you can die from oversprinting. Otherwise it'll stop when hitting critical health.");
}
}
[BepInPlugin("RunForYourLife", "Run For Your Life", "0.1")]
public class Plugin : BaseUnityPlugin
{
private const string PLUGIN_GUID = "RunForYourLife";
private const string PLUGIN_NAME = "Run For Your Life";
private const string PLUGIN_VERSION = "0.1";
private readonly Harmony harmony = new Harmony("RunForYourLife");
internal static ManualLogSource mls;
public static BaseUnityPlugin Instance { get; private set; }
private void Awake()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Expected O, but got Unknown
if ((Object)Instance == (Object)null)
{
Instance = (BaseUnityPlugin)this;
}
mls = Logger.CreateLogSource("RunForYourLife");
mls.LogInfo((object)"Loaded Run For Your Life");
RFYLConfig.Setup();
harmony.PatchAll(typeof(PlayerControllerBPatch));
}
}
}
namespace Patch
{
[HarmonyPatch(typeof(PlayerControllerB))]
internal class PlayerControllerBPatch
{
[HarmonyPatch("Update")]
[HarmonyPostfix]
private static void overStamina(ref float ___sprintMeter, ref bool ___isSprinting, ref bool ___isExhausted)
{
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
if (!((___sprintMeter <= RFYLConfig.damageInterval.Value + 0.1f) & ___isSprinting))
{
return;
}
if (!localPlayerController.isPlayerDead && localPlayerController.isPlayerControlled)
{
if (localPlayerController.health <= RFYLConfig.damageMagnitude.Value && RFYLConfig.isFatal.Value)
{
localPlayerController.KillPlayer(default(Vector3), true, (CauseOfDeath)0, 0, default(Vector3));
}
else
{
localPlayerController.DamagePlayer(RFYLConfig.damageMagnitude.Value, false, true, (CauseOfDeath)0, 0, false, default(Vector3));
if (RFYLConfig.isFatal.Value)
{
localPlayerController.MakeCriticallyInjured(false);
}
}
}
___sprintMeter += RFYLConfig.damageInterval.Value;
___isExhausted = true;
}
}
}