Decompiled source of MonsterEscort HealthBar v1.0.1

MonsterEscortBar.dll

Decompiled 3 weeks 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 System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HG.Reflection;
using On.RoR2.UI;
using R2API.Networking;
using R2API.Networking.Interfaces;
using R2API.Utils;
using RoR2;
using RoR2.UI;
using TMPro;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: OptIn]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("MonsterEscortBar")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MonsterEscortBar")]
[assembly: AssemblyTitle("MonsterEscortBar")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace ShrineClamper.Utils
{
	public static class ListHandlers
	{
		public static List<ItemDef> ItemDefList { get; }
	}
}
namespace MonsterEscortBar
{
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.thebugreport.monsterEscortBar", "Monster Escort Health Bar", "1.0.0")]
	public class Main : BaseUnityPlugin
	{
		public const string ModGUID = "com.thebugreport.monsterEscortBar";

		public const string ModName = "Monster Escort Health Bar";

		public const string ModVersion = "1.0.0";

		private readonly Dictionary<uint, float> _stressByMaster = new Dictionary<uint, float>();

		private bool _clientStressBound;

		private bool _serverStressBound;

		public void OnEnable()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			PlayerConfigs.Init(((BaseUnityPlugin)this).Config);
			HUD.Awake += new hook_Awake(HUD_Awake);
			NetworkingAPI.RegisterMessageType<StressMsg>();
		}

		private void HUD_Awake(orig_Awake orig, HUD self)
		{
			orig.Invoke(self);
			EscortHealthBarController.ClientInstance = ((Component)self).GetComponent<EscortHealthBarController>() ?? ((Component)self).gameObject.AddComponent<EscortHealthBarController>();
			if (!Object.op_Implicit((Object)(object)((Component)self).GetComponent<EscortAutoSelector>()))
			{
				((Component)self).gameObject.AddComponent<EscortAutoSelector>();
			}
		}

		public void OnDisable()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			HUD.Awake -= new hook_Awake(HUD_Awake);
		}
	}
	public struct StressMsg : INetMessage, ISerializableObject
	{
		public uint masterId;

		public float value;

		public bool echoed;

		public void Serialize(NetworkWriter w)
		{
			w.Write(masterId);
			w.Write(value);
			w.Write(echoed);
		}

		public void Deserialize(NetworkReader r)
		{
			masterId = r.ReadUInt32();
			value = r.ReadSingle();
			echoed = r.ReadBoolean();
		}

		public void OnReceived()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			if (NetworkServer.active)
			{
				if (!echoed)
				{
					echoed = true;
					NetMessageExtensions.Send((INetMessage)(object)this, (NetworkDestination)1);
				}
				return;
			}
			GameObject val = ClientScene.FindLocalObject(new NetworkInstanceId(masterId));
			CharacterMaster val2 = (Object.op_Implicit((Object)(object)val) ? val.GetComponent<CharacterMaster>() : null);
			if (Object.op_Implicit((Object)(object)val2))
			{
				val2.GetBody();
			}
			EscortHealthBarController clientInstance = EscortHealthBarController.ClientInstance;
			if (Object.op_Implicit((Object)(object)clientInstance) && Object.op_Implicit((Object)(object)clientInstance.targetBody) && (Object)(object)clientInstance.targetBody.master == (Object)(object)val2)
			{
				clientInstance.SetStressFromNet(value);
			}
		}
	}
	public class EscortAutoSelector : MonoBehaviour
	{
		[CompilerGenerated]
		private sealed class <Loop>d__3 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public EscortAutoSelector <>4__this;

			private WaitForSecondsRealtime <wait>5__2;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				//IL_002e: Expected O, but got Unknown
				int num = <>1__state;
				EscortAutoSelector escortAutoSelector = <>4__this;
				if (num != 0)
				{
					if (num != 1)
					{
						return false;
					}
					<>1__state = -1;
				}
				else
				{
					<>1__state = -1;
					<wait>5__2 = new WaitForSecondsRealtime(0.5f);
				}
				CharacterBody val = FindUniqueMonsterMashPlayerBody();
				CharacterMaster val2 = (Object.op_Implicit((Object)(object)val) ? val.master : null);
				if (Object.op_Implicit((Object)(object)val2))
				{
					escortAutoSelector._lastMaster = val2;
					escortAutoSelector._ctrl?.LockToMaster(val.master);
					return false;
				}
				<>2__current = <wait>5__2;
				<>1__state = 1;
				return true;
			}

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

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

		private EscortHealthBarController _ctrl;

		private CharacterMaster _lastMaster;

		private void Awake()
		{
			_ctrl = ((Component)this).GetComponent<EscortHealthBarController>();
			((MonoBehaviour)this).StartCoroutine(Loop());
		}

		[IteratorStateMachine(typeof(<Loop>d__3))]
		private IEnumerator Loop()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <Loop>d__3(0)
			{
				<>4__this = this
			};
		}

		private static CharacterBody FindUniqueMonsterMashPlayerBody()
		{
			CharacterBody result = null;
			int num = 0;
			foreach (NetworkUser readOnlyInstances in NetworkUser.readOnlyInstancesList)
			{
				CharacterMaster val = (Object.op_Implicit((Object)(object)readOnlyInstances) ? readOnlyInstances.master : null);
				CharacterBody val2 = (Object.op_Implicit((Object)(object)val) ? val.GetBody() : null);
				if (Object.op_Implicit((Object)(object)val2) && (((Object)val2).name ?? "").StartsWith("MonsterMash", StringComparison.OrdinalIgnoreCase))
				{
					num++;
					if (num > 1)
					{
						return null;
					}
					result = val2;
				}
			}
			return result;
		}

		private static bool IsMonsterMashPlayerBody(CharacterBody b)
		{
			if (!Object.op_Implicit((Object)(object)b))
			{
				return false;
			}
			CharacterMaster master = b.master;
			if (!Object.op_Implicit((Object)(object)master) || (Object)(object)master.playerCharacterMasterController == (Object)null || (Object)(object)master.playerCharacterMasterController.networkUser == (Object)null)
			{
				return false;
			}
			return (((Object)b).name ?? "").StartsWith("MonsterMash", StringComparison.OrdinalIgnoreCase);
		}
	}
	public class EscortHealthBarController : MonoBehaviour
	{
		[CompilerGenerated]
		private sealed class <InitStressGradientOnce>d__66 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public EscortHealthBarController <>4__this;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0046: Unknown result type (might be due to invalid IL or missing references)
				//IL_004b: Unknown result type (might be due to invalid IL or missing references)
				//IL_007d: 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)
				int num = <>1__state;
				EscortHealthBarController escortHealthBarController = <>4__this;
				Rect rect;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = null;
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					rect = escortHealthBarController._root.rect;
					if (((Rect)(ref rect)).width <= 0f)
					{
						<>2__current = null;
						<>1__state = 2;
						return true;
					}
					break;
				case 2:
					<>1__state = -1;
					break;
				}
				rect = escortHealthBarController._root.rect;
				escortHealthBarController._stressMaxWidth = Mathf.Max(1f, ((Rect)(ref rect)).width * Mathf.Max(0f, escortHealthBarController.StressWidthScale));
				((Graphic)escortHealthBarController._stressTrack).rectTransform.SetSizeWithCurrentAnchors((Axis)0, escortHealthBarController._stressMaxWidth);
				escortHealthBarController._stressFill.SetSizeWithCurrentAnchors((Axis)0, escortHealthBarController._stressMaxWidth);
				escortHealthBarController.RebuildStressGradient();
				escortHealthBarController.SetStressFraction(escortHealthBarController._stress01);
				escortHealthBarController._stressDisplay = escortHealthBarController._stress01;
				escortHealthBarController.ApplyStressVisual();
				return false;
			}

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

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

		public HUD hud;

		public CharacterBody targetBody;

		private RectTransform _root;

		private Image _bg;

		private HGTextMeshProUGUI _labelTMP;

		public static EscortHealthBarController ClientInstance;

		private CharacterMaster _lockedMaster;

		private float _nextReattachPoll;

		private float _lastSentStress = -1f;

		private float _nextSendAt;

		private const float UiUpdateInterval = 0.1f;

		private float _nextUiUpdateTime;

		private int _lastHP = -1;

		private int _lastMax = -1;

		private float _lastFracShown = -1f;

		public int EdgeFadePixels = 64;

		public int BorderPixels = 3;

		public float BorderAlphaMult = 1.1f;

		public Color BarColor = new Color(0f, 0f, 0f, 0.75f);

		public Color FillColor = new Color(0.3f, 0.8f, 0.25f, 0.6f);

		public Color FlashColorA = new Color(1f, 1f, 1f, 1f);

		public Color FlashColorB = new Color(1f, 0.2f, 0.2f, 1f);

		public float LowHealthThreshold = 0.25f;

		public float FlashHz = 6f;

		public Vector4 FillInset = new Vector4(4f, 2f, 4f, 2f);

		public int StripePixels = 1;

		public float TopDarkenAlpha = 0.18f;

		public float BotLightenAlpha = 0.14f;

		private RectTransform _mask;

		private RectTransform _fillContent;

		private Image _fillBase;

		private Image _stripeTop;

		private Image _stripeBot;

		private float _lastFrac;

		private float _stress01;

		public float ScrollSensitivity = 0.2f;

		public float StressHeight = 5f;

		public float StressGap = 3f;

		public float StressWidthScale = 0.8f;

		private float _stressMaxWidth;

		private RectTransform _stressMask;

		private RectTransform _stressFill;

		private Image _stressImg;

		private Image _stressTrack;

		public float StressTrackAlpha = 0.75f;

		public int StressBorderPx = 1;

		public float HealthSmoothSpeed = 16f;

		public float StressSmoothSpeed = 3f;

		private float _hpFracTarget;

		private float _hpFracDisplay = -1f;

		private float _stressDisplay;

		public Vector2 BarSize;

		public Vector2 BarAnchor;

		public Vector2 BarPosition;

		public void SetStressFromNet(float v)
		{
			SetStressFraction(v);
		}

		public void GetBarPosition(out Vector2 size, out Vector2 anchor, out Vector2 position)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: 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_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)
			size = new Vector2(1100f, 16f);
			anchor = new Vector2(0.5f, 1f);
			position = new Vector2(0f, -180f);
		}

		public void ApplyLayout()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: 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_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_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			GetBarPosition(out BarSize, out BarAnchor, out BarPosition);
			if (Object.op_Implicit((Object)(object)_root))
			{
				_root.anchorMin = BarAnchor;
				_root.anchorMax = BarAnchor;
				_root.pivot = new Vector2(0.5f, 1f);
				_root.sizeDelta = BarSize;
				_root.anchoredPosition = BarPosition;
				RebuildBackground();
				if (Object.op_Implicit((Object)(object)_stressMask))
				{
					_stressMask.sizeDelta = new Vector2(0f, StressHeight);
					_stressMask.anchoredPosition = new Vector2(0f, 0f - StressGap);
				}
				RebuildStressGradient();
				SetStressFraction(_stress01);
				if (Object.op_Implicit((Object)(object)_mask))
				{
					_mask.offsetMin = new Vector2(FillInset.x, FillInset.y);
					_mask.offsetMax = new Vector2(0f - FillInset.z, 0f - FillInset.w);
				}
				SetFillFraction(_lastFrac);
			}
		}

		private void Awake()
		{
			hud = ((Component)this).GetComponent<HUD>();
			BuildUI();
			((Component)_root).gameObject.SetActive(false);
			Debug.Log((object)"[EscortHB] EscortHealthBarController attached.");
		}

		private void OnEnable()
		{
			CharacterBody.onBodyStartGlobal += OnAnyBodyStart;
		}

		private void OnDisable()
		{
			CharacterBody.onBodyStartGlobal -= OnAnyBodyStart;
		}

		private void OnAnyBodyStart(CharacterBody b)
		{
			if (!((Object)(object)_lockedMaster == (Object)null) && !((Object)(object)b == (Object)null))
			{
				CharacterMaster master = b.master;
				if (!((Object)(object)master != (Object)(object)_lockedMaster) && IsPlayerOwnedMaster(master))
				{
					SetTarget(b);
				}
			}
		}

		private void LateUpdate()
		{
			//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a8: 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_00d4: 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)
			if (!Object.op_Implicit((Object)(object)targetBody) || !Object.op_Implicit((Object)(object)targetBody.healthComponent))
			{
				SetVisible(v: false);
				return;
			}
			SetVisible(v: true);
			if (TargetControlledByLocalUser())
			{
				float axis = Input.GetAxis("Mouse ScrollWheel");
				if (Mathf.Abs(axis) > 0.0001f)
				{
					float num = Mathf.Clamp01(_stress01 + axis * ScrollSensitivity);
					if (!Mathf.Approximately(num, _stress01))
					{
						SetStressFraction(num);
						float unscaledTime = Time.unscaledTime;
						if (unscaledTime >= _nextSendAt && Mathf.Abs(num - _lastSentStress) >= 0.01f)
						{
							_lastSentStress = num;
							_nextSendAt = unscaledTime + 0.05f;
							CharacterMaster master = targetBody.master;
							StressMsg stressMsg = default(StressMsg);
							NetworkInstanceId netId = ((NetworkBehaviour)master).netId;
							stressMsg.masterId = ((NetworkInstanceId)(ref netId)).Value;
							stressMsg.value = num;
							NetMessageExtensions.Send((INetMessage)(object)stressMsg, (NetworkDestination)2);
						}
					}
				}
			}
			if (Time.unscaledTime >= _nextUiUpdateTime)
			{
				_nextUiUpdateTime = Time.unscaledTime + 0.1f;
				HealthComponent healthComponent = targetBody.healthComponent;
				int num2 = Mathf.CeilToInt(healthComponent.combinedHealth);
				int num3 = Mathf.CeilToInt(healthComponent.fullCombinedHealth);
				float num4 = (((float)num3 > 0f) ? (healthComponent.combinedHealth / healthComponent.fullCombinedHealth) : 0f);
				if (!Mathf.Approximately(num4, _lastFracShown))
				{
					_hpFracTarget = num4;
					_lastFracShown = num4;
				}
				if (Object.op_Implicit((Object)(object)_labelTMP) && (num2 != _lastHP || num3 != _lastMax))
				{
					((TMP_Text)_labelTMP).text = $"{num2} / {num3}";
					_lastHP = num2;
					_lastMax = num3;
				}
			}
			if (_hpFracDisplay < 0f)
			{
				_hpFracDisplay = _hpFracTarget;
			}
			float num5 = 1f - Mathf.Exp((0f - HealthSmoothSpeed) * Time.unscaledDeltaTime);
			_hpFracDisplay = Mathf.Lerp(_hpFracDisplay, _hpFracTarget, num5);
			SetFillFraction(_hpFracDisplay);
			float num6 = 1f - Mathf.Exp((0f - StressSmoothSpeed) * Time.unscaledDeltaTime);
			_stressDisplay = Mathf.Lerp(_stressDisplay, _stress01, num6);
			ApplyStressVisual();
			if (_lastFracShown <= LowHealthThreshold && Object.op_Implicit((Object)(object)_fillBase))
			{
				float num7 = Mathf.PingPong(Time.unscaledTime * FlashHz, 1f);
				((Graphic)_fillBase).color = Color.Lerp(FlashColorA, FlashColorB, num7);
			}
			else if (Object.op_Implicit((Object)(object)_fillBase))
			{
				((Graphic)_fillBase).color = FillColor;
			}
			if (Object.op_Implicit((Object)(object)_lockedMaster) && !Object.op_Implicit((Object)(object)targetBody) && Time.unscaledTime >= _nextReattachPoll)
			{
				_nextReattachPoll = Time.unscaledTime + 0.25f;
				if (IsPlayerOwnedMaster(_lockedMaster))
				{
					SetTarget(_lockedMaster.GetBody());
				}
			}
		}

		private void RebuildBackground()
		{
			//IL_005f: 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_006c: Expected O, but got Unknown
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_bg == (Object)null || (Object)(object)_root == (Object)null)
			{
				return;
			}
			int num = Mathf.Max(1, Mathf.RoundToInt(BarSize.x));
			int num2 = Mathf.Max(1, Mathf.RoundToInt(BarSize.y));
			int num3 = Mathf.Clamp(EdgeFadePixels, 0, num / 2);
			Texture2D val = new Texture2D(num, num2, (TextureFormat)5, false)
			{
				wrapMode = (TextureWrapMode)1
			};
			for (int i = 0; i < num2; i++)
			{
				float num4 = ((i < BorderPixels || i >= num2 - BorderPixels) ? BorderAlphaMult : 1f);
				for (int j = 0; j < num; j++)
				{
					float num5 = ((j >= num3) ? ((j < num - num3) ? 1f : ((num3 == 0) ? 1f : ((float)(num - 1 - j) / (float)num3))) : ((num3 == 0) ? 1f : ((float)j / (float)num3)));
					num5 = Mathf.Clamp01(num5 * num4);
					val.SetPixel(j, i, new Color(1f, 1f, 1f, num5));
				}
			}
			val.Apply(false, true);
			Sprite sprite = Sprite.Create(val, new Rect(0f, 0f, (float)num, (float)num2), new Vector2(0.5f, 0.5f), 100f);
			_bg.sprite = sprite;
			_bg.type = (Type)0;
			((Graphic)_bg).color = BarColor;
		}

		private void RebuildStressGradient()
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: 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)
			if ((Object)(object)_stressImg == (Object)null)
			{
				return;
			}
			int num = Mathf.Max(1, Mathf.RoundToInt(_stressMaxWidth));
			int num2 = Mathf.Max(1, Mathf.RoundToInt(StressHeight));
			Texture2D val = new Texture2D(num, num2, (TextureFormat)5, false)
			{
				wrapMode = (TextureWrapMode)1
			};
			Color val2 = default(Color);
			for (int i = 0; i < num2; i++)
			{
				for (int j = 0; j < num; j++)
				{
					float num3 = (float)j / (float)(num - 1) * 0.8f;
					((Color)(ref val2))..ctor(0.8f, 0.8f - num3, 0f, 0.6f);
					val.SetPixel(j, i, val2);
				}
			}
			val.Apply(false, true);
			Sprite sprite = Sprite.Create(val, new Rect(0f, 0f, (float)num, (float)num2), new Vector2(0.5f, 0.5f), 100f);
			_stressImg.sprite = sprite;
		}

		private void BuildUI()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			//IL_0063: 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_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Expected O, but got Unknown
			//IL_00bc: 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_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Expected O, but got Unknown
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Expected O, but got Unknown
			//IL_01f0: 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_0206: 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_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Expected O, but got Unknown
			//IL_0269: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ef: Expected O, but got Unknown
			//IL_0321: Unknown result type (might be due to invalid IL or missing references)
			//IL_0336: Unknown result type (might be due to invalid IL or missing references)
			//IL_034b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0362: Unknown result type (might be due to invalid IL or missing references)
			//IL_036c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0391: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0427: Unknown result type (might be due to invalid IL or missing references)
			//IL_0439: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("EscortBarRoot");
			val.transform.SetParent(hud.mainContainer.transform, false);
			_root = val.AddComponent<RectTransform>();
			GameObject val2 = new GameObject("BG");
			val2.transform.SetParent((Transform)(object)_root, false);
			_bg = val2.AddComponent<Image>();
			RectTransform component = val2.GetComponent<RectTransform>();
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.one;
			component.offsetMin = Vector2.zero;
			component.offsetMax = Vector2.zero;
			GameObject val3 = new GameObject("FillMask");
			val3.transform.SetParent((Transform)(object)_root, false);
			_mask = val3.AddComponent<RectTransform>();
			_mask.anchorMin = Vector2.zero;
			_mask.anchorMax = Vector2.one;
			_mask.offsetMin = new Vector2(FillInset.x, FillInset.y);
			_mask.offsetMax = new Vector2(0f - FillInset.z, 0f - FillInset.w);
			val3.AddComponent<RectMask2D>();
			GameObject val4 = new GameObject("FillContent");
			val4.transform.SetParent((Transform)(object)_mask, false);
			_fillContent = val4.AddComponent<RectTransform>();
			_fillContent.anchorMin = new Vector2(0f, 0f);
			_fillContent.anchorMax = new Vector2(0f, 1f);
			_fillContent.pivot = new Vector2(0f, 0.5f);
			_fillContent.sizeDelta = new Vector2(0f, 0f);
			GameObject val5 = new GameObject("Base");
			val5.transform.SetParent((Transform)(object)_fillContent, false);
			_fillBase = val5.AddComponent<Image>();
			RectTransform component2 = val5.GetComponent<RectTransform>();
			component2.anchorMin = Vector2.zero;
			component2.anchorMax = Vector2.one;
			component2.offsetMin = Vector2.zero;
			component2.offsetMax = Vector2.zero;
			((Graphic)_fillBase).color = FillColor;
			GameObject val6 = new GameObject("TopStripe");
			val6.transform.SetParent((Transform)(object)_fillContent, false);
			_stripeTop = val6.AddComponent<Image>();
			RectTransform component3 = val6.GetComponent<RectTransform>();
			component3.anchorMin = new Vector2(0f, 1f);
			component3.anchorMax = new Vector2(1f, 1f);
			component3.pivot = new Vector2(0.5f, 1f);
			component3.sizeDelta = new Vector2(0f, (float)StripePixels);
			component3.anchoredPosition = Vector2.zero;
			((Graphic)_stripeTop).color = new Color(1f, 1f, 1f, BotLightenAlpha);
			GameObject val7 = new GameObject("BottomStripe");
			val7.transform.SetParent((Transform)(object)_fillContent, false);
			_stripeBot = val7.AddComponent<Image>();
			RectTransform component4 = val7.GetComponent<RectTransform>();
			component4.anchorMin = new Vector2(0f, 0f);
			component4.anchorMax = new Vector2(1f, 0f);
			component4.pivot = new Vector2(0.5f, 0f);
			component4.sizeDelta = new Vector2(0f, (float)StripePixels);
			component4.anchoredPosition = Vector2.zero;
			((Graphic)_stripeBot).color = new Color(0f, 0f, 0f, TopDarkenAlpha);
			GameObject val8 = new GameObject("Label");
			val8.transform.SetParent((Transform)(object)_root, false);
			HGTextMeshProUGUI val9 = val8.AddComponent<HGTextMeshProUGUI>();
			RectTransform component5 = ((Component)val9).GetComponent<RectTransform>();
			component5.anchorMin = Vector2.zero;
			component5.anchorMax = Vector2.one;
			component5.offsetMin = Vector2.zero;
			component5.offsetMax = Vector2.zero;
			((TMP_Text)val9).enableWordWrapping = false;
			((TMP_Text)val9).alignment = (TextAlignmentOptions)4098;
			((TMP_Text)val9).fontSize = 18f;
			((Graphic)val9).raycastTarget = false;
			((TMP_Text)val9).text = "TEST";
			((Graphic)val9).color = Color.white;
			_labelTMP = val9;
			val8.transform.SetAsLastSibling();
			val8.transform.SetAsLastSibling();
			ApplyLayout();
			BuildStressUI();
		}

		private void BuildStressUI()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_003f: 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_0069: 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)
			//IL_0095: 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_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Expected O, but got Unknown
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Expected O, but got Unknown
			//IL_01c0: 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_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: 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_02c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0306: Unknown result type (might be due to invalid IL or missing references)
			//IL_031b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0330: Unknown result type (might be due to invalid IL or missing references)
			//IL_0346: Unknown result type (might be due to invalid IL or missing references)
			//IL_0364: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("StressTrack");
			val.transform.SetParent((Transform)(object)_root, false);
			_stressTrack = val.AddComponent<Image>();
			RectTransform rectTransform = ((Graphic)_stressTrack).rectTransform;
			rectTransform.anchorMin = new Vector2(0.5f, 0f);
			rectTransform.anchorMax = new Vector2(0.5f, 0f);
			rectTransform.pivot = new Vector2(0.5f, 0.5f);
			rectTransform.sizeDelta = new Vector2(0f, StressHeight);
			rectTransform.anchoredPosition = new Vector2(0f, 0f - StressGap);
			((Graphic)_stressTrack).color = new Color(0f, 0f, 0f, StressTrackAlpha);
			val.transform.SetSiblingIndex(0);
			GameObject val2 = new GameObject("StressMask");
			val2.transform.SetParent(((Component)_stressTrack).transform, false);
			_stressMask = val2.AddComponent<RectTransform>();
			_stressMask.anchorMin = new Vector2(0f, 0f);
			_stressMask.anchorMax = new Vector2(0f, 1f);
			_stressMask.pivot = new Vector2(0f, 0.5f);
			_stressMask.sizeDelta = new Vector2(0f, 0f);
			_stressMask.anchoredPosition = new Vector2(0f, 0f);
			val2.AddComponent<RectMask2D>();
			GameObject val3 = new GameObject("StressFill");
			val3.transform.SetParent((Transform)(object)_stressMask, false);
			_stressFill = val3.AddComponent<RectTransform>();
			_stressFill.anchorMin = new Vector2(0f, 0f);
			_stressFill.anchorMax = new Vector2(0f, 1f);
			_stressFill.pivot = new Vector2(0f, 0.5f);
			_stressFill.sizeDelta = new Vector2(0f, 0f);
			_stressImg = val3.AddComponent<Image>();
			_stressImg.type = (Type)0;
			GameObject val4 = new GameObject("TopBorder");
			val4.transform.SetParent(((Component)_stressTrack).transform, false);
			Image obj = val4.AddComponent<Image>();
			RectTransform rectTransform2 = ((Graphic)obj).rectTransform;
			rectTransform2.anchorMin = new Vector2(0f, 1f);
			rectTransform2.anchorMax = new Vector2(1f, 1f);
			rectTransform2.pivot = new Vector2(0.5f, 1f);
			rectTransform2.sizeDelta = new Vector2(0f, (float)StressBorderPx);
			((Graphic)obj).color = new Color(1f, 1f, 1f, 0.08f);
			GameObject val5 = new GameObject("BotBorder");
			val5.transform.SetParent(((Component)_stressTrack).transform, false);
			Image obj2 = val5.AddComponent<Image>();
			RectTransform rectTransform3 = ((Graphic)obj2).rectTransform;
			rectTransform3.anchorMin = new Vector2(0f, 0f);
			rectTransform3.anchorMax = new Vector2(1f, 0f);
			rectTransform3.pivot = new Vector2(0.5f, 0f);
			rectTransform3.sizeDelta = new Vector2(0f, (float)StressBorderPx);
			((Graphic)obj2).color = new Color(0f, 0f, 0f, 0.2f);
			((MonoBehaviour)this).StartCoroutine(InitStressGradientOnce());
		}

		[IteratorStateMachine(typeof(<InitStressGradientOnce>d__66))]
		private IEnumerator InitStressGradientOnce()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <InitStressGradientOnce>d__66(0)
			{
				<>4__this = this
			};
		}

		private static bool IsPlayerOwnedMaster(CharacterMaster m)
		{
			PlayerCharacterMasterController val = (Object.op_Implicit((Object)(object)m) ? m.playerCharacterMasterController : null);
			if ((Object)(object)val != (Object)null)
			{
				return (Object)(object)val.networkUser != (Object)null;
			}
			return false;
		}

		private bool TargetControlledByLocalUser()
		{
			CharacterMaster val = (Object.op_Implicit((Object)(object)targetBody) ? targetBody.master : null);
			PlayerCharacterMasterController val2 = (Object.op_Implicit((Object)(object)val) ? val.playerCharacterMasterController : null);
			NetworkUser val3 = (Object.op_Implicit((Object)(object)val2) ? val2.networkUser : null);
			if ((Object)(object)val3 == (Object)null)
			{
				return false;
			}
			foreach (NetworkUser readOnlyLocalPlayers in NetworkUser.readOnlyLocalPlayersList)
			{
				if ((Object)(object)readOnlyLocalPlayers == (Object)(object)val3)
				{
					return true;
				}
			}
			return false;
		}

		private float AvailableFillWidth()
		{
			//IL_0019: 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)
			if (!Object.op_Implicit((Object)(object)_mask))
			{
				return 0f;
			}
			Rect rect = _mask.rect;
			return ((Rect)(ref rect)).width;
		}

		private void SetFillFraction(float frac)
		{
			if (!((Object)(object)_fillContent == (Object)null))
			{
				frac = Mathf.Clamp01(frac);
				_lastFrac = frac;
				float num = AvailableFillWidth() * frac;
				_fillContent.SetSizeWithCurrentAnchors((Axis)0, num);
			}
		}

		private float AvailableStressWidth()
		{
			//IL_0019: 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)
			if (!Object.op_Implicit((Object)(object)_stressMask))
			{
				return 0f;
			}
			Rect rect = _stressMask.rect;
			return ((Rect)(ref rect)).width;
		}

		public void LockToMaster(CharacterMaster m)
		{
			_lockedMaster = m;
			TryAttachToCurrentBody();
		}

		private void TryAttachToCurrentBody()
		{
			CharacterBody target = (Object.op_Implicit((Object)(object)_lockedMaster) ? _lockedMaster.GetBody() : null);
			SetTarget(target);
		}

		private void SetStressFraction(float f)
		{
			_stress01 = Mathf.Clamp01(f);
		}

		private void ApplyStressVisual()
		{
			if (Object.op_Implicit((Object)(object)_stressMask))
			{
				_stressMask.SetSizeWithCurrentAnchors((Axis)0, _stressMaxWidth * _stressDisplay);
			}
		}

		private void SetVisible(bool v)
		{
			if (Object.op_Implicit((Object)(object)_root))
			{
				((Component)_root).gameObject.SetActive(v);
			}
		}

		public void SetTarget(CharacterBody body)
		{
			targetBody = body;
			SetVisible((Object)(object)body != (Object)null);
			Debug.Log((object)("[EscortHB] Target set -> " + (Object.op_Implicit((Object)(object)body) ? body.GetDisplayName() : "null")));
		}
	}
	public static class PlayerConfigs
	{
		public static void Init(ConfigFile config)
		{
		}
	}
}