using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using DG.Tweening;
using DG.Tweening.Core;
using DG.Tweening.Plugins.Options;
using HarmonyLib;
using MonoMod.RuntimeDetour;
using PeakStats.MonoBehaviours;
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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("PeakStats")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.2.2")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("PeakStats")]
[assembly: AssemblyTitle("PeakStats")]
[assembly: AssemblyVersion("0.2.2.0")]
namespace PeakStats
{
[BepInPlugin("nickklmao.peakstats", "PeakStats", "0.2.0")]
internal sealed class Entry : BaseUnityPlugin
{
private const string MOD_NAME = "PeakStats";
internal static readonly ManualLogSource logger = Logger.CreateLogSource("PeakStats");
internal static ConfigEntry<bool> displayTimer;
internal static ConfigEntry<bool> displayHeight;
internal static ConfigEntry<bool> displayTeammateStaminaBars;
internal static ConfigEntry<float> teammateStaminaBarProximity;
private static void GUIManagerStartHook(Action<GUIManager> orig, GUIManager self)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
orig(self);
Scene activeScene = SceneManager.GetActiveScene();
if (!(((Scene)(ref activeScene)).name == "Airport"))
{
CreateTimerAndHeightStats();
}
FixBarGroup();
void CreateTimerAndHeightStats()
{
//IL_001b: 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_002b: 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_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_0044: 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_005d: 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_0064: 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)
Transform transform = ((Component)((Component)self).GetComponentInChildren<AscentUI>()).transform;
RectTransform val2 = (RectTransform)Object.Instantiate<Transform>(transform, transform.parent);
((Object)val2).name = "Timer & Height UI";
Object.Destroy((Object)(object)((Component)val2).GetComponent<AscentUI>());
((Component)val2).gameObject.AddComponent<TimerHeightStats>();
Vector2 val3 = default(Vector2);
((Vector2)(ref val3))..ctor(0.5f, 1f);
val2.anchorMin = val3;
Vector2 pivot = (val2.anchorMax = val3);
val2.pivot = pivot;
val2.anchoredPosition = Vector2.zero;
}
void FixBarGroup()
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: 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_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: 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_0036: 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)
RectTransform val = (RectTransform)((Component)self.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;
}
}
private static void PlayerHandlerRegisterCharacterHook(Action<Character> orig, Character character)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
orig(character);
if (((MonoBehaviourPun)character).photonView.IsMine)
{
Scene activeScene = SceneManager.GetActiveScene();
if (!(((Scene)(ref activeScene)).name == "Airport"))
{
((Component)character).gameObject.AddComponent<ProximityStaminaManager>();
}
}
}
private void Awake()
{
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Expected O, but got Unknown
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_0105: Unknown result type (might be due to invalid IL or missing references)
logger.LogInfo((object)"Creating config entries");
displayTimer = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Display Timer", true, "Displays how long you've been climbing for, at the top of your screen");
displayHeight = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Display Height", true, "Displays how far you've climbed, in meters, at the top of your screen");
displayTeammateStaminaBars = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Display Teammate Stamina Bars", true, "Displays your teammates' stamina bars at the bottom left of your screen");
teammateStaminaBarProximity = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Teammate Stamina Bar Proximity", 10f, new ConfigDescription("How close you need to be to your teammate to see their stamina bar", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 10000f), Array.Empty<object>()));
logger.LogMessage((object)"Hooking GUIManager.Start");
new Hook((MethodBase)AccessTools.Method(typeof(GUIManager), "Start", (Type[])null, (Type[])null), (Delegate)new Action<Action<GUIManager>, GUIManager>(GUIManagerStartHook));
new Hook((MethodBase)AccessTools.Method(typeof(PlayerHandler), "RegisterCharacter", (Type[])null, (Type[])null), (Delegate)new Action<Action<Character>, Character>(PlayerHandlerRegisterCharacterHook));
}
}
}
namespace PeakStats.MonoBehaviours
{
internal sealed 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_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: 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)
RectTransform obj = rectTransform;
Vector2 sizeDelta = rectTransform.sizeDelta;
sizeDelta.x = Mathf.Lerp(rectTransform.sizeDelta.x, size, Mathf.Min(Time.deltaTime * 10f, 0.1f));
obj.sizeDelta = sizeDelta;
}
}
internal sealed class CharacterStaminaBar : MonoBehaviour
{
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_00be: 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_0121: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: Unknown result type (might be due to invalid IL or missing references)
//IL_0141: Unknown result type (might be due to invalid IL or missing references)
//IL_014e: 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_0187: Unknown result type (might be due to invalid IL or missing references)
//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
//IL_01eb: 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_01fa: Unknown result type (might be due to invalid IL or missing references)
//IL_0211: Unknown result type (might be due to invalid IL or missing references)
//IL_023b: Unknown result type (might be due to invalid IL or missing references)
//IL_0240: Unknown result type (might be due to invalid IL or missing references)
//IL_025d: 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_02ba: 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 obj = staminaBarRectTransform;
Vector2 sizeDelta = staminaBarRectTransform.sizeDelta;
sizeDelta.x = Mathf.Lerp(staminaBarRectTransform.sizeDelta.x, num, num2);
obj.sizeDelta = sizeDelta;
float num3 = Mathf.Clamp01((staminaBarRectTransform.sizeDelta.x - num) * 0.5f);
sinTime += num2 * num3;
Image obj2 = glowImage;
Color color = ((Graphic)glowImage).color;
color.a = num3 * 0.4f - Mathf.Abs(Mathf.Sin(sinTime)) * 0.2f;
((Graphic)obj2).color = color;
float x = fullBarRectTransform.sizeDelta.x;
float num4 = Mathf.Max(0f, observedCharacter.GetMaxStamina() * x);
RectTransform obj3 = maxStaminaBarRectTransform;
sizeDelta = maxStaminaBarRectTransform.sizeDelta;
sizeDelta.x = Mathf.Lerp(maxStaminaBarRectTransform.sizeDelta.x, num4, num2);
obj3.sizeDelta = sizeDelta;
float statusSum = observedCharacter.refs.afflictions.statusSum;
RectTransform obj4 = staminaBarOutlineRectTransform;
sizeDelta = staminaBarOutlineRectTransform.sizeDelta;
sizeDelta.x = 14f + Mathf.Max(1f, statusSum) * x;
obj4.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);
}
private IEnumerator EnableIEnumerator()
{
((Component)this).transform.localScale = Vector3.zero;
TweenSettingsExtensions.SetEase<TweenerCore<Vector3, Vector3, VectorOptions>>(ShortcutExtensions.DOScale(((Component)this).transform, 0.72f, 0.5f), (Ease)24);
yield return (object)new WaitForSeconds(0.5f);
animateEnableDisableCoroutine = null;
}
private IEnumerator DisableIEnumerator()
{
((Component)this).transform.localScale = Vector3.one * 0.72f;
TweenSettingsExtensions.SetEase<TweenerCore<Vector3, Vector3, VectorOptions>>(ShortcutExtensions.DOScale(((Component)this).transform, 0f, 0.5f), (Ease)17);
yield return (object)new WaitForSeconds(0.5f);
((Component)this).gameObject.SetActive(false);
animateEnableDisableCoroutine = null;
}
}
internal sealed class ProximityStaminaManager : MonoBehaviour
{
private readonly Dictionary<Character, CharacterStaminaBar> staminaBars = new Dictionary<Character, CharacterStaminaBar>();
private bool disabledStaminaBars;
private static CharacterStaminaBar CreateStaminaBar(Character observedCharacter)
{
//IL_0036: 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_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: 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_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: 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_0109: Expected O, but got Unknown
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_011f: Expected O, but got Unknown
//IL_012b: Unknown result type (might be due to invalid IL or missing references)
//IL_0135: Expected O, but got Unknown
//IL_0141: Unknown result type (might be due to invalid IL or missing references)
//IL_014b: Expected O, but got Unknown
//IL_017c: Unknown result type (might be due to invalid IL or missing references)
//IL_0186: Expected O, but got Unknown
//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
//IL_01ca: 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();
RectTransform val2 = (RectTransform)Object.Instantiate<Transform>(((Component)((Component)GUIManager.instance).GetComponentInChildren<AscentUI>()).transform, val);
((Object)val2).name = "Character Name";
Vector2 val3 = default(Vector2);
((Vector2)(ref val3))..ctor(0f, 1f);
val2.anchorMin = val3;
val2.anchorMax = val3;
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 val4 in componentsInChildren)
{
CharacterBarAffliction characterBarAffliction = ((Component)val4).gameObject.AddComponent<CharacterBarAffliction>();
characterBarAffliction.afflictionType = val4.afflictionType;
characterBarAffliction.FetchReferences();
Object.Destroy((Object)(object)val4);
}
return characterStaminaBar;
}
private void Update()
{
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
if (!Object.op_Implicit((Object)(object)Character.localCharacter) || !Entry.displayTeammateStaminaBars.Value || Object.op_Implicit((Object)(object)MainCameraMovement.specCharacter))
{
if (disabledStaminaBars)
{
return;
}
foreach (KeyValuePair<Character, CharacterStaminaBar> staminaBar in staminaBars)
{
staminaBar.Value.AnimateDisable();
}
disabledStaminaBars = true;
return;
}
foreach (Character allCharacter in Character.AllCharacters)
{
if (((Behaviour)allCharacter).isActiveAndEnabled && !allCharacter.IsLocal)
{
if (!staminaBars.TryGetValue(allCharacter, out var value))
{
staminaBars.TryAdd(allCharacter, CreateStaminaBar(allCharacter));
}
else if (Vector3.Distance(Character.localCharacter.Center, allCharacter.Center) < Entry.teammateStaminaBarProximity.Value)
{
value.AnimateEnable();
}
else
{
value.AnimateDisable();
}
}
}
disabledStaminaBars = false;
}
}
internal sealed class TimerHeightStats : MonoBehaviour
{
private TMP_Text tmpText;
private static string GetTimeString(float totalSeconds)
{
int num = Mathf.FloorToInt(totalSeconds);
int num2 = num / 3600;
int num3 = num % 3600 / 60;
int num4 = num % 60;
return $"{num2}:{num3:00}:{num4:00}";
}
private void Start()
{
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
tmpText = ((Component)this).GetComponent<TMP_Text>();
tmpText.autoSizeTextContainer = true;
tmpText.textWrappingMode = (TextWrappingModes)0;
tmpText.alignment = (TextAlignmentOptions)258;
tmpText.lineSpacing = -40f;
tmpText.fontSize = 28f;
tmpText.outlineColor = new Color32((byte)0, (byte)0, (byte)0, byte.MaxValue);
tmpText.outlineWidth = 0.055f;
}
private void Update()
{
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
Character localCharacter = Character.localCharacter;
if (Object.op_Implicit((Object)(object)tmpText) && Object.op_Implicit((Object)(object)localCharacter))
{
CharacterStats stats = localCharacter.refs.stats;
string text = string.Empty;
if (Entry.displayTimer.Value)
{
text = text + GetTimeString(Time.time - stats.GetFirstTimelineInfo().time) + "\n";
}
if (Entry.displayHeight.Value)
{
text += $"{stats.heightInMeters}m";
}
tmpText.text = text;
}
}
}
}