using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using FistVR;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyCompany("Aiyke")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Configurable health regeneration.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("health_regen")]
[assembly: AssemblyTitle("BepInEx Plugin Title")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace BepInEx
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
internal sealed class BepInAutoPluginAttribute : Attribute
{
public BepInAutoPluginAttribute(string id = null, string name = null, string version = null)
{
}
}
}
namespace BepInEx.Preloader.Core.Patching
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
internal sealed class PatcherAutoPluginAttribute : Attribute
{
public PatcherAutoPluginAttribute(string id = null, string name = null, string version = null)
{
}
}
}
namespace plugin
{
[BepInPlugin("Aiyke.Regeneration", "Regenerating Health", "1.0.0")]
[BepInProcess("h3vr.exe")]
public class health_regen : BaseUnityPlugin
{
public static ConfigEntry<float> regen_rate;
public static ConfigEntry<float> regen_threshold;
internal static ManualLogSource Logger { get; private set; }
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
Logger.LogMessage((object)"health_regen active.");
regen_rate = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "regen_rate", 2f, "Amount of health restored per second.");
regen_threshold = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "regen_threshold", 0.25f, "The proportion of health below which it starts to regenerate.\nFor example: 0.25 = health regenerates when at 25% or less; 1.0 = health always regenerates.");
Harmony.CreateAndPatchAll(typeof(health_regen), (string)null);
}
private void Update()
{
Logger = ((BaseUnityPlugin)this).Logger;
}
[HarmonyPatch(typeof(FVRPlayerBody), "Update")]
[HarmonyPostfix]
private static void UpdatePlayerBody_postix(FVRPlayerBody __instance)
{
if (__instance.Health <= __instance.m_startingHealth * regen_threshold.Value)
{
__instance.Health += regen_rate.Value * Time.deltaTime;
}
}
}
}