Decompiled source of SidewaysHealthBar v1.2.0

SidewaysHealthBar.dll

Decompiled 15 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("0.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace SidewaysHealthBar
{
	internal sealed class BarHeight
	{
		private readonly RectTransform _root;

		private readonly List<RectTransform> _rects = new List<RectTransform>();

		private readonly List<float> _sizes = new List<float>();

		private readonly List<float> _positions = new List<float>();

		private float _applied = 1f;

		internal BarHeight(RectTransform root)
		{
			//IL_004a: 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)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			_root = root;
			RectTransform[] componentsInChildren = ((Component)root).GetComponentsInChildren<RectTransform>(true);
			foreach (RectTransform val in componentsInChildren)
			{
				if (Mathf.Approximately(val.anchorMin.y, val.anchorMax.y))
				{
					_rects.Add(val);
					_sizes.Add(val.sizeDelta.y);
					_positions.Add(val.anchoredPosition.y);
				}
			}
		}

		internal void Apply(float factor)
		{
			//IL_0031: 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_004d: 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_0067: 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)
			if (Mathf.Approximately(factor, _applied))
			{
				return;
			}
			_applied = factor;
			for (int i = 0; i < _rects.Count; i++)
			{
				RectTransform val = _rects[i];
				if (!((Object)(object)val == (Object)null))
				{
					Vector2 sizeDelta = val.sizeDelta;
					sizeDelta.y = _sizes[i] * factor;
					val.sizeDelta = sizeDelta;
					if ((Object)(object)val != (Object)(object)_root)
					{
						Vector2 anchoredPosition = val.anchoredPosition;
						anchoredPosition.y = _positions[i] * factor;
						val.anchoredPosition = anchoredPosition;
					}
				}
			}
		}
	}
	internal static class BarOverlay
	{
		private const float BorderBuffer = 16f;

		private const float EdgeMargin = 10f;

		private static Hud _hud;

		private static RectTransform _canvas;

		private static bool _failed;

		private static RectTransform _root;

		private static GuiBar _fast;

		private static GuiBar _slow;

		private static TMP_Text _text;

		private static Animator _animator;

		private static BarHeight _healthHeight;

		private static BarHeight _staminaHeight;

		private static BarHeight _eitrHeight;

		private static List<Graphic> _originalHealth;

		private static bool _originalHidden;

		internal static void Update(Hud hud, Player player)
		{
			Attach(hud);
			UpdateOriginalHealthBar(hud);
			UpdateResourceBars(hud, player);
			UpdateHealthBar(hud, player);
		}

		private static void Attach(Hud hud)
		{
			if (!((Object)(object)_hud == (Object)(object)hud))
			{
				_hud = hud;
				Canvas componentInParent = ((Component)hud.m_staminaBar2Root).GetComponentInParent<Canvas>();
				_canvas = (RectTransform)(((Object)(object)componentInParent != (Object)null) ? /*isinst with value type is only supported in some contexts*/: null);
				_failed = false;
				_root = null;
				_healthHeight = null;
				_originalHealth = null;
				_originalHidden = false;
				_staminaHeight = new BarHeight(hud.m_staminaBar2Root);
				_eitrHeight = (((Object)(object)hud.m_eitrBarRoot != (Object)null) ? new BarHeight(hud.m_eitrBarRoot) : null);
			}
		}

		private static void UpdateOriginalHealthBar(Hud hud)
		{
			bool flag = !Plugin.ShowOriginalHealthBar.Value;
			if (!flag && !_originalHidden)
			{
				return;
			}
			if (_originalHealth == null)
			{
				_originalHealth = CollectOriginalHealth(hud);
			}
			foreach (Graphic item in _originalHealth)
			{
				if ((Object)(object)item != (Object)null)
				{
					((Behaviour)item).enabled = !flag;
				}
			}
			_originalHidden = flag;
		}

		private static List<Graphic> CollectOriginalHealth(Hud hud)
		{
			List<Transform> list = new List<Transform>();
			AddTransform(list, (Component)(object)hud.m_foodBarRoot);
			AddTransform(list, (Component)(object)hud.m_foodBaseBar);
			AddTransform(list, (Component)(object)hud.m_foodIcon);
			AddTransform(list, (Component)(object)hud.m_foodText);
			AddTransforms(list, (IEnumerable<Component>)(object)hud.m_foodBars);
			AddTransforms(list, (IEnumerable<Component>)(object)hud.m_foodIcons);
			AddTransforms(list, (IEnumerable<Component>)(object)hud.m_foodTime);
			List<Component> obj = new List<Component>
			{
				(Component)(object)hud.m_healthBarRoot,
				(Component)(object)hud.m_healthBarFast,
				(Component)(object)hud.m_healthBarSlow,
				(Component)(object)hud.m_healthText
			};
			HashSet<Graphic> hashSet = new HashSet<Graphic>();
			List<Graphic> list2 = new List<Graphic>();
			foreach (Component item in obj)
			{
				if ((Object)(object)item == (Object)null)
				{
					continue;
				}
				Graphic[] componentsInChildren = item.GetComponentsInChildren<Graphic>(true);
				foreach (Graphic val in componentsInChildren)
				{
					if (((Behaviour)val).enabled && !IsUnder(((Component)val).transform, list) && hashSet.Add(val))
					{
						list2.Add(val);
					}
				}
			}
			return list2;
		}

		private static void AddTransform(List<Transform> list, Component component)
		{
			if ((Object)(object)component != (Object)null)
			{
				list.Add(component.transform);
			}
		}

		private static void AddTransforms(List<Transform> list, IEnumerable<Component> components)
		{
			if (components == null)
			{
				return;
			}
			foreach (Component component in components)
			{
				AddTransform(list, component);
			}
		}

		private static bool IsUnder(Transform transform, List<Transform> parents)
		{
			foreach (Transform parent in parents)
			{
				if (transform.IsChildOf(parent))
				{
					return true;
				}
			}
			return false;
		}

		private static void UpdateResourceBars(Hud hud, Player player)
		{
			if ((Object)(object)hud.m_staminaText != (Object)null)
			{
				hud.m_staminaText.text = Format(player.GetStamina(), ((Character)player).GetMaxStamina());
			}
			if ((Object)(object)hud.m_eitrText != (Object)null)
			{
				hud.m_eitrText.text = Format(player.GetEitr(), ((Character)player).GetMaxEitr());
			}
			_staminaHeight.Apply(Plugin.StaminaHeight.Value);
			Place(hud.m_staminaBar2Root, Plugin.StaminaPlacement);
			if (Plugin.StaminaAlwaysVisible.Value && (Object)(object)hud.m_staminaAnimator != (Object)null)
			{
				hud.m_staminaAnimator.SetBool("Visible", true);
			}
			if (_eitrHeight != null)
			{
				_eitrHeight.Apply(Plugin.EitrHeight.Value);
				Place(hud.m_eitrBarRoot, Plugin.EitrPlacement);
			}
			if (Plugin.EitrAlwaysVisible.Value && (Object)(object)hud.m_eitrAnimator != (Object)null && ((Character)player).GetMaxEitr() > 0f)
			{
				hud.m_eitrAnimator.SetBool("Visible", true);
			}
		}

		private static void Place(RectTransform bar, BarPlacement placement)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			ScreenAnchor value = placement.Anchor.Value;
			float value2 = placement.OffsetX.Value;
			float value3 = placement.OffsetY.Value;
			if (value == ScreenAnchor.BottomCenter)
			{
				Vector2 anchoredPosition = bar.anchoredPosition;
				anchoredPosition.x += value2;
				anchoredPosition.y += value3;
				bar.anchoredPosition = anchoredPosition;
			}
			else
			{
				SnapTo(bar, value, value2, value3);
			}
		}

		private static void SnapTo(RectTransform bar, ScreenAnchor anchor, float offsetX, float offsetY)
		{
			//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)
			//IL_001a: 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_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: 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_0099: 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_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: 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_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: 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_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_canvas == (Object)null))
			{
				Rect rect = _canvas.rect;
				Rect rect2 = bar.rect;
				Vector2 pivot = bar.pivot;
				float num;
				switch (anchor)
				{
				case ScreenAnchor.TopLeft:
				case ScreenAnchor.MiddleLeft:
				case ScreenAnchor.BottomLeft:
					num = ((Rect)(ref rect)).xMin + 10f + pivot.x * ((Rect)(ref rect2)).width;
					break;
				case ScreenAnchor.TopRight:
				case ScreenAnchor.MiddleRight:
				case ScreenAnchor.BottomRight:
					num = ((Rect)(ref rect)).xMax - 10f - (1f - pivot.x) * ((Rect)(ref rect2)).width;
					break;
				default:
					num = ((Rect)(ref rect)).center.x + (pivot.x - 0.5f) * ((Rect)(ref rect2)).width;
					break;
				}
				float num2;
				switch (anchor)
				{
				case ScreenAnchor.TopLeft:
				case ScreenAnchor.TopCenter:
				case ScreenAnchor.TopRight:
					num2 = ((Rect)(ref rect)).yMax - 10f - (1f - pivot.y) * ((Rect)(ref rect2)).height;
					break;
				case ScreenAnchor.BottomLeft:
				case ScreenAnchor.BottomCenter:
				case ScreenAnchor.BottomRight:
					num2 = ((Rect)(ref rect)).yMin + 10f + pivot.y * ((Rect)(ref rect2)).height;
					break;
				default:
					num2 = ((Rect)(ref rect)).center.y + (pivot.y - 0.5f) * ((Rect)(ref rect2)).height;
					break;
				}
				Vector3 val = ((Transform)_canvas).TransformPoint(new Vector3(num + offsetX, num2 + offsetY, 0f));
				Vector3 val2 = ((Transform)bar).parent.InverseTransformPoint(val);
				((Transform)bar).localPosition = new Vector3(val2.x, val2.y, ((Transform)bar).localPosition.z);
			}
		}

		private static string Format(float current, float max)
		{
			return Mathf.CeilToInt(current) + " / " + Mathf.CeilToInt(max);
		}

		private static void UpdateHealthBar(Hud hud, Player player)
		{
			if (!Plugin.Enabled.Value)
			{
				if ((Object)(object)_root != (Object)null)
				{
					((Component)_root).gameObject.SetActive(false);
				}
			}
			else if (EnsureCreated(hud))
			{
				((Component)_root).gameObject.SetActive(true);
				float num = Mathf.Max(((Character)player).GetMaxHealth(), 1f);
				float health = ((Character)player).GetHealth();
				float num2 = Mathf.Ceil(num / 25f * 32f * Plugin.WidthMultiplier.Value);
				_root.SetSizeWithCurrentAnchors((Axis)0, num2 + 16f);
				_fast.SetWidth(num2);
				_slow.SetWidth(num2);
				_fast.SetValue(health / num);
				_slow.SetValue(health / num);
				_text.text = Format(health, num);
				_healthHeight.Apply(Plugin.HealthHeight.Value);
				if ((Object)(object)_animator != (Object)null)
				{
					_animator.SetBool("Visible", true);
				}
				Position(hud, player);
			}
		}

		private static void Position(Hud hud, Player player)
		{
			//IL_008b: 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_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			BarPlacement healthPlacement = Plugin.HealthPlacement;
			if (healthPlacement.Anchor.Value != ScreenAnchor.BottomCenter)
			{
				SnapTo(_root, healthPlacement.Anchor.Value, healthPlacement.OffsetX.Value, healthPlacement.OffsetY.Value);
				return;
			}
			Transform parent = ((Transform)_root).parent;
			float num = TopEdge(parent, hud.m_staminaBar2Root);
			if (((Character)player).GetMaxEitr() > 0f && (Object)(object)hud.m_eitrBarRoot != (Object)null)
			{
				num = Mathf.Max(num, TopEdge(parent, hud.m_eitrBarRoot));
			}
			Vector3 localPosition = ((Transform)_root).localPosition;
			localPosition.x = parent.InverseTransformPoint(((Transform)hud.m_staminaBar2Root).position).x + healthPlacement.OffsetX.Value;
			float num2 = num + Plugin.VerticalGap.Value + healthPlacement.OffsetY.Value;
			float y = _root.pivot.y;
			Rect rect = _root.rect;
			localPosition.y = num2 + y * ((Rect)(ref rect)).height;
			((Transform)_root).localPosition = localPosition;
		}

		private static float TopEdge(Transform space, RectTransform bar)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: 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)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			float y = space.InverseTransformPoint(((Transform)bar).position).y;
			float num = 1f - bar.pivot.y;
			Rect rect = bar.rect;
			return y + num * ((Rect)(ref rect)).height;
		}

		private static bool EnsureCreated(Hud hud)
		{
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Expected O, but got Unknown
			if (_failed)
			{
				return false;
			}
			if ((Object)(object)_root != (Object)null)
			{
				return true;
			}
			RectTransform staminaBar2Root = hud.m_staminaBar2Root;
			_staminaHeight.Apply(1f);
			GameObject val = Object.Instantiate<GameObject>(((Component)staminaBar2Root).gameObject, ((Transform)staminaBar2Root).parent);
			_staminaHeight.Apply(Plugin.StaminaHeight.Value);
			((Object)val).name = "SidewaysHealthBar";
			RectTransform val2 = (RectTransform)val.transform;
			GuiBar val3 = Mirror<GuiBar>((Transform)(object)staminaBar2Root, (Transform)(object)val2, hud.m_staminaBar2Fast);
			GuiBar val4 = Mirror<GuiBar>((Transform)(object)staminaBar2Root, (Transform)(object)val2, hud.m_staminaBar2Slow);
			TMP_Text val5 = Mirror<TMP_Text>((Transform)(object)staminaBar2Root, (Transform)(object)val2, hud.m_staminaText);
			if ((Object)(object)val3 == (Object)null || (Object)(object)val4 == (Object)null || (Object)(object)val5 == (Object)null)
			{
				Object.Destroy((Object)(object)val);
				_failed = true;
				return false;
			}
			ApplyHealthLook(val3, hud.m_healthBarFast);
			ApplyHealthLook(val4, hud.m_healthBarSlow);
			_root = val2;
			_healthHeight = new BarHeight(val2);
			_fast = val3;
			_slow = val4;
			_text = val5;
			_animator = Mirror<Animator>((Transform)(object)staminaBar2Root, (Transform)(object)val2, hud.m_staminaAnimator);
			return true;
		}

		private static void ApplyHealthLook(GuiBar target, GuiBar healthBar)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			Image component = ((Component)target.m_bar).GetComponent<Image>();
			Image component2 = ((Component)healthBar.m_bar).GetComponent<Image>();
			if (!((Object)(object)component == (Object)null) && !((Object)(object)component2 == (Object)null))
			{
				component.sprite = component2.sprite;
				component.type = component2.type;
				((Graphic)component).material = ((Graphic)component2).material;
				((Graphic)component).color = ((Graphic)component2).color;
			}
		}

		private static T Mirror<T>(Transform sourceRoot, Transform cloneRoot, T original) where T : Component
		{
			if ((Object)(object)original == (Object)null)
			{
				return default(T);
			}
			Stack<int> stack = new Stack<int>();
			Transform val = ((Component)original).transform;
			while ((Object)(object)val != (Object)(object)sourceRoot)
			{
				if ((Object)(object)val == (Object)null)
				{
					return default(T);
				}
				stack.Push(val.GetSiblingIndex());
				val = val.parent;
			}
			Transform val2 = cloneRoot;
			foreach (int item in stack)
			{
				val2 = val2.GetChild(item);
			}
			return ((Component)val2).GetComponent<T>();
		}
	}
	internal enum ScreenAnchor
	{
		TopLeft,
		TopCenter,
		TopRight,
		MiddleLeft,
		MiddleCenter,
		MiddleRight,
		BottomLeft,
		BottomCenter,
		BottomRight
	}
	internal sealed class BarPlacement
	{
		internal readonly ConfigEntry<ScreenAnchor> Anchor;

		internal readonly ConfigEntry<float> OffsetX;

		internal readonly ConfigEntry<float> OffsetY;

		internal BarPlacement(ConfigFile config, string section, string anchorNote)
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Expected O, but got Unknown
			Anchor = config.Bind<ScreenAnchor>(section, "Anchor", ScreenAnchor.BottomCenter, "Screen position the bar snaps to. BottomCenter is the vanilla position. " + anchorNote);
			OffsetX = config.Bind<float>(section, "Horizontal offset", 0f, new ConfigDescription("Moves the bar right (positive) or left (negative), in pixels, from its anchor.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-3000f, 3000f), Array.Empty<object>()));
			OffsetY = config.Bind<float>(section, "Vertical offset", 0f, new ConfigDescription("Moves the bar up (positive) or down (negative), in pixels, from its anchor.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-3000f, 3000f), Array.Empty<object>()));
		}
	}
	[BepInPlugin("rainb.SidewaysHealthBar", "Sideways Health Bar", "1.2.0")]
	public class Plugin : BaseUnityPlugin
	{
		public const string Guid = "rainb.SidewaysHealthBar";

		public const string Name = "Sideways Health Bar";

		public const string Version = "1.2.0";

		internal static ConfigEntry<bool> Enabled;

		internal static ConfigEntry<float> WidthMultiplier;

		internal static ConfigEntry<float> VerticalGap;

		internal static ConfigEntry<float> HealthHeight;

		internal static ConfigEntry<bool> ShowOriginalHealthBar;

		internal static ConfigEntry<float> StaminaHeight;

		internal static ConfigEntry<bool> StaminaAlwaysVisible;

		internal static ConfigEntry<float> EitrHeight;

		internal static ConfigEntry<bool> EitrAlwaysVisible;

		internal static BarPlacement HealthPlacement;

		internal static BarPlacement StaminaPlacement;

		internal static BarPlacement EitrPlacement;

		private void Awake()
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Expected O, but got Unknown
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Expected O, but got Unknown
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Health bar", "Enabled", true, "Show the sideways health bar above the stamina/Eitr bars.");
			WidthMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Health bar", "Width multiplier", 1f, new ConfigDescription("Scales the health bar width. 1 matches the stamina bar scale (32 px per 25 health). It still grows evenly from the middle as max health increases.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.25f, 5f), Array.Empty<object>()));
			HealthHeight = ((BaseUnityPlugin)this).Config.Bind<float>("Health bar", "Height multiplier", 1f, HeightDescription());
			HealthPlacement = new BarPlacement(((BaseUnityPlugin)this).Config, "Health bar", "With BottomCenter the bar sits above the stamina/Eitr bars; any other anchor places it independently.");
			VerticalGap = ((BaseUnityPlugin)this).Config.Bind<float>("Health bar", "Vertical gap", 4f, new ConfigDescription("Gap in pixels between the top of the stamina/Eitr bars and the health bar. Only used when the anchor is BottomCenter.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-2000f, 2000f), Array.Empty<object>()));
			ShowOriginalHealthBar = ((BaseUnityPlugin)this).Config.Bind<bool>("Original health bar", "Show", true, "Show the original vertical health bar on the left. Food icons are not affected.");
			StaminaHeight = ((BaseUnityPlugin)this).Config.Bind<float>("Stamina bar", "Height multiplier", 1f, HeightDescription());
			StaminaPlacement = new BarPlacement(((BaseUnityPlugin)this).Config, "Stamina bar", "");
			StaminaAlwaysVisible = ((BaseUnityPlugin)this).Config.Bind<bool>("Stamina bar", "Always visible", false, "Keep the stamina bar on screen when it is full and unused, instead of fading out.");
			EitrHeight = ((BaseUnityPlugin)this).Config.Bind<float>("Eitr bar", "Height multiplier", 1f, HeightDescription());
			EitrPlacement = new BarPlacement(((BaseUnityPlugin)this).Config, "Eitr bar", "");
			EitrAlwaysVisible = ((BaseUnityPlugin)this).Config.Bind<bool>("Eitr bar", "Always visible", false, "Keep the Eitr bar on screen when it is full and unused, instead of fading out. Stays hidden while your max Eitr is 0.");
			new Harmony("rainb.SidewaysHealthBar").PatchAll();
		}

		private static ConfigDescription HeightDescription()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			return new ConfigDescription("Scales the bar height. 1 is the vanilla height.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.25f, 4f), Array.Empty<object>());
		}
	}
	[HarmonyPatch(typeof(Hud), "Update")]
	internal static class HudUpdatePatch
	{
		private static void Postfix(Hud __instance)
		{
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer != (Object)null)
			{
				BarOverlay.Update(__instance, localPlayer);
			}
		}
	}
}