Decompiled source of Colored Food UI v0.1.1

plugins/ColoredFoodUI.dll

Decompiled 6 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8.1", FrameworkDisplayName = ".NET Framework 4.8.1")]
[assembly: AssemblyCompany("ColoredFoodUI")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.1.0")]
[assembly: AssemblyInformationalVersion("0.1.1+1aafe5c5482c968ad2aec4e616019dd09daa0128")]
[assembly: AssemblyProduct("ColoredFoodUI")]
[assembly: AssemblyTitle("ColoredFoodUI")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.1.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 ColoredFoodUI
{
	public class Patches
	{
		private const float Alpha = 0.503f;

		private static Color s_healthColor;

		private static Color s_staminaColor;

		private static Color s_eitrColor;

		private static Color s_mixedColor;

		private static Color s_defaultColor;

		private static Color InitializeColor(Color color, float alpha = 0.503f)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			return new Color(color.r, color.g, color.b, alpha);
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(InventoryGui), "Awake")]
		private static void InitializeColors(InventoryGui __instance)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			s_healthColor = InitializeColor(__instance.m_playerGrid.m_foodHealthColor);
			s_staminaColor = InitializeColor(__instance.m_playerGrid.m_foodStaminaColor);
			s_eitrColor = InitializeColor(__instance.m_playerGrid.m_foodEitrColor);
			s_mixedColor = InitializeColor(Color.white);
			s_defaultColor = InitializeColor(Color.black);
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Hud), "UpdateFood")]
		private static void UpdateFood(Hud __instance, Player player)
		{
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			List<Food> foods = player.GetFoods();
			Image[] foodIcons = __instance.m_foodIcons;
			for (int i = 0; i < foodIcons.Length; i++)
			{
				Image component = ((Component)((Component)foodIcons[i]).transform.parent).gameObject.GetComponent<Image>();
				if (i < foods.Count)
				{
					Food val = foods[i];
					if (val != null)
					{
						if (val.m_eitr / 2f > val.m_health && val.m_eitr / 2f > val.m_stamina)
						{
							((Graphic)component).color = s_eitrColor;
						}
						else if (val.m_health / 2f > val.m_stamina)
						{
							((Graphic)component).color = s_healthColor;
						}
						else if (val.m_stamina / 2f > val.m_health)
						{
							((Graphic)component).color = s_staminaColor;
						}
						else
						{
							((Graphic)component).color = s_mixedColor;
						}
						continue;
					}
				}
				((Graphic)component).color = s_defaultColor;
			}
		}
	}
	[BepInPlugin("nbusseneau.ColoredFoodUI", "ColoredFoodUI", "0.1.1")]
	public class Plugin : BaseUnityPlugin
	{
		private const string ModGUID = "nbusseneau.ColoredFoodUI";

		private const string ModName = "ColoredFoodUI";

		private const string ModVersion = "0.1.1";

		public void Awake()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			new Harmony("nbusseneau.ColoredFoodUI").PatchAll(typeof(Patches));
		}
	}
}