using System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using ComputerysModdingUtilities; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: StraftatMod(true)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("0.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 SlideCooldownOverlay { [BepInPlugin("landa.straftat.slidecooldownoverlay", "Slide Cooldown Overlay", "1.2.1")] public class Plugin : BaseUnityPlugin { internal static ManualLogSource Log; internal static ConfigEntry AlwaysShow; internal static ConfigEntry ShowLabel; internal static ConfigEntry YFraction; internal static ConfigEntry BarWidth; internal static ConfigEntry BarHeight; internal static ConfigEntry ReadyFlash; private void Awake() { //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Expected O, but got Unknown //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Expected O, but got Unknown //IL_0104: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; AlwaysShow = ((BaseUnityPlugin)this).Config.Bind("SlideCooldownOverlay.Display", "AlwaysShow", false, "Show the bar even while slide is ready. Off = only during cooldown plus a short ready flash."); ShowLabel = ((BaseUnityPlugin)this).Config.Bind("SlideCooldownOverlay.Display", "ShowLabel", true, "Show remaining seconds while cooling down and SLIDE when it becomes ready."); YFraction = ((BaseUnityPlugin)this).Config.Bind("SlideCooldownOverlay.Display", "VerticalPosition", 0.78f, new ConfigDescription("Bar position as a fraction of screen height (0 = top, 1 = bottom).", (AcceptableValueBase)(object)new AcceptableValueRange(0.05f, 0.95f), Array.Empty())); BarWidth = ((BaseUnityPlugin)this).Config.Bind("SlideCooldownOverlay.Display", "BarWidth", 180f, "Bar width in pixels at 1080p (scales with resolution)."); BarHeight = ((BaseUnityPlugin)this).Config.Bind("SlideCooldownOverlay.Display", "BarHeight", 10f, "Bar height in pixels at 1080p (scales with resolution)."); ReadyFlash = ((BaseUnityPlugin)this).Config.Bind("SlideCooldownOverlay.Display", "ReadyFlashSeconds", 0.35f, "How long the green ready flash stays on screen after the cooldown ends."); GameObject val = new GameObject("SlideCooldownOverlay"); Object.DontDestroyOnLoad((Object)val); ((Object)val).hideFlags = (HideFlags)61; val.AddComponent(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Slide Cooldown Overlay loaded."); } private void OnDisable() { ((BaseUnityPlugin)this).Logger.LogWarning((object)"Plugin component disabled."); } private void OnDestroy() { ((BaseUnityPlugin)this).Logger.LogWarning((object)"Plugin component destroyed."); } } internal class OverlayBehaviour : MonoBehaviour { private Type _fpcType; private FieldInfo _slideResetTimer; private FieldInfo _slideResetTime; private PropertyInfo _isOwner; private Type _phType; private PropertyInfo _healthProp; private Component _playerHealth; private Component _player; private float _nextScan; private bool _wasCooling; private float _readyAt = -1f; private bool _loggedFirstCooldown; private bool _warnedNoOwner; private Texture2D _tex; private GUIStyle _labelStyle; private void Awake() { //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Expected O, but got Unknown //IL_0119: Unknown result type (might be due to invalid IL or missing references) _fpcType = Type.GetType("FirstPersonController, Assembly-CSharp"); if (_fpcType == null) { Plugin.Log.LogError((object)"FirstPersonController not found in Assembly-CSharp - the game may have updated. Overlay disabled."); ((Behaviour)this).enabled = false; return; } _slideResetTimer = _fpcType.GetField("slideResetTimer", BindingFlags.Instance | BindingFlags.NonPublic); _slideResetTime = _fpcType.GetField("slideResetTime", BindingFlags.Instance | BindingFlags.NonPublic); _isOwner = _fpcType.GetProperty("IsOwner"); if (_slideResetTimer == null || _slideResetTime == null) { Plugin.Log.LogError((object)"Slide cooldown fields not found - the game may have updated. Overlay disabled."); ((Behaviour)this).enabled = false; return; } _phType = Type.GetType("PlayerHealth, Assembly-CSharp"); _healthProp = ((_phType != null) ? _phType.GetProperty("SyncAccessor_health") : null); if (_healthProp == null) { Plugin.Log.LogWarning((object)"PlayerHealth.SyncAccessor_health not found - overlay will not auto-hide on death."); } _tex = new Texture2D(1, 1, (TextureFormat)4, false); _tex.SetPixel(0, 0, Color.white); _tex.Apply(); Plugin.Log.LogInfo((object)"Overlay behaviour alive."); } private void Update() { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Expected O, but got Unknown //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Expected O, but got Unknown if ((Object)(object)_player == (Object)null && Time.unscaledTime >= _nextScan) { _nextScan = Time.unscaledTime + 1f; Camera main = Camera.main; if ((Object)(object)main != (Object)null) { Component componentInParent = ((Component)main).GetComponentInParent(_fpcType); if ((Object)(object)componentInParent != (Object)null) { Bind(componentInParent, "camera hierarchy"); return; } } Object[] array = Object.FindObjectsOfType(_fpcType); Object[] array2 = array; for (int i = 0; i < array2.Length; i++) { Component val = (Component)array2[i]; bool flag; try { flag = _isOwner != null && (bool)_isOwner.GetValue(val, null); } catch { flag = false; } if (flag) { Bind(val, "IsOwner"); return; } } if (array.Length == 1) { Bind((Component)array[0], "only controller in scene"); } else if (array.Length != 0 && !_warnedNoOwner) { _warnedNoOwner = true; Plugin.Log.LogWarning((object)$"Found {array.Length} controllers but could not identify the local player."); } } else if ((Object)(object)_player != (Object)null && !_loggedFirstCooldown) { CheckFirstCooldown(); } } private void Bind(Component player, string how) { _player = player; _playerHealth = ((_phType != null) ? player.GetComponent(_phType) : null); Plugin.Log.LogInfo((object)("Bound to local player via " + how + ": " + ((Object)player).name)); } private void CheckFirstCooldown() { float num = (float)_slideResetTimer.GetValue(_player); if (num > 0f) { _loggedFirstCooldown = true; Plugin.Log.LogInfo((object)$"Slide cooldown ticking: {num:0.00}s remaining of {(float)_slideResetTime.GetValue(_player):0.00}s."); } } private void OnGUI() { //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_023e: 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_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_02f0: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Unknown result type (might be due to invalid IL or missing references) //IL_0309: Unknown result type (might be due to invalid IL or missing references) //IL_031b: 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_0353: Unknown result type (might be due to invalid IL or missing references) //IL_035a: Unknown result type (might be due to invalid IL or missing references) //IL_0366: Expected O, but got Unknown //IL_03ef: 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_0470: Unknown result type (might be due to invalid IL or missing references) //IL_0458: Unknown result type (might be due to invalid IL or missing references) //IL_047a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_player == (Object)null || Cursor.visible) { return; } if ((Object)(object)_playerHealth != (Object)null && _healthProp != null) { try { if (Convert.ToSingle(_healthProp.GetValue(_playerHealth, null)) <= 0f) { _wasCooling = false; _readyAt = -1f; return; } } catch { } } float num = (float)_slideResetTimer.GetValue(_player); float num2 = Mathf.Max(0.01f, (float)_slideResetTime.GetValue(_player)); bool flag = num > 0f; if (flag) { _wasCooling = true; } else if (_wasCooling) { _wasCooling = false; _readyAt = Time.unscaledTime; } float num3 = ((!flag && _readyAt >= 0f) ? (1f - (Time.unscaledTime - _readyAt) / Mathf.Max(0.01f, Plugin.ReadyFlash.Value)) : 0f); bool flag2 = num3 > 0f; if (!flag && !flag2 && !Plugin.AlwaysShow.Value) { return; } float num4 = (float)Screen.height / 1080f; float num5 = Plugin.BarWidth.Value * num4; float num6 = Plugin.BarHeight.Value * num4; float num7 = ((float)Screen.width - num5) / 2f; float num8 = (float)Screen.height * Plugin.YFraction.Value; if (flag2) { for (int num9 = 3; num9 >= 1; num9--) { float num10 = (float)num9 * 3f * num4; GUI.DrawTexture(new Rect(num7 - num10, num8 - num10, num5 + num10 * 2f, num6 + num10 * 2f), (Texture)(object)_tex, (ScaleMode)0, true, 0f, new Color(0.3f, 1f, 0.45f, 0.1f * num3), 0f, (num6 + num10 * 2f) / 2f); } } GUI.DrawTexture(new Rect(num7, num8, num5, num6), (Texture)(object)_tex, (ScaleMode)0, true, 0f, new Color(0.07f, 0.07f, 0.08f, 0.38f), 0f, num6 / 2f); float num11 = 1.5f * num4; float num12 = num6 - num11 * 2f; float num13 = (num5 - num11 * 2f) * (flag ? Mathf.Clamp01(1f - num / num2) : 1f); Color val = (flag ? new Color(0.96f, 0.93f, 0.84f, 0.9f) : (flag2 ? new Color(0.3f, 1f, 0.45f, 0.5f + 0.5f * num3) : new Color(0.96f, 0.93f, 0.84f, 0.55f))); if (num13 > 0.5f) { GUI.DrawTexture(new Rect(num7 + num11, num8 + num11, num13, num12), (Texture)(object)_tex, (ScaleMode)0, true, 0f, val, 0f, Mathf.Min(num12, num13) / 2f); } if (Plugin.ShowLabel.Value) { if (_labelStyle == null) { _labelStyle = new GUIStyle { alignment = (TextAnchor)4, fontStyle = (FontStyle)0 }; } _labelStyle.fontSize = Mathf.RoundToInt(13f * num4); float num14 = (flag ? 0.85f : num3); if (num14 > 0.01f) { string text = (flag ? num.ToString("0.0") : "SLIDE"); Rect val2 = default(Rect); ((Rect)(ref val2))..ctor(num7, num8 - 20f * num4, num5, 18f * num4); _labelStyle.normal.textColor = new Color(0f, 0f, 0f, 0.5f * num14); GUI.Label(new Rect(((Rect)(ref val2)).x + 1f * num4, ((Rect)(ref val2)).y + 1f * num4, ((Rect)(ref val2)).width, ((Rect)(ref val2)).height), text, _labelStyle); _labelStyle.normal.textColor = (flag ? new Color(0.97f, 0.95f, 0.9f, num14) : new Color(0.5f, 1f, 0.6f, num14)); GUI.Label(val2, text, _labelStyle); } } } private void OnDisable() { Plugin.Log.LogWarning((object)"Overlay behaviour disabled."); } private void OnDestroy() { Plugin.Log.LogWarning((object)"Overlay behaviour destroyed."); } } }