Decompiled source of UniversalBlood v1.1.0

UniversalBlood.dll

Decompiled a month ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using Configgy;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("UniversalBlood")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("UniversalBlood")]
[assembly: AssemblyTitle("UniversalBlood")]
[assembly: AssemblyVersion("1.0.0.0")]
[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;
		}
	}
}
[BepInPlugin("UniversalBlood.adry.ultrakill", "Universal Blood", "1.1.1")]
public class UniversalBlood : BaseUnityPlugin
{
	[Configgable("Settings", "Enable Mod", 0, null)]
	private static ConfigToggle modEnabled = new ConfigToggle(true);

	[Configgable("Settings", "Health Regen Amount", 0, null)]
	private static ConfigInputField<int> healthRegenAmount = new ConfigInputField<int>(1, (Func<int, bool>)((int value) => value >= 1 && value <= 100), (Func<string, ValueTuple<bool, int>>)((string input) => (int.TryParse(input, out var result) && result >= 1 && result <= 100) ? (true, result) : (false, 0)));

	private float lastStylePoints;

	private const int MaxHealthThreshold = 100;

	private ConfigBuilder config;

	private void Awake()
	{
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Expected O, but got Unknown
		((BaseUnityPlugin)this).Logger.LogInfo((object)"[UniversalBlood] Mod initialized.");
		config = new ConfigBuilder("UniversalBlood.adry.ultrakill", "Universal Blood");
		config.BuildAll();
	}

	private void Update()
	{
		if (((ConfigValueElement<bool>)(object)modEnabled).Value)
		{
			DetectStylePointChanges();
		}
	}

	private void DetectStylePointChanges()
	{
		StatsManager instance = MonoSingleton<StatsManager>.Instance;
		if (!((Object)(object)instance == (Object)null))
		{
			float num = instance.stylePoints;
			if (num > lastStylePoints)
			{
				RegenerateHealth();
				((BaseUnityPlugin)this).Logger.LogInfo((object)$"[UniversalBlood] Style points increased. Healing player. Current: {num}");
			}
			lastStylePoints = num;
		}
	}

	private void RegenerateHealth()
	{
		NewMovement instance = MonoSingleton<NewMovement>.Instance;
		if ((Object)(object)instance != (Object)null && instance.hp > 0)
		{
			if (instance.hp >= 100)
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)$"[UniversalBlood] Player health is at or above the max threshold ({100}). No healing applied.");
				return;
			}
			int num = Mathf.Clamp(((ConfigValueElement<int>)(object)healthRegenAmount).Value, 1, 100);
			int num2 = Mathf.Min(num, 100 - instance.hp);
			instance.GetHealth(num2, false, false);
			((BaseUnityPlugin)this).Logger.LogInfo((object)$"[UniversalBlood] Player healed by {num2} HP. Current health: {instance.hp}");
		}
	}
}