Decompiled source of HudRevizualized v0.2.0

ValheimHudRevizualized.dll

Decompiled 21 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("0.0.0.0")]
namespace ValheimHudRevizualized;

public static class HotkeyBarPatch
{
	private static readonly FieldInfo ElementsField = AccessTools.Field(typeof(HotkeyBar), "m_elements");

	private static readonly FieldInfo SelectedField = AccessTools.Field(typeof(HotkeyBar), "m_selected");

	private static int _selectedSlot;

	private static bool _pendingEquip;

	private static int _pendingSlot;

	public static int GetSelectedSlot()
	{
		return _selectedSlot;
	}

	internal static void ResetState()
	{
		_selectedSlot = 0;
		_pendingEquip = false;
		_pendingSlot = 0;
	}

	[HarmonyPatch(typeof(HotkeyBar), "Update")]
	[HarmonyPostfix]
	private static void HotkeyBar_Update_Postfix(HotkeyBar __instance)
	{
		if (SelectedField == null || ElementsField == null)
		{
			return;
		}
		Player localPlayer = Player.m_localPlayer;
		if ((Object)(object)localPlayer == (Object)null || ((Character)localPlayer).IsDead())
		{
			return;
		}
		int num = (int)SelectedField.GetValue(__instance);
		if (num >= 0)
		{
			_selectedSlot = num;
		}
		for (int i = 0; i < 8; i++)
		{
			if (Input.GetKeyDown((KeyCode)(49 + i)))
			{
				_selectedSlot = i;
				SelectedField.SetValue(__instance, i);
				break;
			}
		}
		if (_pendingEquip)
		{
			float axis = Input.GetAxis("Mouse ScrollWheel");
			if (!Input.GetMouseButton(1) || axis == 0f)
			{
				_pendingEquip = false;
				localPlayer.UseHotbarItem(_pendingSlot + 1);
			}
		}
		if (!Input.GetMouseButton(1))
		{
			return;
		}
		float axis2 = Input.GetAxis("Mouse ScrollWheel");
		if (axis2 != 0f && ElementsField.GetValue(__instance) is IList list && list.Count != 0)
		{
			int count = list.Count;
			if (axis2 > 0f)
			{
				_selectedSlot = (_selectedSlot - 1 + count) % count;
			}
			else
			{
				_selectedSlot = (_selectedSlot + 1) % count;
			}
			SelectedField.SetValue(__instance, _selectedSlot);
			_pendingEquip = true;
			_pendingSlot = _selectedSlot;
		}
	}

	[HarmonyPatch(typeof(ZInput), "GetMouseScrollWheel")]
	[HarmonyPrefix]
	private static bool ZInput_GetMouseScrollWheel_Prefix(ref float __result)
	{
		if (!Input.GetMouseButton(1))
		{
			return true;
		}
		Player localPlayer = Player.m_localPlayer;
		if ((Object)(object)localPlayer == (Object)null || ((Character)localPlayer).IsDead())
		{
			return true;
		}
		__result = 0f;
		return false;
	}

	[HarmonyPatch(typeof(HotkeyBar), "UpdateIcons")]
	[HarmonyPostfix]
	private static void HotkeyBar_UpdateIcons_Postfix(HotkeyBar __instance)
	{
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		RectTransform component = ((Component)__instance).GetComponent<RectTransform>();
		if ((Object)(object)component != (Object)null)
		{
			((Transform)component).localPosition = new Vector3(10000f, 0f, 0f);
		}
	}
}
public static class HudPatch
{
	[HarmonyPatch(typeof(Hud), "Awake")]
	[HarmonyPostfix]
	private static void Hud_Awake_Postfix()
	{
		CustomHotbar.Destroy();
		HotkeyBarPatch.ResetState();
	}

	[HarmonyPatch(typeof(Hud), "Update")]
	[HarmonyPostfix]
	private static void Hud_Update_Postfix(Hud __instance)
	{
		if (!CustomHotbar.IsBuilt)
		{
			CustomHotbar.Build(((Component)__instance).transform);
		}
		CustomHotbar.UpdateSlots();
		CustomHotbar.UpdateBars();
		CustomHotbar.UpdateGuardianPower();
		CustomHotbar.HideVanillaHud(__instance);
	}
}
[BepInPlugin("com.shadow.hudrevizualized", "Valheim HUD Revizualized", "0.2.0")]
public class Plugin : BaseUnityPlugin
{
	public const string PluginGUID = "com.shadow.hudrevizualized";

	public const string PluginName = "Valheim HUD Revizualized";

	public const string PluginVersion = "0.2.0";

	private Harmony _harmony;

	private void Awake()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Expected O, but got Unknown
		_harmony = new Harmony("com.shadow.hudrevizualized");
		_harmony.PatchAll(typeof(HotkeyBarPatch));
		_harmony.PatchAll(typeof(HudPatch));
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Valheim HUD Revizualized v0.2.0 loaded.");
	}

	private void OnDestroy()
	{
		Harmony harmony = _harmony;
		if (harmony != null)
		{
			harmony.UnpatchSelf();
		}
	}
}
public static class CustomHotbar
{
	private const int SlotCount = 8;

	private const int LeftGroupCount = 4;

	private const float SlotSize = 64f;

	private const float SlotSpacing = 8f;

	private const float GpGap = 140f;

	private const float BottomMargin = 45f;

	private const float HudScale = 0.65f;

	private const float BarHeight = 22f;

	private const float BarSlotGap = 5f;

	private const float GpIconSize = 128f;

	private static readonly float GroupWidth = 280f;

	private static readonly float HalfGap = 70f;

	private static GameObject _hudRoot;

	private static bool _built;

	private static Image[] _slotIcons;

	private static GameObject[] _slotSelections;

	private static TextMeshProUGUI[] _slotStackTexts;

	private static ResourceBarElement _healthBar;

	private static ResourceBarElement _staminaBar;

	private static ResourceBarElement _eitrBar;

	private static ResourceBarElement _adrenalineBar;

	private static GameObject _gpRoot;

	private static Image _gpIconImage;

	private static Image _gpCooldownOverlay;

	private static TextMeshProUGUI _gpCooldownText;

	private static RectTransform _vanillaHotkeyBarRT;

	private static readonly Vector3 OffScreen = new Vector3(10000f, 0f, 0f);

	private static Transform[] _extraFoodElements;

	private static bool _foodFieldsResolved;

	public static bool IsBuilt => _built;

	public static void Build(Transform hudParent)
	{
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Expected O, but got Unknown
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: 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_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00de: 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_020b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0224: Unknown result type (might be due to invalid IL or missing references)
		//IL_023d: Unknown result type (might be due to invalid IL or missing references)
		//IL_025c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0262: 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_0294: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b3: 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_02d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_030a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0310: Unknown result type (might be due to invalid IL or missing references)
		//IL_0329: Unknown result type (might be due to invalid IL or missing references)
		//IL_0342: Unknown result type (might be due to invalid IL or missing references)
		//IL_0193: Unknown result type (might be due to invalid IL or missing references)
		if (!_built)
		{
			Canvas componentInParent = ((Component)hudParent).GetComponentInParent<Canvas>();
			Transform val = (((Object)(object)componentInParent != (Object)null) ? ((Component)componentInParent).transform : hudParent);
			_hudRoot = new GameObject("HudRevizualized_Root", new Type[1] { typeof(RectTransform) });
			_hudRoot.transform.SetParent(val, false);
			RectTransform component = _hudRoot.GetComponent<RectTransform>();
			component.anchorMin = new Vector2(0.5f, 0f);
			component.anchorMax = new Vector2(0.5f, 0f);
			component.pivot = new Vector2(0.5f, 0f);
			component.anchoredPosition = new Vector2(0f, 45f);
			component.sizeDelta = Vector2.zero;
			((Transform)component).localScale = new Vector3(0.65f, 0.65f, 1f);
			CanvasGroup val2 = _hudRoot.AddComponent<CanvasGroup>();
			val2.alpha = 0.8f;
			val2.interactable = false;
			val2.blocksRaycasts = false;
			ResourceBarElement.GameFont = FindGameFont();
			_slotIcons = (Image[])(object)new Image[8];
			_slotSelections = (GameObject[])(object)new GameObject[8];
			_slotStackTexts = (TextMeshProUGUI[])(object)new TextMeshProUGUI[8];
			float num = 0f - (HalfGap + GroupWidth) + 32f;
			float num2 = HalfGap + 32f;
			float num3 = 32f;
			for (int i = 0; i < 8; i++)
			{
				float num4 = ((i < 4) ? (num + (float)i * 72f) : (num2 + (float)(i - 4) * 72f));
				BuildSlot(i, new Vector2(num4, num3));
			}
			float num5 = 0f - (HalfGap + GroupWidth / 2f);
			float num6 = HalfGap + GroupWidth / 2f;
			float num7 = 80f;
			float num8 = -16f;
			Vector2 size = default(Vector2);
			((Vector2)(ref size))..ctor(GroupWidth, 22f);
			_healthBar = new ResourceBarElement(_hudRoot.transform, "HealthBar", size, new Vector2(num5, num7), new Color(0.85f, 0.15f, 0.15f, 1f), new Color(0.85f, 0.15f, 0.15f, 0.35f), isHorizontal: true);
			_staminaBar = new ResourceBarElement(_hudRoot.transform, "StaminaBar", size, new Vector2(num6, num7), new Color(0.5f, 0.43f, 0f, 1f), new Color(0.5f, 0.43f, 0f, 0.35f), isHorizontal: true);
			_eitrBar = new ResourceBarElement(_hudRoot.transform, "EitrBar", size, new Vector2(num5, num8), new Color(0.15f, 0.8f, 0.35f, 1f), new Color(0.15f, 0.8f, 0.35f, 0.35f), isHorizontal: true);
			_adrenalineBar = new ResourceBarElement(_hudRoot.transform, "AdrenalineBar", size, new Vector2(num6, num8), new Color(0.6f, 0.28f, 0f, 1f), new Color(0.6f, 0.28f, 0f, 0.35f), isHorizontal: true);
			LiftBarText(_healthBar.TextRectTransform, num5, num7, GroupWidth);
			LiftBarText(_staminaBar.TextRectTransform, num6, num7, GroupWidth);
			LiftBarText(_eitrBar.TextRectTransform, num5, num8, GroupWidth);
			LiftBarText(_adrenalineBar.TextRectTransform, num6, num8, GroupWidth);
			BuildGuardianIcon(num3);
			_built = true;
		}
	}

	private static void BuildSlot(int index, Vector2 center)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Expected O, but got Unknown
		//IL_005c: 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_0066: 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_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c0: Expected O, but got Unknown
		//IL_00db: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0113: Unknown result type (might be due to invalid IL or missing references)
		//IL_0152: Unknown result type (might be due to invalid IL or missing references)
		//IL_019b: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a2: Expected O, but got Unknown
		//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0228: Unknown result type (might be due to invalid IL or missing references)
		//IL_0261: Unknown result type (might be due to invalid IL or missing references)
		//IL_0268: Expected O, but got Unknown
		//IL_029c: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_02af: 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_02d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0320: Unknown result type (might be due to invalid IL or missing references)
		//IL_0327: Expected O, but got Unknown
		//IL_0350: Unknown result type (might be due to invalid IL or missing references)
		//IL_0367: Unknown result type (might be due to invalid IL or missing references)
		//IL_037e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0395: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_03fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_042f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0436: Expected O, but got Unknown
		//IL_045f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0476: Unknown result type (might be due to invalid IL or missing references)
		//IL_048d: Unknown result type (might be due to invalid IL or missing references)
		//IL_04a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_04bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_051d: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject($"Slot_{index}", new Type[1] { typeof(RectTransform) });
		val.transform.SetParent(_hudRoot.transform, false);
		RectTransform component = val.GetComponent<RectTransform>();
		Vector2 val2 = default(Vector2);
		((Vector2)(ref val2))..ctor(0.5f, 0.5f);
		component.pivot = val2;
		Vector2 anchorMin = (component.anchorMax = val2);
		component.anchorMin = anchorMin;
		component.sizeDelta = new Vector2(64f, 64f);
		component.anchoredPosition = center;
		GameObject val4 = new GameObject("Selection", new Type[2]
		{
			typeof(RectTransform),
			typeof(Image)
		});
		val4.transform.SetParent(val.transform, false);
		RectTransform component2 = val4.GetComponent<RectTransform>();
		component2.anchorMin = Vector2.zero;
		component2.anchorMax = Vector2.one;
		component2.offsetMin = new Vector2(-3f, -3f);
		component2.offsetMax = new Vector2(3f, 3f);
		Image component3 = val4.GetComponent<Image>();
		component3.sprite = ResourceBarElement.WhiteSprite;
		component3.type = (Type)0;
		((Graphic)component3).color = new Color(1f, 0.85f, 0.2f, 0.7f);
		((Graphic)component3).raycastTarget = false;
		val4.SetActive(false);
		_slotSelections[index] = val4;
		GameObject val5 = new GameObject("SlotBG", new Type[2]
		{
			typeof(RectTransform),
			typeof(Image)
		});
		val5.transform.SetParent(val.transform, false);
		RectTransform component4 = val5.GetComponent<RectTransform>();
		component4.anchorMin = Vector2.zero;
		component4.anchorMax = Vector2.one;
		anchorMin = (component4.offsetMax = Vector2.zero);
		component4.offsetMin = anchorMin;
		Image component5 = val5.GetComponent<Image>();
		component5.sprite = ResourceBarElement.WhiteSprite;
		component5.type = (Type)0;
		((Graphic)component5).color = new Color(0.15f, 0.15f, 0.15f, 0.9f);
		((Graphic)component5).raycastTarget = false;
		GameObject val6 = new GameObject("ItemIcon", new Type[2]
		{
			typeof(RectTransform),
			typeof(Image)
		});
		val6.transform.SetParent(val.transform, false);
		RectTransform component6 = val6.GetComponent<RectTransform>();
		((Vector2)(ref val2))..ctor(0.5f, 0.5f);
		component6.pivot = val2;
		anchorMin = (component6.anchorMax = val2);
		component6.anchorMin = anchorMin;
		component6.sizeDelta = new Vector2(56f, 56f);
		component6.anchoredPosition = Vector2.zero;
		Image component7 = val6.GetComponent<Image>();
		component7.preserveAspect = true;
		((Graphic)component7).raycastTarget = false;
		((Behaviour)component7).enabled = false;
		_slotIcons[index] = component7;
		GameObject val8 = new GameObject("StackText", new Type[1] { typeof(RectTransform) });
		val8.transform.SetParent(val.transform, false);
		RectTransform component8 = val8.GetComponent<RectTransform>();
		component8.anchorMin = new Vector2(1f, 0f);
		component8.anchorMax = new Vector2(1f, 0f);
		component8.pivot = new Vector2(1f, 0f);
		component8.sizeDelta = new Vector2(64f, 16f);
		component8.anchoredPosition = new Vector2(-2f, 2f);
		TextMeshProUGUI val9 = val8.AddComponent<TextMeshProUGUI>();
		if ((Object)(object)ResourceBarElement.GameFont != (Object)null)
		{
			((TMP_Text)val9).font = ResourceBarElement.GameFont;
		}
		((TMP_Text)val9).fontSize = 11f;
		((TMP_Text)val9).alignment = (TextAlignmentOptions)1028;
		((Graphic)val9).color = Color.white;
		((Graphic)val9).raycastTarget = false;
		_slotStackTexts[index] = val9;
		GameObject val10 = new GameObject("BindingText", new Type[1] { typeof(RectTransform) });
		val10.transform.SetParent(val.transform, false);
		RectTransform component9 = val10.GetComponent<RectTransform>();
		component9.anchorMin = new Vector2(0f, 1f);
		component9.anchorMax = new Vector2(0f, 1f);
		component9.pivot = new Vector2(0f, 1f);
		component9.sizeDelta = new Vector2(20f, 14f);
		component9.anchoredPosition = new Vector2(2f, -2f);
		TextMeshProUGUI val11 = val10.AddComponent<TextMeshProUGUI>();
		if ((Object)(object)ResourceBarElement.GameFont != (Object)null)
		{
			((TMP_Text)val11).font = ResourceBarElement.GameFont;
		}
		((TMP_Text)val11).fontSize = 9f;
		((TMP_Text)val11).alignment = (TextAlignmentOptions)257;
		((Graphic)val11).color = new Color(1f, 1f, 1f, 0.5f);
		((Graphic)val11).raycastTarget = false;
		((TMP_Text)val11).text = (index + 1).ToString();
	}

	private static void BuildGuardianIcon(float centerY)
	{
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Expected O, but got Unknown
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: 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_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_0081: 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_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c9: Expected O, but got Unknown
		//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0103: Unknown result type (might be due to invalid IL or missing references)
		//IL_0105: Unknown result type (might be due to invalid IL or missing references)
		//IL_0106: Unknown result type (might be due to invalid IL or missing references)
		//IL_010e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0119: Unknown result type (might be due to invalid IL or missing references)
		//IL_0125: 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_019d: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a4: Expected O, but got Unknown
		//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_0203: Unknown result type (might be due to invalid IL or missing references)
		//IL_0210: Unknown result type (might be due to invalid IL or missing references)
		//IL_0264: Unknown result type (might be due to invalid IL or missing references)
		//IL_026b: Expected O, but got Unknown
		//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0347: Unknown result type (might be due to invalid IL or missing references)
		//IL_0386: Unknown result type (might be due to invalid IL or missing references)
		//IL_038d: Expected O, but got Unknown
		//IL_03c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_03cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_03cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_0403: Unknown result type (might be due to invalid IL or missing references)
		//IL_0460: Unknown result type (might be due to invalid IL or missing references)
		float num = 132f;
		_gpRoot = new GameObject("GPRoot", new Type[1] { typeof(RectTransform) });
		_gpRoot.transform.SetParent(_hudRoot.transform, false);
		RectTransform component = _gpRoot.GetComponent<RectTransform>();
		Vector2 val = default(Vector2);
		((Vector2)(ref val))..ctor(0.5f, 0.5f);
		component.pivot = val;
		Vector2 anchorMin = (component.anchorMax = val);
		component.anchorMin = anchorMin;
		component.sizeDelta = new Vector2(num, num);
		component.anchoredPosition = new Vector2(0f, centerY);
		GameObject val3 = new GameObject("GPIconBG", new Type[2]
		{
			typeof(RectTransform),
			typeof(Image)
		});
		val3.transform.SetParent(_gpRoot.transform, false);
		RectTransform component2 = val3.GetComponent<RectTransform>();
		((Vector2)(ref val))..ctor(0.5f, 0.5f);
		component2.pivot = val;
		anchorMin = (component2.anchorMax = val);
		component2.anchorMin = anchorMin;
		component2.sizeDelta = new Vector2(num, num);
		component2.anchoredPosition = Vector2.zero;
		Image component3 = val3.GetComponent<Image>();
		component3.sprite = ResourceBarElement.WhiteSprite;
		component3.type = (Type)0;
		((Graphic)component3).color = new Color(0.15f, 0.15f, 0.15f, 0.9f);
		((Graphic)component3).raycastTarget = false;
		GameObject val5 = new GameObject("GPIcon", new Type[2]
		{
			typeof(RectTransform),
			typeof(Image)
		});
		val5.transform.SetParent(_gpRoot.transform, false);
		RectTransform component4 = val5.GetComponent<RectTransform>();
		((Vector2)(ref val))..ctor(0.5f, 0.5f);
		component4.pivot = val;
		anchorMin = (component4.anchorMax = val);
		component4.anchorMin = anchorMin;
		component4.sizeDelta = new Vector2(128f, 128f);
		component4.anchoredPosition = Vector2.zero;
		_gpIconImage = val5.GetComponent<Image>();
		_gpIconImage.preserveAspect = true;
		((Graphic)_gpIconImage).raycastTarget = false;
		GameObject val7 = new GameObject("GPCooldown", new Type[2]
		{
			typeof(RectTransform),
			typeof(Image)
		});
		val7.transform.SetParent(_gpRoot.transform, false);
		RectTransform component5 = val7.GetComponent<RectTransform>();
		((Vector2)(ref val))..ctor(0.5f, 0.5f);
		component5.pivot = val;
		anchorMin = (component5.anchorMax = val);
		component5.anchorMin = anchorMin;
		component5.sizeDelta = new Vector2(128f, 128f);
		component5.anchoredPosition = Vector2.zero;
		_gpCooldownOverlay = val7.GetComponent<Image>();
		_gpCooldownOverlay.sprite = ResourceBarElement.WhiteSprite;
		_gpCooldownOverlay.type = (Type)3;
		_gpCooldownOverlay.fillMethod = (FillMethod)4;
		_gpCooldownOverlay.fillOrigin = 2;
		_gpCooldownOverlay.fillClockwise = true;
		((Graphic)_gpCooldownOverlay).color = new Color(0f, 0f, 0f, 0.65f);
		_gpCooldownOverlay.fillAmount = 0f;
		((Graphic)_gpCooldownOverlay).raycastTarget = false;
		GameObject val9 = new GameObject("GPCooldownText", new Type[1] { typeof(RectTransform) });
		val9.transform.SetParent(_gpRoot.transform, false);
		RectTransform component6 = val9.GetComponent<RectTransform>();
		((Vector2)(ref val))..ctor(0.5f, 0.5f);
		component6.pivot = val;
		anchorMin = (component6.anchorMax = val);
		component6.anchorMin = anchorMin;
		component6.sizeDelta = new Vector2(148f, 18f);
		component6.anchoredPosition = new Vector2(0f, -75f);
		_gpCooldownText = val9.AddComponent<TextMeshProUGUI>();
		if ((Object)(object)ResourceBarElement.GameFont != (Object)null)
		{
			((TMP_Text)_gpCooldownText).font = ResourceBarElement.GameFont;
		}
		((TMP_Text)_gpCooldownText).fontSize = 11f;
		((TMP_Text)_gpCooldownText).alignment = (TextAlignmentOptions)514;
		((Graphic)_gpCooldownText).color = Color.white;
		((Graphic)_gpCooldownText).raycastTarget = false;
	}

	public static void UpdateSlots()
	{
		if (!_built)
		{
			return;
		}
		Player localPlayer = Player.m_localPlayer;
		if ((Object)(object)localPlayer == (Object)null || ((Character)localPlayer).IsDead())
		{
			SetAllVisible(visible: false);
			return;
		}
		SetAllVisible(visible: true);
		Inventory inventory = ((Humanoid)localPlayer).GetInventory();
		if (inventory == null)
		{
			return;
		}
		int selectedSlot = HotkeyBarPatch.GetSelectedSlot();
		for (int i = 0; i < 8; i++)
		{
			ItemData itemAt = inventory.GetItemAt(i, 0);
			if (itemAt != null)
			{
				_slotIcons[i].sprite = itemAt.GetIcon();
				((Behaviour)_slotIcons[i]).enabled = true;
				((TMP_Text)_slotStackTexts[i]).text = ((itemAt.m_shared.m_maxStackSize > 1) ? itemAt.m_stack.ToString() : "");
			}
			else
			{
				((Behaviour)_slotIcons[i]).enabled = false;
				((TMP_Text)_slotStackTexts[i]).text = "";
			}
			bool flag = i == selectedSlot;
			if (!flag && itemAt != null)
			{
				flag = ((Humanoid)localPlayer).IsItemEquiped(itemAt);
			}
			_slotSelections[i].SetActive(flag);
		}
	}

	public static void UpdateBars()
	{
		if (_built)
		{
			Player localPlayer = Player.m_localPlayer;
			if (!((Object)(object)localPlayer == (Object)null) && !((Character)localPlayer).IsDead())
			{
				float deltaTime = Time.deltaTime;
				_healthBar.UpdateValue(((Character)localPlayer).GetHealth(), ((Character)localPlayer).GetMaxHealth(), deltaTime);
				_staminaBar.UpdateValue(localPlayer.GetStamina(), ((Character)localPlayer).GetMaxStamina(), deltaTime);
				_eitrBar.UpdateValue(localPlayer.GetEitr(), ((Character)localPlayer).GetMaxEitr(), deltaTime);
				_adrenalineBar.UpdateValue(localPlayer.GetAdrenaline(), ((Character)localPlayer).GetMaxAdrenaline(), deltaTime);
			}
		}
	}

	public static void UpdateGuardianPower()
	{
		//IL_018b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: 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_010d: Unknown result type (might be due to invalid IL or missing references)
		if (!_built || (Object)(object)_gpIconImage == (Object)null)
		{
			return;
		}
		Player localPlayer = Player.m_localPlayer;
		if ((Object)(object)localPlayer == (Object)null || ((Character)localPlayer).IsDead())
		{
			return;
		}
		StatusEffect val = default(StatusEffect);
		float num = default(float);
		localPlayer.GetGuardianPowerHUD(ref val, ref num);
		if ((Object)(object)val != (Object)null)
		{
			((Component)_gpIconImage).gameObject.SetActive(true);
			_gpIconImage.sprite = val.m_icon;
			((Graphic)_gpIconImage).color = (Color)((num <= 0f) ? Color.white : new Color(1f, 1f, 1f, 0.5f));
			((Component)_gpCooldownText).gameObject.SetActive(true);
			if (num > 0f)
			{
				((Component)_gpCooldownOverlay).gameObject.SetActive(true);
				_gpCooldownOverlay.fillAmount = Mathf.Clamp01(num);
				((TMP_Text)_gpCooldownText).text = StatusEffect.GetTimeString(num, false, false);
				((Graphic)_gpCooldownText).color = Color.white;
			}
			else
			{
				((Component)_gpCooldownOverlay).gameObject.SetActive(false);
				((TMP_Text)_gpCooldownText).text = "Ready";
				((Graphic)_gpCooldownText).color = new Color(0.4f, 1f, 0.4f, 1f);
			}
		}
		else
		{
			_gpIconImage.sprite = null;
			((Graphic)_gpIconImage).color = new Color(0.2f, 0.2f, 0.2f, 0.5f);
			((Component)_gpCooldownOverlay).gameObject.SetActive(false);
			((Component)_gpCooldownText).gameObject.SetActive(false);
		}
	}

	public static void HideVanillaHud(Hud hud)
	{
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: 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_0116: Unknown result type (might be due to invalid IL or missing references)
		//IL_015a: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)hud.m_healthBarRoot != (Object)null)
		{
			((Transform)hud.m_healthBarRoot).localPosition = OffScreen;
		}
		if ((Object)(object)hud.m_staminaBar2Root != (Object)null)
		{
			((Transform)hud.m_staminaBar2Root).localPosition = OffScreen;
		}
		if ((Object)(object)hud.m_eitrBarRoot != (Object)null)
		{
			((Transform)hud.m_eitrBarRoot).localPosition = OffScreen;
		}
		if ((Object)(object)hud.m_adrenalineBarRoot != (Object)null)
		{
			((Transform)hud.m_adrenalineBarRoot).localPosition = OffScreen;
		}
		if ((Object)(object)hud.m_gpRoot != (Object)null)
		{
			((Transform)hud.m_gpRoot).localPosition = OffScreen;
		}
		if ((Object)(object)hud.m_foodBarRoot != (Object)null)
		{
			((Transform)hud.m_foodBarRoot).localPosition = OffScreen;
		}
		if ((Object)(object)_vanillaHotkeyBarRT == (Object)null)
		{
			HotkeyBar componentInChildren = ((Component)hud).GetComponentInChildren<HotkeyBar>();
			if ((Object)(object)componentInChildren != (Object)null)
			{
				_vanillaHotkeyBarRT = ((Component)componentInChildren).GetComponent<RectTransform>();
			}
		}
		if ((Object)(object)_vanillaHotkeyBarRT != (Object)null)
		{
			((Transform)_vanillaHotkeyBarRT).localPosition = OffScreen;
		}
		ResolveExtraFoodElements(hud);
		if (_extraFoodElements == null)
		{
			return;
		}
		Transform[] extraFoodElements = _extraFoodElements;
		foreach (Transform val in extraFoodElements)
		{
			if ((Object)(object)val != (Object)null)
			{
				val.localPosition = OffScreen;
			}
		}
	}

	private static void ResolveExtraFoodElements(Hud hud)
	{
		if (_foodFieldsResolved)
		{
			return;
		}
		_foodFieldsResolved = true;
		List<Transform> list = new List<Transform>();
		Transform[] componentsInChildren = ((Component)hud).GetComponentsInChildren<Transform>(true);
		foreach (Transform val in componentsInChildren)
		{
			if (!((Object)(object)val == (Object)(object)((Component)hud).transform) && (!((Object)(object)_hudRoot != (Object)null) || !val.IsChildOf(_hudRoot.transform)))
			{
				string name = ((Object)((Component)val).gameObject).name;
				if (name.IndexOf("food", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("health", StringComparison.OrdinalIgnoreCase) >= 0)
				{
					list.Add(val);
				}
			}
		}
		_extraFoodElements = ((list.Count > 0) ? list.ToArray() : null);
	}

	public static void Destroy()
	{
		if ((Object)(object)_hudRoot != (Object)null)
		{
			Object.Destroy((Object)(object)_hudRoot);
		}
		ResourceBarElement.GameFont = null;
		_hudRoot = null;
		_slotIcons = null;
		_slotSelections = null;
		_slotStackTexts = null;
		_healthBar = null;
		_staminaBar = null;
		_eitrBar = null;
		_adrenalineBar = null;
		_gpRoot = null;
		_gpIconImage = null;
		_gpCooldownOverlay = null;
		_gpCooldownText = null;
		_vanillaHotkeyBarRT = null;
		_extraFoodElements = null;
		_foodFieldsResolved = false;
		_built = false;
	}

	private static TMP_FontAsset FindGameFont()
	{
		TextMeshProUGUI[] array = Object.FindObjectsByType<TextMeshProUGUI>((FindObjectsSortMode)0);
		foreach (TextMeshProUGUI val in array)
		{
			if ((Object)(object)((TMP_Text)val).font != (Object)null)
			{
				return ((TMP_Text)val).font;
			}
		}
		return null;
	}

	private static void LiftBarText(RectTransform textRT, float cx, float cy, float barWidth)
	{
		//IL_0027: 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_002f: 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_0037: 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_0059: Unknown result type (might be due to invalid IL or missing references)
		((Transform)textRT).SetParent(_hudRoot.transform, false);
		Vector2 val = default(Vector2);
		((Vector2)(ref val))..ctor(0.5f, 0.5f);
		textRT.pivot = val;
		Vector2 anchorMin = (textRT.anchorMax = val);
		textRT.anchorMin = anchorMin;
		textRT.anchoredPosition = new Vector2(cx, cy);
		textRT.sizeDelta = new Vector2(barWidth - 4f, 26f);
	}

	private static void SetAllVisible(bool visible)
	{
		if ((Object)(object)_hudRoot != (Object)null)
		{
			_hudRoot.SetActive(visible);
		}
	}
}
public class ResourceBarElement
{
	private const float FastBarSpeed = 8f;

	private const float SlowDecaySpeed = 1.5f;

	private const float SlowGainSpeed = 6f;

	private const float FillInset = 2f;

	private readonly bool _isHorizontal;

	private readonly GameObject _root;

	private readonly RectTransform _rootRT;

	private readonly RectTransform _bgRT;

	private readonly Image _slowBarImage;

	private readonly Image _fastBarImage;

	private readonly TextMeshProUGUI _valueText;

	private readonly GameObject _textRoot;

	private float _currentFast;

	private float _currentSlow;

	private float _targetValue;

	private static Sprite _whiteSprite;

	private static Sprite _gradientSprite;

	public static TMP_FontAsset GameFont { get; set; }

	public static Sprite WhiteSprite
	{
		get
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			//IL_0067: 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_0024: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_whiteSprite == (Object)null)
			{
				Texture2D val = new Texture2D(4, 4);
				for (int i = 0; i < 4; i++)
				{
					for (int j = 0; j < 4; j++)
					{
						val.SetPixel(i, j, Color.white);
					}
				}
				val.Apply();
				_whiteSprite = Sprite.Create(val, new Rect(0f, 0f, 4f, 4f), new Vector2(0.5f, 0.5f));
			}
			return _whiteSprite;
		}
	}

	public static Sprite GradientSprite
	{
		get
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			//IL_00af: 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_006a: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_gradientSprite == (Object)null)
			{
				Texture2D val = new Texture2D(4, 32, (TextureFormat)4, false);
				((Texture)val).filterMode = (FilterMode)1;
				((Texture)val).wrapMode = (TextureWrapMode)1;
				Color val2 = default(Color);
				for (int i = 0; i < 32; i++)
				{
					float num = (float)i / 31f;
					float num2 = Mathf.Lerp(0.4f, 1f, num);
					((Color)(ref val2))..ctor(num2, num2, num2, 1f);
					for (int j = 0; j < 4; j++)
					{
						val.SetPixel(j, i, val2);
					}
				}
				val.Apply();
				_gradientSprite = Sprite.Create(val, new Rect(0f, 0f, 4f, 32f), new Vector2(0.5f, 0.5f));
			}
			return _gradientSprite;
		}
	}

	public RectTransform TextRectTransform => _textRoot.GetComponent<RectTransform>();

	public ResourceBarElement(Transform parent, string name, Vector2 size, Vector2 position, Color fastColor, Color slowColor, bool isHorizontal = false)
	{
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Expected O, but got Unknown
		//IL_0076: 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_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: 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_00b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f8: Expected O, but got Unknown
		//IL_013f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0147: 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_014a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0152: Unknown result type (might be due to invalid IL or missing references)
		//IL_0160: Unknown result type (might be due to invalid IL or missing references)
		//IL_016c: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0229: Unknown result type (might be due to invalid IL or missing references)
		//IL_0233: Expected O, but got Unknown
		//IL_0270: Unknown result type (might be due to invalid IL or missing references)
		//IL_0278: Unknown result type (might be due to invalid IL or missing references)
		//IL_027a: 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_0283: 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_0309: Unknown result type (might be due to invalid IL or missing references)
		_isHorizontal = isHorizontal;
		_root = new GameObject(name, new Type[1] { typeof(RectTransform) });
		_root.transform.SetParent(parent, false);
		_rootRT = _root.GetComponent<RectTransform>();
		RectTransform rootRT = _rootRT;
		RectTransform rootRT2 = _rootRT;
		RectTransform rootRT3 = _rootRT;
		Vector2 val = default(Vector2);
		((Vector2)(ref val))..ctor(0.5f, 0.5f);
		rootRT3.pivot = val;
		rootRT.anchorMin = (rootRT2.anchorMax = val);
		_rootRT.sizeDelta = size;
		_root.transform.localPosition = new Vector3(position.x, position.y, 0f);
		GameObject val3 = new GameObject(name + "_BG", new Type[2]
		{
			typeof(RectTransform),
			typeof(Image)
		});
		val3.transform.SetParent(_root.transform, false);
		_bgRT = val3.GetComponent<RectTransform>();
		RectTransform bgRT = _bgRT;
		RectTransform bgRT2 = _bgRT;
		RectTransform bgRT3 = _bgRT;
		((Vector2)(ref val))..ctor(0.5f, 0.5f);
		bgRT3.pivot = val;
		bgRT.anchorMin = (bgRT2.anchorMax = val);
		_bgRT.anchoredPosition = Vector2.zero;
		SetBgSize(size);
		Image component = val3.GetComponent<Image>();
		component.sprite = WhiteSprite;
		component.type = (Type)0;
		((Graphic)component).color = new Color(0.1f, 0.1f, 0.1f, 1f);
		((Graphic)component).raycastTarget = false;
		Vector2 size2 = FillSize(size);
		_slowBarImage = CreateFilledImage(_root.transform, name + "_Slow", size2, slowColor, isHorizontal);
		_fastBarImage = CreateFilledImage(_root.transform, name + "_Fast", size2, fastColor, isHorizontal);
		_textRoot = new GameObject(name + "_Text", new Type[1] { typeof(RectTransform) });
		_textRoot.transform.SetParent(_root.transform, false);
		RectTransform component2 = _textRoot.GetComponent<RectTransform>();
		((Vector2)(ref val))..ctor(0.5f, 0.5f);
		component2.pivot = val;
		component2.anchorMin = (component2.anchorMax = val);
		_valueText = _textRoot.AddComponent<TextMeshProUGUI>();
		if ((Object)(object)GameFont != (Object)null)
		{
			((TMP_Text)_valueText).font = GameFont;
		}
		((TMP_Text)_valueText).alignment = (TextAlignmentOptions)514;
		((Graphic)_valueText).color = Color.white;
		((TMP_Text)_valueText).enableAutoSizing = false;
		((TMP_Text)_valueText).overflowMode = (TextOverflowModes)0;
		((Graphic)_valueText).raycastTarget = false;
		PositionText(component2, size);
	}

	public void UpdateValue(float current, float max, float deltaTime)
	{
		_targetValue = ((max > 0f) ? Mathf.Clamp01(current / max) : 0f);
		_currentFast = Mathf.MoveTowards(_currentFast, _targetValue, deltaTime * 8f);
		if (_targetValue < _currentSlow)
		{
			_currentSlow = Mathf.MoveTowards(_currentSlow, _targetValue, deltaTime * 1.5f);
		}
		else
		{
			_currentSlow = Mathf.MoveTowards(_currentSlow, _targetValue, deltaTime * 6f);
		}
		_fastBarImage.fillAmount = _currentFast;
		_slowBarImage.fillAmount = _currentSlow;
		((TMP_Text)_valueText).text = $"{Mathf.CeilToInt(current)}/{Mathf.CeilToInt(max)}";
	}

	private Vector2 FillSize(Vector2 size)
	{
		//IL_0000: 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_0018: Unknown result type (might be due to invalid IL or missing references)
		return new Vector2(size.x - 4f, size.y - 4f);
	}

	private void SetBgSize(Vector2 size)
	{
		//IL_0034: 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_0060: 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_001f: Unknown result type (might be due to invalid IL or missing references)
		if (_isHorizontal)
		{
			_bgRT.sizeDelta = size;
			((Transform)_bgRT).localRotation = Quaternion.identity;
		}
		else
		{
			_bgRT.sizeDelta = new Vector2(size.y, size.x);
			((Transform)_bgRT).localRotation = Quaternion.Euler(0f, 0f, 90f);
		}
	}

	private void PositionText(RectTransform textRT, Vector2 size)
	{
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: 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_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: 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)
		if (_isHorizontal)
		{
			textRT.sizeDelta = new Vector2(size.x - 4f, size.y + 4f);
			textRT.anchoredPosition = Vector2.zero;
			((TMP_Text)_valueText).fontSize = 12f;
			((TMP_Text)_valueText).fontStyle = (FontStyles)1;
		}
		else
		{
			textRT.sizeDelta = new Vector2(60f, 16f);
			textRT.anchoredPosition = new Vector2(0f, 0f - (size.y * 0.5f + 10f));
			((TMP_Text)_valueText).fontSize = 11f;
			((TMP_Text)_valueText).fontStyle = (FontStyles)0;
		}
	}

	private static Image CreateFilledImage(Transform parent, string name, Vector2 size, Color color, bool isHorizontal)
	{
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Expected O, but got Unknown
		//IL_0051: 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_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_009a: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject(name, new Type[2]
		{
			typeof(RectTransform),
			typeof(Image)
		});
		val.transform.SetParent(parent, false);
		RectTransform component = val.GetComponent<RectTransform>();
		Vector2 val2 = default(Vector2);
		((Vector2)(ref val2))..ctor(0.5f, 0.5f);
		component.pivot = val2;
		Vector2 anchorMin = (component.anchorMax = val2);
		component.anchorMin = anchorMin;
		component.sizeDelta = size;
		component.anchoredPosition = Vector2.zero;
		Image component2 = val.GetComponent<Image>();
		component2.sprite = GradientSprite;
		component2.type = (Type)3;
		((Graphic)component2).color = color;
		((Graphic)component2).raycastTarget = false;
		if (isHorizontal)
		{
			component2.fillMethod = (FillMethod)0;
			component2.fillOrigin = 0;
		}
		else
		{
			component2.fillMethod = (FillMethod)1;
			component2.fillOrigin = 0;
		}
		component2.fillAmount = 0f;
		return component2;
	}
}