Decompiled source of AlternateHealthbars v1.0.0

Mods/AlternateHealthbars.dll

Decompiled 5 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using AlternateHealthbars;
using HarmonyLib;
using Il2CppRUMBLE.Managers;
using Il2CppRUMBLE.Players;
using Il2CppRUMBLE.Utilities;
using Il2CppSystem.Collections.Generic;
using Il2CppTMPro;
using MelonLoader;
using RumbleModUI;
using RumbleModdingAPI;
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: MelonInfo(typeof(Main), "AlternateHealthbars", "1.0.0", "UlvakSkillz", null)]
[assembly: MelonGame("Buckethead Entertainment", "RUMBLE")]
[assembly: MelonColor(255, 195, 0, 255)]
[assembly: MelonAuthorColor(255, 195, 0, 255)]
[assembly: VerifyLoaderVersion(0, 6, 6, true)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("AlternateHealthbars")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("AlternateHealthbars")]
[assembly: AssemblyTitle("AlternateHealthbars")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace AlternateHealthbars;

public static class BuildInfo
{
	public const string ModName = "AlternateHealthbars";

	public const string ModVersion = "1.0.0";

	public const string Author = "UlvakSkillz";
}
public class Main : MelonMod
{
	[HarmonyPatch(typeof(PlayerController), "Initialize", new Type[] { typeof(Player) })]
	public static class playerspawn
	{
		private static void Postfix(ref PlayerController __instance, ref Player player)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Invalid comparison between Unknown and I4
			if (enabled && (Scene.GetSceneName() != "Park" || (Scene.GetSceneName() == "Park" && (int)__instance.controllerType == 1)))
			{
				MelonCoroutines.Start(PlayerSpawned(__instance));
			}
		}
	}

	[CompilerGenerated]
	private sealed class <FlashHealth>d__35 : IEnumerator<object>, IEnumerator, IDisposable
	{
		private int <>1__state;

		private object <>2__current;

		public GameObject healthVarientObject;

		public int storedHealth;

		public int health;

		private Transform <damageFlash>5__1;

		private int <i>5__2;

		private int <i>5__3;

		private int <i>5__4;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <FlashHealth>d__35(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<damageFlash>5__1 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Expected O, but got Unknown
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_021f: Expected O, but got Unknown
			//IL_0251: Unknown result type (might be due to invalid IL or missing references)
			//IL_025b: Expected O, but got Unknown
			//IL_028d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0297: Expected O, but got Unknown
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<damageFlash>5__1 = healthVarientObject.transform.GetChild(21);
				((Component)<damageFlash>5__1.GetChild(0)).gameObject.SetActive(true);
				<i>5__2 = 0;
				while (<i>5__2 <= health)
				{
					((Component)<damageFlash>5__1.GetChild(<i>5__2)).gameObject.SetActive(false);
					<i>5__2++;
				}
				<i>5__3 = health + 1;
				while (<i>5__3 <= storedHealth)
				{
					((Component)<damageFlash>5__1.GetChild(<i>5__3)).gameObject.SetActive(true);
					<i>5__3++;
				}
				<i>5__4 = storedHealth + 1;
				while (<i>5__4 <= 20)
				{
					((Component)<damageFlash>5__1.GetChild(<i>5__4)).gameObject.SetActive(false);
					<i>5__4++;
				}
				try
				{
					((Component)<damageFlash>5__1).gameObject.SetActive(true);
				}
				catch
				{
					return false;
				}
				<>2__current = (object)new WaitForSeconds(0.15f);
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				try
				{
					((Component)<damageFlash>5__1).gameObject.SetActive(false);
				}
				catch
				{
					return false;
				}
				<>2__current = (object)new WaitForSeconds(0.15f);
				<>1__state = 2;
				return true;
			case 2:
				<>1__state = -1;
				try
				{
					((Component)<damageFlash>5__1).gameObject.SetActive(true);
				}
				catch
				{
					return false;
				}
				<>2__current = (object)new WaitForSeconds(0.15f);
				<>1__state = 3;
				return true;
			case 3:
				<>1__state = -1;
				try
				{
					((Component)<damageFlash>5__1).gameObject.SetActive(false);
				}
				catch
				{
					return false;
				}
				<>2__current = (object)new WaitForSeconds(0.15f);
				<>1__state = 4;
				return true;
			case 4:
				<>1__state = -1;
				try
				{
					((Component)<damageFlash>5__1).gameObject.SetActive(true);
				}
				catch
				{
					return false;
				}
				<>2__current = (object)new WaitForSeconds(0.15f);
				<>1__state = 5;
				return true;
			case 5:
				<>1__state = -1;
				try
				{
					((Component)<damageFlash>5__1).gameObject.SetActive(false);
				}
				catch
				{
					return false;
				}
				return false;
			}
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	[CompilerGenerated]
	private sealed class <PlayerSpawned>d__31 : IEnumerator<object>, IEnumerator, IDisposable
	{
		private int <>1__state;

		private object <>2__current;

		public PlayerController playerController;

		private GameObject <newHealthbar>5__1;

		private Exception <e>5__2;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <PlayerSpawned>d__31(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<newHealthbar>5__1 = null;
			<e>5__2 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Invalid comparison between Unknown and I4
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_0263: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0304: Unknown result type (might be due to invalid IL or missing references)
			//IL_031a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0330: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			if (<>1__state != 0)
			{
				return false;
			}
			<>1__state = -1;
			<newHealthbar>5__1 = null;
			try
			{
				if ((int)playerController.controllerType == 1)
				{
					if (!changeSelf)
					{
						return false;
					}
					<newHealthbar>5__1 = Object.Instantiate<GameObject>(storedHealthbars);
					<newHealthbar>5__1.transform.GetChild(2).localScale = new Vector3(1f, 1.5f, 1f);
					<newHealthbar>5__1.transform.GetChild(3).localScale = new Vector3(1f, 1.5f, 1f);
					<newHealthbar>5__1.transform.GetChild(4).localScale = new Vector3(1f, 1.1f, 1f);
					<newHealthbar>5__1.transform.parent = ((Component)playerController).transform.FindChild("UI/LocalUI/Local UI Bar");
					<newHealthbar>5__1.transform.localScale = new Vector3(0.0075f, 0.001f, 0.01f);
					<newHealthbar>5__1.transform.localPosition = new Vector3(-0.98f, 0f, 0f);
					<newHealthbar>5__1.transform.localRotation = Quaternion.Euler(60f, 270f, 0f);
				}
				else
				{
					if (!changeOthers)
					{
						return false;
					}
					<newHealthbar>5__1 = Object.Instantiate<GameObject>(storedHealthbars);
					<newHealthbar>5__1.transform.localScale = new Vector3(0.02f, 0.35f, 1f);
					<newHealthbar>5__1.transform.GetChild(0).localScale = new Vector3(1f, 0.5f, 1f);
					<newHealthbar>5__1.transform.GetChild(1).localScale = new Vector3(1f, 0.5f, 1f);
					<newHealthbar>5__1.transform.GetChild(2).localScale = new Vector3(1f, 0.75f, 1f);
					<newHealthbar>5__1.transform.GetChild(3).localScale = new Vector3(1f, 0.75f, 1f);
					<newHealthbar>5__1.transform.GetChild(4).localScale = new Vector3(1f, 0.5f, 1f);
					<newHealthbar>5__1.transform.GetChild(5).localScale = new Vector3(10f, 2.5f, 1f);
					<newHealthbar>5__1.transform.parent = ((Component)playerController).transform.FindChild("UI/RemoteUI/Remote UI Bar");
					<newHealthbar>5__1.transform.localScale = new Vector3(0.015f, 0.3f, 0f);
					<newHealthbar>5__1.transform.localPosition = Vector3.zero;
					<newHealthbar>5__1.transform.localRotation = Quaternion.identity;
				}
			}
			catch (Exception ex)
			{
				<e>5__2 = ex;
				MelonLogger.Error((object)<e>5__2);
			}
			if ((Object)(object)<newHealthbar>5__1 != (Object)null)
			{
				<newHealthbar>5__1.SetActive(true);
				healthbars.Add(<newHealthbar>5__1);
				TurnOnCorrectHealthbar(<newHealthbar>5__1, playerController);
			}
			return false;
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	[CompilerGenerated]
	private sealed class <WatchHealthWhileActive>d__33 : IEnumerator<object>, IEnumerator, IDisposable
	{
		private int <>1__state;

		private object <>2__current;

		public GameObject objectToWatch;

		public PlayerController playerController;

		private int <storedHealth>5__1;

		private object <FlashHealthCoroutine>5__2;

		private int <health>5__3;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <WatchHealthWhileActive>d__33(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<FlashHealthCoroutine>5__2 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<storedHealth>5__1 = -1;
				<FlashHealthCoroutine>5__2 = null;
				break;
			case 1:
				<>1__state = -1;
				break;
			}
			if ((Object)(object)objectToWatch != (Object)null && objectToWatch.activeSelf)
			{
				<health>5__3 = playerController.AssignedPlayer.Data.HealthPoints;
				if (<storedHealth>5__1 != <health>5__3)
				{
					FixHealth(objectToWatch, <health>5__3);
					if (((Object)objectToWatch).name == "Minecraft")
					{
						if (<FlashHealthCoroutine>5__2 != null)
						{
							MelonCoroutines.Stop(<FlashHealthCoroutine>5__2);
							<FlashHealthCoroutine>5__2 = null;
							((Component)objectToWatch.transform.GetChild(21)).gameObject.SetActive(false);
						}
						if (<health>5__3 < <storedHealth>5__1)
						{
							<FlashHealthCoroutine>5__2 = MelonCoroutines.Start(FlashHealth(objectToWatch, <storedHealth>5__1, <health>5__3));
						}
					}
					<storedHealth>5__1 = <health>5__3;
				}
				<>2__current = (object)new WaitForFixedUpdate();
				<>1__state = 1;
				return true;
			}
			return false;
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	private const int VARIETYCOUNT = 6;

	public static Mod AlternateHealthbars = new Mod();

	private static bool enabled = true;

	private static bool changeSelf = true;

	private static bool changeOthers = true;

	private static int varietySelf = 0;

	private static int varietyOthers = 0;

	private static bool randomSelf = false;

	private static bool randomOthers = false;

	private List<ModSetting> settings = new List<ModSetting>();

	private static GameObject storedHealthbars = null;

	private static List<GameObject> healthbars = new List<GameObject>();

	private static Random random = new Random();

	private static string primaryColorChange = "";

	private static string secondaryColorChange = "";

	private static string thirdColorChange = "";

	private static bool debug = false;

	private static void Log(string msg)
	{
		if (debug)
		{
			MelonLogger.Msg(msg);
		}
	}

	public override void OnLateInitializeMelon()
	{
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Expected O, but got Unknown
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Expected O, but got Unknown
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a7: Expected O, but got Unknown
		//IL_0178: Unknown result type (might be due to invalid IL or missing references)
		//IL_0182: Expected O, but got Unknown
		//IL_0253: Unknown result type (might be due to invalid IL or missing references)
		//IL_025d: Expected O, but got Unknown
		//IL_027a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0284: Expected O, but got Unknown
		//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ab: Expected O, but got Unknown
		//IL_031b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0325: Expected O, but got Unknown
		//IL_0395: Unknown result type (might be due to invalid IL or missing references)
		//IL_039f: Expected O, but got Unknown
		//IL_040f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0419: Expected O, but got Unknown
		LoadAssets();
		AlternateHealthbars.ModName = "AlternateHealthbars";
		AlternateHealthbars.ModVersion = "1.0.0";
		AlternateHealthbars.SetFolder("AlternateHealthbars");
		settings.Add((ModSetting)(object)AlternateHealthbars.AddToList("Enabled", true, 0, "Toggles Mod On/Off", new Tags()));
		settings.Add((ModSetting)(object)AlternateHealthbars.AddToList("Show on Own", true, 0, "Toggles Own Healthbar Customization", new Tags()));
		settings.Add((ModSetting)(object)AlternateHealthbars.AddToList("Show on Others", true, 0, "Toggles Others Healthbar Customization", new Tags()));
		settings.Add((ModSetting)(object)AlternateHealthbars.AddToList("Style of Own Healthbar", 0, $"Changes Your Own Healthbar Customization: {Environment.NewLine}0 : Classic{Environment.NewLine}1 : Minecraft{Environment.NewLine}2 : Zelda Quarters{Environment.NewLine}3 : Zelda Shrinking{Environment.NewLine}4 : Heart Bar{Environment.NewLine}5 : Skyrim", new Tags()));
		settings.Add((ModSetting)(object)AlternateHealthbars.AddToList("Style of Others Healthbar", 0, $"Changes Others Healthbar Customization: {Environment.NewLine}0 : Classic{Environment.NewLine}1 : Minecraft{Environment.NewLine}2 : Zelda Quarters{Environment.NewLine}3 : Zelda Shrinking{Environment.NewLine}4 : Heart Bar{Environment.NewLine}5 : Skyrim", new Tags()));
		settings.Add((ModSetting)(object)AlternateHealthbars.AddToList("Random Healthbar for Self", false, 0, "Randomizes the Customization of Your Own Healthbar", new Tags()));
		settings.Add((ModSetting)(object)AlternateHealthbars.AddToList("Random Healthbar for Others", false, 0, "Randomizes the Customization of Others Healthbar", new Tags()));
		settings.Add((ModSetting)(object)AlternateHealthbars.AddToList("Primary Color Change", "FFFFFF", $"Colorblind Accessability{Environment.NewLine}Changes Main Health Color{Environment.NewLine}Starts Colors at FFFFFF then Edit from there (Color won't be the same as you see on Google)", new Tags()));
		settings.Add((ModSetting)(object)AlternateHealthbars.AddToList("Secondary Color Change", "FFFFFF", $"Colorblind Accessability{Environment.NewLine}Changes Main Health Color (Red on Heartbar){Environment.NewLine}Starts Colors at FFFFFF then Edit from there (Color won't be the same as you see on Google)", new Tags()));
		settings.Add((ModSetting)(object)AlternateHealthbars.AddToList("Third Color Change", "FFFFFF", $"Colorblind Accessability{Environment.NewLine}Changes 3rd Health Color (Yellow on Heartbar){Environment.NewLine}Starts Colors at FFFFFF then Edit from there (Color won't be the same as you see on Google)", new Tags()));
		AlternateHealthbars.GetFromFile();
		UI.instance.UI_Initialized += UIInit;
		AlternateHealthbars.ModSaved += Save;
		SaveInit();
		Log("ModUI Setup");
	}

	private void LoadAssets()
	{
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		storedHealthbars = Object.Instantiate<GameObject>(Calls.LoadAssetFromStream<GameObject>((MelonMod)(object)this, "AlternateHealthbars.healthbars", "Healthbars"));
		((Object)storedHealthbars).name = "AlternateHealthbars";
		storedHealthbars.transform.localPosition = Vector3.zero;
		storedHealthbars.transform.rotation = Quaternion.identity;
		storedHealthbars.transform.localScale = Vector3.one;
		storedHealthbars.SetActive(false);
		Object.DontDestroyOnLoad((Object)(object)storedHealthbars);
		Log("Assets Loaded");
	}

	private void UIInit()
	{
		UI.instance.AddMod(AlternateHealthbars);
		Log("Mod Added to ModUI");
	}

	private void SaveInit()
	{
		enabled = (bool)settings[0].SavedValue;
		changeSelf = (bool)settings[1].SavedValue;
		changeOthers = (bool)settings[2].SavedValue;
		varietySelf = (int)settings[3].SavedValue;
		varietyOthers = (int)settings[4].SavedValue;
		randomSelf = (bool)settings[5].SavedValue;
		randomOthers = (bool)settings[6].SavedValue;
		primaryColorChange = (string)settings[7].SavedValue;
		secondaryColorChange = (string)settings[8].SavedValue;
		thirdColorChange = (string)settings[9].SavedValue;
		if (0 > varietySelf || varietySelf >= 6)
		{
			Log("varietySelf Clamped");
			int num = (varietySelf = Math.Clamp(varietySelf, 0, 5));
			settings[3].SavedValue = num;
			settings[3].Value = num;
		}
		if (0 > varietyOthers || varietyOthers >= 6)
		{
			Log("varietyOters Clamped");
			int num2 = (varietyOthers = Math.Clamp(varietyOthers, 0, 5));
			settings[4].SavedValue = num2;
			settings[4].Value = num2;
		}
		if (primaryColorChange.Length < 6)
		{
			Log("Primary Color too Short!");
			primaryColorChange = "FFFFFF";
			settings[7].SavedValue = "FFFFFF";
			settings[7].Value = "FFFFFF";
		}
		if (secondaryColorChange.Length < 6)
		{
			Log("Secondary Color too Short!");
			secondaryColorChange = "FFFFFF";
			settings[8].SavedValue = "FFFFFF";
			settings[8].Value = "FFFFFF";
		}
		if (thirdColorChange.Length < 6)
		{
			Log("Third Color too Short!");
			thirdColorChange = "FFFFFF";
			settings[9].SavedValue = "FFFFFF";
			settings[9].Value = "FFFFFF";
		}
		SetupColorblindColors();
		Log("Initialized ModUI Stored Values");
	}

	private void Save()
	{
		Log("Saving");
		bool flag = enabled;
		enabled = (bool)settings[0].SavedValue;
		bool flag2 = changeSelf;
		changeSelf = (bool)settings[1].SavedValue;
		bool flag3 = changeOthers;
		changeOthers = (bool)settings[2].SavedValue;
		int num = varietySelf;
		varietySelf = (int)settings[3].SavedValue;
		int num2 = varietyOthers;
		varietyOthers = (int)settings[4].SavedValue;
		randomSelf = (bool)settings[5].SavedValue;
		randomOthers = (bool)settings[6].SavedValue;
		string text = primaryColorChange;
		primaryColorChange = (string)settings[7].SavedValue;
		string text2 = secondaryColorChange;
		secondaryColorChange = (string)settings[8].SavedValue;
		string text3 = thirdColorChange;
		thirdColorChange = (string)settings[9].SavedValue;
		if (0 > varietySelf || varietySelf >= 6)
		{
			Log("varietySelf Clamped");
			int num3 = (varietySelf = Math.Clamp(varietySelf, 0, 5));
			settings[3].SavedValue = num3;
			settings[3].Value = num3;
		}
		if (0 > varietyOthers || varietyOthers >= 6)
		{
			Log("varietyOters Clamped");
			int num4 = (varietyOthers = Math.Clamp(varietyOthers, 0, 5));
			settings[4].SavedValue = num4;
			settings[4].Value = num4;
		}
		if (primaryColorChange.Length < 6)
		{
			Log("Primary Color too Short!");
			primaryColorChange = "FFFFFF";
			settings[7].SavedValue = "FFFFFF";
			settings[7].Value = "FFFFFF";
		}
		if (secondaryColorChange.Length < 6)
		{
			Log("Secondary Color too Short!");
			secondaryColorChange = "FFFFFF";
			settings[8].SavedValue = "FFFFFF";
			settings[8].Value = "FFFFFF";
		}
		if (thirdColorChange.Length < 6)
		{
			Log("Third Color too Short!");
			thirdColorChange = "FFFFFF";
			settings[9].SavedValue = "FFFFFF";
			settings[9].Value = "FFFFFF";
		}
		if (text != primaryColorChange || text2 != secondaryColorChange || text3 != thirdColorChange)
		{
			Log("Colorblind Setting Changed");
			SetupColorblindColors();
		}
		if (enabled != flag)
		{
			Log("Toggled Enabled");
			if (enabled)
			{
				CreateHealthBars();
			}
			else
			{
				RemoveHealthbars();
			}
		}
		if (text != primaryColorChange || text2 != secondaryColorChange || text3 != thirdColorChange || changeSelf != flag2 || changeOthers != flag3 || varietySelf != num || varietyOthers != num2)
		{
			Log("Changed Customizations, Destroying and Recreating Healthbars");
			RemoveHealthbars();
			CreateHealthBars();
		}
	}

	private void SetupColorblindColors()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_0092: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
		Color primaryColor = hexToColor(primaryColorChange);
		Color secondaryColor = hexToColor(secondaryColorChange);
		Color thirdColor = hexToColor(thirdColorChange);
		Recolor_BG_20PRI(((Component)storedHealthbars.transform.GetChild(0)).gameObject, primaryColor, secondaryColor);
		Recolor_BG_20PRI_BG(((Component)storedHealthbars.transform.GetChild(1)).gameObject, primaryColor, secondaryColor);
		Recolor_BG_20PRI(((Component)storedHealthbars.transform.GetChild(2)).gameObject, primaryColor, secondaryColor);
		Recolor_BG_20PRI(((Component)storedHealthbars.transform.GetChild(3)).gameObject, primaryColor, secondaryColor);
		Recolor_Heartbar(((Component)storedHealthbars.transform.GetChild(4)).gameObject, primaryColor, secondaryColor, thirdColor);
		Recolor_BG_PRI(((Component)storedHealthbars.transform.GetChild(5)).gameObject, primaryColor, secondaryColor);
	}

	private void Recolor_Heartbar(GameObject healthbar, Color primaryColor, Color secondaryColor, Color thirdColor)
	{
		//IL_0017: 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_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		for (int i = 1; i <= 7; i++)
		{
			((Graphic)((Component)healthbar.transform.GetChild(i)).GetComponent<RawImage>()).color = secondaryColor;
		}
		for (int j = 8; j <= 14; j++)
		{
			((Graphic)((Component)healthbar.transform.GetChild(j)).GetComponent<RawImage>()).color = thirdColor;
		}
		for (int k = 15; k <= 20; k++)
		{
			((Graphic)((Component)healthbar.transform.GetChild(k)).GetComponent<RawImage>()).color = primaryColor;
		}
		((Graphic)((Component)healthbar.transform.GetChild(22)).GetComponent<RawImage>()).color = secondaryColor;
	}

	private void Recolor_BG_PRI(GameObject healthbar, Color primaryColor, Color secondaryColor)
	{
		//IL_0012: 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)
		((Graphic)((Component)healthbar.transform.GetChild(0)).GetComponent<RawImage>()).color = secondaryColor;
		((Graphic)((Component)healthbar.transform.GetChild(1)).GetComponent<RawImage>()).color = primaryColor;
	}

	private void Recolor_BG_20PRI(GameObject healthbar, Color primaryColor, Color secondaryColor)
	{
		//IL_0012: 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)
		((Graphic)((Component)healthbar.transform.GetChild(0)).GetComponent<RawImage>()).color = secondaryColor;
		for (int i = 1; i < 21; i++)
		{
			((Graphic)((Component)healthbar.transform.GetChild(i)).GetComponent<RawImage>()).color = primaryColor;
		}
	}

	private void Recolor_BG_20PRI_BG(GameObject healthbar, Color primaryColor, Color secondaryColor)
	{
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_0004: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		Recolor_BG_20PRI(healthbar, primaryColor, secondaryColor);
		RecolorAllChildren(((Component)healthbar.transform.GetChild(21)).gameObject, secondaryColor);
	}

	private void RecolorAllChildren(GameObject parent, Color color)
	{
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		for (int i = 0; i < parent.transform.childCount; i++)
		{
			((Graphic)((Component)parent.transform.GetChild(i)).GetComponent<RawImage>()).color = color;
		}
	}

	public static Color hexToColor(string hex)
	{
		//IL_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			hex = hex.Replace("0x", "");
			hex = hex.Replace("#", "");
			byte b = byte.MaxValue;
			byte b2 = byte.Parse(hex.Substring(0, 2), NumberStyles.HexNumber);
			byte b3 = byte.Parse(hex.Substring(2, 2), NumberStyles.HexNumber);
			byte b4 = byte.Parse(hex.Substring(4, 2), NumberStyles.HexNumber);
			return Color32.op_Implicit(new Color32(b2, b3, b4, b));
		}
		catch
		{
			return Color.white;
		}
	}

	[IteratorStateMachine(typeof(<PlayerSpawned>d__31))]
	private static IEnumerator PlayerSpawned(PlayerController playerController)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <PlayerSpawned>d__31(0)
		{
			playerController = playerController
		};
	}

	private static void TurnOnCorrectHealthbar(GameObject healthbar, PlayerController playerController)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Invalid comparison between Unknown and I4
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Invalid comparison between Unknown and I4
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_0099: Invalid comparison between Unknown and I4
		int num = (((int)playerController.controllerType == 1) ? varietySelf : varietyOthers);
		if (((int)playerController.controllerType == 1 && randomSelf) || ((int)playerController.controllerType == 2 && randomOthers))
		{
			num = random.Next(6);
		}
		GameObject gameObject = ((Component)healthbar.transform.GetChild(num)).gameObject;
		for (int i = 0; i < healthbar.transform.childCount; i++)
		{
			if (i == num)
			{
				((Component)healthbar.transform.GetChild(num)).gameObject.SetActive(true);
				((Renderer)((Component)((Component)playerController).transform.FindChild("UI/" + (((int)playerController.controllerType == 1) ? "LocalUI/Local UI Bar" : "RemoteUI/Remote UI Bar"))).GetComponent<MeshRenderer>()).enabled = false;
			}
			((Component)healthbar.transform.GetChild(i)).gameObject.SetActive(false);
		}
		gameObject.SetActive(true);
		MelonCoroutines.Start(WatchHealthWhileActive(gameObject, playerController));
	}

	[IteratorStateMachine(typeof(<WatchHealthWhileActive>d__33))]
	private static IEnumerator WatchHealthWhileActive(GameObject objectToWatch, PlayerController playerController)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <WatchHealthWhileActive>d__33(0)
		{
			objectToWatch = objectToWatch,
			playerController = playerController
		};
	}

	private static void FixHealth(GameObject healthbar, int health)
	{
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		if (((Object)healthbar).name == "Skyrim")
		{
			healthbar.transform.GetChild(1).localScale = new Vector3(0.005f * (float)health, 0.025f, 0.1f);
			return;
		}
		if (((Object)healthbar).name == "TeamFortress2")
		{
			((TMP_Text)((Component)healthbar.transform.GetChild(1)).GetComponent<TextMeshPro>()).text = (health * 10).ToString();
			return;
		}
		for (int num = 20; num > health; num--)
		{
			((Component)healthbar.transform.GetChild(num)).gameObject.SetActive(false);
		}
		for (int num2 = health; num2 > 0; num2--)
		{
			((Component)healthbar.transform.GetChild(num2)).gameObject.SetActive(true);
		}
	}

	[IteratorStateMachine(typeof(<FlashHealth>d__35))]
	public static IEnumerator FlashHealth(GameObject healthVarientObject, int storedHealth, int health)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <FlashHealth>d__35(0)
		{
			healthVarientObject = healthVarientObject,
			storedHealth = storedHealth,
			health = health
		};
	}

	private static void CreateHealthBars()
	{
		for (int i = 0; i < Singleton<PlayerManager>.instance.AllPlayers.Count; i++)
		{
			MelonCoroutines.Start(PlayerSpawned(Singleton<PlayerManager>.instance.AllPlayers[i].Controller));
		}
	}

	private static void RemoveHealthbars()
	{
		//IL_0091: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: Invalid comparison between Unknown and I4
		while (healthbars.Count > 0)
		{
			if ((Object)(object)healthbars[0] != (Object)null)
			{
				Object.Destroy((Object)(object)healthbars[0]);
				Log("Destroyed a Healthbar");
			}
			healthbars.RemoveAt(0);
			Log("Removed Destroyed or Null Healthbar from List");
		}
		Enumerator<Player> enumerator = Singleton<PlayerManager>.instance.AllPlayers.GetEnumerator();
		while (enumerator.MoveNext())
		{
			Player current = enumerator.Current;
			((Renderer)((Component)((Component)current.Controller).transform.FindChild("UI/" + (((int)current.Controller.controllerType == 1) ? "LocalUI/Local UI Bar" : "RemoteUI/Remote UI Bar"))).GetComponent<MeshRenderer>()).enabled = true;
		}
		Log("Turned On All Players Original Healthbars");
	}
}