Decompiled source of DeathStatus v1.1.0

BepInEx/plugins/DeathStatus.dll

Decompiled 6 months ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using DeathStatus.Patches;
using HarmonyLib;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("DeathStatus")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("DeathStatus")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("36ce61e9-a4d5-4aed-b5f8-c2f7879eb3be")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace DeathStatus
{
	[BepInPlugin("DeathStatus", "Death Status", "1.1.0")]
	[ContentWarningPlugin("DeathStatus", "1.1.0", true)]
	public class PluginBase : BaseUnityPlugin
	{
		private const string PLUGIN_GUID = "DeathStatus";

		private const string PLUGIN_NAME = "Death Status";

		private const string PLUGIN_VERSION = "1.1.0";

		public static PluginBase Instance;

		internal ManualLogSource logger;

		private Harmony harmony;

		private void Awake()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
				logger = Logger.CreateLogSource("DeathStatus");
				harmony = new Harmony("DeathStatus");
				harmony.PatchAll(typeof(DivingBellSuitCellUIPatches));
				logger.LogInfo((object)"Plugin DeathStatus is loaded!");
			}
		}
	}
}
namespace DeathStatus.Patches
{
	[HarmonyPatch(typeof(DivingBellSuitCellUI))]
	public class DivingBellSuitCellUIPatches
	{
		public static Color greenColor = new Color(0.4f, 0.84f, 0.313f, 1f);

		public static Color redColor = new Color(0.8f, 0.2f, 0.2f, 1f);

		[HarmonyPostfix]
		[HarmonyPatch("Set")]
		public static void SetPostfix(DivingBellSuitCellUI __instance, Player player)
		{
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)player != (Object)null) || player.data == null)
			{
				return;
			}
			if (player.data.dead || player.data.health < 0f)
			{
				Image[] componentsInChildren = ((Component)__instance).GetComponentsInChildren<Image>(true);
				foreach (Image val in componentsInChildren)
				{
					if (Mathf.Abs(((Graphic)val).color.g - 0.84f) < 0.082f)
					{
						((Graphic)val).color = redColor;
					}
				}
				return;
			}
			Image[] componentsInChildren2 = ((Component)__instance).GetComponentsInChildren<Image>(true);
			foreach (Image val2 in componentsInChildren2)
			{
				if (Mathf.Abs(((Graphic)val2).color.r - 0.8f) < 0.78f)
				{
					((Graphic)val2).color = greenColor;
				}
			}
		}
	}
}