using System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; 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("UltimateLethal.ScannerBarHUD")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("UltimateLethal.ScannerBarHUD")] [assembly: AssemblyTitle("UltimateLethal.ScannerBarHUD")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace UltimateLethal.ScannerBarHUD { [BepInPlugin("ultimatelethal.scannerbarhud", "Ultimate Lethal Scanner Bar HUD", "1.0.0")] public sealed class ScannerBarHudPlugin : BaseUnityPlugin { public const string Guid = "ultimatelethal.scannerbarhud"; public const string Name = "Ultimate Lethal Scanner Bar HUD"; public const string Version = "1.0.0"; internal static ConfigEntry CooldownSeconds; internal static ConfigEntry BarHeight; internal static ConfigEntry BarGap; private Harmony _harmony; private void Awake() { //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Expected O, but got Unknown CooldownSeconds = ((BaseUnityPlugin)this).Config.Bind("HUD", "CooldownSeconds", 3.2f, "Visual recharge duration. Keep this equal to ScannerCooldown's cooldown."); BarHeight = ((BaseUnityPlugin)this).Config.Bind("HUD", "BarHeight", 6f, "Recharge bar height."); BarGap = ((BaseUnityPlugin)this).Config.Bind("HUD", "BarGap", 5f, "Gap below EladsHUD stamina bar."); _harmony = new Harmony("ultimatelethal.scannerbarhud"); _harmony.PatchAll(); } private void Update() { ScanBar.EnsureAttached(); ScanBar.UpdateVisual(ScanTracker.Progress); } private void OnDestroy() { ScanBar.Destroy(); Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } } [HarmonyPatch(typeof(HUDManager), "PingScan_performed")] internal static class ScanTracker { private static float _lastSuccessfulVisualScan = -999f; internal static float Progress { get { float num = Mathf.Max(0.01f, ScannerBarHudPlugin.CooldownSeconds.Value); return Mathf.Clamp01((Time.unscaledTime - _lastSuccessfulVisualScan) / num); } } [HarmonyPostfix] private static void Postfix() { if (Progress >= 0.999f) { _lastSuccessfulVisualScan = Time.unscaledTime; } } } internal static class ScanBar { private static GameObject _root; private static Image _fill; private static RectTransform _staminaRect; private static float _nextSearch; internal static void EnsureAttached() { //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Expected O, but got Unknown //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_root != (Object)null && (Object)(object)_staminaRect != (Object)null) { Position(); } else { if (Time.unscaledTime < _nextSearch) { return; } _nextSearch = Time.unscaledTime + 1f; Image val = FindStamina(); if (!((Object)(object)val == (Object)null)) { _staminaRect = ((Graphic)val).rectTransform; Transform parent = ((Transform)_staminaRect).parent; RectTransform val2 = (RectTransform)(object)((parent is RectTransform) ? parent : null); if (!((Object)(object)val2 == (Object)null)) { _root = new GameObject("UltimateScannerRechargeBar", new Type[1] { typeof(RectTransform) }); RectTransform component = _root.GetComponent(); ((Transform)component).SetParent((Transform)(object)val2, false); GameObject val3 = new GameObject("Background", new Type[3] { typeof(RectTransform), typeof(CanvasRenderer), typeof(Image) }); RectTransform component2 = val3.GetComponent(); ((Transform)component2).SetParent((Transform)(object)component, false); component2.anchorMin = Vector2.zero; component2.anchorMax = Vector2.one; component2.offsetMin = Vector2.zero; component2.offsetMax = Vector2.zero; ((Graphic)val3.GetComponent()).color = new Color(0f, 0f, 0f, 0.62f); GameObject val4 = new GameObject("Fill", new Type[3] { typeof(RectTransform), typeof(CanvasRenderer), typeof(Image) }); RectTransform component3 = val4.GetComponent(); ((Transform)component3).SetParent((Transform)(object)component, false); component3.anchorMin = new Vector2(0f, 0f); component3.anchorMax = new Vector2(0f, 1f); component3.pivot = new Vector2(0f, 0.5f); component3.offsetMin = Vector2.zero; component3.offsetMax = Vector2.zero; _fill = val4.GetComponent(); ((Graphic)_fill).color = new Color(0.15f, 0.86f, 1f, 0.95f); Position(); } } } } private static Image FindStamina() { //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) Image[] array = Object.FindObjectsOfType(true); Image result = null; float num = -999f; Image[] array2 = array; foreach (Image val in array2) { if (!((Object)(object)val == (Object)null) && !((Object)(object)((Graphic)val).rectTransform == (Object)null)) { string text = (((Object)val).name ?? "").ToLowerInvariant(); string obj = (((Object)(object)((Component)val).transform.parent != (Object)null) ? (((Object)((Component)val).transform.parent).name ?? "").ToLowerInvariant() : ""); float num2 = 0f; if (text.Contains("stamina")) { num2 += 100f; } if (obj.Contains("stamina")) { num2 += 90f; } if (text.Contains("sprint")) { num2 += 70f; } if (obj.Contains("sprint")) { num2 += 60f; } Rect rect = ((Graphic)val).rectTransform.rect; Vector2 size = ((Rect)(ref rect)).size; if (size.x > size.y * 2f) { num2 += 15f; } if (num2 > num) { num = num2; result = val; } } } if (!(num >= 60f)) { return null; } return result; } private static void Position() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_003b: 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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: 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) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_root == (Object)null) && !((Object)(object)_staminaRect == (Object)null)) { RectTransform component = _root.GetComponent(); component.anchorMin = _staminaRect.anchorMin; component.anchorMax = _staminaRect.anchorMax; component.pivot = _staminaRect.pivot; float value = ScannerBarHudPlugin.BarHeight.Value; float value2 = ScannerBarHudPlugin.BarGap.Value; float x = _staminaRect.anchoredPosition.x; float y = _staminaRect.anchoredPosition.y; Rect rect = _staminaRect.rect; component.anchoredPosition = new Vector2(x, y - ((Rect)(ref rect)).height * 0.5f - value2 - value * 0.5f); rect = _staminaRect.rect; component.sizeDelta = new Vector2(((Rect)(ref rect)).width, value); ((Transform)component).localScale = Vector3.one; ((Transform)component).localRotation = Quaternion.identity; } } internal static void UpdateVisual(float progress) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_root == (Object)null) && !((Object)(object)_fill == (Object)null)) { progress = Mathf.Clamp01(progress); ((Graphic)_fill).rectTransform.anchorMax = new Vector2(progress, 1f); _root.SetActive(progress < 0.999f); } } internal static void Destroy() { if ((Object)(object)_root != (Object)null) { Object.Destroy((Object)(object)_root); } _root = null; _fill = null; _staminaRect = null; } } }