Decompiled source of PeakStamina v0.1.1

plugins/com.lstrings.peak.peakstamina.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using DG.Tweening;
using DG.Tweening.Core;
using DG.Tweening.Plugins.Options;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("com.lstrings.peak.peakstamina")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.1.0")]
[assembly: AssemblyInformationalVersion("0.1.1")]
[assembly: AssemblyProduct("com.lstrings.peak.peakstamina")]
[assembly: AssemblyTitle("PeakStamina")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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 BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace PeakStamina
{
	internal class CharacterBarAffliction : MonoBehaviour
	{
		internal STATUSTYPE afflictionType;

		private RectTransform rectTransform;

		private CharacterStaminaBar characterStaminaBar;

		private float size;

		internal void FetchReferences()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			rectTransform = (RectTransform)((Component)this).transform;
			Object.Destroy((Object)(object)((Component)((Component)this).transform.Find("Icon")).gameObject);
			characterStaminaBar = ((Component)this).GetComponentInParent<CharacterStaminaBar>();
			characterStaminaBar.AddCharacterBarAffliction(this);
		}

		internal void FetchDesiredSize()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			Character val = characterStaminaBar?.ObservedCharacter;
			if (!Object.op_Implicit((Object)(object)val))
			{
				return;
			}
			float currentStatus = val.refs.afflictions.GetCurrentStatus(afflictionType);
			size = characterStaminaBar.fullBarRectTransform.sizeDelta.x * currentStatus;
			if (currentStatus > 0.01f)
			{
				if (size < 15f)
				{
					size = 15f;
				}
				((Component)this).gameObject.SetActive(true);
			}
			else
			{
				((Component)this).gameObject.SetActive(false);
			}
		}

		internal void UpdateVisual()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: 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)
			RectTransform val = rectTransform;
			Vector2 sizeDelta = rectTransform.sizeDelta;
			sizeDelta.x = Mathf.Lerp(rectTransform.sizeDelta.x, size, Mathf.Min(Time.deltaTime * 10f, 0.1f));
			val.sizeDelta = sizeDelta;
		}
	}
	internal class CharacterStaminaBar : MonoBehaviour
	{
		[CompilerGenerated]
		private sealed class <DisableIEnumerator>d__26 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public CharacterStaminaBar <>4__this;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0024: 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_005b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0065: Expected O, but got Unknown
				int num = <>1__state;
				CharacterStaminaBar characterStaminaBar = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					((Component)characterStaminaBar).transform.localScale = Vector3.one * 0.72f;
					TweenSettingsExtensions.SetEase<TweenerCore<Vector3, Vector3, VectorOptions>>(ShortcutExtensions.DOScale(((Component)characterStaminaBar).transform, 0f, 0.5f), (Ease)17);
					<>2__current = (object)new WaitForSeconds(0.5f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					((Component)characterStaminaBar).gameObject.SetActive(false);
					characterStaminaBar.animateEnableDisableCoroutine = null;
					return false;
				}
			}

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

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

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

			private object <>2__current;

			public CharacterStaminaBar <>4__this;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				//IL_0056: Unknown result type (might be due to invalid IL or missing references)
				//IL_0060: Expected O, but got Unknown
				int num = <>1__state;
				CharacterStaminaBar characterStaminaBar = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					((Component)characterStaminaBar).transform.localScale = Vector3.zero;
					TweenSettingsExtensions.SetEase<TweenerCore<Vector3, Vector3, VectorOptions>>(ShortcutExtensions.DOScale(((Component)characterStaminaBar).transform, Plugin.DisplayScale.Value, 0.5f), (Ease)24);
					<>2__current = (object)new WaitForSeconds(0.5f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					characterStaminaBar.animateEnableDisableCoroutine = null;
					return false;
				}
			}

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

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

		private static readonly Color defaultBarColor = new Color(0.1035f, 0.2656f, 0.3019f, 1f);

		private static readonly Color outOfStaminaColor = new Color(0.566f, 0.0089f, 0.0089f, 1f);

		internal RectTransform fullBarRectTransform;

		internal RectTransform staminaBarRectTransform;

		internal RectTransform maxStaminaBarRectTransform;

		internal RectTransform staminaBarOutlineRectTransform;

		internal RectTransform staminaBarOutlineOverflowBar;

		private readonly List<CharacterBarAffliction> characterBarAfflictions = new List<CharacterBarAffliction>();

		internal TMP_Text characterNameTMP;

		internal Image barImage;

		internal Image glowImage;

		private Coroutine? animateEnableDisableCoroutine;

		private Character? _observedCharacter;

		private bool isEnabled;

		private bool hadObservedCharacter;

		private bool outOfStamina;

		private float sinTime;

		internal Character? ObservedCharacter
		{
			get
			{
				return _observedCharacter;
			}
			set
			{
				if (Object.op_Implicit((Object)(object)value))
				{
					hadObservedCharacter = true;
				}
				_observedCharacter = value;
			}
		}

		internal void AddCharacterBarAffliction(CharacterBarAffliction characterBarAffliction)
		{
			characterBarAfflictions.Add(characterBarAffliction);
		}

		internal void AnimateEnable()
		{
			if (!isEnabled && animateEnableDisableCoroutine == null)
			{
				isEnabled = true;
				((Component)this).gameObject.SetActive(true);
				animateEnableDisableCoroutine = ((MonoBehaviour)this).StartCoroutine(EnableIEnumerator());
			}
		}

		internal void AnimateDisable()
		{
			if (isEnabled && animateEnableDisableCoroutine == null)
			{
				isEnabled = false;
				animateEnableDisableCoroutine = ((MonoBehaviour)this).StartCoroutine(DisableIEnumerator());
			}
		}

		private void Update()
		{
			//IL_0049: 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_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: 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_0147: 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_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: 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_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: 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_02cd: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)ObservedCharacter) || !((Component)ObservedCharacter).gameObject.activeSelf)
			{
				if (hadObservedCharacter)
				{
					Object.Destroy((Object)(object)((Component)this).gameObject);
				}
				return;
			}
			((Graphic)characterNameTMP).color = ObservedCharacter.refs.customization.PlayerColor;
			characterNameTMP.text = ObservedCharacter.characterName;
			foreach (CharacterBarAffliction characterBarAffliction in characterBarAfflictions)
			{
				characterBarAffliction.FetchDesiredSize();
				characterBarAffliction.UpdateVisual();
			}
			float num = Mathf.Max(0f, ObservedCharacter.data.currentStamina * fullBarRectTransform.sizeDelta.x);
			if (ObservedCharacter.data.currentStamina <= 0.005f)
			{
				if (!outOfStamina)
				{
					outOfStamina = true;
					OutOfStaminaPulse();
				}
			}
			else
			{
				outOfStamina = false;
			}
			float num2 = Time.deltaTime * 10f;
			RectTransform val = staminaBarRectTransform;
			Vector2 sizeDelta = staminaBarRectTransform.sizeDelta;
			sizeDelta.x = Mathf.Lerp(staminaBarRectTransform.sizeDelta.x, num, num2);
			val.sizeDelta = sizeDelta;
			float num3 = Mathf.Clamp01((staminaBarRectTransform.sizeDelta.x - num) * 0.5f);
			sinTime += num2 * num3;
			Image val2 = glowImage;
			Color color = ((Graphic)glowImage).color;
			color.a = num3 * 0.4f - Mathf.Abs(Mathf.Sin(sinTime)) * 0.2f;
			((Graphic)val2).color = color;
			float x = fullBarRectTransform.sizeDelta.x;
			float num4 = Mathf.Max(0f, ObservedCharacter.GetMaxStamina() * x);
			RectTransform val3 = maxStaminaBarRectTransform;
			sizeDelta = maxStaminaBarRectTransform.sizeDelta;
			sizeDelta.x = Mathf.Lerp(maxStaminaBarRectTransform.sizeDelta.x, num4, num2);
			val3.sizeDelta = sizeDelta;
			float statusSum = ObservedCharacter.refs.afflictions.statusSum;
			RectTransform val4 = staminaBarOutlineRectTransform;
			sizeDelta = staminaBarOutlineRectTransform.sizeDelta;
			sizeDelta.x = 14f + Mathf.Max(1f, statusSum) * x;
			val4.sizeDelta = sizeDelta;
			((Component)staminaBarOutlineOverflowBar).gameObject.SetActive((double)statusSum > 1.005);
			((Component)staminaBarRectTransform).gameObject.SetActive(staminaBarRectTransform.sizeDelta.x > 0f);
			((Component)maxStaminaBarRectTransform).gameObject.SetActive(maxStaminaBarRectTransform.sizeDelta.x > 0f);
			if (sinTime > MathF.PI * 2f)
			{
				sinTime -= MathF.PI * 2f;
			}
		}

		private void OutOfStaminaPulse()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			((Graphic)barImage).color = outOfStaminaColor;
			DOTweenModuleUI.DOColor(barImage, defaultBarColor, 0.5f);
		}

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

		[IteratorStateMachine(typeof(<DisableIEnumerator>d__26))]
		private IEnumerator DisableIEnumerator()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <DisableIEnumerator>d__26(0)
			{
				<>4__this = this
			};
		}
	}
	[BepInPlugin("com.lstrings.peak.peakstamina", "PeakStamina", "0.1.1")]
	public class Plugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(GUIManager), "Start")]
		internal static class Patch_GUIManager_Start
		{
			private static void Postfix(GUIManager __instance)
			{
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				//IL_0016: Expected O, but got Unknown
				//IL_0021: Unknown result type (might be due to invalid IL or missing references)
				//IL_002c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0031: Unknown result type (might be due to invalid IL or missing references)
				//IL_003f: Unknown result type (might be due to invalid IL or missing references)
				RectTransform val = (RectTransform)((Component)__instance.bar).transform.parent;
				val.sizeDelta = new Vector2(600f, 600f);
				Vector2 anchoredPosition = val.anchoredPosition;
				anchoredPosition.y = 353f;
				val.anchoredPosition = anchoredPosition;
				((HorizontalOrVerticalLayoutGroup)((Component)val).GetComponent<VerticalLayoutGroup>()).spacing = 25f;
			}
		}

		[HarmonyPatch(typeof(PlayerHandler), "RegisterCharacter")]
		internal static class Patch_PlayerHandler_RegisterCharacter
		{
			private static void Postfix(Character character)
			{
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				//IL_0029: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)character != (Object)null && (Object)(object)((MonoBehaviourPun)character).photonView != (Object)null && ((MonoBehaviourPun)character).photonView.IsMine)
				{
					Scene activeScene = SceneManager.GetActiveScene();
					if (((Scene)(ref activeScene)).name != "Airport")
					{
						((Component)character).gameObject.AddComponent<ProximityStaminaManager>();
					}
				}
			}
		}

		internal static ConfigEntry<bool> EnableMod;

		internal static ConfigEntry<int> DisplayLimit;

		internal static ConfigEntry<float> DisplayScale;

		internal static ConfigEntry<float> DisplayProximity;

		public const string Id = "com.lstrings.peak.peakstamina";

		internal static ManualLogSource Log { get; private set; }

		public static string Name => "PeakStamina";

		public static string Version => "0.1.1";

		private void Awake()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			ConfigInit();
			Harmony val = new Harmony("com.lstrings.peak.peakstamina");
			val.PatchAll(Assembly.GetExecutingAssembly());
			Log.LogInfo((object)("Plugin " + Name + " is loaded!"));
		}

		private void ConfigInit()
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Expected O, but got Unknown
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Expected O, but got Unknown
			EnableMod = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enable Mod", true, "");
			DisplayLimit = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Display Limit", 4, new ConfigDescription("", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 32), Array.Empty<object>()));
			DisplayScale = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Display Scale (Default: 0.72)", 0.72f, new ConfigDescription("", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.2f, 1f), Array.Empty<object>()));
			DisplayProximity = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Display Proximity", 10f, new ConfigDescription("", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 10000f), Array.Empty<object>()));
		}
	}
	internal class ProximityStaminaManager : MonoBehaviour
	{
		private readonly Dictionary<Character, CharacterStaminaBar> _staminaBars = new Dictionary<Character, CharacterStaminaBar>();

		private bool _disabledStaminaBars;

		private static CharacterStaminaBar CreateStaminaBar(Character observedCharacter)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected O, but got Unknown
			//IL_0056: 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_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_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Expected O, but got Unknown
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Expected O, but got Unknown
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Expected O, but got Unknown
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Expected O, but got Unknown
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Expected O, but got Unknown
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			Transform transform = ((Component)GUIManager.instance.bar).transform;
			Transform val = Object.Instantiate<Transform>(transform, transform.parent);
			val.SetAsFirstSibling();
			Transform transform2 = ((Component)((Component)GUIManager.instance).GetComponentInChildren<AscentUI>()).transform;
			RectTransform val2 = (RectTransform)Object.Instantiate<Transform>(transform2, val);
			((Object)val2).name = "Character Name";
			val2.anchorMin = new Vector2(0f, 1f);
			val2.anchorMax = new Vector2(0f, 1f);
			val2.pivot = Vector2.zero;
			val2.anchoredPosition = Vector2.zero;
			Object.Destroy((Object)(object)((Component)val2).GetComponent<AscentUI>());
			Object.Destroy((Object)(object)((Component)val).GetComponent<StaminaBar>());
			TMP_Text component = ((Component)val2).GetComponent<TMP_Text>();
			component.textWrappingMode = (TextWrappingModes)0;
			component.fontSize = 32f;
			component.autoSizeTextContainer = true;
			component.outlineColor = new Color32((byte)0, (byte)0, (byte)0, byte.MaxValue);
			component.outlineWidth = 0.055f;
			component.alignment = (TextAlignmentOptions)1025;
			CharacterStaminaBar characterStaminaBar = ((Component)val).gameObject.AddComponent<CharacterStaminaBar>();
			characterStaminaBar.ObservedCharacter = observedCharacter;
			characterStaminaBar.characterNameTMP = component;
			characterStaminaBar.fullBarRectTransform = (RectTransform)val.Find("FullBar");
			characterStaminaBar.maxStaminaBarRectTransform = (RectTransform)val.Find("LayoutGroup/MaxStamina");
			characterStaminaBar.staminaBarOutlineRectTransform = (RectTransform)val.Find("OutlineMask/Outline");
			characterStaminaBar.staminaBarOutlineOverflowBar = (RectTransform)val.Find("OutlineOverflowLine");
			characterStaminaBar.barImage = ((Component)((Transform)characterStaminaBar.maxStaminaBarRectTransform).Find("Back")).GetComponent<Image>();
			characterStaminaBar.staminaBarRectTransform = (RectTransform)((Component)characterStaminaBar.barImage).transform.Find("Stamina");
			characterStaminaBar.glowImage = ((Component)((Transform)characterStaminaBar.staminaBarRectTransform).Find("Glow")).GetComponent<Image>();
			BarAffliction[] componentsInChildren = ((Component)val).GetComponentsInChildren<BarAffliction>(true);
			foreach (BarAffliction val3 in componentsInChildren)
			{
				CharacterBarAffliction characterBarAffliction = ((Component)val3).gameObject.AddComponent<CharacterBarAffliction>();
				characterBarAffliction.afflictionType = val3.afflictionType;
				characterBarAffliction.FetchReferences();
				Object.Destroy((Object)(object)val3);
			}
			return characterStaminaBar;
		}

		private void DisableAllBars()
		{
			foreach (KeyValuePair<Character, CharacterStaminaBar> staminaBar in _staminaBars)
			{
				staminaBar.Value?.AnimateDisable();
			}
			_disabledStaminaBars = true;
		}

		private void Update()
		{
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)Character.localCharacter) || !Plugin.EnableMod.Value)
			{
				if (!_disabledStaminaBars)
				{
					DisableAllBars();
				}
				return;
			}
			List<Character> list = (from kv in _staminaBars
				where !Object.op_Implicit((Object)(object)kv.Key) || (Object)(object)kv.Value == (Object)null
				select kv.Key).ToList();
			foreach (Character item in list)
			{
				_staminaBars.Remove(item);
			}
			Character val = (MainCameraMovement.IsSpectating ? MainCameraMovement.specCharacter : Character.localCharacter);
			Vector3 targetCenter = val.Center;
			IOrderedEnumerable<(Character, float)> orderedEnumerable = from c in Character.AllCharacters
				where (Object)(object)c != (Object)null && ((Behaviour)c).isActiveAndEnabled && !c.IsLocal
				select (c, Vector3.Distance(targetCenter, c.Center)) into t
				orderby t.dist
				select t;
			int num = 0;
			int value = Plugin.DisplayLimit.Value;
			float value2 = Plugin.DisplayProximity.Value;
			foreach (var (val2, num2) in orderedEnumerable)
			{
				if (!_staminaBars.TryGetValue(val2, out CharacterStaminaBar value3) || (Object)(object)value3 == (Object)null)
				{
					value3 = CreateStaminaBar(val2);
					_staminaBars[val2] = value3;
					value3.AnimateEnable();
				}
				if (num2 < value2 && num < value && (Object)(object)val2 != (Object)(object)val)
				{
					value3.AnimateEnable();
					num++;
				}
				else
				{
					value3.AnimateDisable();
				}
			}
			_disabledStaminaBars = false;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}