using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
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("Repo_Training")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Repo_Training")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("edc661b0-040f-4e4d-9cd0-0701a92bb841")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Repo_Training;
[BepInPlugin("Wan7._Repo_Training", "Wan7_Repo_Training", "1.0.0")]
[BepInProcess("REPO.exe")]
public class Main : BaseUnityPlugin
{
internal static ManualLogSource Log;
private Harmony _harmony;
private void Awake()
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
Log = ((BaseUnityPlugin)this).Logger;
_harmony = new Harmony("Wan7.Repo_Training");
_harmony.PatchAll();
Log.LogInfo((object)"Wan7_Repo_Training 已加载");
}
}
[HarmonyPatch(typeof(PlayerController), "FixedUpdate")]
public static class Patch_CrouchStandHeal
{
private static readonly FieldRef<PlayerAvatar, bool> f_isLocal = AccessTools.FieldRefAccess<PlayerAvatar, bool>("isLocal");
private static readonly FieldRef<PlayerHealth, int> f_maxHealth = AccessTools.FieldRefAccess<PlayerHealth, int>("maxHealth");
private static readonly FieldRef<PlayerHealth, int> f_health = AccessTools.FieldRefAccess<PlayerHealth, int>("health");
private static bool wasCrouching = false;
private static void Prefix(PlayerController __instance)
{
if (!((Object)(object)__instance == (Object)null) && __instance.Crouching)
{
wasCrouching = true;
}
}
private static void Postfix(PlayerController __instance)
{
if ((Object)(object)__instance == (Object)null)
{
return;
}
PlayerAvatar playerAvatarScript = __instance.playerAvatarScript;
if ((Object)(object)playerAvatarScript == (Object)null || !f_isLocal.Invoke(playerAvatarScript) || !wasCrouching || __instance.Crouching)
{
return;
}
wasCrouching = false;
PlayerHealth playerHealth = playerAvatarScript.playerHealth;
if ((Object)(object)playerHealth == (Object)null || f_health.Invoke(playerHealth) >= f_maxHealth.Invoke(playerHealth))
{
return;
}
float energyStart = __instance.EnergyStart;
int num = Mathf.FloorToInt(energyStart * 0.2f);
if (__instance.EnergyCurrent < (float)num)
{
return;
}
__instance.EnergyCurrent -= (float)num;
if ((Object)(object)playerHealth != (Object)null)
{
int num2 = Mathf.Max(1, Mathf.FloorToInt((float)f_maxHealth.Invoke(playerHealth) * 0.01f));
if (num2 > 0)
{
playerHealth.Heal(num2, true);
}
}
}
}