using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("patchnote.OverheadStamina")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+1c6e44c74b8f718db966f046aba9b3244536d6a4")] [assembly: AssemblyProduct("patchnote.OverheadStamina")] [assembly: AssemblyTitle("patchnote.OverheadStamina")] [assembly: AssemblyVersion("1.0.0.0")] [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 OverheadStamina { public static class OverheadStaminaAPI { public static bool FarSightDisabled => Plugin.FarSightDisabled; public static void DisableFarSight(string requesterId) { Plugin.SetFarSightDisabled(requesterId, disabled: true); } public static void EnableFarSight(string requesterId) { Plugin.SetFarSightDisabled(requesterId, disabled: false); } } internal static class CompatibilityPluginGuids { internal const string Hunter = "com.github.BloopTankStudios.PEAK-Hunter"; } [BepInPlugin("patchnote.overheadstamina", "Overhead Stamina", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class Plugin : BaseUnityPlugin { [HarmonyPatch(typeof(UIPlayerNames), "UpdateName")] private static class UIPlayerNamesUpdateNamePatch { private static void Prefix(UIPlayerNames __instance, int index, ref bool visible) { if (!visible && __instance.playerNameText != null && index >= 0 && index < __instance.playerNameText.Length) { PlayerName val = __instance.playerNameText[index]; Character localCharacter = Character.localCharacter; Character val2 = (((Object)(object)val != (Object)null && (Object)(object)val.characterInteractable != (Object)null) ? val.characterInteractable.character : null); if ((Object)(object)localCharacter != (Object)null && (Object)(object)val2 != (Object)null && (Object)(object)val2 != (Object)(object)localCharacter && OverheadStaminaNameplate.IsVisibleForMod(localCharacter, val2)) { visible = true; } } } private static void Postfix(UIPlayerNames __instance, int index, bool visible) { if (__instance.playerNameText == null || index < 0 || index >= __instance.playerNameText.Length) { return; } PlayerName val = __instance.playerNameText[index]; if (!((Object)(object)val == (Object)null)) { OverheadStaminaNameplate overheadStaminaNameplate = ((Component)val).GetComponent(); if ((Object)(object)overheadStaminaNameplate == (Object)null) { overheadStaminaNameplate = ((Component)val).gameObject.AddComponent(); } overheadStaminaNameplate.Refresh(val, visible); } } } [HarmonyPatch(typeof(UIPlayerNames), "DisableName")] private static class UIPlayerNamesDisableNamePatch { private static void Prefix(UIPlayerNames __instance, int index) { if (__instance.playerNameText != null && index >= 0 && index < __instance.playerNameText.Length) { PlayerName val = __instance.playerNameText[index]; OverheadStaminaNameplate overheadStaminaNameplate = default(OverheadStaminaNameplate); if ((Object)(object)val != (Object)null && ((Component)val).TryGetComponent(ref overheadStaminaNameplate)) { overheadStaminaNameplate.Hide(); } } } } [HarmonyPatch(typeof(GUIManager), "LateUpdate")] private static class GUIManagerLateUpdatePatch { private static void Postfix(GUIManager __instance) { //IL_0005: 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) int num; if ((int)DistanceOverlayKeyboardKey.Value != 0 && !IsInputBlocked()) { num = (IsKeyboardKeyPressed(DistanceOverlayKeyboardKey.Value) ? 1 : 0); if (num != 0 && !s_distanceOverlayKeyWasDown) { DistanceOverlayEnabled = !DistanceOverlayEnabled; OverheadStaminaNameplate.RefreshAllNameText(__instance.playerNames); } } else { num = 0; } s_distanceOverlayKeyWasDown = (byte)num != 0; } private static bool IsKeyboardKeyPressed(KeyCode key) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Invalid comparison between Unknown and I4 //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Invalid comparison between Unknown and I4 //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Invalid comparison between Unknown and I4 Keyboard current = Keyboard.current; if (current != null) { if ((int)key == 103) { return ((ButtonControl)current.gKey).isPressed; } if ((int)key == 116) { return ((ButtonControl)current.tKey).isPressed; } if ((int)key == 121) { return ((ButtonControl)current.yKey).isPressed; } } return TryGetLegacyKey(key); } private static bool TryGetLegacyKey(KeyCode key) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) try { return Input.GetKey(key); } catch { return false; } } private static bool IsInputBlocked() { try { return (Object)(object)GUIManager.instance != (Object)null && (GUIManager.instance.windowBlockingInput || GUIManager.instance.wheelActive); } catch { return false; } } } internal const string PluginGuid = "patchnote.overheadstamina"; internal const string PluginName = "Overhead Stamina"; internal const string PluginVersion = "1.0.0"; private Harmony? _harmony; private static readonly HashSet s_farSightDisableRequests = new HashSet(); internal const float BaseBarWidth = 118f; internal const float BaseBarHeight = 12f; internal const float BaseExtraStaminaHeight = 3f; internal const float BaseExtraStaminaGap = 2f; internal const float BaseMinSegmentWidth = 12f; internal const float NameTextClearance = 28f; internal const float DistanceOverlayMaxDistance = 2000f; private static bool s_distanceOverlayKeyWasDown; internal static ConfigEntry MaxDistance { get; private set; } = null; internal static ConfigEntry BarScale { get; private set; } = null; internal static ConfigEntry DistanceOverlayKeyboardKey { get; private set; } = null; internal static bool DistanceOverlayEnabled { get; private set; } internal static bool FarSightDisabled => s_farSightDisableRequests.Count > 0; private void Awake() { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected O, but got Unknown //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Expected O, but got Unknown MaxDistance = ((BaseUnityPlugin)this).Config.Bind("General", "MaxDistance", 18f, "Maximum world-space distance at which another player's stamina bar is shown above their name."); BarScale = ((BaseUnityPlugin)this).Config.Bind("General", "BarScale", 1.5f, new ConfigDescription("Scale multiplier for the stamina bar shown above player names.", (AcceptableValueBase)(object)new AcceptableValueRange(0.25f, 3f), Array.Empty())); DistanceOverlayKeyboardKey = ((BaseUnityPlugin)this).Config.Bind("General", "DistanceOverlayKeyboardKey", (KeyCode)96, "Keyboard key used to toggle the distance debug overlay. Set to None to disable."); EnableHunterCompatibilityIfLoaded(); _harmony = new Harmony("patchnote.overheadstamina"); _harmony.PatchAll(typeof(Plugin).Assembly); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Loaded Overhead Stamina 1.0.0."); } private void OnDestroy() { Harmony? harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } internal static void SetFarSightDisabled(string requesterId, bool disabled) { if (string.IsNullOrWhiteSpace(requesterId)) { throw new ArgumentException("A stable requester id is required.", "requesterId"); } if (disabled) { s_farSightDisableRequests.Add(requesterId); } else { s_farSightDisableRequests.Remove(requesterId); } } private void EnableHunterCompatibilityIfLoaded() { if (Chainloader.PluginInfos.ContainsKey("com.github.BloopTankStudios.PEAK-Hunter")) { OverheadStaminaAPI.DisableFarSight("com.github.BloopTankStudios.PEAK-Hunter"); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Hunter detected; distance overlay range is limited to General.MaxDistance."); } } } internal sealed class OverheadStaminaNameplate : MonoBehaviour { private sealed class StatusSegment { internal GameObject GameObject; internal RectTransform RootRect; internal RectTransform Rect; internal STATUSTYPE StatusType; internal float TargetWidth; } private readonly List _segments = new List(); private RectTransform? _container; private RectTransform? _staminaEmpty; private RectTransform? _staminaFill; private RectTransform? _extraStaminaFill; private Vector2 _staminaEmptySourceSize; private Vector2 _staminaFillSourceSize; private Vector2 _extraStaminaSourceSize; private StaminaBar? _sourceBar; private PlayerName? _playerName; internal void Refresh(PlayerName playerName, bool baseNameIsVisible) { _playerName = playerName; Character localCharacter = Character.localCharacter; Character val = (((Object)(object)playerName.characterInteractable != (Object)null) ? playerName.characterInteractable.character : null); if ((Object)(object)localCharacter == (Object)null || (Object)(object)val == (Object)null || (Object)(object)val == (Object)(object)localCharacter || !IsVisibleForMod(localCharacter, val)) { Hide(); return; } CharacterAfflictions afflictions = val.refs.afflictions; if ((Object)(object)afflictions == (Object)null) { Hide(); return; } if ((Object)(object)playerName.text == (Object)null) { Hide(); return; } UpdateNameText(playerName, val, localCharacter); if (!EnsureSegments(((TMP_Text)playerName.text).transform)) { Hide(); return; } if (!baseNameIsVisible) { ((Component)playerName).gameObject.SetActive(true); if ((Object)(object)playerName.group != (Object)null) { playerName.group.alpha = Mathf.MoveTowards(playerName.group.alpha, 1f, Time.deltaTime * 5f); } } UpdateLayout(val, afflictions); } internal void Hide() { RestoreNameText(_playerName); if ((Object)(object)_container != (Object)null) { ((Component)_container).gameObject.SetActive(false); } } internal static bool IsVisibleForMod(Character localCharacter, Character targetCharacter) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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) //IL_0077: Unknown result type (might be due to invalid IL or missing references) if (GetDistanceToViewer(localCharacter, targetCharacter) > GetEffectiveMaxDistance()) { return false; } Camera val = (((Object)(object)MainCamera.instance != (Object)null) ? ((Component)MainCamera.instance).GetComponent() : null); if ((Object)(object)val == (Object)null) { return true; } Vector3 val2 = val.WorldToViewportPoint(targetCharacter.Center); if (val2.z > 0f && val2.x >= -0.1f && val2.x <= 1.1f && val2.y >= -0.1f) { return val2.y <= 1.1f; } return false; } internal static void RefreshAllNameText(UIPlayerNames? playerNames) { if ((Object)(object)playerNames == (Object)null || playerNames.playerNameText == null) { return; } Character localCharacter = Character.localCharacter; for (int i = 0; i < playerNames.playerNameText.Length; i++) { PlayerName val = playerNames.playerNameText[i]; if (!((Object)(object)val == (Object)null) && !((Object)(object)val.text == (Object)null)) { Character targetCharacter = (((Object)(object)val.characterInteractable != (Object)null) ? val.characterInteractable.character : null); UpdateNameText(val, targetCharacter, localCharacter); } } } private static float GetEffectiveMaxDistance() { float num = (Plugin.DistanceOverlayEnabled ? 2000f : Plugin.MaxDistance.Value); if (!Plugin.FarSightDisabled) { return num; } return Mathf.Min(num, Plugin.MaxDistance.Value); } private static float GetDistanceToViewer(Character localCharacter, Character targetCharacter) { //IL_0018: 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_001e: Unknown result type (might be due to invalid IL or missing references) Character observedCharacter = Character.observedCharacter; return Vector3.Distance(((Object)(object)observedCharacter != (Object)null) ? observedCharacter.Center : localCharacter.Center, targetCharacter.Center); } private static void UpdateNameText(PlayerName playerName, Character? targetCharacter, Character? localCharacter) { if (!Plugin.DistanceOverlayEnabled || (Object)(object)playerName.text == (Object)null || (Object)(object)playerName.characterInteractable == (Object)null || (Object)(object)targetCharacter == (Object)null || (Object)(object)localCharacter == (Object)null || (Object)(object)targetCharacter == (Object)(object)localCharacter) { RestoreNameText(playerName); return; } float distanceToViewer = GetDistanceToViewer(localCharacter, targetCharacter); ((TMP_Text)playerName.text).text = $"{playerName.characterInteractable.GetName()} {Mathf.RoundToInt(distanceToViewer)}m"; } private static void RestoreNameText(PlayerName? playerName) { if (!((Object)(object)playerName == (Object)null) && !((Object)(object)playerName.text == (Object)null) && !((Object)(object)playerName.characterInteractable == (Object)null)) { ((TMP_Text)playerName.text).text = playerName.characterInteractable.GetName(); } } private bool EnsureSegments(Transform parent) { //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Expected O, but got Unknown //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: 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_0171: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: 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_027c: Unknown result type (might be due to invalid IL or missing references) //IL_0281: 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_02d1: Expected O, but got Unknown //IL_0317: 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_031c: Unknown result type (might be due to invalid IL or missing references) //IL_035d: Unknown result type (might be due to invalid IL or missing references) //IL_0396: Unknown result type (might be due to invalid IL or missing references) //IL_041d: Unknown result type (might be due to invalid IL or missing references) //IL_0433: Unknown result type (might be due to invalid IL or missing references) //IL_0449: Unknown result type (might be due to invalid IL or missing references) //IL_0455: Unknown result type (might be due to invalid IL or missing references) //IL_046b: Unknown result type (might be due to invalid IL or missing references) //IL_0477: Unknown result type (might be due to invalid IL or missing references) //IL_04db: Unknown result type (might be due to invalid IL or missing references) //IL_04e0: Unknown result type (might be due to invalid IL or missing references) StaminaBar val = (((Object)(object)GUIManager.instance != (Object)null) ? GUIManager.instance.bar : null); if ((Object)(object)val == (Object)null || val.afflictions == null || val.afflictions.Length == 0) { return false; } if ((Object)(object)_container != (Object)null && (Object)(object)_sourceBar == (Object)(object)val && (Object)(object)((Transform)_container).parent == (Object)(object)parent && _segments.Count == val.afflictions.Length) { RemoveDuplicateContainers(parent, ((Component)_container).gameObject); return true; } ClearSegments(); _sourceBar = val; GameObject val2 = new GameObject("OverheadStaminaBar", new Type[1] { typeof(RectTransform) }); val2.transform.SetParent(parent, false); _container = val2.GetComponent(); _container.anchorMin = new Vector2(0.5f, 0.5f); _container.anchorMax = new Vector2(0.5f, 0.5f); _container.pivot = new Vector2(0.5f, 0.5f); RemoveDuplicateContainers(parent, ((Component)_container).gameObject); GameObject val3 = (GameObject)(((Object)(object)val.maxStaminaBar != (Object)null) ? ((object)Object.Instantiate(((Component)val.maxStaminaBar).gameObject, (Transform)(object)_container)) : ((object)new GameObject("OverheadStaminaEmpty", new Type[3] { typeof(RectTransform), typeof(CanvasRenderer), typeof(Image) }))); ((Object)val3).name = "OverheadStaminaEmpty"; RemoveCopiedNestedStaminaBar(val3, val); RemoveCopiedStaminaInfoText(val3); val3.transform.SetParent((Transform)(object)_container, false); _staminaEmpty = val3.GetComponent(); _staminaEmptySourceSize = _staminaEmpty.sizeDelta; ConfigureBarChild(_staminaEmpty); SetRaycastTargets(val3, value: false); GameObject val4 = (GameObject)(((Object)(object)val.staminaBar != (Object)null) ? ((object)Object.Instantiate(((Component)val.staminaBar).gameObject, (Transform)(object)_container)) : ((object)new GameObject("OverheadStaminaFill", new Type[3] { typeof(RectTransform), typeof(CanvasRenderer), typeof(Image) }))); ((Object)val4).name = "OverheadStaminaFill"; RemoveCopiedStaminaInfoText(val4); val4.transform.SetParent((Transform)(object)_container, false); _staminaFill = val4.GetComponent(); _staminaFillSourceSize = _staminaFill.sizeDelta; ConfigureBarChild(_staminaFill); SetRaycastTargets(val4, value: false); GameObject val5 = new GameObject("OverheadExtraStaminaFill", new Type[3] { typeof(RectTransform), typeof(CanvasRenderer), typeof(Image) }); val5.transform.SetParent((Transform)(object)_container, false); _extraStaminaFill = val5.GetComponent(); _extraStaminaSourceSize = (Vector2)(((Object)(object)val.staminaBar != (Object)null) ? val.staminaBar.sizeDelta : new Vector2(118f, 45f)); ConfigureLeftAnchoredCenteredBarChild(_extraStaminaFill); ConfigureExtraStaminaImage(val5, val); if ((Object)(object)val.maxStaminaBar == (Object)null) { Image component = val3.GetComponent(); ((Graphic)component).color = new Color(0.56f, 0.62f, 0.57f, 0.75f); ((Graphic)component).raycastTarget = false; } if ((Object)(object)val.staminaBar == (Object)null) { Image component2 = val4.GetComponent(); ((Graphic)component2).color = new Color(0.36f, 0.82f, 0.2f, 0.95f); ((Graphic)component2).raycastTarget = false; } BarAffliction[] afflictions = val.afflictions; foreach (BarAffliction val6 in afflictions) { if (!((Object)(object)val6 == (Object)null)) { GameObject val7 = Object.Instantiate(((Component)val6).gameObject, (Transform)(object)_container); ((Object)val7).name = "Overhead" + ((object)(STATUSTYPE)(ref val6.afflictionType)).ToString(); RemoveCopiedStaminaInfoText(val7); RectTransform component3 = val7.GetComponent(); component3.anchorMin = new Vector2(0.5f, 0.5f); component3.anchorMax = new Vector2(0.5f, 0.5f); component3.pivot = new Vector2(0.5f, 0.5f); component3.anchoredPosition = Vector2.zero; component3.sizeDelta = new Vector2(0f, 0f); ((Transform)component3).localScale = Vector3.one; BarAffliction component4 = val7.GetComponent(); RectTransform rect = (((Object)(object)component4.rtf != (Object)null) ? component4.rtf : component3); ConfigureBarChild(rect); SetRaycastTargets(val7, value: false); _segments.Add(new StatusSegment { GameObject = val7, RootRect = component3, Rect = rect, StatusType = component4.afflictionType }); val7.SetActive(false); } } return _segments.Count > 0; } private static void RemoveDuplicateContainers(Transform parent, GameObject? keep) { for (int num = parent.childCount - 1; num >= 0; num--) { Transform child = parent.GetChild(num); if ((Object)(object)((Component)child).gameObject != (Object)(object)keep && ((Object)child).name == "OverheadStaminaBar") { Object.Destroy((Object)(object)((Component)child).gameObject); } } } private static void RemoveCopiedNestedStaminaBar(GameObject root, StaminaBar sourceBar) { if ((Object)(object)sourceBar.staminaBar == (Object)null) { return; } Transform[] componentsInChildren = root.GetComponentsInChildren(true); for (int num = componentsInChildren.Length - 1; num >= 0; num--) { Transform val = componentsInChildren[num]; if ((Object)(object)val != (Object)(object)root.transform && ((Object)val).name == ((Object)sourceBar.staminaBar).name) { Object.Destroy((Object)(object)((Component)val).gameObject); } } } private static void RemoveCopiedStaminaInfoText(GameObject root) { Transform[] componentsInChildren = root.GetComponentsInChildren(true); for (int num = componentsInChildren.Length - 1; num >= 0; num--) { Transform val = componentsInChildren[num]; if ((Object)(object)val != (Object)(object)root.transform && ((Object)val).name == "StaminaInfo") { Object.Destroy((Object)(object)((Component)val).gameObject); } } } private static void ConfigureBarChild(RectTransform rect) { //IL_000b: 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_0035: 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) rect.anchorMin = new Vector2(0f, 0.5f); rect.anchorMax = new Vector2(0f, 0.5f); rect.pivot = new Vector2(0f, 0.5f); rect.anchoredPosition = Vector2.zero; } private static void ConfigureLeftAnchoredCenteredBarChild(RectTransform rect) { //IL_000b: 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_0035: 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) rect.anchorMin = new Vector2(0.5f, 0.5f); rect.anchorMax = new Vector2(0.5f, 0.5f); rect.pivot = new Vector2(0f, 0.5f); rect.anchoredPosition = Vector2.zero; } private static void SetRaycastTargets(GameObject gameObject, bool value) { Graphic[] componentsInChildren = gameObject.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].raycastTarget = value; } } private static void ConfigureExtraStaminaImage(GameObject extraStaminaObject, StaminaBar sourceBar) { //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) Image component = extraStaminaObject.GetComponent(); Image val = FindFillImage(sourceBar.extraBarStamina) ?? FindFillImage(sourceBar.staminaBar); if ((Object)(object)val != (Object)null) { component.sprite = val.sprite; component.type = val.type; component.pixelsPerUnitMultiplier = val.pixelsPerUnitMultiplier; ((Graphic)component).color = ((Graphic)val).color; } else { ((Graphic)component).color = new Color(0.36f, 0.82f, 0.2f, 0.95f); } ((Graphic)component).raycastTarget = false; } private static Image? FindFillImage(RectTransform? root) { if ((Object)(object)root == (Object)null) { return null; } Image[] componentsInChildren = ((Component)root).GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { if (((Object)componentsInChildren[i]).name == "Fill") { return componentsInChildren[i]; } } if (componentsInChildren.Length == 0) { return null; } return componentsInChildren[0]; } private void ClearSegments() { //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_0051: 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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) _segments.Clear(); if ((Object)(object)_container != (Object)null) { Object.Destroy((Object)(object)((Component)_container).gameObject); _container = null; } _staminaFill = null; _staminaEmpty = null; _extraStaminaFill = null; _staminaFillSourceSize = Vector2.zero; _staminaEmptySourceSize = Vector2.zero; _extraStaminaSourceSize = Vector2.zero; } private void UpdateLayout(Character targetCharacter, CharacterAfflictions afflictions) { //IL_008d: 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_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0182: 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_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0335: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: 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_02e5: Unknown result type (might be due to invalid IL or missing references) //IL_02f9: Unknown result type (might be due to invalid IL or missing references) //IL_030b: 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_0314: Unknown result type (might be due to invalid IL or missing references) //IL_0325: Unknown result type (might be due to invalid IL or missing references) //IL_0327: Unknown result type (might be due to invalid IL or missing references) //IL_034e: Unknown result type (might be due to invalid IL or missing references) //IL_038a: Unknown result type (might be due to invalid IL or missing references) //IL_03c8: Unknown result type (might be due to invalid IL or missing references) //IL_04c4: Unknown result type (might be due to invalid IL or missing references) //IL_0461: Unknown result type (might be due to invalid IL or missing references) //IL_0478: Unknown result type (might be due to invalid IL or missing references) //IL_0491: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Max(0.01f, Plugin.BarScale.Value); float num2 = 118f * num; float num3 = 12f * num; float num4 = 3f * num; float num5 = 2f * num; float num6 = Mathf.Clamp(12f * num, 0f, num2); float num7 = Mathf.Clamp01(targetCharacter.GetMaxStamina()) * num2; float num8 = Mathf.Max(0f, num2 - num7); float num9 = 0f; bool flag = false; for (int i = 0; i < _segments.Count; i++) { StatusSegment statusSegment = _segments[i]; float currentStatus = afflictions.GetCurrentStatus(statusSegment.StatusType); if (currentStatus > 0.01f) { statusSegment.TargetWidth = Mathf.Min(Mathf.Max(num6, num2 * currentStatus), Mathf.Max(0f, num8 - num9)); num9 += statusSegment.TargetWidth; flag = statusSegment.TargetWidth > 0.5f || flag; } else { statusSegment.TargetWidth = 0f; } } float num10 = num7; if ((Object)(object)_container == (Object)null) { return; } _container.sizeDelta = new Vector2(num2, num3); float num11 = 0f; Bounds val = default(Bounds); bool flag2 = false; for (int j = 0; j < _segments.Count; j++) { StatusSegment statusSegment2 = _segments[j]; if (statusSegment2.TargetWidth > 0f) { float num12 = num10 + num11 - num2 * 0.5f; statusSegment2.RootRect.anchoredPosition = Vector2.zero; statusSegment2.RootRect.sizeDelta = new Vector2(statusSegment2.TargetWidth, num3); statusSegment2.Rect.anchoredPosition = Vector2.zero; statusSegment2.Rect.sizeDelta = new Vector2(Mathf.Lerp(statusSegment2.Rect.sizeDelta.x, statusSegment2.TargetWidth, Mathf.Min(Time.deltaTime * 10f, 0.1f)), num3); statusSegment2.GameObject.SetActive(true); Bounds val2 = CalculateSegmentBarBounds(_container, statusSegment2); statusSegment2.RootRect.anchoredPosition = new Vector2(num12 - ((Bounds)(ref val2)).min.x, 0f); Bounds val3 = CalculateSegmentBarBounds(_container, statusSegment2); if (flag2) { ((Bounds)(ref val)).Encapsulate(val3); } else { val = val3; flag2 = true; } num11 += statusSegment2.TargetWidth; } else { statusSegment2.GameObject.SetActive(false); } } if (!flag2 && _segments.Count > 0) { StatusSegment statusSegment3 = _segments[0]; statusSegment3.RootRect.anchoredPosition = Vector2.zero; statusSegment3.RootRect.sizeDelta = new Vector2(num6, num3); statusSegment3.Rect.anchoredPosition = Vector2.zero; statusSegment3.Rect.sizeDelta = new Vector2(num6, num3); Bounds val4 = CalculateSegmentBarBounds(_container, statusSegment3); if (((Bounds)(ref val4)).size.y > 0.5f) { val = val4; flag2 = true; } } float num13 = (flag2 ? ((Bounds)(ref val)).size.y : num3); float num14 = (flag2 ? ((Bounds)(ref val)).center.y : 0f); if ((Object)(object)_staminaFill != (Object)null) { float num15 = Mathf.Clamp(targetCharacter.data.currentStamina * num2, 0f, num7); ApplyClonedStaminaLayout(_staminaFill, _staminaFillSourceSize, num15, num13, num14); ((Component)_staminaFill).gameObject.SetActive(num15 > 0.5f); } if ((Object)(object)_staminaEmpty != (Object)null) { ApplyClonedStaminaLayout(_staminaEmpty, _staminaEmptySourceSize, num7, num13, num14); ((Component)_staminaEmpty).gameObject.SetActive(num7 > 0.5f); } if ((Object)(object)_extraStaminaFill != (Object)null) { float num16 = Mathf.Clamp01(targetCharacter.data.extraStamina) * num2; float num17 = Mathf.Max(1f, _extraStaminaSourceSize.y); float num18 = Mathf.Max(0.01f, num4 / num17); _extraStaminaFill.anchoredPosition = new Vector2((0f - num2) * 0.5f, num14 - num13 * 0.5f - num5 - num4 * 0.5f); _extraStaminaFill.sizeDelta = new Vector2(num16 / num18, num17); ((Transform)_extraStaminaFill).localScale = new Vector3(num18, num18, 1f); ((Component)_extraStaminaFill).gameObject.SetActive(num16 > 0.5f); } _container.anchoredPosition = new Vector2(0f, 28f); ((Component)_container).gameObject.SetActive(flag || ((Object)(object)_staminaFill != (Object)null && ((Component)_staminaFill).gameObject.activeSelf) || ((Object)(object)_staminaEmpty != (Object)null && ((Component)_staminaEmpty).gameObject.activeSelf) || ((Object)(object)_extraStaminaFill != (Object)null && ((Component)_extraStaminaFill).gameObject.activeSelf)); } private static Bounds CalculateSegmentBarBounds(RectTransform container, StatusSegment segment) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) RectTransform[] componentsInChildren = segment.GameObject.GetComponentsInChildren(true); Bounds result = default(Bounds); bool flag = false; foreach (RectTransform val in componentsInChildren) { if (!(((Object)val).name != "Fill") || !(((Object)val).name != "Outline")) { Bounds val2 = RectTransformUtility.CalculateRelativeRectTransformBounds((Transform)(object)container, (Transform)(object)val); if (flag) { ((Bounds)(ref result)).Encapsulate(val2); continue; } result = val2; flag = true; } } if (!flag) { return RectTransformUtility.CalculateRelativeRectTransformBounds((Transform)(object)container, (Transform)(object)segment.Rect); } return result; } private static void ApplyClonedStaminaLayout(RectTransform rect, Vector2 sourceSize, float targetWidth, float targetHeight, float targetCenterY) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Max(1f, sourceSize.y); float num2 = Mathf.Max(0.01f, targetHeight / num); rect.anchoredPosition = new Vector2(0f, targetCenterY); rect.sizeDelta = new Vector2(targetWidth / num2, num); ((Transform)rect).localScale = new Vector3(num2, num2, 1f); } } }