Decompiled source of HunkHud v0.2.2

HunkHud.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HunkHud.Components;
using HunkHud.Components.UI;
using HunkHud.Modules;
using MaterialHud;
using MonoMod.RuntimeDetour;
using On.RoR2.UI;
using RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
using RoR2.UI;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using ZioConfigFile;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
namespace HunkHud
{
	public class CustomHudElement : HudElement
	{
		public HUD targetHud => base._hud;

		public CharacterBody targetBody => base._targetCharacterBody;

		public CharacterMaster targetMaster
		{
			get
			{
				HUD hud = base._hud;
				if (hud == null)
				{
					return null;
				}
				return hud.targetMaster;
			}
		}

		protected virtual void OnEnable()
		{
			InstanceTracker.Add<CustomHudElement>(this);
		}

		protected virtual void OnDisable()
		{
			InstanceTracker.Remove<CustomHudElement>(this);
		}
	}
	public class LevelDisplay : ExpBar
	{
		private float expFillMin;

		private float expFillMax = 0.76f;

		public Image fillImage;

		private void Update()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			TeamIndex val = (TeamIndex)((!Object.op_Implicit((Object)(object)base.source)) ? 1 : ((int)base.source.teamIndex));
			float num = 0f;
			if (Object.op_Implicit((Object)(object)TeamManager.instance))
			{
				num = Mathf.InverseLerp((float)TeamManager.instance.GetTeamCurrentLevelExperience(val), (float)TeamManager.instance.GetTeamNextLevelExperience(val), (float)TeamManager.instance.GetTeamExperience(val));
			}
			if (Object.op_Implicit((Object)(object)fillImage))
			{
				fillImage.fillAmount = Util.Remap(num, 0f, 1f, expFillMin, expFillMax);
			}
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.public_ParticleSystem.HunkHud", "HunkHud", "0.2.1")]
	public class HunkHudMain : BaseUnityPlugin
	{
		public const string GUID = "com.public_ParticleSystem.HunkHud";

		public const string MODAUTHOR = "public_ParticleSystem";

		public const string MODNAME = "HunkHud";

		public const string VERSION = "0.2.1";

		public static HunkHudMain instance { get; private set; }

		public static bool ROOInstalled => Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions");

		public static bool HunkInstalled => Chainloader.PluginInfos.ContainsKey("com.rob.Hunk");

		public static bool RiskUIEnabled
		{
			get
			{
				if (Chainloader.PluginInfos.ContainsKey("bubbet.riskui"))
				{
					return GetRiskUIEnabled();
				}
				return false;
			}
		}

		public void Awake()
		{
			instance = this;
			Log.Init(((BaseUnityPlugin)this).Logger);
			PluginConfig.Init(((BaseUnityPlugin)this).Config);
			((MonoBehaviour)this).StartCoroutine("Load");
		}

		private IEnumerator Load()
		{
			AssetBundleCreateRequest request = AssetBundle.LoadFromFileAsync(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "hunkhudassets"));
			yield return request;
			HudAssets.mainAssetBundle = request.assetBundle;
			HudAssets.Init();
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		private static bool GetRiskUIEnabled()
		{
			return RiskUIPlugin.Enabled.Value;
		}
	}
}
namespace HunkHud.Modules
{
	public static class HudAssets
	{
		public static AssetBundle mainAssetBundle;

		internal static void Init()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			CrosshairController.Awake += new hook_Awake(CrosshairController_Awake);
			HUD.onHudTargetChangedGlobal += OnHudTargetChangedGlobal;
			new Hook((MethodBase)typeof(RiskUIPlugin).GetMethod("onLoad", (BindingFlags)(-1)), typeof(HudAssets).GetMethod("onLoad", (BindingFlags)(-1)));
		}

		private static void OnHudTargetChangedGlobal(HUD hud)
		{
			SetupHud(hud);
			foreach (CustomHudElement instances in InstanceTracker.GetInstancesList<CustomHudElement>())
			{
				((HudElement)instances).hud = hud;
				if (instances is DisplayMover displayMover)
				{
					displayMover.activeTimer = 8f;
					displayMover.delayTimer = displayMover.activeTimer - displayMover.refreshTimer;
				}
			}
		}

		private static void CrosshairController_Awake(orig_Awake orig, CrosshairController self)
		{
			orig.Invoke(self);
			if (Object.op_Implicit((Object)(object)self) && !Object.op_Implicit((Object)(object)((Component)self).GetComponent<DynamicCrosshair>()))
			{
				((Component)self).gameObject.AddComponent<DynamicCrosshair>();
			}
		}

		private static void onLoad(Action<RiskUIPlugin> orig, RiskUIPlugin self)
		{
			orig(self);
			SetRiskUISettings(RiskUIPlugin._newHud.GetComponent<HUD>());
		}

		private static void SetRiskUISettings(HUD hud)
		{
			//IL_0034: 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_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: 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_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: 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)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			Transform val = hud.mainUIPanel.transform.Find("SpringCanvas");
			ChildLocator component = ((Component)hud).GetComponent<ChildLocator>();
			List<NameTransformPair> list = component.transformPairs.ToList();
			list.AddRange((IEnumerable<NameTransformPair>)(object)new NameTransformPair[4]
			{
				new NameTransformPair
				{
					name = "NotificationArea",
					transform = hud.mainContainer.transform.Find("NotificationArea")
				},
				new NameTransformPair
				{
					name = "UpperLeftCluster",
					transform = val.Find("UpperLeftCluster")
				},
				new NameTransformPair
				{
					name = "SkillIconContainer",
					transform = val.Find("BottomRightCluster/Scaler")
				},
				new NameTransformPair
				{
					name = "AllyCardContainer",
					transform = val.Find("LeftCluster/AllyCardContainer")
				}
			});
			BepinConfigParentManager[] componentsInChildren = ((Component)hud).GetComponentsInChildren<BepinConfigParentManager>();
			foreach (BepinConfigParentManager val2 in componentsInChildren)
			{
				string name = ((Object)((Component)val2).gameObject).name;
				if (!(name == "BuffDisplayRoot"))
				{
					if (name == "InventoryContainer")
					{
						val2.choices[0] = val2.choices[1];
						((Component)val2).transform.SetParent(val2.choices[1], false);
						list.Add(new NameTransformPair
						{
							name = "InventoryContainer",
							transform = ((Component)val2).transform
						});
					}
				}
				else
				{
					Transform val3 = val2.choices[2];
					((Component)val3).GetComponent<RectTransform>().anchoredPosition3D = new Vector3(0f, -40f, 0f);
					val2.choices[0] = val3;
					val2.choices[1] = val3;
					val2.choices[2] = val3;
					val2.choices[3] = val3;
					((Component)val2).transform.SetParent(val3, false);
					RectTransform component2 = ((Component)val2).GetComponent<RectTransform>();
					component2.pivot = new Vector2(0.5f, 1f);
					component2.anchoredPosition3D = Vector3.zero;
					list.Add(new NameTransformPair
					{
						name = "BuffDisplayRoot",
						transform = ((Component)val2).transform
					});
				}
			}
			component.transformPairs = list.ToArray();
			RiskUIPlugin._allyCard.AddComponent<CanvasGroup>();
			RiskUIPlugin._allyCard.AddComponent<AllyHealthBarMover>();
			((Component)RiskUIPlugin._allyCard.transform.Find("Healthbar/HealthTextContainer/CurrentHealthText")).gameObject.SetActive(false);
			((Component)RiskUIPlugin._allyCard.transform.Find("Healthbar/HealthTextContainer/Slash")).gameObject.SetActive(false);
			((Component)RiskUIPlugin._allyCard.transform.Find("Healthbar/HealthTextContainer/MaxHealthText")).gameObject.SetActive(false);
			SetActiveSafe((Component)(object)component.FindChild("BottomLeftCluster").Find("BarRoots/HealthText"), active: false);
			SetActiveSafe((Component)(object)component.FindChild("BottomLeftCluster").Find("BarRoots/Seperator"), active: false);
			SetActiveSafe((Component)(object)hud.healthBar, active: false);
			SetActiveSafe((Component)(object)hud.expBar, active: false);
			SetActiveSafe((Component)(object)hud.levelText, active: false);
			Transform val4 = component.FindChild("InventoryContainer");
			if (Object.op_Implicit((Object)(object)val4))
			{
				((Component)(object)val4).GetOrAddComponent<ItemDisplayMover>();
			}
			Transform val5 = component.FindChild("SkillIconContainer");
			if (Object.op_Implicit((Object)(object)val5))
			{
				((Component)(object)val5).GetOrAddComponent<SkillIconMover>();
			}
			Transform val6 = component.FindChild("UpperLeftCluster");
			if (Object.op_Implicit((Object)(object)val6))
			{
				((Component)(object)val6).GetOrAddComponent<MoneyDisplayMover>();
			}
		}

		private static void SetupHud(HUD hud)
		{
			ChildLocator component = ((Component)hud).GetComponent<ChildLocator>();
			if (Object.op_Implicit((Object)(object)hud.gameModeUiInstance))
			{
				hud.gameModeUiInstance.GetOrAddComponent<ObjectiveDisplayMover>();
			}
			NotificationUIController val = component.FindChildComponent<NotificationUIController>("NotificationArea");
			if (Object.op_Implicit((Object)(object)val))
			{
				val.genericNotificationPrefab = mainAssetBundle.LoadAsset<GameObject>("ItemNotification");
			}
			Transform val2 = component.FindChild("TopCenterCluster");
			if (Object.op_Implicit((Object)(object)val2))
			{
				val2.FindOrInstantiate("ObjectiveGauge");
			}
			Transform val3 = component.FindChild("CrosshairExtras");
			if (Object.op_Implicit((Object)(object)val3))
			{
				val3.FindOrInstantiate<LuminousDisplay>("LuminousGauge");
			}
			Transform val4 = component.FindChild("BottomLeftCluster");
			if (Object.op_Implicit((Object)(object)val4))
			{
				CustomHealthBar component2 = ((Component)val4.FindOrInstantiate("CustomHealthBar").transform.GetChild(0)).GetComponent<CustomHealthBar>();
				((HealthBar)component2).source = (Object.op_Implicit((Object)(object)hud.targetBodyObject) ? hud.targetBodyObject.GetComponent<HealthComponent>() : null);
				component2.SetCharacterIcon();
				hud.healthBar = (HealthBar)(object)component2;
				hud.levelText = ((Component)component2).GetComponentInChildren<LevelText>();
				hud.expBar = ((Component)component2).GetComponentInChildren<ExpBar>();
				FuckinLee(val4, hud.targetBodyObject);
			}
		}

		private static void FuckinLee(Transform hud, GameObject targetBody)
		{
			Transform val = hud.Find("ChatBoxPos1");
			Transform val2 = hud.Find("ChatBoxPos2");
			if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val2))
			{
				Transform val3 = val.Find("ChatBoxRoot");
				if (!Object.op_Implicit((Object)(object)val3))
				{
					val2.Find("ChatBoxRoot");
				}
				BepinConfigParentManager val4 = (Object.op_Implicit((Object)(object)val3) ? ((Component)val3).GetComponent<BepinConfigParentManager>() : null);
				if (Object.op_Implicit((Object)(object)val4))
				{
					val4.choices[0] = ((Object.op_Implicit((Object)(object)targetBody) && ((Object)targetBody).name == "LeeHyperrealBody(Clone)") ? val2 : val);
					val4.OnEnable();
				}
			}
		}

		private static T GetOrAddComponent<T>(this GameObject go) where T : Component
		{
			return go.GetComponent<T>() ?? go.AddComponent<T>();
		}

		private static T GetOrAddComponent<T>(this Component co) where T : Component
		{
			return co.GetComponent<T>() ?? co.gameObject.AddComponent<T>();
		}

		private static void SetActiveSafe(Component co, bool active)
		{
			if (Object.op_Implicit((Object)(object)co))
			{
				co.gameObject.SetActive(active);
			}
		}

		private static GameObject FindOrInstantiate(this Transform transform, string assetName)
		{
			Transform obj = transform.Find(assetName);
			GameObject val = ((obj != null) ? ((Component)obj).gameObject : null);
			if (!Object.op_Implicit((Object)(object)val))
			{
				val = Object.Instantiate<GameObject>(mainAssetBundle.LoadAsset<GameObject>(assetName), transform);
				((Object)val).name = assetName;
			}
			return val;
		}

		private static T FindOrInstantiate<T>(this Transform transform, string assetName) where T : MonoBehaviour
		{
			Transform obj = transform.Find(assetName);
			GameObject val = ((obj != null) ? ((Component)obj).gameObject : null);
			if (!Object.op_Implicit((Object)(object)val))
			{
				val = Object.Instantiate<GameObject>(mainAssetBundle.LoadAsset<GameObject>(assetName), transform);
				((Object)val).name = assetName;
			}
			return val.GetComponent<T>();
		}
	}
	internal static class Log
	{
		private static ManualLogSource _logSource;

		internal static void Init(ManualLogSource logSource)
		{
			_logSource = logSource;
		}

		internal static void Debug(object data)
		{
			_logSource.LogDebug(data);
		}

		internal static void Error(object data)
		{
			_logSource.LogError(data);
		}

		internal static void Fatal(object data)
		{
			_logSource.LogFatal(data);
		}

		internal static void Info(object data)
		{
			_logSource.LogInfo(data);
		}

		internal static void Message(object data)
		{
			_logSource.LogMessage(data);
		}

		internal static void Warning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
	public static class PluginConfig
	{
		private static ConfigFile cfg;

		public static ConfigEntry<bool> customHUD;

		public static ConfigEntry<bool> dynamicCustomHUD;

		public static ConfigEntry<bool> disableChat;

		public static ConfigEntry<bool> dynamicCrosshair;

		public static ConfigEntry<bool> fancyShield;

		public static ConfigEntry<bool> shieldBubble;

		public static ConfigEntry<float> vignetteStrength;

		public static ConfigEntry<bool> overTheShoulderCamera;

		public static ConfigEntry<bool> overTheShoulderCameraGlobal;

		public static ConfigEntry<float> cameraSmoothSpeed;

		internal static void Init(ConfigFile config)
		{
			cfg = config;
			customHUD = cfg.BindAndOptions("01 - General", "Custom HUD", defaultValue: true, "Set to true to enable a custom HUD tailored just for HUNK.");
			dynamicCustomHUD = cfg.BindAndOptions("01 - General", "Dynamic Custom HUD", defaultValue: true, "Set to false to keep HUNK's custom HUD on the screen at all times.");
			vignetteStrength = cfg.BindAndOptionsSlider("03 - Camera", "Vignette Strength", 0f, "Adds a subtle vignette to the screen to put more focus on the center.", 0f, 1f);
		}

		public static void InitROO(Sprite modSprite, string modDescription)
		{
			ModSettingsManager.SetModIcon(modSprite);
			ModSettingsManager.SetModDescription(modDescription);
		}

		public static ConfigEntry<T> BindAndOptions<T>(this ConfigFile config, string section, string name, T defaultValue, string description = "", bool restartRequired = false)
		{
			if (string.IsNullOrEmpty(description))
			{
				description = name;
			}
			description += $" (Default: {defaultValue})";
			if (restartRequired)
			{
				description += " (restart required)";
			}
			ConfigEntry<T> val = config.Bind<T>(section, name, defaultValue, description);
			if (HunkHudMain.ROOInstalled)
			{
				TryRegisterOption<T>(val, restartRequired);
			}
			return val;
		}

		public static ConfigEntry<float> BindAndOptionsSlider(this ConfigFile config, string section, string name, float defaultValue, string description = "", float min = 0f, float max = 20f, bool restartRequired = false)
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			if (string.IsNullOrEmpty(description))
			{
				description = name;
			}
			description += $" (Default: {defaultValue})";
			if (restartRequired)
			{
				description += " (restart required)";
			}
			ConfigEntry<float> val = config.Bind<float>(section, name, defaultValue, new ConfigDescription(description, (AcceptableValueBase)(object)new AcceptableValueRange<float>(min, max), Array.Empty<object>()));
			if (HunkHudMain.ROOInstalled)
			{
				TryRegisterOptionSlider(val, min, max, restartRequired);
			}
			return val;
		}

		public static ConfigEntry<int> BindAndOptionsSlider(this ConfigFile config, string section, string name, int defaultValue, string description = "", int min = 0, int max = 20, bool restartRequired = false)
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			if (string.IsNullOrEmpty(description))
			{
				description = name;
			}
			description += $" (Default: {defaultValue})";
			if (restartRequired)
			{
				description += " (restart required)";
			}
			ConfigEntry<int> val = config.Bind<int>(section, name, defaultValue, new ConfigDescription(description, (AcceptableValueBase)(object)new AcceptableValueRange<int>(min, max), Array.Empty<object>()));
			if (HunkHudMain.ROOInstalled)
			{
				TryRegisterOptionSlider(val, min, max, restartRequired);
			}
			return val;
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		private static void TryRegisterOption<T>(ConfigEntry<T> entry, bool restartRequired)
		{
			//IL_000e: 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)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected O, but got Unknown
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Expected O, but got Unknown
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Expected O, but got Unknown
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Expected O, but got Unknown
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Expected O, but got Unknown
			if (entry is ConfigEntry<float>)
			{
				ModSettingsManager.AddOption((BaseOption)new SliderOption(entry as ConfigEntry<float>, new SliderConfig
				{
					min = 0f,
					max = 20f,
					FormatString = "{0:0.00}",
					restartRequired = restartRequired
				}), "com.public_ParticleSystem.HunkHud", "HunkHud");
			}
			if (entry is ConfigEntry<int>)
			{
				ModSettingsManager.AddOption((BaseOption)new IntSliderOption(entry as ConfigEntry<int>, restartRequired), "com.public_ParticleSystem.HunkHud", "HunkHud");
			}
			if (entry is ConfigEntry<bool>)
			{
				ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(entry as ConfigEntry<bool>, restartRequired), "com.public_ParticleSystem.HunkHud", "HunkHud");
			}
			if (entry is ConfigEntry<KeyboardShortcut>)
			{
				ModSettingsManager.AddOption((BaseOption)new KeyBindOption(entry as ConfigEntry<KeyboardShortcut>, restartRequired), "com.public_ParticleSystem.HunkHud", "HunkHud");
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		private static void TryRegisterOptionSlider(ConfigEntry<int> entry, int min, int max, bool restartRequired)
		{
			//IL_0001: 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_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			ModSettingsManager.AddOption((BaseOption)new IntSliderOption(entry, new IntSliderConfig
			{
				min = min,
				max = max,
				formatString = "{0:0.00}",
				restartRequired = restartRequired
			}), "com.public_ParticleSystem.HunkHud", "HunkHud");
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		private static void TryRegisterOptionSlider(ConfigEntry<float> entry, float min, float max, bool restartRequired)
		{
			//IL_0001: 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_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			ModSettingsManager.AddOption((BaseOption)new SliderOption(entry, new SliderConfig
			{
				min = min,
				max = max,
				FormatString = "{0:0.00}",
				restartRequired = restartRequired
			}), "com.public_ParticleSystem.HunkHud", "HunkHud");
		}
	}
}
namespace HunkHud.Components
{
	public class AllyHealthBarMover : DisplayMover
	{
		private AllyCardController cardController;

		private CanvasGroup canvas;

		protected override void Awake()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			base.Awake();
			offset = new Vector3(-500f, 0f, 0f);
			cardController = ((Component)this).GetComponent<AllyCardController>();
			canvas = ((Component)this).GetComponent<CanvasGroup>();
		}

		protected override void Update()
		{
			base.Update();
			if (Object.op_Implicit((Object)(object)canvas))
			{
				canvas.alpha = Mathf.Clamp01(activeTimer + 1f);
			}
		}

		public override void CheckForActivity()
		{
			if (Object.op_Implicit((Object)(object)cardController))
			{
				CharacterBody cachedSourceCharacterBody = cardController.cachedSourceCharacterBody;
				if (Object.op_Implicit((Object)(object)cachedSourceCharacterBody) && Object.op_Implicit((Object)(object)cachedSourceCharacterBody.healthComponent) && cachedSourceCharacterBody.healthComponent.missingCombinedHealth > 0f)
				{
					SetActive();
				}
			}
		}
	}
	public abstract class DisplayMover : CustomHudElement, IConfigHandler
	{
		[NonSerialized]
		public ZioConfigEntry<bool> _configEntry;

		public float delayTimer = 0.1f;

		public float refreshTimer = 2.8f;

		public float activeTimer = 8f;

		public float smoothSpeed = 4f;

		public Vector3 offset;

		[NonSerialized]
		public Vector3 activePosition;

		[NonSerialized]
		public Vector3 desiredPosition;

		public abstract void CheckForActivity();

		private void ConfigUpdated(ZioConfigEntryBase zioConfigEntryBase, object o, bool arg3)
		{
			((Behaviour)this).enabled = _configEntry?.Value ?? true;
		}

		public void Startup()
		{
			_configEntry = ConfigHelper.Bind<bool>("HunkHud", ((object)this).GetType().Name, true, "Enable or disable moving this hud element", (Action<ZioConfigEntry<bool>>)null, (object)null);
		}

		public virtual void SetActive()
		{
			activeTimer = Mathf.Max(activeTimer, refreshTimer);
			delayTimer = Mathf.Max(delayTimer, 0.1f);
		}

		protected virtual void Awake()
		{
			Startup();
			((ZioConfigEntryBase)_configEntry).SettingChanged += ConfigUpdated;
		}

		protected virtual void Start()
		{
			//IL_0007: 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_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			activePosition = ((Component)this).transform.localPosition;
			offset.x = Mathf.Abs(offset.x) * Mathf.Sign(((Component)this).transform.position.x);
			offset.y = Mathf.Abs(offset.y) * Mathf.Sign(((Component)this).transform.position.y);
		}

		protected override void OnEnable()
		{
			base.OnEnable();
			ConfigUpdated(null, null, arg3: false);
		}

		protected virtual void Update()
		{
			//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_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: 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_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: 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)
			Vector3 localPosition = ((Component)this).transform.localPosition;
			Vector3 val = activePosition;
			if (activeTimer <= 0f)
			{
				val += offset;
			}
			if (offset.x == 0f)
			{
				val.x = localPosition.x;
			}
			if (offset.y == 0f)
			{
				val.y = localPosition.y;
			}
			if (offset.z == 0f)
			{
				val.z = localPosition.z;
			}
			((Component)this).transform.localPosition = Vector3.Lerp(localPosition, val, smoothSpeed * Time.deltaTime);
		}

		protected virtual void FixedUpdate()
		{
			activeTimer -= Time.fixedDeltaTime;
			delayTimer -= Time.fixedDeltaTime;
			if (Object.op_Implicit((Object)(object)base.targetHud) && Object.op_Implicit((Object)(object)base.targetHud.scoreboardPanel) && base.targetHud.scoreboardPanel.activeSelf)
			{
				SetActive();
			}
			if (delayTimer <= 0f)
			{
				delayTimer = 0.1f;
				CheckForActivity();
			}
		}

		protected virtual void OnDestroy()
		{
			((ZioConfigEntryBase)_configEntry).SettingChanged -= ConfigUpdated;
		}
	}
	[RequireComponent(typeof(CrosshairController))]
	[RequireComponent(typeof(HudElement))]
	public class DynamicCrosshair : MonoBehaviour
	{
		public float range = 300f;

		public float interval = 0.2f;

		private HudElement hudElement;

		private (Image image, Color color)[] crosshairSprites;

		private float stopwatch;

		private void Awake()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: 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_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			hudElement = ((Component)this).GetComponent<HudElement>();
			List<(Image, Color)> list = new List<(Image, Color)>();
			SpritePosition[] spriteSpreadPositions = ((Component)this).GetComponent<CrosshairController>().spriteSpreadPositions;
			foreach (SpritePosition val in spriteSpreadPositions)
			{
				Image val2 = (Object.op_Implicit((Object)(object)val.target) ? ((Component)val.target).GetComponent<Image>() : null);
				if (Object.op_Implicit((Object)(object)val2))
				{
					list.Add((val2, ((Graphic)val2).color));
				}
			}
			crosshairSprites = list.ToArray();
		}

		private void FixedUpdate()
		{
			stopwatch -= Time.fixedDeltaTime;
			if (stopwatch <= 0f)
			{
				stopwatch = interval;
				Simulate();
			}
		}

		private void Simulate()
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			CharacterBody val = (Object.op_Implicit((Object)(object)hudElement) ? hudElement.targetCharacterBody : null);
			if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val.inputBank))
			{
				return;
			}
			Ray aimRay = val.inputBank.GetAimRay();
			Color? val2 = null;
			RaycastHit val3 = default(RaycastHit);
			if (Physics.Raycast(aimRay, ref val3, range, LayerMask.op_Implicit(CommonMasks.bullet), (QueryTriggerInteraction)2))
			{
				HurtBox val4 = (Object.op_Implicit((Object)(object)((RaycastHit)(ref val3)).collider) ? ((Component)((RaycastHit)(ref val3)).collider).GetComponent<HurtBox>() : null);
				if (Object.op_Implicit((Object)(object)val4))
				{
					CharacterBody val5 = (Object.op_Implicit((Object)(object)val4.healthComponent) ? val4.healthComponent.body : null);
					if (Object.op_Implicit((Object)(object)val5) && (Object)(object)val5 != (Object)(object)val)
					{
						val2 = ((val5.teamComponent.teamIndex == val.teamComponent.teamIndex) ? Color.green : Color.red);
					}
				}
			}
			for (int i = 0; i < crosshairSprites.Length; i++)
			{
				((Graphic)crosshairSprites[i].image).color = (Color)(((??)val2) ?? crosshairSprites[i].color);
			}
		}
	}
	public class HealthBarMover : DisplayMover
	{
		private int prevLevel;

		public override void CheckForActivity()
		{
			if (Object.op_Implicit((Object)(object)base.targetBody) && Object.op_Implicit((Object)(object)base.targetBody.healthComponent))
			{
				if (base.targetBody.healthComponent.missingCombinedHealth > 0f)
				{
					SetActive();
				}
				int num = Mathf.RoundToInt(base.targetBody.level);
				if (num != prevLevel)
				{
					prevLevel = num;
					SetActive();
				}
			}
		}
	}
	public class ItemDisplayMover : DisplayMover
	{
		private CharacterMaster _prevMaster;

		protected override void Awake()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			base.Awake();
			offset = new Vector3(0f, 250f, 0f);
		}

		protected override void Start()
		{
			//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_001e: Unknown result type (might be due to invalid IL or missing references)
			Vector3 localPosition = ((Component)this).transform.localPosition;
			localPosition.x = 0f;
			((Component)this).transform.localPosition = localPosition;
			base.Start();
		}

		public override void CheckForActivity()
		{
			if ((Object)(object)_prevMaster != (Object)(object)base.targetMaster)
			{
				if (Object.op_Implicit((Object)(object)_prevMaster) && Object.op_Implicit((Object)(object)_prevMaster.inventory))
				{
					_prevMaster.inventory.onInventoryChanged -= SetActive;
				}
				_prevMaster = base.targetMaster;
				if (Object.op_Implicit((Object)(object)base.targetMaster) && Object.op_Implicit((Object)(object)base.targetMaster.inventory))
				{
					base.targetMaster.inventory.onInventoryChanged += SetActive;
				}
			}
		}

		protected override void OnDestroy()
		{
			base.OnDestroy();
			if (Object.op_Implicit((Object)(object)base.targetMaster) && Object.op_Implicit((Object)(object)base.targetMaster.inventory))
			{
				base.targetMaster.inventory.onInventoryChanged -= SetActive;
			}
		}
	}
	public class MoneyDisplayMover : DisplayMover
	{
		private int cachedMoney;

		private int cachedCoin;

		protected override void Awake()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			base.Awake();
			offset = new Vector3(-450f, 100f, 0f);
		}

		public override void CheckForActivity()
		{
			if (!Object.op_Implicit((Object)(object)base.targetHud))
			{
				return;
			}
			if (Object.op_Implicit((Object)(object)base.targetHud.lunarCoinText))
			{
				int displayAmount = base.targetHud.lunarCoinText.displayAmount;
				if (displayAmount != cachedCoin)
				{
					cachedCoin = displayAmount;
					SetActive();
				}
			}
			if (Object.op_Implicit((Object)(object)base.targetHud.moneyText))
			{
				int displayAmount2 = base.targetHud.moneyText.displayAmount;
				if (displayAmount2 != cachedMoney)
				{
					cachedMoney = displayAmount2;
					SetActive();
				}
			}
		}
	}
	public class ObjectiveDisplayMover : DisplayMover
	{
		private int prevCount;

		private ObjectivePanelController objectivePanel;

		protected override void Awake()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			base.Awake();
			offset = new Vector3(400f, 100f, 0f);
			objectivePanel = ((Component)this).GetComponentInChildren<ObjectivePanelController>();
			GlobalEventManager.onTeamLevelUp += GlobalEventManager_onTeamLevelUp;
		}

		protected override void OnDestroy()
		{
			base.OnDestroy();
			GlobalEventManager.onTeamLevelUp -= GlobalEventManager_onTeamLevelUp;
		}

		private void GlobalEventManager_onTeamLevelUp(TeamIndex team)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Invalid comparison between Unknown and I4
			if ((int)team == 2)
			{
				activeTimer = refreshTimer;
			}
		}

		public override void CheckForActivity()
		{
			if (Object.op_Implicit((Object)(object)objectivePanel))
			{
				int count = objectivePanel.objectiveTrackers.Count;
				if (count != prevCount)
				{
					prevCount = count;
					SetActive();
				}
			}
		}
	}
	public class SkillIconMover : DisplayMover
	{
		protected override void Awake()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			base.Awake();
			offset = new Vector3(0f, -300f, 0f);
		}

		public override void CheckForActivity()
		{
			if (!Object.op_Implicit((Object)(object)base.targetBody))
			{
				return;
			}
			if (Object.op_Implicit((Object)(object)base.targetBody.equipmentSlot) && base.targetBody.equipmentSlot.cooldownTimer > 0f)
			{
				SetActive();
			}
			else
			{
				if (!Object.op_Implicit((Object)(object)base.targetBody.skillLocator))
				{
					return;
				}
				for (int i = 0; i < base.targetBody.skillLocator.allSkills.Length; i++)
				{
					GenericSkill val = base.targetBody.skillLocator.allSkills[i];
					if (Object.op_Implicit((Object)(object)val) && val.cooldownRemaining != 0f)
					{
						SetActive();
						break;
					}
				}
			}
		}
	}
}
namespace HunkHud.Components.UI
{
	public class BandDisplay : CustomHudElement
	{
		public Gradient fillGradient;

		public GameObject fullObj;

		public GameObject fillObj;

		public Image fillImage;

		public string buffName;

		public string cooldownName;

		[NonSerialized]
		public HealthBarMover healthBar;

		private float timer;

		private int maxBuffs;

		private void FixedUpdate()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)base.targetBody) && Object.op_Implicit((Object)(object)healthBar))
			{
				if (base.targetBody.HasBuff(BuffCatalog.FindBuffIndex(buffName)))
				{
					SetRingReady();
					return;
				}
				int buffCount = base.targetBody.GetBuffCount(BuffCatalog.FindBuffIndex(cooldownName));
				if (buffCount > 0)
				{
					SetRingCooldown(buffCount);
					return;
				}
			}
			fillObj.SetActive(false);
			fullObj.SetActive(false);
		}

		private void SetRingReady()
		{
			fullObj.SetActive(true);
			fillObj.SetActive(false);
			timer = 0f;
			maxBuffs = 0;
		}

		private void SetRingCooldown(int newBuffs)
		{
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			fullObj.SetActive(false);
			fillObj.SetActive(true);
			healthBar.SetActive();
			maxBuffs = Math.Max(maxBuffs, newBuffs);
			float num = Util.Remap(timer, 0f, (float)maxBuffs, 0f, 1f);
			((Graphic)fillImage).color = fillGradient.Evaluate(num);
			fillImage.fillAmount = num;
			timer += Time.fixedDeltaTime;
		}

		public BandDisplay()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: 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_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: 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_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			Gradient val = new Gradient();
			val.alphaKeys = (GradientAlphaKey[])(object)new GradientAlphaKey[2]
			{
				new GradientAlphaKey
				{
					alpha = 1f,
					time = 0f
				},
				new GradientAlphaKey
				{
					alpha = 1f,
					time = 1f
				}
			};
			val.colorKeys = (GradientColorKey[])(object)new GradientColorKey[5]
			{
				new GradientColorKey
				{
					color = Color.red,
					time = 0f
				},
				new GradientColorKey
				{
					color = Color.yellow,
					time = 0.5f
				},
				new GradientColorKey
				{
					color = new Color(31f / 85f, 57f / 85f, 23f / 51f),
					time = 0.6f
				},
				new GradientColorKey
				{
					color = new Color(31f / 85f, 57f / 85f, 23f / 51f),
					time = 0.95f
				},
				new GradientColorKey
				{
					color = Color.white,
					time = 1f
				}
			};
			fillGradient = val;
			base..ctor();
		}
	}
	public class BandDisplayController : CustomHudElement
	{
		public HealthBarMover healthBar;

		private CharacterMaster prevMaster;

		private bool isInventoryCheckDirty;

		private void FixedUpdate()
		{
			if ((Object)(object)prevMaster != (Object)(object)base.targetMaster)
			{
				CharacterMaster obj = prevMaster;
				if (Object.op_Implicit((Object)(object)((obj != null) ? obj.inventory : null)))
				{
					prevMaster.inventory.onInventoryChanged -= OnInventoryChanged;
				}
				CharacterMaster obj2 = base.targetMaster;
				if (Object.op_Implicit((Object)(object)((obj2 != null) ? obj2.inventory : null)))
				{
					base.targetMaster.inventory.onInventoryChanged += OnInventoryChanged;
				}
				prevMaster = base.targetMaster;
				OnInventoryChanged();
			}
			if (isInventoryCheckDirty)
			{
				CheckInventory();
			}
		}

		public void OnInventoryChanged()
		{
			isInventoryCheckDirty = true;
		}

		private void CheckInventory()
		{
			isInventoryCheckDirty = false;
			Inventory inventory = (Object.op_Implicit((Object)(object)base.targetMaster) ? base.targetMaster.inventory : null);
			AddOrRemovePrefab("BandDisplay", new string[2] { "FireRing", "IceRing" });
			AddOrRemovePrefab("BandDisplayVoid", new string[1] { "ElementalRingVoid" });
			AddOrRemovePrefab("BandDisplayHealing", new string[2] { "ITEM_HEALING_BAND", "ITEM_BARRIER_BAND" });
			AddOrRemovePrefab("BandDisplayNova", new string[1] { "ITEM_NOVA_BAND" });
			AddOrRemovePrefab("BandDisplaySacrificial", new string[1] { "ITEM_SANDSWEPT_SACRIFICIAL_BAND" });
			void AddOrRemovePrefab(string prefabName, string[] itemName)
			{
				//IL_0016: Unknown result type (might be due to invalid IL or missing references)
				//IL_001b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0023: Unknown result type (might be due to invalid IL or missing references)
				bool flag = false;
				if (Object.op_Implicit((Object)(object)inventory))
				{
					for (int i = 0; i < itemName.Length; i++)
					{
						ItemIndex val = ItemCatalog.FindItemIndex(itemName[i]);
						if (inventory.GetItemCount(val) > 0)
						{
							flag = true;
							break;
						}
					}
				}
				Transform val2 = ((Component)this).transform.Find(prefabName);
				bool flag2 = (Object)(object)val2 != (Object)null;
				if (flag != flag2)
				{
					if (flag2)
					{
						Object.Destroy((Object)(object)((Component)val2).gameObject);
					}
					else
					{
						GameObject obj = Object.Instantiate<GameObject>(HudAssets.mainAssetBundle.LoadAsset<GameObject>(prefabName), ((Component)this).transform);
						((Object)obj).name = prefabName;
						BandDisplay component = obj.GetComponent<BandDisplay>();
						component.healthBar = healthBar;
						((HudElement)component).hud = ((HudElement)this).hud;
					}
				}
			}
		}
	}
	public class CustomHealthBar : HealthBar
	{
		[Serializable]
		public struct CustomBarInfo
		{
			[NonSerialized]
			public bool enabled;

			[NonSerialized]
			public float targetFill;

			[NonSerialized]
			public float currentFill;

			[SerializeField]
			public Image image;
		}

		public static CustomHealthBar instance;

		public Gradient healthBarGradient;

		public Color shieldColor;

		public Color pinkShieldColor;

		public Color infusionColor;

		public CustomBarInfo healthFill;

		public CustomBarInfo lowHealthFill;

		public CustomBarInfo shieldFill;

		public CustomBarInfo damageFill;

		public CustomBarInfo healingFill;

		public CustomBarInfo curseFill;

		public CustomBarInfo barrierFill;

		public CustomBarInfo barrierFillShiny;

		public CustomBarInfo delayedDamageMask;

		public CustomBarInfo ospFill;

		public CustomBarInfo echoFill;

		public CustomBarInfo collapseFill;

		public CustomBarInfo cullFill;

		public TextMeshProUGUI gunText;

		public RawImage gunIcon;

		public GameObject gunIconHolder;

		public RawImage characterIcon;

		public RawImage characterIconBorder;

		public GameObject characterIconHolder;

		public GameObject lunarRuinDisplay;

		public GameObject immunityDisplay;

		public GameObject biomassBar;

		public HealthBarMover hpBarMover;

		private float fillSpeed;

		private float minFill;

		private float maxFill;

		private float inverseFillMin;

		private float inverseFillMax;

		public CharacterBody targetBody => ((HealthBar)this).source?.body;

		private void Awake()
		{
			((HealthBar)this).Awake();
			SetDefaults();
			GameObject obj = biomassBar;
			if (obj != null)
			{
				obj.SetActive(false);
			}
			GameObject obj2 = gunIconHolder;
			if (obj2 != null)
			{
				obj2.SetActive(false);
			}
			GameObject obj3 = characterIconHolder;
			if (obj3 != null)
			{
				obj3.SetActive(true);
			}
		}

		private void OnEnable()
		{
			((HealthBar)this).OnEnable();
			SingletonHelper.Assign<CustomHealthBar>(ref instance, this);
		}

		private void OnDisable()
		{
			((HealthBar)this).OnDisable();
			SingletonHelper.Unassign<CustomHealthBar>(ref instance, this);
		}

		private void Update()
		{
			base.updateTimer -= Time.deltaTime;
			if ((Object)(object)base._source != (Object)(object)base.oldSource)
			{
				base.updateTimer = 0f;
				base.oldSource = base._source;
			}
			if (base.updateTimer <= 0f)
			{
				base.updateTimer = base.updateDelay;
				UpdateCustomBarInfos();
				ApplyCustomBars();
			}
			ApplyCustomBarsUpdate();
		}

		private void ApplyCustomBarsUpdate()
		{
			Apply(ref healthFill);
			Apply(ref shieldFill);
			Apply(ref damageFill);
		}

		private void ApplyCustomBars()
		{
			Apply(ref healingFill);
			Apply(ref barrierFill);
			Apply(ref barrierFillShiny);
			Apply(ref lowHealthFill);
			Apply(ref curseFill);
			Apply(ref cullFill);
			Apply(ref delayedDamageMask);
			Apply(ref collapseFill);
			Apply(ref echoFill);
			Apply(ref ospFill);
		}

		private void Apply(ref CustomBarInfo info)
		{
			if (info.currentFill != info.targetFill)
			{
				info.currentFill = Mathf.Lerp(info.currentFill, info.targetFill, fillSpeed * Time.deltaTime);
			}
			((Behaviour)info.image).enabled = info.enabled;
			info.image.fillAmount = info.currentFill;
		}

		private void SetDefaults()
		{
			healthFill.enabled = false;
			healingFill.enabled = false;
			lowHealthFill.enabled = false;
			shieldFill.enabled = false;
			barrierFill.enabled = false;
			barrierFillShiny.enabled = false;
			damageFill.targetFill = 0f;
			damageFill.enabled = 0f < damageFill.currentFill;
			delayedDamageMask.enabled = false;
			collapseFill.enabled = false;
			echoFill.enabled = false;
			ospFill.enabled = false;
			cullFill.enabled = false;
			GameObject obj = immunityDisplay;
			if (obj != null)
			{
				obj.SetActive(false);
			}
		}

		private void UpdateCustomBarInfos()
		{
			//IL_0035: 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_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: 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_0086: 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_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0295: Unknown result type (might be due to invalid IL or missing references)
			//IL_029b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02db: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0317: Unknown result type (might be due to invalid IL or missing references)
			//IL_031d: Unknown result type (might be due to invalid IL or missing references)
			//IL_035d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0365: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)((HealthBar)this).source) || !Object.op_Implicit((Object)(object)targetBody))
			{
				SetDefaults();
				return;
			}
			if (base.isInventoryCheckDirty)
			{
				((HealthBar)this).CheckInventory();
			}
			HealthBarValues healthBarValues = ((HealthBar)this).source.GetHealthBarValues();
			float num = 1f - (healthBarValues.healthFraction + healthBarValues.shieldFraction);
			float num2 = 1f - healthBarValues.curseFraction;
			float num3 = Mathf.Clamp01(GetCollapseFraction() * num2);
			((Graphic)shieldFill.image).color = (healthBarValues.hasVoidShields ? pinkShieldColor : shieldColor);
			((Graphic)healthFill.image).color = (healthBarValues.hasInfusion ? infusionColor : healthBarGradient.Evaluate(healthBarValues.healthFraction));
			GameObject obj = immunityDisplay;
			if (obj != null)
			{
				obj.SetActive(targetBody.HasBuff(Buffs.HiddenInvincibility));
			}
			GameObject obj2 = lunarRuinDisplay;
			if (obj2 != null)
			{
				obj2.SetActive(healthBarValues.hasLunarRuin);
			}
			float num4 = Util.Remap(healthBarValues.healthFraction, 0f, 1f, minFill, maxFill);
			healthFill.enabled = healthBarValues.healthFraction > 0f;
			healthFill.targetFill = num4;
			healthFill.currentFill = Mathf.Min(num4, healthFill.currentFill);
			float num5 = Util.Remap(healthBarValues.healthFraction + healthBarValues.shieldFraction, 0f, 1f, minFill, maxFill);
			damageFill.targetFill = num5;
			damageFill.currentFill = Mathf.Max(num5, damageFill.currentFill);
			damageFill.enabled = damageFill.currentFill > num5;
			shieldFill.enabled = healthBarValues.shieldFraction > 0f;
			shieldFill.targetFill = num5;
			shieldFill.currentFill = Mathf.Min(num5, shieldFill.currentFill);
			Remap(ref healingFill, healthBarValues.healthFraction, healthFill.currentFill < healthFill.targetFill, inverse: false);
			Remap(ref lowHealthFill, HealthComponent.lowHealthFraction * num2, (base.hasLowHealthItem || base.hasLowHealthBuff) && !((HealthBar)this).source.isHealthLow, inverse: false);
			Remap(ref barrierFill, healthBarValues.barrierFraction, healthBarValues.barrierFraction > 0f, inverse: false);
			Remap(ref barrierFillShiny, healthBarValues.barrierFraction, healthBarValues.barrierFraction > 0f, inverse: false);
			Remap(ref cullFill, healthBarValues.cullFraction, healthBarValues.cullFraction > 0f, inverse: false);
			Remap(ref curseFill, healthBarValues.curseFraction, healthBarValues.curseFraction > 0f, inverse: true);
			Remap(ref ospFill, healthBarValues.ospFraction + num, healthBarValues.ospFraction > 0f, inverse: true);
			Remap(ref delayedDamageMask, healthBarValues.healthFraction + healthBarValues.shieldFraction, enabled: true, inverse: false);
			Remap(ref collapseFill, num3 + num, num3 > 0f && targetBody.HasBuff(Buffs.Fracture), inverse: true);
			Remap(ref echoFill, healthBarValues.echoFraction + num, healthBarValues.echoFraction > 0f && targetBody.HasBuff(Buffs.DelayedDamageDebuff), inverse: true);
			if (echoFill.enabled || collapseFill.enabled)
			{
				hpBarMover?.SetActive();
				damageFill.currentFill = damageFill.targetFill;
			}
			void Remap(ref CustomBarInfo bar, float value, bool enabled, bool inverse)
			{
				bar.enabled = enabled;
				value = Mathf.Clamp01(value);
				bar.currentFill = (bar.targetFill = (inverse ? Util.Remap(value, 0f, 1f, inverseFillMin, inverseFillMax) : Util.Remap(value, 0f, 1f, minFill, maxFill)));
			}
		}

		private float GetCollapseFraction()
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			DotController val = DotController.FindDotController(((Component)targetBody).gameObject);
			if (!Object.op_Implicit((Object)(object)val) || !val.HasDotActive((DotIndex)8))
			{
				return 0f;
			}
			float num = 0f;
			foreach (DotStack dotStack in val.dotStackList)
			{
				if ((int)dotStack.dotIndex == 8)
				{
					float damage = dotStack.damage;
					ModifyIncomingDamage(ref damage, dotStack.attackerObject, dotStack.attackerTeam, dotStack.damageType);
					num += Mathf.Max(0f, damage);
				}
			}
			return num / ((HealthBar)this).source.fullCombinedHealth;
		}

		private void ModifyIncomingDamage(ref float damage, GameObject attacker, TeamIndex attackerTeam, DamageTypeCombo damageType)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: 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_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_0316: Unknown result type (might be due to invalid IL or missing references)
			//IL_0318: Unknown result type (might be due to invalid IL or missing references)
			//IL_0322: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b7: 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_02c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			if ((damageType.damageTypeExtended & 0x10000000) != 0)
			{
				damage = ((HealthBar)this).source.fullHealth * 0.1f;
			}
			if (targetBody.HasBuff(Buffs.KnockUpHitEnemiesJuggleCount))
			{
				damage *= 1f + 0.1f * (float)targetBody.GetBuffCount(Buffs.KnockUpHitEnemiesJuggleCount);
			}
			if (targetBody.HasBuff(Buffs.lunarruin))
			{
				damage *= 1f + 0.1f * (float)targetBody.GetBuffCount(Buffs.lunarruin);
			}
			if (attackerTeam == targetBody.teamComponent.teamIndex)
			{
				damage *= TeamCatalog.GetTeamDef(attackerTeam)?.friendlyFireScaling ?? 1f;
			}
			CharacterBody val = (Object.op_Implicit((Object)(object)attacker) ? attacker.GetComponent<CharacterBody>() : null);
			if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.inventory))
			{
				int itemCount;
				if (((HealthBar)this).source.combinedHealth >= ((HealthBar)this).source.fullCombinedHealth * 0.9f)
				{
					itemCount = val.inventory.GetItemCount(Items.Crowbar);
					if (itemCount > 0)
					{
						damage *= 1f + 0.75f * (float)itemCount;
					}
				}
				itemCount = val.inventory.GetItemCount(Items.NearbyDamageBonus);
				if (itemCount > 0)
				{
					Vector3 val2 = targetBody.corePosition - val.corePosition;
					if (((Vector3)(ref val2)).sqrMagnitude <= 169f)
					{
						damage *= 1f + (float)itemCount * 0.2f;
					}
				}
				itemCount = val.inventory.GetItemCount(Items.FragileDamageBonus);
				if (itemCount > 0)
				{
					damage *= 1f + (float)itemCount * 0.2f;
				}
			}
			if ((damageType.damageType & 0x10) != 0)
			{
				damage *= 1.5f;
			}
			if (targetBody.HasBuff(Buffs.DeathMark))
			{
				damage *= 1.5f;
			}
			if ((damageType.damageType & 2) == 0)
			{
				float num = targetBody.armor + ((HealthBar)this).source.adaptiveArmorValue;
				if ((targetBody.bodyFlags & 0x40) != 0 && DamageTypeCombo.op_Implicit(damageType & DamageTypeCombo.op_Implicit((DamageType)131072)) != 0L)
				{
					num += 300f;
				}
				float num2 = ((num >= 0f) ? (1f - num / (num + 100f)) : (2f - 100f / (100f - num)));
				damage = Mathf.Max(1f, damage * num2);
				if (Object.op_Implicit((Object)(object)targetBody.inventory))
				{
					int itemCount = targetBody.inventory.GetItemCount(Items.ArmorPlate);
					if (itemCount > 0)
					{
						damage = Mathf.Max(1f, damage - 5f * (float)itemCount);
					}
				}
			}
			if (targetBody.hasOneShotProtection && (damageType.damageType & 0x40000) == 0)
			{
				float num3 = (((HealthBar)this).source.fullCombinedHealth + ((HealthBar)this).source.barrier) * (1f - targetBody.oneShotProtectionFraction);
				float num4 = Mathf.Max(0f, num3 - ((HealthBar)this).source.serverDamageTakenThisUpdate);
				damage = Mathf.Min(damage, num4);
			}
			if ((damageType.damageType & 0x80000) != 0)
			{
				damage *= Mathf.Lerp(3f, 1f, ((HealthBar)this).source.combinedHealthFraction);
			}
			if (targetBody.HasBuff(Buffs.LunarShell))
			{
				damage = Mathf.Min(damage, ((HealthBar)this).source.fullHealth * 0.1f);
			}
			if (Object.op_Implicit((Object)(object)targetBody.inventory))
			{
				int itemCount = targetBody.inventory.GetItemCount(Items.MinHealthPercentage);
				if (itemCount > 0)
				{
					float num5 = ((HealthBar)this).source.fullCombinedHealth * ((float)itemCount / 100f);
					damage = Mathf.Max(0f, Mathf.Min(damage, ((HealthBar)this).source.combinedHealth - num5));
				}
			}
			if (targetBody.HasBuff(Buffs.DelayedDamageBuff))
			{
				damage *= 0.8f;
			}
		}

		public void SetCharacterIcon(Color? colorOverride = null)
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: 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_0057: Unknown result type (might be due to invalid IL or missing references)
			gunIconHolder.SetActive(false);
			characterIconHolder.SetActive(true);
			if (Object.op_Implicit((Object)(object)targetBody))
			{
				Color color = (Color)(((??)colorOverride) ?? targetBody.bodyColor);
				color.a = 0.25f;
				((Graphic)characterIconBorder).color = color;
				characterIcon.texture = targetBody.portraitIcon;
			}
		}

		public void SetGenericIcon(Texture icon)
		{
			gunIconHolder.SetActive(true);
			characterIconHolder.SetActive(false);
			gunIcon.texture = icon;
		}

		public CustomHealthBar()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: 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_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: 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_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			Gradient val = new Gradient();
			val.alphaKeys = (GradientAlphaKey[])(object)new GradientAlphaKey[2]
			{
				new GradientAlphaKey
				{
					alpha = 1f,
					time = 0f
				},
				new GradientAlphaKey
				{
					alpha = 1f,
					time = 1f
				}
			};
			val.colorKeys = (GradientColorKey[])(object)new GradientColorKey[4]
			{
				new GradientColorKey
				{
					color = Color.red,
					time = 0f
				},
				new GradientColorKey
				{
					color = Color.yellow,
					time = 0.5f
				},
				new GradientColorKey
				{
					color = new Color(31f / 85f, 57f / 85f, 23f / 51f),
					time = 0.8f
				},
				new GradientColorKey
				{
					color = new Color(31f / 85f, 57f / 85f, 23f / 51f),
					time = 1f
				}
			};
			healthBarGradient = val;
			shieldColor = new Color(0.14901961f, 0.70980394f, 0.80784315f);
			pinkShieldColor = new Color(0.80784315f, 0.29803923f, 0.7607843f);
			infusionColor = new Color(1f, 18f / 85f, 0.23137255f);
			fillSpeed = 1.5f;
			minFill = 0.341f;
			maxFill = 0.752f;
			inverseFillMin = 0.248f;
			inverseFillMax = 0.659f;
			((HealthBar)this)..ctor();
		}
	}
	public class LuminousDisplay : CustomHudElement
	{
		public Color activeColor = Color.white;

		public Color inactiveColor = new Color(0f, 0f, 0f, 0.25f);

		public TextMeshProUGUI label;

		public GameObject baseHolder;

		public Image[] pips;

		private int GetBuffCount()
		{
			return base.targetBody.GetBuffCount(Buffs.IncreasePrimaryDamageBuff);
		}

		private void FixedUpdate()
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			int num = (Object.op_Implicit((Object)(object)base.targetBody) ? base.targetBody.GetBuffCount(Buffs.IncreasePrimaryDamageBuff) : 0);
			if (num == 0)
			{
				baseHolder.SetActive(false);
				return;
			}
			for (int i = 0; i < pips.Length; i++)
			{
				((Graphic)pips[i]).color = ((num > i) ? activeColor : inactiveColor);
			}
			((TMP_Text)label).text = num.ToString();
			baseHolder.SetActive(true);
		}
	}
	public class ObjectiveChargeDisplay : MonoBehaviour
	{
		public Image fill;

		public GameObject fullBar;

		public TextMeshProUGUI label;

		public CanvasGroup canvas;

		private float targetAlpha;

		private void Awake()
		{
			((Component)this).transform.SetSiblingIndex(1);
		}

		private void FixedUpdate()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected I4, but got Unknown
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			ActivationState val = (ActivationState)0;
			if (Object.op_Implicit((Object)(object)TeleporterInteraction.instance))
			{
				val = TeleporterInteraction.instance.activationState;
			}
			switch (val - 1)
			{
			default:
				targetAlpha = 0f;
				break;
			case 0:
				fullBar.SetActive(false);
				fill.fillAmount = 0f;
				((TMP_Text)label).text = "";
				targetAlpha = Mathf.Lerp(targetAlpha, 1f, Time.fixedDeltaTime);
				break;
			case 1:
				fullBar.SetActive(false);
				fill.fillAmount = TeleporterInteraction.instance.chargeFraction;
				((TMP_Text)label).text = $"{TeleporterInteraction.instance.chargePercent}%";
				targetAlpha = 1f;
				break;
			case 2:
				fullBar.SetActive(true);
				fill.fillAmount = 1f;
				((TMP_Text)label).text = "100%";
				targetAlpha = Mathf.Lerp(targetAlpha, 0f, Time.fixedDeltaTime);
				break;
			}
			canvas.alpha = targetAlpha;
			((Component)canvas).gameObject.SetActive(targetAlpha > 0f);
		}
	}
}