Decompiled source of YouCanHeal v1.0.3

YouCanHeal.dll

Decompiled 2 weeks ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyVersion("0.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 YouCanHeal
{
	[BepInPlugin("dralfredo.YouCanHeal", "You Can Heal (dr. alfredo)", "1.0.3")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ConfigEntry<float> PercentPerTick;

		internal static ConfigEntry<float> TickSeconds;

		internal static ConfigEntry<float> CooldownAfterHit;

		internal static ConfigEntry<bool> OnlyWhileConscious;

		private void Awake()
		{
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			PercentPerTick = ((BaseUnityPlugin)this).Config.Bind<float>("General", "PercentPerTick", 1f, "How much Injury (in %) is healed per tick.");
			TickSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("General", "TickSeconds", 60f, "Seconds between healing ticks.");
			CooldownAfterHit = ((BaseUnityPlugin)this).Config.Bind<float>("General", "CooldownAfterHit", 10f, "Seconds without healing after taking a new injury.");
			OnlyWhileConscious = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "OnlyWhileConscious", true, "If true, no healing while passed out.");
			new Harmony("dralfredo.YouCanHeal").PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)$"You Can Heal loaded: {PercentPerTick.Value}% every {TickSeconds.Value}s");
		}
	}
	[HarmonyPatch(typeof(CharacterAfflictions), "UpdateNormalStatuses")]
	internal static class UpdateNormalStatusesPatch
	{
		private static void Postfix(CharacterAfflictions __instance)
		{
			Character character = __instance.character;
			if (!((Object)(object)character == (Object)null) && character.IsLocal && (!Plugin.OnlyWhileConscious.Value || character.data.fullyConscious) && !(__instance.GetCurrentStatus((STATUSTYPE)0) <= 0f) && !(Time.time - __instance.LastAddedStatus((STATUSTYPE)0) < Plugin.CooldownAfterHit.Value))
			{
				float num = Plugin.PercentPerTick.Value / 100f / Mathf.Max(1f, Plugin.TickSeconds.Value);
				__instance.SubtractStatus((STATUSTYPE)0, num * Time.deltaTime, false, true);
			}
		}
	}
}