Decompiled source of Scoreboard v1.0.0
BepInEx/plugins/Scoreboard/PeakScoreboard.dll
Decompiled 6 days ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using ExitGames.Client.Photon; using HarmonyLib; using Microsoft.CodeAnalysis; using PeakScoreboard.Ui; using Photon.Pun; using Photon.Realtime; using TMPro; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.SceneManagement; using UnityEngine.UI; using Zorro.Core; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("Zorro.Core.Runtime")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("PeakScoreboard")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("PeakScoreboard")] [assembly: AssemblyTitle("PeakScoreboard")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [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 PeakScoreboard { public static class PeakUi { public static readonly Color Panel = Color32.op_Implicit(new Color32((byte)22, (byte)18, (byte)14, (byte)242)); public static readonly Color PanelSoft = Color32.op_Implicit(new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)14)); public static readonly Color Ink = Color32.op_Implicit(new Color32((byte)233, (byte)224, (byte)205, byte.MaxValue)); public static readonly Color InkDim = Color32.op_Implicit(new Color32((byte)233, (byte)224, (byte)205, (byte)140)); public static readonly Color Accent = Color32.op_Implicit(new Color32(byte.MaxValue, (byte)196, (byte)92, byte.MaxValue)); public static readonly Color Danger = Color32.op_Implicit(new Color32((byte)232, (byte)96, (byte)72, byte.MaxValue)); private static TMP_FontAsset _cached; private static Sprite _circle; private static Sprite _capsule; public static TMP_FontAsset GameFont() { if ((Object)(object)_cached != (Object)null) { return _cached; } GUIManager instance = GUIManager.instance; if ((Object)(object)instance != (Object)null) { if ((Object)(object)instance.interactPromptText != (Object)null && (Object)(object)((TMP_Text)instance.interactPromptText).font != (Object)null) { _cached = ((TMP_Text)instance.interactPromptText).font; } else if ((Object)(object)instance.heroText != (Object)null && (Object)(object)((TMP_Text)instance.heroText).font != (Object)null) { _cached = ((TMP_Text)instance.heroText).font; } } if ((Object)(object)_cached == (Object)null) { TextMeshProUGUI val = Object.FindAnyObjectByType<TextMeshProUGUI>(); _cached = (((Object)(object)val != (Object)null && (Object)(object)((TMP_Text)val).font != (Object)null) ? ((TMP_Text)val).font : TMP_Settings.defaultFontAsset); } return _cached; } public static void DropFontCache() { _cached = null; } public static Sprite Circle() { if ((Object)(object)_circle == (Object)null) { _circle = BuildCircle(out _capsule); } return _circle; } public static Sprite Capsule() { if ((Object)(object)_capsule == (Object)null) { _circle = BuildCircle(out _capsule); } return _capsule; } private static Sprite BuildCircle(out Sprite capsule) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_00fa: 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_0117: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(64, 64, (TextureFormat)4, false) { filterMode = (FilterMode)1, wrapMode = (TextureWrapMode)1, hideFlags = (HideFlags)61 }; Color32[] array = (Color32[])(object)new Color32[4096]; for (int i = 0; i < 64; i++) { for (int j = 0; j < 64; j++) { float num = (float)j + 0.5f - 32f; float num2 = (float)i + 0.5f - 32f; float num3 = Mathf.Sqrt(num * num + num2 * num2); float num4 = Mathf.Clamp01(32f - num3); array[i * 64 + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)(num4 * 255f)); } } val.SetPixels32(array); val.Apply(false); Rect val2 = default(Rect); ((Rect)(ref val2))..ctor(0f, 0f, 64f, 64f); Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(0.5f, 0.5f); capsule = Sprite.Create(val, val2, val3, 100f, 0u, (SpriteMeshType)0, new Vector4(32f, 32f, 32f, 32f)); ((Object)capsule).hideFlags = (HideFlags)61; Sprite obj = Sprite.Create(val, val2, val3, 100f, 0u, (SpriteMeshType)0); ((Object)obj).hideFlags = (HideFlags)61; return obj; } public static Image MakeCircle(Transform parent, string name, Color color) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) Image obj = MakeImage(parent, name, color); obj.sprite = Circle(); obj.type = (Type)0; return obj; } public static Image MakeCapsule(Transform parent, string name, Color color, float thickness) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) Image obj = MakeImage(parent, name, color); obj.sprite = Capsule(); obj.type = (Type)1; obj.pixelsPerUnitMultiplier = Mathf.Max(1f, 64f / Mathf.Max(thickness, 1f)); return obj; } public static GameObject MakeCanvas(string name, int sortingOrder, bool interactive) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0040: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name); ((Object)val).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)val); Canvas obj = val.AddComponent<Canvas>(); obj.renderMode = (RenderMode)0; obj.sortingOrder = sortingOrder; CanvasScaler obj2 = val.AddComponent<CanvasScaler>(); obj2.uiScaleMode = (ScaleMode)1; obj2.referenceResolution = new Vector2(1920f, 1080f); obj2.matchWidthOrHeight = 0.5f; if (interactive) { val.AddComponent<GraphicRaycaster>(); } return val; } public static TextMeshProUGUI MakeLabel(Transform parent, string name, float size, TextAlignmentOptions align, Color color) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0057: 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) GameObject val = new GameObject(name, new Type[2] { typeof(RectTransform), typeof(TextMeshProUGUI) }); val.transform.SetParent(parent, false); TextMeshProUGUI component = val.GetComponent<TextMeshProUGUI>(); TMP_FontAsset val2 = GameFont(); if ((Object)(object)val2 != (Object)null) { ((TMP_Text)component).font = val2; } ((TMP_Text)component).fontSize = size; ((TMP_Text)component).alignment = align; ((Graphic)component).color = color; ((Graphic)component).raycastTarget = false; ((TMP_Text)component).textWrappingMode = (TextWrappingModes)1; return component; } public static Image MakeImage(Transform parent, string name, Color color) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: 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) GameObject val = new GameObject(name, new Type[2] { typeof(RectTransform), typeof(Image) }); val.transform.SetParent(parent, false); Image component = val.GetComponent<Image>(); ((Graphic)component).color = color; return component; } public static void PlaceFromTop(RectTransform rt, float top, float height, float sideMargin) { //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_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0058: 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_007b: Unknown result type (might be due to invalid IL or missing references) rt.anchorMin = new Vector2(0f, 1f); rt.anchorMax = new Vector2(1f, 1f); rt.pivot = new Vector2(0.5f, 1f); rt.offsetMin = new Vector2(sideMargin, 0f); rt.offsetMax = new Vector2(0f - sideMargin, 0f); rt.anchoredPosition = new Vector2(0f, 0f - top); rt.sizeDelta = new Vector2(0f, height); } public static void Stretch(RectTransform rt, float padX = 0f, float padY = 0f) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: 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) //IL_0028: Unknown result type (might be due to invalid IL or missing references) rt.anchorMin = Vector2.zero; rt.anchorMax = Vector2.one; rt.offsetMin = new Vector2(padX, padY); rt.offsetMax = new Vector2(0f - padX, 0f - padY); } } [BepInPlugin("com.bananegame.peakscoreboard", "Scoreboard", "1.0.0")] public class Plugin : BaseUnityPlugin { public const string Guid = "com.bananegame.peakscoreboard"; public const string FeedbackUrl = "https://github.com/xBananegame/PEAKModes/issues"; private Harmony _harmony; private GameObject _hudRoot; public static Plugin Instance { get; private set; } public static ManualLogSource Log { get; private set; } public static Cfg Cfg { get; private set; } private void Awake() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown Instance = this; Log = ((BaseUnityPlugin)this).Logger; Cfg = new Cfg(((BaseUnityPlugin)this).Config); _harmony = new Harmony("com.bananegame.peakscoreboard"); _harmony.PatchAll(); StatTracker.Install(); ScoreboardNet.Install(); SceneManager.sceneLoaded += OnSceneLoaded; Log.LogInfo((object)"Scoreboard bereit. Fehler und Wuensche bitte hier melden: https://github.com/xBananegame/PEAKModes/issues"); } private void OnDestroy() { SceneManager.sceneLoaded -= OnSceneLoaded; ScoreboardNet.Uninstall(); StatTracker.Uninstall(); if ((Object)(object)_hudRoot != (Object)null) { Object.Destroy((Object)(object)_hudRoot); } Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { PeakUi.DropFontCache(); AfflictionStyle.Reset(); StatTracker.OnSceneChanged(((Scene)(ref scene)).name); if ((Object)(object)_hudRoot != (Object)null) { Object.Destroy((Object)(object)_hudRoot); } _hudRoot = null; if (IsGameplayScene(((Scene)(ref scene)).name)) { ((MonoBehaviour)this).StartCoroutine(BuildHudWhenReady()); } } private static bool IsGameplayScene(string sceneName) { if (string.IsNullOrEmpty(sceneName)) { return false; } if (!sceneName.Contains("Island")) { return sceneName.Contains("Level_"); } return true; } private IEnumerator BuildHudWhenReady() { float waited = 0f; while ((Object)(object)GUIManager.instance == (Object)null && waited < 30f) { waited += Time.deltaTime; yield return null; } if ((Object)(object)GUIManager.instance == (Object)null) { Log.LogWarning((object)"Kein GUIManager gefunden - das HUD bleibt aus."); yield break; } _hudRoot = new GameObject("PeakScoreboard.Hud"); Object.DontDestroyOnLoad((Object)(object)_hudRoot); _hudRoot.AddComponent<ScoreboardHud>(); _hudRoot.AddComponent<LeaderboardHud>(); _hudRoot.AddComponent<AltitudeBar>(); } private void Update() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) Keyboard current = Keyboard.current; if (current != null && (int)Cfg.HudToggleKey.Value != 0 && ((ButtonControl)current[Cfg.HudToggleKey.Value]).wasPressedThisFrame) { Cfg.HudVisible = !Cfg.HudVisible; } } } public enum StaminaBarStyle { Drawn, GameClone } public class Cfg { public readonly ConfigEntry<Key> ScoreboardKey; public readonly ConfigEntry<bool> ScoreboardIsToggle; public readonly ConfigEntry<Key> HudToggleKey; public readonly ConfigEntry<bool> ShowLeaderboard; public readonly ConfigEntry<bool> ShowAltitudeBar; public readonly ConfigEntry<bool> ShowFedColumn; public readonly ConfigEntry<bool> ShowStaminaPercent; public readonly ConfigEntry<bool> ShowBiomeLabels; public readonly ConfigEntry<bool> ShowAltitudeText; public readonly ConfigEntry<StaminaBarStyle> StaminaBar; public readonly ConfigEntry<float> LeaderboardMarginRight; public readonly ConfigEntry<float> LeaderboardMarginTop; public readonly ConfigEntry<float> ExtraBarOffsetY; public readonly ConfigEntry<bool> DebugStaminaBar; public readonly ConfigEntry<float> AltitudeBarMarginRight; public readonly ConfigEntry<float> UiScale; public readonly ConfigEntry<float> HudOpacity; public readonly ConfigEntry<string> Feedback; public bool HudVisible = true; public Cfg(ConfigFile file) { //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Expected O, but got Unknown //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Expected O, but got Unknown //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Expected O, but got Unknown //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Expected O, but got Unknown //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Expected O, but got Unknown //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Expected O, but got Unknown ScoreboardKey = file.Bind<Key>("Controls", "ScoreboardKey", (Key)3, "Key that opens the full scoreboard."); ScoreboardIsToggle = file.Bind<bool>("Controls", "ScoreboardIsToggle", false, "Off: the scoreboard shows while the key is held. On: the key toggles it."); HudToggleKey = file.Bind<Key>("Controls", "HudToggleKey", (Key)100, "Key that hides or shows the always-on leaderboard and altitude bar. Set to None to disable."); ShowLeaderboard = file.Bind<bool>("HUD", "ShowLeaderboard", true, "Show the compact height leaderboard in the top right corner."); ShowAltitudeBar = file.Bind<bool>("HUD", "ShowAltitudeBar", true, "Show the vertical altitude bar with biome bands on the right edge."); ShowFedColumn = file.Bind<bool>("Scoreboard", "ShowFedColumn", false, "Add a FED column that counts items handed to other players."); ShowStaminaPercent = file.Bind<bool>("Scoreboard", "ShowStaminaPercent", true, "Print the stamina value as a percentage next to each bar."); StaminaBar = file.Bind<StaminaBarStyle>("Scoreboard", "StaminaBarStyle", StaminaBarStyle.Drawn, "Drawn: a rounded bar drawn by the mod, matching the game's look. GameClone: clone the game's own bar - closer in detail, but it can bring along HUD parts that do not belong in a table row."); ExtraBarOffsetY = file.Bind<float>("Scoreboard", "ExtraBarOffsetY", 0f, new ConfigDescription("Shifts the bonus stamina bar up or down. 0 keeps it where the game puts it, which is already below the main bar.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-120f, 60f), Array.Empty<object>())); DebugStaminaBar = file.Bind<bool>("Scoreboard", "DebugStaminaBar", false, "Write the layout of the cloned stamina bar to the BepInEx log. Only needed when something looks wrong in a row."); ShowBiomeLabels = file.Bind<bool>("HUD", "ShowBiomeLabels", false, "Write the biome name next to each band of the altitude bar."); ShowAltitudeText = file.Bind<bool>("HUD", "ShowAltitudeText", true, "Write your own height in metres below the altitude bar."); AltitudeBarMarginRight = file.Bind<float>("HUD", "AltitudeBarMarginRight", 12f, new ConfigDescription("Distance from the right screen edge to the altitude bar.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 400f), Array.Empty<object>())); LeaderboardMarginRight = file.Bind<float>("HUD", "LeaderboardMarginRight", 56f, new ConfigDescription("Distance from the right screen edge to the leaderboard.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 600f), Array.Empty<object>())); LeaderboardMarginTop = file.Bind<float>("HUD", "LeaderboardMarginTop", 22f, new ConfigDescription("Distance from the top screen edge to the leaderboard.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 600f), Array.Empty<object>())); UiScale = file.Bind<float>("HUD", "UiScale", 1f, new ConfigDescription("Overall size of every element this mod draws.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.6f, 1.8f), Array.Empty<object>())); HudOpacity = file.Bind<float>("HUD", "HudOpacity", 0.85f, new ConfigDescription("Opacity of the always-on leaderboard and altitude bar.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.2f, 1f), Array.Empty<object>())); Feedback = file.Bind<string>("About", "Feedback", "https://github.com/xBananegame/PEAKModes/issues", "Found a bug or have an idea? Open an issue here. Please attach BepInEx/LogOutput.log when reporting a bug. Changing this value does nothing."); } } public static class ScoreboardNet { private class Listener : MonoBehaviour, IOnEventCallback, IInRoomCallbacks { private bool _registered; private void Update() { if (!_registered) { try { if (PhotonNetwork.NetworkingClient != null) { PhotonNetwork.AddCallbackTarget((object)this); _registered = true; Plugin.Log.LogInfo((object)"Photon-Callbacks registriert."); } return; } catch (Exception ex) { Plugin.Log.LogDebug((object)("Photon noch nicht bereit: " + ex.Message)); return; } } _sinceHeartbeat += Time.deltaTime; if (!(_sinceHeartbeat < 10f)) { _sinceHeartbeat = 0f; Heartbeat(); } } private void OnDestroy() { if (!_registered) { return; } try { PhotonNetwork.RemoveCallbackTarget((object)this); } catch { } } public void OnEvent(EventData photonEvent) { if (photonEvent.Code == 160) { Apply(photonEvent.CustomData); } else if (photonEvent.Code == 161) { ApplyAssist(photonEvent.CustomData); } } public void OnPlayerEnteredRoom(Player newPlayer) { _sinceHeartbeat = 10f; } public void OnPlayerLeftRoom(Player otherPlayer) { StatBook.DropAbsentPlayers(); } public void OnRoomPropertiesUpdate(Hashtable propertiesThatChanged) { } public void OnPlayerPropertiesUpdate(Player targetPlayer, Hashtable changedProps) { } public void OnMasterClientSwitched(Player newMasterClient) { } } public const byte EvtCounters = 160; public const byte EvtAssist = 161; private const float HeartbeatSeconds = 10f; private const float ResetGuardSeconds = 4f; private static Listener _listener; private static float _sinceHeartbeat; public static void Install() { //IL_0013: 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) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown if (!((Object)(object)_listener != (Object)null)) { GameObject val = new GameObject("PeakScoreboard.Net") { hideFlags = (HideFlags)61 }; Object.DontDestroyOnLoad((Object)val); _listener = val.AddComponent<Listener>(); } } public static void Uninstall() { if ((Object)(object)_listener != (Object)null) { Object.Destroy((Object)(object)((Component)_listener).gameObject); } _listener = null; } public static void BroadcastCounters(PlayerStats stats) { //IL_0044: 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_004b: 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_005a: Expected O, but got Unknown if (stats != null && PhotonNetwork.InRoom) { PhotonNetwork.RaiseEvent((byte)160, (object)new object[3] { PhotonNetwork.LocalPlayer.ActorNumber, stats.Used, stats.Fed }, new RaiseEventOptions { Receivers = (ReceiverGroup)0 }, SendOptions.SendReliable); } } public static void BroadcastAssist(int helperActor, float seconds) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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_003b: Expected O, but got Unknown if (PhotonNetwork.InRoom) { PhotonNetwork.RaiseEvent((byte)161, (object)new object[2] { helperActor, seconds }, new RaiseEventOptions { Receivers = (ReceiverGroup)0 }, SendOptions.SendReliable); } } private static void ApplyAssist(object content) { if (content is object[] array && array.Length >= 2 && !(Time.realtimeSinceStartup - StatBook.LastResetTime < 4f)) { StatTracker.ApplyAssist((int)array[0], (float)array[1]); } } private static void Heartbeat() { Character localCharacter = Character.localCharacter; if (!((Object)(object)localCharacter == (Object)null)) { PlayerStats playerStats = StatBook.For(localCharacter); if (playerStats != null) { BroadcastCounters(playerStats); } } } private static void Apply(object content) { if (content is object[] array && array.Length >= 3 && !(Time.realtimeSinceStartup - StatBook.LastResetTime < 4f)) { PlayerStats playerStats = StatBook.For((int)array[0]); if (playerStats != null) { playerStats.Used = (int)array[1]; playerStats.Fed = (int)array[2]; } } } } public class PlayerStats { public int Actor; public string Name = ""; public int Eaten; public int Received; public int Used; public int Fed; public int Deaths; public int Assists; public float AssistSeconds; public void Clear() { Eaten = (Received = (Used = (Fed = (Deaths = (Assists = 0))))); AssistSeconds = 0f; } } public static class StatBook { private static readonly Dictionary<int, PlayerStats> _byActor = new Dictionary<int, PlayerStats>(); public static IEnumerable<PlayerStats> All => _byActor.Values; public static float LastResetTime { get; private set; } = float.NegativeInfinity; public static PlayerStats For(int actor) { if (actor <= 0) { return null; } if (!_byActor.TryGetValue(actor, out var value)) { value = new PlayerStats { Actor = actor }; _byActor[actor] = value; } return value; } public static PlayerStats For(Character character) { int num = ActorOf(character); if (num <= 0) { return null; } PlayerStats playerStats = For(num); if (playerStats != null && string.IsNullOrEmpty(playerStats.Name)) { playerStats.Name = NameOf(character); } return playerStats; } public static int ActorOf(Character character) { if ((Object)(object)character == (Object)null || character.isBot) { return 0; } PhotonView photonView = ((MonoBehaviourPun)character).photonView; if ((Object)(object)photonView == (Object)null || photonView.Owner == null) { return 0; } return photonView.Owner.ActorNumber; } public static string NameOf(Character character) { if ((Object)(object)character == (Object)null) { return "?"; } if (!string.IsNullOrWhiteSpace(character.characterName)) { return character.characterName; } PhotonView photonView = ((MonoBehaviourPun)character).photonView; if ((Object)(object)photonView != (Object)null && photonView.Owner != null && !string.IsNullOrWhiteSpace(photonView.Owner.NickName)) { return photonView.Owner.NickName; } return "Scout"; } public static Character CharacterOf(int actor) { List<Character> allCharacters = Character.AllCharacters; for (int i = 0; i < allCharacters.Count; i++) { if ((Object)(object)allCharacters[i] != (Object)null && ActorOf(allCharacters[i]) == actor) { return allCharacters[i]; } } return null; } public static void ResetCounters() { foreach (PlayerStats value in _byActor.Values) { value.Clear(); } LastResetTime = Time.realtimeSinceStartup; Plugin.Log.LogInfo((object)"Statistiken fuer die neue Runde zurueckgesetzt."); } public static void Clear() { _byActor.Clear(); } public static void DropAbsentPlayers() { if (!PhotonNetwork.InRoom) { return; } List<int> list = null; foreach (int key in _byActor.Keys) { if (!PhotonNetwork.CurrentRoom.Players.ContainsKey(key)) { if (list == null) { list = new List<int>(); } list.Add(key); } } if (list == null) { return; } foreach (int item in list) { _byActor.Remove(item); } } } public static class StatTracker { private struct FeedRecord { public ushort ItemId; public float Time; } private struct HelpSession { public float Seconds; public float LastSeen; } private class TrackerBehaviour : MonoBehaviour { private float _sinceCheck; private float _sinceNames; private void Update() { if (Character.localCharacterExists) { _sinceCheck += Time.deltaTime; if (_sinceCheck >= 0.1f) { _sinceCheck = 0f; UpdateHelping(); } _sinceNames += Time.deltaTime; if (_sinceNames >= 2f) { _sinceNames = 0f; RefreshNames(); StatBook.DropAbsentPlayers(); } } } } private const float MinHelpSeconds = 0.5f; private const float ReachRange = 4f; private const float ReachAngle = 60f; private const float HelpCheckInterval = 0.1f; private static GameObject _host; private static bool _subscribed; private static readonly Dictionary<long, HelpSession> _running = new Dictionary<long, HelpSession>(); private static readonly List<long> _finished = new List<long>(); private static readonly Dictionary<ushort, bool> _foodCache = new Dictionary<ushort, bool>(); private static readonly Dictionary<int, FeedRecord> _feeds = new Dictionary<int, FeedRecord>(); private const float FeedWindowSeconds = 12f; public static void Install() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown if (!((Object)(object)_host != (Object)null)) { _host = new GameObject("PeakScoreboard.Tracker"); Object.DontDestroyOnLoad((Object)(object)_host); ((Object)_host).hideFlags = (HideFlags)61; _host.AddComponent<TrackerBehaviour>(); Subscribe(); } } public static void Uninstall() { Unsubscribe(); if ((Object)(object)_host != (Object)null) { Object.Destroy((Object)(object)_host); } _host = null; StatBook.Clear(); } public static void Subscribe() { if (!_subscribed) { GlobalEvents.OnCharacterDied = (Action<Character>)Delegate.Combine(GlobalEvents.OnCharacterDied, new Action<Character>(OnCharacterDied)); GlobalEvents.OnPlayerDisconnected = (Action<Player>)Delegate.Combine(GlobalEvents.OnPlayerDisconnected, new Action<Player>(OnPlayerDisconnected)); _subscribed = true; } } public static void Unsubscribe() { if (_subscribed) { GlobalEvents.OnCharacterDied = (Action<Character>)Delegate.Remove(GlobalEvents.OnCharacterDied, new Action<Character>(OnCharacterDied)); GlobalEvents.OnPlayerDisconnected = (Action<Player>)Delegate.Remove(GlobalEvents.OnPlayerDisconnected, new Action<Player>(OnPlayerDisconnected)); _subscribed = false; } } public static void Resubscribe() { _subscribed = false; Subscribe(); } public static void OnSceneChanged(string sceneName) { _running.Clear(); _foodCache.Clear(); _feeds.Clear(); if (sceneName != null && (sceneName.Contains("Level_") || sceneName.Contains("Island"))) { StatBook.ResetCounters(); } } private static void OnCharacterDied(Character character) { PlayerStats playerStats = StatBook.For(character); if (playerStats != null) { playerStats.Deaths++; } } private static void OnPlayerDisconnected(Player player) { StatBook.DropAbsentPlayers(); } public static void NoteFeedStarted(int receiverViewId, ushort itemId) { if (receiverViewId != 0) { _feeds[receiverViewId] = new FeedRecord { ItemId = itemId, Time = Time.time }; } } private static bool WasFed(Character consumer, Item item) { PhotonView photonView = ((MonoBehaviourPun)consumer).photonView; if ((Object)(object)photonView == (Object)null) { return false; } if (_feeds.TryGetValue(photonView.ViewID, out var value)) { bool flag = Time.time - value.Time <= 12f; if (flag && value.ItemId == item.itemID) { _feeds.Remove(photonView.ViewID); return true; } if (!flag) { _feeds.Remove(photonView.ViewID); } } Character val = default(Character); if (item.TryGetFeeder(ref val) && (Object)(object)val != (Object)null) { return (Object)(object)val != (Object)(object)consumer; } return false; } public static void NoteConsumed(Item item, Character consumer) { if ((Object)(object)item == (Object)null || (Object)(object)consumer == (Object)null) { return; } PlayerStats playerStats = StatBook.For(consumer); if (playerStats != null) { if (WasFed(consumer, item)) { playerStats.Received++; } else if (IsFood(item)) { playerStats.Eaten++; } } } public static void NoteLocalUse(Character user) { PlayerStats playerStats = StatBook.For(user); if (playerStats != null) { playerStats.Used++; ScoreboardNet.BroadcastCounters(playerStats); } } public static void NoteLocalFeed(Character feeder) { PlayerStats playerStats = StatBook.For(feeder); if (playerStats != null) { playerStats.Used++; playerStats.Fed++; ScoreboardNet.BroadcastCounters(playerStats); } } public static bool IsFood(Item item) { //IL_0022: 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)item == (Object)null) { return false; } if (_foodCache.TryGetValue(item.itemID, out var value)) { return value; } bool flag = (item.itemTags & 0xE) != 0 || (Object)(object)((Component)item).GetComponent<Action_RestoreHunger>() != (Object)null; _foodCache[item.itemID] = flag; return flag; } internal static void UpdateHelping() { Character localCharacter = Character.localCharacter; if ((Object)(object)localCharacter == (Object)null || localCharacter.data.dead) { return; } List<Character> allCharacters = Character.AllCharacters; float time = Time.time; for (int i = 0; i < allCharacters.Count; i++) { Character val = allCharacters[i]; if (!((Object)(object)val == (Object)null) && !((Object)(object)val == (Object)(object)localCharacter) && val.data.isReaching && !val.data.dead) { int num = StatBook.ActorOf(val); if (num > 0 && IsBeingHelped(val, localCharacter)) { _running.TryGetValue(num, out var value); value.Seconds += ((value.LastSeen > 0f) ? Mathf.Min(time - value.LastSeen, 0.3f) : 0f); value.LastSeen = time; _running[num] = value; } } } CloseStaleSessions(time); } private static bool IsBeingHelped(Character helper, Character target) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //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) //IL_002a: 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) Vector3 center = helper.Center; Vector3 center2 = target.Center; if (Vector3.Distance(center, center2) > 4f) { return false; } if (Vector3.Angle(helper.data.lookDirection, center2 - center) > 60f) { return false; } return CharacterGrabbing.TargetCanBeHelped(target, helper); } private static void CloseStaleSessions(float now) { _finished.Clear(); foreach (KeyValuePair<long, HelpSession> item in _running) { if (!(now - item.Value.LastSeen <= 0.3f)) { _finished.Add(item.Key); } } foreach (long item2 in _finished) { HelpSession helpSession = _running[item2]; _running.Remove(item2); if (!(helpSession.Seconds < 0.5f)) { int helperActor = (int)item2; ApplyAssist(helperActor, helpSession.Seconds); ScoreboardNet.BroadcastAssist(helperActor, helpSession.Seconds); } } } public static void NoteLocalThornPull(Character helper, float seconds) { int num = StatBook.ActorOf(helper); if (num > 0) { ApplyAssist(num, seconds); ScoreboardNet.BroadcastAssist(num, seconds); } } public static void ApplyAssist(int helperActor, float seconds) { PlayerStats playerStats = StatBook.For(helperActor); if (playerStats != null) { playerStats.Assists++; playerStats.AssistSeconds += seconds; } } internal static void RefreshNames() { List<Character> allCharacters = Character.AllCharacters; for (int i = 0; i < allCharacters.Count; i++) { Character val = allCharacters[i]; if ((Object)(object)val == (Object)null) { continue; } PlayerStats playerStats = StatBook.For(val); if (playerStats != null) { string text = StatBook.NameOf(val); if (!string.IsNullOrWhiteSpace(text) && text != "Scout") { playerStats.Name = text; } } } } } } namespace PeakScoreboard.Ui { public static class AfflictionStyle { private const int StatusCount = 15; private static Sprite[] _icons; private static bool _iconsLoaded; private static readonly Color32[] Colors = (Color32[])(object)new Color32[15] { new Color32(byte.MaxValue, (byte)92, (byte)80, byte.MaxValue), new Color32((byte)214, (byte)168, (byte)84, byte.MaxValue), new Color32((byte)104, (byte)196, (byte)240, byte.MaxValue), new Color32((byte)168, (byte)88, (byte)220, byte.MaxValue), new Color32((byte)244, (byte)132, (byte)56, byte.MaxValue), new Color32((byte)32, (byte)29, (byte)36, byte.MaxValue), new Color32((byte)240, (byte)118, (byte)188, byte.MaxValue), new Color32((byte)138, (byte)98, (byte)60, byte.MaxValue), new Color32((byte)232, (byte)58, (byte)32, byte.MaxValue), new Color32((byte)110, (byte)186, (byte)84, byte.MaxValue), new Color32((byte)198, (byte)158, (byte)112, byte.MaxValue), new Color32((byte)232, (byte)232, (byte)238, byte.MaxValue), new Color32((byte)150, (byte)46, (byte)42, byte.MaxValue), new Color32((byte)146, (byte)146, (byte)140, byte.MaxValue), new Color32((byte)66, (byte)148, (byte)84, byte.MaxValue) }; public static readonly Color32 Stamina = new Color32((byte)126, (byte)205, (byte)62, byte.MaxValue); public static readonly Color32 Refillable = new Color32((byte)34, (byte)66, (byte)88, byte.MaxValue); public static readonly Color32 ExtraStamina = new Color32(byte.MaxValue, (byte)205, (byte)92, byte.MaxValue); public static Color ColorOf(int statusIndex) { //IL_0022: 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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) if (statusIndex < 0 || statusIndex >= Colors.Length) { return Color32.op_Implicit(new Color32((byte)180, (byte)180, (byte)180, byte.MaxValue)); } return Color32.op_Implicit(Colors[statusIndex]); } public static Sprite IconOf(int statusIndex) { if (!_iconsLoaded) { LoadIcons(); } if (_icons == null || statusIndex < 0 || statusIndex >= _icons.Length) { return null; } return _icons[statusIndex]; } public static void Reset() { _icons = null; _iconsLoaded = false; } private static void LoadIcons() { //IL_00af: Unknown result type (might be due to invalid IL or missing references) _iconsLoaded = true; StaminaBar val = (((Object)(object)GUIManager.instance != (Object)null) ? GUIManager.instance.bar : null); if ((Object)(object)val == (Object)null) { return; } BarAffliction[] componentsInChildren = ((Component)(((Object)(object)((Component)val).transform.parent != (Object)null) ? ((Component)val).transform.parent : ((Component)val).transform)).GetComponentsInChildren<BarAffliction>(true); if (componentsInChildren == null || componentsInChildren.Length == 0) { return; } _icons = (Sprite[])(object)new Sprite[15]; BarAffliction[] array = componentsInChildren; foreach (BarAffliction val2 in array) { if (!((Object)(object)val2 == (Object)null) && !((Object)(object)val2.icon == (Object)null) && !((Object)(object)val2.icon.sprite == (Object)null)) { int num = (val2.isPetrify ? 13 : ((int)val2.afflictionType)); if (num >= 0 && num < 15 && (Object)(object)_icons[num] == (Object)null) { _icons[num] = val2.icon.sprite; } } } Plugin.Log.LogInfo((object)"Statussymbole aus der Spielleiste uebernommen."); } public static bool FitsIcon(float blockWidth, float blockHeight) { if (blockWidth >= blockHeight * 0.85f) { return blockHeight >= 10f; } return false; } } public class AltitudeBar : MonoBehaviour { private class Marker { public RectTransform Root; public Image Head; public Image Ring; public Image Pin; } private struct SegmentBound { public float from; public float to; public string name; } private const float PeakUnits = 1200f; private const float BarWidth = 26f; private const float BarHeightFraction = 0.62f; private GameObject _canvas; private RectTransform _barRoot; private RectTransform _bar; private RectTransform _markerLayer; private TextMeshProUGUI _localLabel; private CanvasGroup _group; private readonly List<GameObject> _bandObjects = new List<GameObject>(); private readonly List<Marker> _markers = new List<Marker>(); private float _barHeight; private bool _bandsReady; private float _appliedMargin = float.NaN; private List<SegmentBound> _cachedBounds; private static readonly Color32[] BandColors = (Color32[])(object)new Color32[7] { new Color32((byte)198, (byte)176, (byte)128, byte.MaxValue), new Color32((byte)96, (byte)150, (byte)92, byte.MaxValue), new Color32((byte)120, (byte)132, (byte)150, byte.MaxValue), new Color32((byte)170, (byte)96, (byte)70, byte.MaxValue), new Color32((byte)120, (byte)74, (byte)96, byte.MaxValue), new Color32((byte)226, (byte)232, (byte)240, byte.MaxValue), new Color32((byte)90, (byte)70, (byte)130, byte.MaxValue) }; private void Awake() { Build(); ((MonoBehaviour)this).StartCoroutine(ReadBandsWhenReady()); } private void OnDestroy() { if ((Object)(object)_canvas != (Object)null) { Object.Destroy((Object)(object)_canvas); } } private void Build() { //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Expected O, but got Unknown //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Expected O, but got Unknown //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_010e: 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_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Expected O, but got Unknown //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Expected O, but got Unknown //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Expected O, but got Unknown //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0246: 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_0270: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Unknown result type (might be due to invalid IL or missing references) _canvas = PeakUi.MakeCanvas("PeakScoreboard.Altitude", 500, interactive: false); _canvas.transform.SetParent(((Component)this).transform, false); _group = _canvas.AddComponent<CanvasGroup>(); _canvas.GetComponent<CanvasScaler>().referenceResolution = new Vector2(1920f / Plugin.Cfg.UiScale.Value, 1080f / Plugin.Cfg.UiScale.Value); _barHeight = 1080f / Plugin.Cfg.UiScale.Value * 0.62f; GameObject val = new GameObject("BarRoot", new Type[1] { typeof(RectTransform) }); val.transform.SetParent(_canvas.transform, false); _barRoot = (RectTransform)val.transform; _barRoot.anchorMin = new Vector2(1f, 0.5f); _barRoot.anchorMax = new Vector2(1f, 0.5f); _barRoot.pivot = new Vector2(1f, 0.5f); _barRoot.sizeDelta = new Vector2(26f, _barHeight); ApplyMargin(); Image val2 = PeakUi.MakeCapsule((Transform)(object)_barRoot, "Bar", Color32.op_Implicit(new Color32((byte)14, (byte)12, (byte)10, (byte)200)), 26f); _bar = (RectTransform)((Component)val2).transform; PeakUi.Stretch(_bar); ((Component)val2).gameObject.AddComponent<Mask>().showMaskGraphic = true; GameObject val3 = new GameObject("Markers", new Type[1] { typeof(RectTransform) }); val3.transform.SetParent((Transform)(object)_barRoot, false); _markerLayer = (RectTransform)val3.transform; PeakUi.Stretch(_markerLayer); _localLabel = PeakUi.MakeLabel((Transform)(object)_barRoot, "LocalLabel", 16f, (TextAlignmentOptions)516, PeakUi.Accent); RectTransform rectTransform = ((TMP_Text)_localLabel).rectTransform; rectTransform.anchorMin = new Vector2(0f, 0f); rectTransform.anchorMax = new Vector2(0f, 0f); rectTransform.pivot = new Vector2(1f, 0.5f); rectTransform.anchoredPosition = new Vector2(-10f, -14f); rectTransform.sizeDelta = new Vector2(240f, 22f); Shadow obj = ((Component)_localLabel).gameObject.AddComponent<Shadow>(); obj.effectColor = new Color(0f, 0f, 0f, 0.75f); obj.effectDistance = new Vector2(1.5f, -1.5f); } private void ApplyMargin() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) _appliedMargin = Plugin.Cfg.AltitudeBarMarginRight.Value; _barRoot.anchoredPosition = new Vector2(0f - _appliedMargin, 0f); } private IEnumerator ReadBandsWhenReady() { float waited = 0f; while (!MapHandler.ExistsAndInitialized && waited < 40f) { waited += Time.deltaTime; yield return null; } yield return (object)new WaitForSeconds(1f); BuildBands(); } private void BuildBands() { //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: 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_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0148: 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_0167: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: 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_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: 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_0214: 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_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Unknown result type (might be due to invalid IL or missing references) //IL_034c: Unknown result type (might be due to invalid IL or missing references) //IL_0360: Unknown result type (might be due to invalid IL or missing references) foreach (GameObject bandObject in _bandObjects) { if ((Object)(object)bandObject != (Object)null) { Object.Destroy((Object)(object)bandObject); } } _bandObjects.Clear(); _cachedBounds = SegmentBounds(); List<SegmentBound> cachedBounds = _cachedBounds; if (cachedBounds == null || cachedBounds.Count == 0) { return; } bool value = Plugin.Cfg.ShowBiomeLabels.Value; for (int i = 0; i < cachedBounds.Count; i++) { float num = Mathf.Clamp01(cachedBounds[i].from / 1200f); float num2 = Mathf.Clamp01(cachedBounds[i].to / 1200f); if (!(num2 <= num)) { Color32 val = BandColors[Mathf.Min(i, BandColors.Length - 1)]; Image val2 = PeakUi.MakeImage((Transform)(object)_bar, "Band" + i, Color32.op_Implicit(new Color32(val.r, val.g, val.b, (byte)70))); RectTransform val3 = (RectTransform)((Component)val2).transform; val3.anchorMin = new Vector2(0f, num); val3.anchorMax = new Vector2(1f, num2); val3.offsetMin = new Vector2(2f, 0f); val3.offsetMax = new Vector2(-2f, 0f); _bandObjects.Add(((Component)val2).gameObject); if (i > 0) { Image val4 = PeakUi.MakeImage((Transform)(object)_bar, "Tick" + i, Color32.op_Implicit(new Color32((byte)233, (byte)224, (byte)205, (byte)70))); RectTransform val5 = (RectTransform)((Component)val4).transform; val5.anchorMin = new Vector2(0f, num); val5.anchorMax = new Vector2(1f, num); val5.pivot = new Vector2(0.5f, 0.5f); val5.offsetMin = new Vector2(0f, -0.75f); val5.offsetMax = new Vector2(0f, 0.75f); _bandObjects.Add(((Component)val4).gameObject); } if (value) { TextMeshProUGUI val6 = PeakUi.MakeLabel((Transform)(object)_barRoot, "BandLabel" + i, 12f, (TextAlignmentOptions)516, Color32.op_Implicit(new Color32((byte)233, (byte)224, (byte)205, (byte)150))); RectTransform rectTransform = ((TMP_Text)val6).rectTransform; rectTransform.anchorMin = new Vector2(0f, (num + num2) * 0.5f); rectTransform.anchorMax = new Vector2(0f, (num + num2) * 0.5f); rectTransform.pivot = new Vector2(1f, 0.5f); rectTransform.anchoredPosition = new Vector2(-8f, 0f); rectTransform.sizeDelta = new Vector2(110f, 16f); ((TMP_Text)val6).text = cachedBounds[i].name; ((TMP_Text)val6).characterSpacing = 2f; Shadow obj = ((Component)val6).gameObject.AddComponent<Shadow>(); obj.effectColor = new Color(0f, 0f, 0f, 0.75f); obj.effectDistance = new Vector2(1.5f, -1.5f); _bandObjects.Add(((Component)val6).gameObject); } } } _bandsReady = _bandObjects.Count > 0; Plugin.Log.LogInfo((object)$"Hoehenleiste: {cachedBounds.Count} Abschnitte eingelesen."); } private List<SegmentBound> SegmentBounds() { if (!MapHandler.Exists) { return null; } MapSegment[] segments = Singleton<MapHandler>.Instance.segments; if (segments == null || segments.Length == 0) { return null; } int num = segments.Length; float[] array = new float[num]; for (int i = 0; i < num; i++) { array[i] = CampfireHeight(segments[i]); } array[num - 1] = 1200f; FillGaps(array); List<SegmentBound> list = new List<SegmentBound>(num); for (int j = 0; j < num; j++) { float num2 = ((j == 0) ? 0f : array[j - 1]); list.Add(new SegmentBound { from = num2, to = array[j], name = BiomeName(segments[j]) }); } return list; } private static float CampfireHeight(MapSegment segment) { //IL_0042: 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) try { GameObject segmentCampfire = segment.segmentCampfire; if ((Object)(object)segmentCampfire == (Object)null) { return float.NaN; } Campfire componentInChildren = segmentCampfire.GetComponentInChildren<Campfire>(true); if ((Object)(object)componentInChildren != (Object)null) { return ((Component)componentInChildren).transform.position.y; } return segmentCampfire.transform.position.y; } catch { return float.NaN; } } private static void FillGaps(float[] tops) { for (int i = 0; i < tops.Length; i++) { if (!float.IsNaN(tops[i])) { continue; } float num = 0f; int num2 = -1; for (int num3 = i - 1; num3 >= 0; num3--) { if (!float.IsNaN(tops[num3])) { num = tops[num3]; num2 = num3; break; } } int num4 = -1; float num5 = 1200f; for (int j = i + 1; j < tops.Length; j++) { if (!float.IsNaN(tops[j])) { num5 = tops[j]; num4 = j; break; } } int num6 = ((num4 < 0) ? tops.Length : num4) - num2; tops[i] = num + (num5 - num) * (float)(i - num2) / (float)Mathf.Max(num6, 1); } } private static string BiomeName(MapSegment segment) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) try { return ((object)segment.biome/*cast due to .constrained prefix*/).ToString().ToUpperInvariant(); } catch { return ""; } } private void Update() { bool flag = Plugin.Cfg.ShowAltitudeBar.Value && HudGate.CanShowHud(); _group.alpha = Mathf.MoveTowards(_group.alpha, flag ? Plugin.Cfg.HudOpacity.Value : 0f, Time.unscaledDeltaTime * 5f); bool flag2 = _group.alpha > 0.01f; if (_canvas.activeSelf != flag2) { _canvas.SetActive(flag2); } if (flag) { if (!Mathf.Approximately(_appliedMargin, Plugin.Cfg.AltitudeBarMarginRight.Value)) { ApplyMargin(); } if (!_bandsReady && MapHandler.ExistsAndInitialized) { BuildBands(); } RefreshMarkers(); RefreshLocalLabel(); } } private void RefreshMarkers() { //IL_0046: 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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) List<Character> allCharacters = Character.AllCharacters; int num = 0; for (int i = 0; i < allCharacters.Count; i++) { Character val = allCharacters[i]; if (!((Object)(object)val == (Object)null) && !val.isBot && StatBook.ActorOf(val) > 0) { Marker marker = MarkerAt(num++); float num2 = Mathf.Clamp01(val.HipPos().y / 1200f); marker.Root.anchorMin = new Vector2(0f, num2); marker.Root.anchorMax = new Vector2(1f, num2); marker.Root.offsetMin = new Vector2(0f, -9f); marker.Root.offsetMax = new Vector2(0f, 9f); ((Component)marker.Root).gameObject.SetActive(true); Color val2 = ((val.refs != null && (Object)(object)val.refs.customization != (Object)null) ? val.refs.customization.PlayerColor : Color.white); float num3 = (val.data.dead ? 0.35f : 1f); ((Graphic)marker.Head).color = new Color(val2.r, val2.g, val2.b, num3); ((Graphic)marker.Ring).color = new Color(0.05f, 0.04f, 0.03f, num3 * 0.85f); ((Graphic)marker.Pin).color = new Color(val2.r, val2.g, val2.b, num3 * 0.85f); } } for (int j = num; j < _markers.Count; j++) { ((Component)_markers[j].Root).gameObject.SetActive(false); } } private Marker MarkerAt(int index) { //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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: 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_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: 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_00fd: 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_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0179: 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_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: 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_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) Vector2 val7 = default(Vector2); while (_markers.Count <= index) { GameObject val = new GameObject("Marker" + _markers.Count, new Type[1] { typeof(RectTransform) }); val.transform.SetParent((Transform)(object)_markerLayer, false); RectTransform val2 = (RectTransform)val.transform; val2.pivot = new Vector2(0.5f, 0.5f); Image val3 = PeakUi.MakeCapsule((Transform)(object)val2, "Pin", Color.white, 3f); RectTransform val4 = (RectTransform)((Component)val3).transform; val4.anchorMin = new Vector2(0f, 0.5f); val4.anchorMax = new Vector2(1f, 0.5f); val4.offsetMin = new Vector2(2f, -1.5f); val4.offsetMax = new Vector2(-2f, 1.5f); Image val5 = PeakUi.MakeCircle((Transform)(object)val2, "Ring", Color.black); RectTransform val6 = (RectTransform)((Component)val5).transform; ((Vector2)(ref val7))..ctor(0f, 0.5f); val6.anchorMax = val7; val6.anchorMin = val7; val6.pivot = new Vector2(0.5f, 0.5f); val6.anchoredPosition = new Vector2(-9f, 0f); val6.sizeDelta = new Vector2(15f, 15f); Image val8 = PeakUi.MakeCircle((Transform)(object)val2, "Head", Color.white); RectTransform val9 = (RectTransform)((Component)val8).transform; ((Vector2)(ref val7))..ctor(0f, 0.5f); val9.anchorMax = val7; val9.anchorMin = val7; val9.pivot = new Vector2(0.5f, 0.5f); val9.anchoredPosition = new Vector2(-9f, 0f); val9.sizeDelta = new Vector2(11f, 11f); _markers.Add(new Marker { Root = val2, Head = val8, Ring = val5, Pin = val3 }); } return _markers[index]; } private void RefreshLocalLabel() { if (!Plugin.Cfg.ShowAltitudeText.Value) { if (((Component)_localLabel).gameObject.activeSelf) { ((Component)_localLabel).gameObject.SetActive(false); } return; } if (!((Component)_localLabel).gameObject.activeSelf) { ((Component)_localLabel).gameObject.SetActive(true); } Character localCharacter = Character.localCharacter; if ((Object)(object)localCharacter == (Object)null) { ((TMP_Text)_localLabel).text = ""; } else { ((TMP_Text)_localLabel).text = Mathf.RoundToInt(ScoreboardHud.HeightMeters(localCharacter)) + " m"; } } } public class GameStaminaBar { private readonly RectTransform _container; private readonly CanvasGroup _group; private readonly float _targetWidth; private RectTransform _root; private RectTransform _fullBar; private RectTransform _staminaBar; private RectTransform _maxStaminaBar; private RectTransform _outline; private RectTransform _overflow; private RectTransform _extraBar; private RectTransform _extraBarStamina; private RectTransform _extraBarOutline; private Image _backing; private Image _extraStaminaIcon; private BarAffliction[] _afflictions; private BarAffliction _petrify; private float _staminaOffset; private float _minAfflictionWidth = 60f; private float _minStaminaWidth = 20f; private Color _defaultBacking; private Color _outOfStaminaBacking; private float _fullBarWidth; private bool _aligned; private float _appliedExtraOffset = float.NaN; private Vector2 _extraBarHome; public static bool IsAvailable { get { if ((Object)(object)GUIManager.instance != (Object)null) { return (Object)(object)GUIManager.instance.bar != (Object)null; } return false; } } public bool Valid { get { if ((Object)(object)_root != (Object)null) { return (Object)(object)_fullBar != (Object)null; } return false; } } public RectTransform Container => _container; public GameStaminaBar(Transform parent, float targetWidth, float height) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) _targetWidth = targetWidth; GameObject val = new GameObject("GameStamina", new Type[2] { typeof(RectTransform), typeof(CanvasGroup) }); val.transform.SetParent(parent, false); _container = (RectTransform)val.transform; _container.pivot = new Vector2(0f, 0.5f); _container.sizeDelta = new Vector2(targetWidth, height); _group = val.GetComponent<CanvasGroup>(); TryClone(); } private void TryClone() { //IL_0041: 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_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: 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_01d1: 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_01df: 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) //IL_023c: 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) { return; } float fullBarWidth; Rect rect; if (!((Object)(object)val.fullBar != (Object)null)) { fullBarWidth = 0f; } else { rect = val.fullBar.rect; fullBarWidth = ((Rect)(ref rect)).width; } _fullBarWidth = fullBarWidth; RectTransform component = ((Component)val).GetComponent<RectTransform>(); GameObject val2 = Object.Instantiate<GameObject>(((Component)val).gameObject); val2.SetActive(false); StaminaBar val3 = val2.GetComponent<StaminaBar>(); BarAffliction[] componentsInChildren = val2.GetComponentsInChildren<BarAffliction>(true); if (componentsInChildren.Length == 0 && (Object)(object)((Component)val).transform.parent != (Object)null) { Object.Destroy((Object)(object)val2); Transform parent = ((Component)val).transform.parent; component = ((Component)parent).GetComponent<RectTransform>(); val2 = Object.Instantiate<GameObject>(((Component)parent).gameObject); val2.SetActive(false); val3 = val2.GetComponentInChildren<StaminaBar>(true); componentsInChildren = val2.GetComponentsInChildren<BarAffliction>(true); } if ((Object)(object)val3 == (Object)null) { Object.Destroy((Object)(object)val2); Plugin.Log.LogWarning((object)"Klon der Ausdauerleiste fehlgeschlagen - nutze den Eigenbau."); return; } TakeReferences(val3, componentsInChildren); StripBehaviours(val2, val3); HideDecoration(val3); HideUnknownGraphics(val2); if (Plugin.Cfg.DebugStaminaBar.Value) { DumpHierarchy(val2); } _root = val2.GetComponent<RectTransform>(); if ((Object)(object)_root == (Object)null) { _root = val2.AddComponent<RectTransform>(); } Vector2 size; if (!((Object)(object)component != (Object)null)) { rect = _root.rect; size = ((Rect)(ref rect)).size; } else { rect = component.rect; size = ((Rect)(ref rect)).size; } Vector2 val4 = size; ((Transform)_root).SetParent((Transform)(object)_container, false); RectTransform root = _root; RectTransform root2 = _root; Vector2 val5 = default(Vector2); ((Vector2)(ref val5))..ctor(0f, 0.5f); root2.anchorMax = val5; root.anchorMin = val5; _root.pivot = new Vector2(0f, 0.5f); if (val4.x > 1f && val4.y > 1f) { _root.sizeDelta = val4; } _root.anchoredPosition = Vector2.zero; float num = ((_fullBarWidth > 1f) ? (_targetWidth / _fullBarWidth) : 1f); ((Transform)_root).localScale = new Vector3(num, num, 1f); val2.SetActive(true); } private void TakeReferences(StaminaBar bar, BarAffliction[] afflictions) { //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: 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_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) _fullBar = bar.fullBar; _staminaBar = bar.staminaBar; _maxStaminaBar = bar.maxStaminaBar; _outline = bar.staminaBarOutline; _overflow = bar.staminaBarOutlineOverflowBar; _extraBar = bar.extraBar; _extraBarStamina = bar.extraBarStamina; _extraBarOutline = bar.extraBarOutline; _backing = bar.backing; _extraStaminaIcon = bar.extraStaminaIcon; _petrify = bar.petrifyAffliction; _afflictions = afflictions; _staminaOffset = bar.staminaBarOffset; _minAfflictionWidth = bar.minAfflictionWidth; _minStaminaWidth = bar.minStaminaBarWidth; _defaultBacking = bar.defaultBackingColor; _outOfStaminaBacking = bar.outOfStaminaBackingColor; if ((Object)(object)_extraBar != (Object)null) { _extraBarHome = _extraBar.anchoredPosition; } } private static void StripBehaviours(GameObject clone, StaminaBar bar) { ((Behaviour)bar).enabled = false; MonoBehaviour[] componentsInChildren = clone.GetComponentsInChildren<MonoBehaviour>(true); foreach (MonoBehaviour val in componentsInChildren) { if (!((Object)(object)val == (Object)null) && !(val is Graphic) && !(val is BarAffliction) && !(val is LayoutGroup) && !(val is ContentSizeFitter) && !(val is LayoutElement) && !(val is AspectRatioFitter) && !(val is Shadow)) { ((Behaviour)val).enabled = false; Object.Destroy((Object)(object)val); } } Animator[] componentsInChildren2 = clone.GetComponentsInChildren<Animator>(true); foreach (Animator val2 in componentsInChildren2) { if ((Object)(object)val2 != (Object)null) { ((Behaviour)val2).enabled = false; } } } private static void HideDecoration(StaminaBar bar) { Hide((Component)(object)bar.staminaGlow); Hide((Component)(object)bar.extraStaminaGlow); Hide((Component)(object)bar.rainbowStamina); Hide((Component)(object)bar.moraleBoostText); if ((Object)(object)bar.shield != (Object)null) { bar.shield.SetActive(false); } if ((Object)(object)bar.campfire != (Object)null) { bar.campfire.SetActive(false); } } private static void Hide(Component component) { if ((Object)(object)component != (Object)null) { component.gameObject.SetActive(false); } } private void HideUnknownGraphics(GameObject clone) { HashSet<Transform> hashSet = new HashSet<Transform>(); KeepBranch(hashSet, (Component)(object)_backing); KeepBranch(hashSet, (Component)(object)_fullBar); KeepBranch(hashSet, (Component)(object)_staminaBar); KeepBranch(hashSet, (Component)(object)_maxStaminaBar); KeepBranch(hashSet, (Component)(object)_outline); KeepBranch(hashSet, (Component)(object)_overflow); KeepBranch(hashSet, (Component)(object)_extraBar); KeepBranch(hashSet, (Component)(object)_extraStaminaIcon); if (_afflictions != null) { BarAffliction[] afflictions = _afflictions; foreach (BarAffliction component in afflictions) { KeepBranch(hashSet, (Component)(object)component); } } Graphic[] componentsInChildren = clone.GetComponentsInChildren<Graphic>(true); foreach (Graphic val in componentsInChildren) { if (!((Object)(object)val == (Object)null) && !hashSet.Contains(((Component)val).transform)) { ((Behaviour)val).enabled = false; } } } private static void KeepBranch(HashSet<Transform> keep, Component component) { if (!((Object)(object)component == (Object)null)) { Transform[] componentsInChildren = ((Component)component.transform).GetComponentsInChildren<Transform>(true); foreach (Transform item in componentsInChildren) { keep.Add(item); } Transform val = component.transform; while ((Object)(object)val != (Object)null) { keep.Add(val); val = val.parent; } } } private static void DumpHierarchy(GameObject clone) { //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) StringBuilder stringBuilder = new StringBuilder("Aufbau des Ausdauer-Klons:").AppendLine(); Transform[] componentsInChildren = clone.GetComponentsInChildren<Transform>(true); foreach (Transform val in componentsInChildren) { int num = 0; Transform parent = val.parent; while ((Object)(object)parent != (Object)null && (Object)(object)parent != (Object)(object)clone.transform.parent) { num++; parent = parent.parent; } RectTransform val2 = (RectTransform)(object)((val is RectTransform) ? val : null); Graphic component = ((Component)val).GetComponent<Graphic>(); stringBuilder.Append(' ', num * 2).Append(((Object)val).name).Append(((Component)val).gameObject.activeSelf ? "" : " [aus]") .Append(((Object)(object)component != (Object)null) ? (" <" + ((object)component).GetType().Name + (((Behaviour)component).enabled ? ">" : " aus>")) : "") .Append(((Object)(object)val2 != (Object)null) ? $" size={val2.sizeDelta} pos={val2.anchoredPosition}" : "") .AppendLine(); } Plugin.Log.LogInfo((object)stringBuilder.ToString()); } public void SetVisible(bool visible) { if (((Component)_container).gameObject.activeSelf != visible) { ((Component)_container).gameObject.SetActive(visible); } } public void Refresh(Character character, float alpha) { //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: 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_017d: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: 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) if (!Valid || (Object)(object)character == (Object)null || character.refs == null || (Object)(object)character.refs.afflictions == (Object)null) { SetVisible(visible: false); return; } SetVisible(visible: true); _group.alpha = alpha; if (!_aligned) { Align(); } ApplyExtraBarOffset(); CharacterAfflictions afflictions = character.refs.afflictions; float num; if (!(_fullBarWidth > 1f)) { Rect rect = _fullBar.rect; num = ((Rect)(ref rect)).width; } else { num = _fullBarWidth; } float num2 = num; float statusSum = afflictions.statusSum; SetWidth(_staminaBar, Mathf.Max(0f, character.data.currentStamina * num2 + _staminaOffset)); SetWidth(_maxStaminaBar, Mathf.Max(0f, character.GetMaxStamina() * num2 + _staminaOffset)); SetWidth(_outline, 14f + Mathf.Max(1f, statusSum) * num2); if ((Object)(object)_overflow != (Object)null) { ((Component)_overflow).gameObject.SetActive(statusSum > 1.005f); } if ((Object)(object)_staminaBar != (Object)null) { ((Component)_staminaBar).gameObject.SetActive(_staminaBar.sizeDelta.x > _minStaminaWidth); } if ((Object)(object)_maxStaminaBar != (Object)null) { ((Component)_maxStaminaBar).gameObject.SetActive(_maxStaminaBar.sizeDelta.x > _minStaminaWidth); } RefreshAfflictions(character, afflictions, num2); RefreshExtraBar(character, num2); if ((Object)(object)_backing != (Object)null) { ((Graphic)_backing).color = ((character.data.currentStamina <= 0.005f) ? _outOfStaminaBacking : _defaultBacking); } } private void RefreshAfflictions(Character character, CharacterAfflictions afflictions, float full) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) if (_afflictions == null) { return; } for (int i = 0; i < _afflictions.Length; i++) { BarAffliction val = _afflictions[i]; if ((Object)(object)val == (Object)null) { continue; } float num = (val.isPetrify ? ((float)character.data.petrifyAmount / 100f) : afflictions.GetCurrentStatus(val.afflictionType)); if (num > 0.01f) { float width = Mathf.Max(full * num, _minAfflictionWidth); if (!((Component)val).gameObject.activeSelf) { ((Component)val).gameObject.SetActive(true); } val.width = width; } else if (((Component)val).gameObject.activeSelf) { ((Component)val).gameObject.SetActive(false); } } } private void RefreshExtraBar(Character character, float full) { //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_extraBar == (Object)null) { return; } bool flag = (Object)(object)_petrify != (Object)null && ((Component)_petrify).gameObject.activeSelf; bool flag2 = character.data.extraStamina > 0f || flag; if (((Component)_extraBar).gameObject.activeSelf != flag2) { ((Component)_extraBar).gameObject.SetActive(flag2); } if (flag2) { _extraBar.sizeDelta = new Vector2(45f, 45f); float num = Mathf.Max(0f, character.data.extraStamina * full); SetWidth(_extraBarStamina, Mathf.Max(6f, num)); SetWidth(_extraBarOutline, Mathf.Max(20f, (flag ? full : num) + 12f)); bool flag3 = (Object)(object)_extraBarStamina != (Object)null && _extraBarStamina.sizeDelta.x > 6.1f; if ((Object)(object)_extraBarStamina != (Object)null && ((Component)_extraBarStamina).gameObject.activeSelf != flag3) { ((Component)_extraBarStamina).gameObject.SetActive(flag3); } if ((Object)(object)_extraStaminaIcon != (Object)null && ((Component)_extraStaminaIcon).gameObject.activeSelf != flag3) { ((Component)_extraStaminaIcon).gameObject.SetActive(flag3); } } } private void ApplyExtraBarOffset() { //IL_003c: 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_004c: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_extraBar == (Object)null)) { float value = Plugin.Cfg.ExtraBarOffsetY.Value; if (!Mathf.Approximately(_appliedExtraOffset, value)) { _appliedExtraOffset = value; _extraBar.anchoredPosition = _extraBarHome + new Vector2(0f, value); } } } private static void SetWidth(RectTransform rt, float width) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)rt == (Object)null)) { rt.sizeDelta = new Vector2(width, rt.sizeDelta.y); } } private void Align() { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003e: 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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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_005a: 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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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) if (!((Object)(object)_fullBar == (Object)null) && !((Object)(object)_root == (Object)null)) { Canvas.ForceUpdateCanvases(); Vector3[] array = (Vector3[])(object)new Vector3[4]; _fullBar.GetWorldCorners(array); Vector3 val = (array[0] + array[1]) * 0.5f; Vector3 val2 = ((Transform)_container).InverseTransformPoint(val); RectTransform root = _root; root.anchoredPosition -= new Vector2(val2.x, val2.y); _aligned = true; } } public static float Fraction(Character character) { if ((Object)(object)character == (Object)null) { return 0f; } float num = Mathf.Max(character.GetMaxStamina(), 0.0001f); return Mathf.Clamp01(character.data.currentStamina / num); } } public static class HudGate { public static bool CanShowHud() { if (!Plugin.Cfg.HudVisible) { return false; } return CanShowAnything(); } public static bool CanShowAnything() { if (!Character.localCharacterExists) { return false; } GUIManager instance = GUIManager.instance; if ((Object)(object)instance == (Object)null) { return false; } try { if (GUIManager.InPauseMenu) { return false; } } catch { } try { if ((Object)(object)instance.endScreen != (Object)null && ((MenuWindow)instance.endScreen).isOpen) { return false; } } catch { } try { if (LoadingScreenHandler.loading) { return false; } } catch { } try { if (instance.wheelActive) { return false; } } catch { } return true; } } public class LeaderboardHud : MonoBehaviour { private class Row { private readonly RectTransform _root; private readonly TextMeshProUGUI _rank; private readonly TextMeshProUGUI _name; private readonly TextMeshProUGUI _height; public Row(RectTransform parent, int index) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: 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_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Row" + index, new Type[1] { typeof(RectTransform) }); val.transform.SetParent((Transform)(object)parent, false); _root = (RectTransform)val.transform; _root.anchorMin = new Vector2(0f, 1f); _root.anchorMax = new Vector2(1f, 1f); _root.pivot = new Vector2(0.5f, 1f); _root.offsetMin = (_root.offsetMax = Vector2.zero); _root.sizeDelta = new Vector2(0f, 26f); _rank = Label("Rank", 15f, (TextAlignmentOptions)516, 0f, 22f); _name = Label("Name", 15f, (TextAlignmentOptions)513, 30f, 112f); _height = Label("Height", 15f, (TextAlignmentOptions)516, 142f, 72f); } private TextMeshProUGUI Label(string name, float size, TextAlignmentOptions align, float x, float width) { //IL_0008: 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_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: 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_0055: 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) TextMeshProUGUI obj = PeakUi.MakeLabel((Transform)(object)_root, name, size, align, PeakUi.Ink); RectTransform rectTransform = ((TMP_Text)obj).rectTransform; Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(0f, 0.5f); rectTransform.anchorMax = val; rectTransform.anchorMin = val; rectTransform.pivot = new Vector2(0f, 0.5f); rectTransform.anchoredPosition = new Vector2(x, 0f); rectTransform.sizeDelta = new Vector2(width, 20f); AddShadow(obj); return obj; } public void SetActive(bool active) { if (((Component)_root).gameObject.activeSelf != active) { ((Component)_root).gameObject.SetActive(active); } } public void Refresh(Character character, int index) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) _root.anchoredPosition = new Vector2(0f, 0f - (26f + (float)index * 26f)); bool dead = character.data.dead; float num = (dead ? 0.4f : 1f); ((TMP_Text)_rank).text = index + 1 + "."; ((Graphic)_rank).color = new Color(PeakUi.InkDim.r, PeakUi.InkDim.g, PeakUi.InkDim.b, num); PlayerStats playerStats = StatBook.For(character); string name = ((playerStats != null && !string.IsNullOrEmpty(playerStats.Name)) ? playerStats.Name : StatBook.NameOf(character)); ((TMP_Text)_name).text = Shorten(name); ((Graphic)_name).color = (character.IsLocal ? new Color(PeakUi.Accent.r, PeakUi.Accent.g, PeakUi.Accent.b, num) : new Color(PeakUi.Ink.r, PeakUi.Ink.g, PeakUi.Ink.b, num)); int num2 = Mathf.RoundToInt(ScoreboardHud.HeightMeters(character)); ((TMP_Text)_height).text = (dead ? "<alpha=#88>DEAD" : (num2 + " m")); ((Graphic)_height).color = new Color(PeakUi.Ink.r, PeakUi.Ink.g, PeakUi.Ink.b, num); } private static string Shorten(string name) { if (string.IsNullOrEmpty(name) || name.Length <= 11) { return name; } return name.Substring(0, 10) + "…"; } } private const float PanelWidth = 214f; private const float RowHeight = 26f; private const float HeaderHeight = 26f; private GameObject _canvas; private RectTransform _panel; private CanvasGroup _group; private TextMeshProUGUI _header; private readonly List<Row> _rows = new List<Row>(); private readonly List<Character> _sorted = new List<Character>(); private float _lastMarginRight; private float _lastMarginTop; private void Awake() { Build(); } private void OnDestroy() { if ((Object)(object)_canvas != (Object)null) { Object.Destroy((Object)(object)_canvas); } } private void Build() { //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Expected O, but got Unknown //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Expected O, but got Unknown //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: 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_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0176: 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_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: 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) _canvas = PeakUi.MakeCanvas("PeakScoreboard.Leaderboard", 500, interactive: false); _canvas.transform.SetParent(((Component)this).transform, false); _group = _canvas.AddComponent<CanvasGroup>(); _canvas.GetComponent<CanvasScaler>().referenceResolution = new Vector2(1920f / Plugin.Cfg.UiScale.Value, 1080f / Plugin.Cfg.UiScale.Value); GameObject val = new GameObject("Panel", new Type[1] { typeof(RectTransform) }); val.transform.SetParent(_canvas.transform, false); _panel = (RectTransform)val.transform; RectTransform panel = _panel; RectTransform panel2 = _panel; Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(1f, 1f); panel2.anchorMax = val2; panel.anchorMin = val2; _panel.pivot = new Vector2(1f, 1f); _panel.sizeDelta = new Vector2(214f, 26f); ApplyMargins(); _header = PeakUi.MakeLabel((Transform)(object)_panel, "Header", 14f, (TextAlignmentOptions)516, PeakUi.InkDim); RectTransform rectTransform = ((TMP_Text)_header).rectTransform; rectTransform.anchorMin = new Vector2(0f, 1f); rectTransform.anchorMax = new Vector2(1f, 1f); rectTransform.pivot = new Vector2(0.5f, 1f); rectTransform.offsetMin = Vector2.zero; rectTransform.offsetMax = Vector2.zero; rectTransform.anchoredPosition = new Vector2(0f, -4f); rectTransform.sizeDelta = new Vector2(0f, 18f); ((TMP_Text)_header).text = "ALTITUDE"; ((TMP_Text)_header).characterSpacing = 6f; AddShadow(_header); } private void ApplyMargins() { //IL_003e: Unknown result type (might be due to invalid IL or missing references) _lastMarginRight = Plugin.Cfg.LeaderboardMarginRight.Value; _lastMarginTop = Plugin.Cfg.LeaderboardMarginTop.Value; _panel.anchoredPosition = new Vector2(0f - _lastMarginRight, 0f - _lastMarginTop); } private static void AddShadow(TextMeshProUGUI label) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) Shadow obj = ((Component)label).gameObject.AddComponent<Shadow>(); obj.effectColor = new Color(0f, 0f, 0f, 0.75f); obj.effectDistance = new Vector2(1.5f, -1.5f); } private void Update() { bool flag = Plugin.Cfg.ShowLeaderboard.Value && HudGate.CanShowHud(); _group.alpha = Mathf.MoveTowards(_group.alpha, flag ? Plugin.Cfg.HudOpacity.Value : 0f, Time.unscaledDeltaTime * 5f); bool flag2 = _group.alpha > 0.01f; if (_canvas.activeSelf != flag2) { _canvas.SetActive(flag2); } if (flag) { if (!Mathf.Approximately(_lastMarginRight, Plugin.Cfg.LeaderboardMarginRight.Value) || !Mathf.Approximately(_lastMarginTop, Plugin.Cfg.LeaderboardMarginTop.Value)) { ApplyMargins(); } Refresh(); } } private void Refresh() { //IL_0133: Unknown result type (might be due to invalid IL or missing references) _sorted.Clear(); List<Character> allCharacters = Character.AllCharacters; for (int i = 0; i < allCharacters.Count; i++) { Character val = allCharacters[i]; if (!((Object)(object)val == (Object)null) && !val.isBot && StatBook.ActorOf(val) > 0) { _sorted.Add(val); } } _sorted.Sort((Character a, Character b) => ScoreboardHud.HeightMeters(b).CompareTo(ScoreboardHud.HeightMeters(a))); while (_rows.Count < _sorted.Count) { _rows.Add(new Row(_panel, _rows.Count)); } for (int num = 0; num < _rows.Count; num++) { bool flag = num < _sorted.Count; _rows[num].SetActive(flag); if (flag) { _rows[num].Refresh(_sorted[num], num); } } _panel.sizeDelta = new Vector2(214f, 26f + (float)_sorted.Count * 26f); } } public class ScoreboardHud : MonoBehaviour { private struct Layout { public bool WithFed; public float PanelWidth; public float NameX; public float NameW; public float StateX; public float StateW; public float StaminaX; public float StaminaW; public float PercentR; public float PercentW; public float EatenR; public float ReceivedR; public float UsedR; public float FedR; public float AssistsR; public float DeathsR; public float HeightR; public float NumW; public float WideW; public float HeightW; public const float FedW = 92f; public static Layout Build(bool withFed) { Layout result = new Layout { WithFed = withFed }; result.NameX = 62f; result.NameW = 270f; result.StateX = 342f; result.StateW = 72f; result.StaminaX = 432f; result.StaminaW = 260f; result.PercentW = 76f; result.PercentR = 786f; result.NumW = 104f; result.WideW = 128f; result.HeightW = 116f; float num = result.PercentR + 26f; num = (result.UsedR = (result.ReceivedR = (result.EatenR = num + result.WideW) + (26f + result.WideW)) + (26f + result.NumW)); if (withFed) { num = (result.FedR = num + 118f); } else { result.FedR = num; } result.PanelWidth = (result.HeightR = (result.DeathsR = (result.AssistsR = num + (26f + result.WideW)) + (26f + result.NumW)) + (26f + result.HeightW)) + 30f; return result; } } private class Row { private readonly RectTransform _root; private readonly Image _stripe; private readonly Image _dot; private readonly TextMeshProUGUI _name; private readonly TextMeshProUGUI _state; private readonly GameStaminaBar _gameBar; private readonly StaminaWidget _stamina; private readonly TextMeshProUGUI _percent; private readonly TextMeshProUGUI _eaten; private readonly TextMeshProUGUI _received; private readonly TextMeshProUGUI _used; private readonly TextMeshProUGUI _fed; private readonly TextMeshProUGUI _assists; private readonly TextMeshProUGUI _deaths; private readonly TextMeshProUGUI _height; public Row(RectTransform parent, int index) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: 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_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Expected O, but got Unknown //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Expected O, but got Unknown GameObject val = new GameObject("Row" + index, new Type[1] { typeof(RectTransform) }); val.transform.SetParent((Transform)(object)parent, false); _root = (RectTransform)val.transform; _root.anchorMin = new Vector2(0f, 1f); _root.anchorMax = new Vector2(1f, 1f); _root.pivot = new Vector2(0.5f, 1f); _root.offsetMin = (_root.offsetMax = Vector2.zero); _root.anchoredPosition = new Vector2(0f, (float)(-index) * 52f); _root.sizeDelta = new Vector2(0f, 52f); _stripe = PeakUi.MakeImage((Transform)(object)_root, "Stripe", Color32.op_Implicit(new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)9))); PeakUi.Stretch((RectTransform)((Component)_stripe).transform, 15f, 3f); _dot = PeakUi.MakeCircle((Transform)(object)_root, "Dot", Color.white); Place((RectTransform)((Component)_dot).transform, 30f, -16f, 14f, 14f); _name = Cell("Name", 21f, (TextAlignmentOptions)513); _state = Cell("State", 15f, (TextAlignmentOptions)513); if (Plugin.Cfg.StaminaBar.Value == StaminaBarStyle.GameClone && GameStaminaBar.IsAvailable) { _gameBar = new GameStaminaBar((Transform)(object)_root, 260f, 26f); if (!_gameBar.Valid) { _gameBar = null; } } if (_gameBar == null) { _stamina = new StaminaWidget((Transform)(object)_root, 260f, 24f); } _percent = Cell("Percent", 18f, (TextAlignmentOptions)516); _eaten = Cell("Eaten", 20f, (TextAlignmentOptions)516); _received = Cell("Received", 20f, (TextAlignmentOptions)516); _used = Cell("Used", 20f, (TextAlignmentOptions)516); _fed = Cell("Fed", 20f, (TextAlignmentOptions)516); _assists = Cell("Assists", 20f, (TextAlignmentOptions)516); _deaths = Cell("Deaths", 20f, (TextAlignmentOptions)516); _height = Cell("Height", 21f, (TextAlignmentOptions)516); } private TextMeshProUGUI Cell(string name, float size, TextAlignmentOptions align) { //IL_0008: 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) return PeakUi.MakeLabel((Transform)(object)_root, name, size, align, PeakUi.Ink); } public void ApplyLayout(Layout l) { Place(((TMP_Text)_name).rectTransform, l.NameX, -12f, l.NameW, 26f); Place(((TMP_Text)_state).rectTransform, l.StateX, -13f, l.StateW, 24f); if (_gameBar != null) { Place(_gameBar.Container, l.StaminaX, -8f, l.StaminaW, 26f); } else { _stamina.SetWidth(l.StaminaW); Place(_stamina.Root, l.StaminaX, -14f, l.StaminaW, 24f); } Place(((TMP_Text)_percent).rectTransform, l.PercentR - l.PercentW, -12f, l.PercentW, 26f); Place(((TMP_Text)_eaten).rectTransform, l.EatenR - l.WideW, -12f, l.WideW, 26f); Place(((TMP_Text)_received).rectTransform, l.ReceivedR - l.WideW, -12f, l.WideW, 26f); Place(((TMP_Text)_used).rectTransform, l.UsedR - l.NumW, -12f, l.NumW, 26f); Place(((TMP_Text)_fed).rectTransform, l.Fe