using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using DG.Tweening; using DG.Tweening.Core; using DG.Tweening.Plugins.Options; using HarmonyLib; using Microsoft.CodeAnalysis; using Peak; using PeakOverheadStats.Compatibility; using PeakOverheadStats.MonoBehaviours; using Photon.Pun; using TMPro; using UnityEngine; 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")] [assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")] [assembly: IgnoresAccessChecksTo("DOTween")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("PeakOverheadStats")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("PeakOverheadStats")] [assembly: AssemblyTitle("PeakOverheadStats")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [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 PeakOverheadStats { internal static class GameRef { private static readonly FieldInfo _runManager_timeSinceRunStarted = typeof(RunManager).GetField("timeSinceRunStarted", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); private static readonly FieldInfo _staminaBar_desiredStaminaSize = typeof(StaminaBar).GetField("desiredStaminaSize", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); private static readonly FieldInfo _staminaBar_desiredExtraStaminaSize = typeof(StaminaBar).GetField("desiredExtraStaminaSize", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); private static readonly FieldInfo _orbFogHandler_sphere = typeof(OrbFogHandler).GetField("sphere", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); private static readonly FieldInfo _characterStats_character = typeof(CharacterStats).GetField("character", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); private static readonly FieldInfo _lavaRising_startHeight = typeof(LavaRising).GetField("startHeight", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); private static readonly FieldInfo _characterData_isInvincible = typeof(CharacterData).GetField("isInvincible", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); private static FieldInfo _thornOnMe_popOutTime; private static FieldInfo _characterAfflictions_m_inAirport; private static FieldInfo _fogSphere_fogPoint; public static float GetTimeSinceRunStarted(RunManager rm) { if (!(_runManager_timeSinceRunStarted != null)) { return Time.time; } return (float)_runManager_timeSinceRunStarted.GetValue(rm); } public static float GetDesiredStaminaSize(StaminaBar bar) { if (!(_staminaBar_desiredStaminaSize != null)) { return 0f; } return (float)_staminaBar_desiredStaminaSize.GetValue(bar); } public static float GetDesiredExtraStaminaSize(StaminaBar bar) { if (!(_staminaBar_desiredExtraStaminaSize != null)) { return 0f; } return (float)_staminaBar_desiredExtraStaminaSize.GetValue(bar); } public static object GetFogSphere(OrbFogHandler handler) { return _orbFogHandler_sphere?.GetValue(handler); } public static Character GetCharacter(CharacterStats stats) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown if (!(_characterStats_character != null)) { return null; } return (Character)_characterStats_character.GetValue(stats); } public static float GetStartHeight(LavaRising lava) { if (!(_lavaRising_startHeight != null)) { return 0f; } return (float)_lavaRising_startHeight.GetValue(lava); } public static bool GetIsInvincible(CharacterData data) { if (_characterData_isInvincible != null) { return (bool)_characterData_isInvincible.GetValue(data); } return false; } public static float GetPopOutTime(object thorn) { if (_thornOnMe_popOutTime == null && thorn != null) { _thornOnMe_popOutTime = thorn.GetType().GetField("popOutTime", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } if (!(_thornOnMe_popOutTime != null)) { return 0f; } return (float)_thornOnMe_popOutTime.GetValue(thorn); } public static bool GetInAirport(object afflictions) { if (_characterAfflictions_m_inAirport == null && afflictions != null) { _characterAfflictions_m_inAirport = afflictions.GetType().GetField("m_inAirport", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } if (_characterAfflictions_m_inAirport != null) { return (bool)_characterAfflictions_m_inAirport.GetValue(afflictions); } return false; } public static Vector3 GetFogPoint(object sphere) { //IL_0045: 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) if (_fogSphere_fogPoint == null && sphere != null) { _fogSphere_fogPoint = sphere.GetType().GetField("fogPoint", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } if (!(_fogSphere_fogPoint != null)) { return Vector3.zero; } return (Vector3)_fogSphere_fogPoint.GetValue(sphere); } } [BepInPlugin("com.yls.peakoverheadstats", "PeakOverheadStats", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { internal static ManualLogSource Logger { get; private set; } private void Awake() { //IL_0054: Unknown result type (might be due to invalid IL or missing references) Logger = ((BaseUnityPlugin)this).Logger; Logger.LogInfo((object)$"Plugin {((BaseUnityPlugin)this).Info.Metadata.Name} v{((BaseUnityPlugin)this).Info.Metadata.Version} loaded!"); PluginConfig.Initialize(((BaseUnityPlugin)this).Config, Logger); new Harmony("com.yls.peakoverheadstats").PatchAll(); } } [HarmonyWrapSafe] internal sealed class Patches { [HarmonyPatch(typeof(GUIManager), "Start")] [HarmonyPostfix] private static void GUIManagerStartHook(GUIManager __instance) { //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) Scene activeScene = SceneManager.GetActiveScene(); if (((Scene)(ref activeScene)).name != "Airport") { CreateTimerAndHeightStats(); CreateMapStats(); } void CreateMapStats() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_0058: 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_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: 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_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014b: 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_0160: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0170: 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) RectTransform val = (RectTransform)((Component)((Component)__instance).GetComponentInChildren()).transform; RectTransform obj = Object.Instantiate(val, ((Transform)val).parent); ((Object)obj).name = "Map & Level UI"; Object.Destroy((Object)(object)((Component)obj).GetComponent()); MapStats mapStats = ((Component)obj).gameObject.AddComponent(); Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(1f, 1f); obj.anchorMin = val2; Vector2 pivot = (obj.anchorMax = val2); obj.pivot = pivot; obj.anchoredPosition = new Vector2(-4f, 5f); RectTransform val4 = Object.Instantiate(val, ((Transform)val).parent); ((Object)val4).name = "Biome Route UI"; Object.Destroy((Object)(object)((Component)val4).GetComponent()); ((Vector2)(ref val2))..ctor(1f, 1f); val4.anchorMin = val2; pivot = (val4.anchorMax = val2); val4.pivot = pivot; float y = val.anchoredPosition.y; Rect rect = val.rect; val4.anchoredPosition = new Vector2(0f, y - ((Rect)(ref rect)).height + 8f); TMP_Text component = ((Component)val4).GetComponent(); RectTransform obj2 = Object.Instantiate(val, ((Transform)val).parent); ((Object)obj2).name = "Biome Variant UI"; Object.Destroy((Object)(object)((Component)obj2).GetComponent()); ((Vector2)(ref val2))..ctor(1f, 1f); obj2.anchorMin = val2; pivot = (obj2.anchorMax = val2); obj2.pivot = pivot; float y2 = val4.anchoredPosition.y; rect = val.rect; obj2.anchoredPosition = new Vector2(0f, y2 - ((Rect)(ref rect)).height + 22f); TMP_Text component2 = ((Component)obj2).GetComponent(); RectTransform component3 = ((Component)__instance.hudCanvas).GetComponent(); mapStats.InitializeRouteText(component, component2, component3); } void CreateTimerAndHeightStats() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) Transform transform = ((Component)((Component)__instance).GetComponentInChildren()).transform; RectTransform val = (RectTransform)Object.Instantiate(transform, transform.parent); ((Object)val).name = "Timer & Height UI"; Object.Destroy((Object)(object)((Component)val).GetComponent()); ((Component)val).gameObject.AddComponent(); Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(0.5f, 1f); val.anchorMin = val2; Vector2 pivot = (val.anchorMax = val2); val.pivot = pivot; val.anchoredPosition = Vector2.zero; } } [HarmonyPatch(typeof(UIPlayerNames), "UpdateName")] [HarmonyPostfix] private static void UIPlayerNamesUpdateNameHook(UIPlayerNames __instance, int index, bool visible) { try { if ((Object)(object)__instance == (Object)null || __instance.playerNameText == null || index < 0 || index >= __instance.playerNameText.Length) { return; } PlayerName val = __instance.playerNameText[index]; if (!((Object)(object)val == (Object)null)) { OverheadNameplate overheadNameplate = ((Component)val).GetComponent(); if ((Object)(object)overheadNameplate == (Object)null) { overheadNameplate = ((Component)val).gameObject.AddComponent(); } overheadNameplate.Refresh(val, visible); } } catch { } } [HarmonyPatch(typeof(UIPlayerNames), "DisableName")] [HarmonyPrefix] private static void UIPlayerNamesDisableNameHook(UIPlayerNames __instance, int index) { if (__instance.playerNameText != null && index >= 0 && index < __instance.playerNameText.Length) { PlayerName val = __instance.playerNameText[index]; OverheadNameplate overheadNameplate = default(OverheadNameplate); if ((Object)(object)val != (Object)null && ((Component)val).TryGetComponent(ref overheadNameplate)) { overheadNameplate.Hide(); } } } [HarmonyPatch(typeof(LoadingScreenHandler), "LoadSceneProcess")] [HarmonyPostfix] private static void LoadSceneProcessHook(string sceneName) { if (sceneName.Contains("Level_")) { MapStats.currentLevelName = sceneName; MapStats.currentLevelIndex = -1; Plugin.Logger.LogDebug((object)("After: LoadingScreenHandler.LoadSceneProcess called. sceneName: " + sceneName)); } } } internal static class StringExtensions { public static string TrimToByteLength(this string input, int byteLength) { if (string.IsNullOrEmpty(input)) { return input; } int byteCount = Encoding.UTF8.GetByteCount(input); if (byteCount <= byteLength) { return input; } if (byteCount == input.Length) { return input.Substring(0, byteLength); } byte[] array = Encoding.UTF8.GetBytes(input); Array.Resize(ref array, byteLength); return Encoding.UTF8.GetString(array, 0, byteLength).TrimEnd('\ufffd'); } } public static class PluginConfig { internal static ConfigEntry DisplayTimer { get; private set; } internal static ConfigEntry DisplayHeight { get; private set; } internal static ConfigEntry DisplayLevel { get; private set; } internal static ConfigEntry DisplayBiomes { get; private set; } internal static ConfigEntry DisplaySelfStaminaBar { get; private set; } internal static ConfigEntry DisplayDayNightCountdown { get; private set; } internal static ConfigEntry DisplayFog { get; private set; } internal static ConfigEntry DisplayLava { get; private set; } internal static ConfigEntry DisplayMapSeed { get; private set; } internal static ConfigEntry SelfStaminaBarCount { get; private set; } internal static ConfigEntry DisplayTeammateStaminaBars { get; private set; } internal static ConfigEntry TeammateStaminaBarProximity { get; private set; } internal static ConfigEntry TeammateStaminaBarLimit { get; private set; } internal static ConfigEntry TeammateStaminaBarScale { get; private set; } internal static ConfigEntry OverheadScale { get; private set; } internal static ConfigEntry ShowInventorySlots { get; private set; } internal static ConfigEntry ShowStaminaInfo { get; private set; } internal static ConfigEntry StaminaInfoFontSize { get; private set; } internal static ConfigEntry StaminaInfoOutlineWidth { get; private set; } internal static ConfigEntry StaminaInfoRoundStaminaBars { get; private set; } internal static ConfigEntry StaminaInfoRoundAfflictionBars { get; private set; } internal static ConfigEntry StaminaInfoShowAfflictionCountdown { get; private set; } internal static ConfigEntry StaminaInfoShowHungerCountdown { get; private set; } internal static ConfigEntry StaminaInfoShowTeammateExtraStaminaOutsideBar { get; private set; } public static void Initialize(ConfigFile config, ManualLogSource logger) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Expected O, but got Unknown //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Expected O, but got Unknown //IL_0318: Unknown result type (might be due to invalid IL or missing references) //IL_0322: Expected O, but got Unknown DisplayTeammateStaminaBars = config.Bind("General", "Display Teammate Stamina Bars", true, "Displays your teammates' stamina bars at the bottom left of your screen"); TeammateStaminaBarProximity = config.Bind("General", "Teammate Stamina Bar Proximity", 30f, new ConfigDescription("How close you need to be to your teammate to see their stamina bar", (AcceptableValueBase)(object)new AcceptableValueRange(1f, 10000f), Array.Empty())); TeammateStaminaBarLimit = config.Bind("General", "Teammate Stamina Bar Limit", 4, new ConfigDescription("Max teammate stamina bars", (AcceptableValueBase)(object)new AcceptableValueRange(0, 16), Array.Empty())); TeammateStaminaBarScale = config.Bind("General", "Teammate Stamina Bar Scale (Default: 0.72)", 0.72f, new ConfigDescription("Teammate stamina bars scale", (AcceptableValueBase)(object)new AcceptableValueRange(0.2f, 1f), Array.Empty())); OverheadScale = config.Bind("Overhead", "Overhead Scale", "75%", new ConfigDescription("Overall size of the overhead teammate status bar", (AcceptableValueBase)(object)new AcceptableValueList(new string[4] { "25%", "50%", "75%", "100%" }), Array.Empty())); ShowInventorySlots = config.Bind("General", "Show Inventory Slots", true, "Show teammate inventory slots"); ShowStaminaInfo = config.Bind("General", "Show Stamina Info", true, "Show all stamina bars info number (current stamina, extra stamina, affliction bars) when stamina bar is visible"); DisplayTimer = config.Bind("Stats", "Display Timer", true, "Displays how long you've been climbing for, at the top of your screen"); DisplayHeight = config.Bind("Stats", "Display Height", true, "Displays how far you've climbed, in meters, at the top of your screen"); DisplayLevel = config.Bind("Stats", "Display Level", true, "Displays current map level name, at the top right of your screen"); DisplayBiomes = config.Bind("Stats", "Display Biomes", true, "Displays current map biomes name, at the top right of your screen"); DisplayDayNightCountdown = config.Bind("Stats", "Display Day Night Countdown", true, "Displays current day and night countdown, at the top of your screen"); DisplayFog = config.Bind("Stats", "Display Fog Stats", true, "Displays current fog stats, at the top of your screen"); DisplayLava = config.Bind("Stats", "Display Lava Stats", true, "Displays current kiln lava, gloom, and void ghost rising stats, at the top of your screen"); DisplayMapSeed = config.Bind("Stats", "Display Map Seed", true, "Displays the current map seed from a supported map generation mod, at the top right of your screen"); StaminaInfoFontSize = config.Bind("StaminaInfo", "Bar Font Size", 20f, "Customize the Font Size for stamina bar text."); StaminaInfoOutlineWidth = config.Bind("StaminaInfo", "Bar Outline Width", 0.08f, "Customize the Outline Width for stamina bar text."); StaminaInfoRoundStaminaBars = config.Bind("StaminaInfo", "Round Stamina Bars", true, "If true, rounds to the nearest whole number for the stamina and extra stamina bars."); StaminaInfoRoundAfflictionBars = config.Bind("StaminaInfo", "Round Affliction Bars", false, "If true, rounds to the nearest whole number for affliction bars."); StaminaInfoShowAfflictionCountdown = config.Bind("StaminaInfo", "Show Affliction Countdown", true, "If true, show self affliction bars with countdown."); StaminaInfoShowHungerCountdown = config.Bind("StaminaInfo", "Show Hunger Countdown", true, "If true, show local hunger countdown values in stamina info."); StaminaInfoShowTeammateExtraStaminaOutsideBar = config.Bind("StaminaInfo", "Show Teammate Extra Stamina Outside Bar", false, "If true, show teammate extra stamina values outside the right side of the full extra stamina bar with a + prefix. If false, show them inside the extra stamina bar."); DisplaySelfStaminaBar = config.Bind("Debug", "Display Self Stamina Bar", false, "Displays your stamina bar at the bottom left of your screen"); SelfStaminaBarCount = config.Bind("Debug", "Self Stamina Bar Count", 1, new ConfigDescription("Number of duplicate self stamina bars to display when Display Self Stamina Bar is enabled", (AcceptableValueBase)(object)new AcceptableValueRange(1, 16), Array.Empty())); logger.LogInfo((object)"Plugin Config Loaded."); } } [HarmonyWrapSafe] internal sealed class StaminaInfoPatch { internal static GUIManager guiManager = null; internal static Dictionary barTexts = new Dictionary(); internal static Dictionary lastKnownData = new Dictionary(); internal static Dictionary lastKnownAffData = new Dictionary(); internal static Dictionary lastAfflictionUpdateTime = new Dictionary(); private const float LargeBarThreshold = 30f; private const float SmallBarThreshold = 15f; private const float BarUnitSize = 6f; private const float AfflictionRefreshInterval = 0.5f; private const float HungerIncrementThreshold = 0.025f; private const float CharacterExtraStaminaTextOffsetX = 6f; private const float CharacterExtraStaminaTextWidth = 80f; private const string HiddenHungerCountdownKey = "HiddenHungerCountdown"; private const string YellowTextStart = ""; private const string ColorTextEnd = ""; private static readonly Dictionary hungerIncrementalStatuses = new Dictionary(); private static readonly Dictionary lastTrackedHungerAddTimes = new Dictionary(); private static readonly Dictionary lastObservedRealHungerIncrementalStatuses = new Dictionary(); private static readonly Dictionary lastRealHungerProgressTimes = new Dictionary(); private static readonly Dictionary wasHungerBlockedByVanilla = new Dictionary(); private static readonly FieldInfo? currentIncrementalStatusesField = AccessTools.Field(typeof(CharacterAfflictions), "currentIncrementalStatuses"); private static bool wasHiddenHungerCountdownShown; internal static Dictionary LastUpdateTime { get; set; } = new Dictionary(); [HarmonyPatch(typeof(StaminaBar), "Update")] [HarmonyPostfix] private static void StaminaInfoStaminaBarUpdate(StaminaBar __instance) { try { if ((Object)(object)guiManager == (Object)null) { barTexts = new Dictionary(); lastKnownData = new Dictionary(); lastKnownAffData = new Dictionary(); lastAfflictionUpdateTime = new Dictionary(); InitStaminaInfo(__instance); } if (!PluginConfig.ShowStaminaInfo.Value) { HideBarTexts(__instance); return; } ConstrainStaminaTextToFill(((Object)__instance.staminaBar).name, __instance.staminaBar); if ((Object)(object)Character.observedCharacter != (Object)null) { UpdateBarTexts(__instance); } } catch (Exception ex) { Plugin.Logger.LogError((object)(ex.Message + ex.StackTrace)); } } [HarmonyPatch(typeof(CharacterStaminaBar), "Update")] [HarmonyPostfix] public static void Update(CharacterStaminaBar __instance) { try { int instanceID = ((Object)__instance).GetInstanceID(); if (!LastUpdateTime.ContainsKey(instanceID)) { LastUpdateTime.Add(instanceID, -1f); } if (!barTexts.ContainsKey(GetCharacterStaminaKey(instanceID))) { InitCharacterStaminaInfo(__instance); } if (!PluginConfig.ShowStaminaInfo.Value) { HideCharacterBarTexts(__instance); return; } ConstrainStaminaTextToFill(GetCharacterStaminaKey(instanceID), __instance.staminaBarRectTransform); if ((Object)(object)Character.observedCharacter != (Object)null && Time.time - LastUpdateTime[instanceID] > 1f) { UpdateCharacterBarTexts(__instance); LastUpdateTime[instanceID] = Time.time; } } catch (Exception ex) { Plugin.Logger.LogError((object)(ex.Message + ex.StackTrace)); } } [HarmonyPatch(typeof(CharacterAfflictions), "AddStatus")] [HarmonyPostfix] private static void CharacterAfflictionsAddStatusPostfix(CharacterAfflictions __instance, STATUSTYPE statusType, float amount, bool __result) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 if ((int)statusType != 1 || amount <= 0f) { return; } if (__result) { if (TryReadCurrentIncrementalHunger(__instance, out var currentIncrementalStatus)) { SetFallbackHungerIncrementalStatus(__instance, currentIncrementalStatus); } else { AddFallbackHungerIncrementalStatus(__instance, amount); } } else if (ShouldTrackHungerAdd(__instance)) { AddFallbackHungerIncrementalStatus(__instance, amount); } } private static bool ShouldTrackHungerAdd(CharacterAfflictions afflictions) { Character observedCharacter = Character.observedCharacter; if ((Object)(object)observedCharacter?.refs?.afflictions != (Object)(object)afflictions) { return false; } if (observedCharacter.data.fullyConscious && afflictions.canGetHungry) { return afflictions.hungerPerSecond * Ascents.hungerRateMultiplier > 0f; } return false; } private static void AddFallbackHungerIncrementalStatus(CharacterAfflictions afflictions, float amount) { int instanceID = ((Object)afflictions).GetInstanceID(); hungerIncrementalStatuses.TryGetValue(instanceID, out var value); value += amount; SetFallbackHungerIncrementalStatus(afflictions, (value >= 0.025f) ? 0f : value); } private static void SetFallbackHungerIncrementalStatus(CharacterAfflictions afflictions, float currentIncrementalStatus) { int instanceID = ((Object)afflictions).GetInstanceID(); hungerIncrementalStatuses[instanceID] = currentIncrementalStatus; lastTrackedHungerAddTimes[instanceID] = Time.time; } private static void ClearFallbackHungerIncrementalStatus(CharacterAfflictions afflictions) { hungerIncrementalStatuses[((Object)afflictions).GetInstanceID()] = 0f; } private static float GetFallbackHungerIncrementalStatus(CharacterAfflictions afflictions) { int instanceID = ((Object)afflictions).GetInstanceID(); hungerIncrementalStatuses.TryGetValue(instanceID, out var value); return value; } [HarmonyPatch(typeof(CharacterAfflictions), "SubtractStatus")] [HarmonyPrefix] private static void CharacterAfflictionsSubtractStatusPrefix(CharacterAfflictions __instance, STATUSTYPE statusType, ref float __state) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 __state = (((int)statusType == 1) ? __instance.GetCurrentStatus((STATUSTYPE)1) : (-1f)); } [HarmonyPatch(typeof(CharacterAfflictions), "SubtractStatus")] [HarmonyPostfix] private static void CharacterAfflictionsSubtractStatusPostfix(CharacterAfflictions __instance, STATUSTYPE statusType, float __state) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 if ((int)statusType == 1 && !(__state <= 0f) && __instance.GetCurrentStatus((STATUSTYPE)1) < __state) { hungerIncrementalStatuses[((Object)__instance).GetInstanceID()] = 0f; } } [HarmonyPatch(typeof(CharacterAfflictions), "SetStatus")] [HarmonyPostfix] private static void CharacterAfflictionsSetStatusPostfix(CharacterAfflictions __instance, STATUSTYPE statusType) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 if ((int)statusType == 1) { hungerIncrementalStatuses[((Object)__instance).GetInstanceID()] = 0f; } } private static void UpdateBarTexts(StaminaBar staminaBar) { //IL_00c5: 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_0128: Unknown result type (might be due to invalid IL or missing references) bool forceUpdate; string staminaHungerCountdownSuffix = GetStaminaHungerCountdownSuffix(staminaBar, out forceUpdate); bool flag = GameRef.GetDesiredStaminaSize(staminaBar) >= 15f; UpdateMaxStaminaHungerCountdown(staminaBar, flag ? string.Empty : staminaHungerCountdownSuffix, forceUpdate); UpdateBarText(((Object)staminaBar.staminaBar).name, GameRef.GetDesiredStaminaSize(staminaBar), PluginConfig.StaminaInfoRoundStaminaBars.Value, trimWholeDecimal: false, lastKnownData, "", flag ? staminaHungerCountdownSuffix : string.Empty, forceUpdate); if (forceUpdate) { lastAfflictionUpdateTime["HiddenHungerCountdown"] = Time.time; } UpdateBarText("ExtraStamina", GameRef.GetDesiredExtraStaminaSize(staminaBar), PluginConfig.StaminaInfoRoundStaminaBars.Value, trimWholeDecimal: false, lastKnownData); BarAffliction[] afflictions = staminaBar.afflictions; foreach (BarAffliction val in afflictions) { string name = ((Object)val).name; bool num = CanShowCountdown(val.afflictionType); bool flag2 = num && val.size > 0f && (!lastAfflictionUpdateTime.ContainsKey(name) || Time.time - lastAfflictionUpdateTime[name] > 0.5f); string suffix = string.Empty; if (num && IsCountdownEnabled(val.afflictionType)) { float reductionTimeRemaining = GetReductionTimeRemaining(val.afflictionType); if (reductionTimeRemaining > 0f && !ShouldMoveHungerCountdownToStamina(val, reductionTimeRemaining)) { suffix = "(" + FormatTime(reductionTimeRemaining) + ")"; } } UpdateBarText(name, val.size, PluginConfig.StaminaInfoRoundAfflictionBars.Value, trimWholeDecimal: true, lastKnownAffData, "", suffix, flag2); if (flag2) { lastAfflictionUpdateTime[name] = Time.time; } } } private static void UpdateMaxStaminaHungerCountdown(StaminaBar staminaBar, string suffix, bool forceUpdate) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) if (!barTexts.TryGetValue("HiddenHungerCountdown", out TextMeshProUGUI value)) { return; } if (string.IsNullOrEmpty(suffix)) { ((Component)value).gameObject.SetActive(false); return; } Transform obj = ((Component)staminaBar).transform.Find("LayoutGroup/MaxStamina"); RectTransform val = (RectTransform)(object)((obj is RectTransform) ? obj : null); if (val == null) { ((Component)value).gameObject.SetActive(false); } else if (((TMP_Text)value).GetPreferredValues(suffix).x > val.sizeDelta.x) { ((Component)value).gameObject.SetActive(false); } else if (forceUpdate || !((Component)value).gameObject.activeSelf) { ((TMP_Text)value).text = suffix; ((Component)value).gameObject.SetActive(true); } } private static string GetStaminaHungerCountdownSuffix(StaminaBar staminaBar, out bool forceUpdate) { forceUpdate = false; Character observedCharacter = Character.observedCharacter; CharacterAfflictions val = observedCharacter?.refs?.afflictions; float num = 0f; bool num2 = PluginConfig.StaminaInfoShowHungerCountdown.Value && (Object)(object)observedCharacter != (Object)null && (Object)(object)val != (Object)null; bool flag = false; if (num2) { num = GetHungerIncreaseTimeRemaining(observedCharacter, val); BarAffliction hungerBar = GetHungerBar(staminaBar); flag = num > 0f && ((Object)(object)hungerBar == (Object)null || !IsVisibleAfflictionBar(hungerBar) || ShouldMoveHungerCountdownToStamina(hungerBar, num)); } string text = string.Empty; if (flag) { text = "(" + FormatTime(num) + ")"; } bool flag2 = !string.IsNullOrEmpty(text); forceUpdate = wasHiddenHungerCountdownShown != flag2 || (flag2 && (!lastAfflictionUpdateTime.ContainsKey("HiddenHungerCountdown") || Time.time - lastAfflictionUpdateTime["HiddenHungerCountdown"] > 0.5f)); wasHiddenHungerCountdownShown = flag2; return text; } private static BarAffliction? GetHungerBar(StaminaBar staminaBar) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Invalid comparison between Unknown and I4 BarAffliction[] afflictions = staminaBar.afflictions; foreach (BarAffliction val in afflictions) { if ((int)val.afflictionType == 1) { return val; } } return null; } private static bool IsVisibleAfflictionBar(BarAffliction affliction) { if (((Component)affliction).gameObject.activeSelf) { return affliction.size >= 15f; } return false; } private static bool ShouldMoveHungerCountdownToStamina(BarAffliction affliction, float timeRemaining) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 //IL_005e: Unknown result type (might be due to invalid IL or missing references) if ((int)affliction.afflictionType != 1 || !IsVisibleAfflictionBar(affliction)) { return false; } if (!barTexts.TryGetValue(((Object)affliction).name, out TextMeshProUGUI value)) { return false; } string text = FormatBarValue(affliction.size, PluginConfig.StaminaInfoRoundAfflictionBars.Value, trimWholeDecimal: true); string text2 = "(" + FormatTime(timeRemaining) + ")"; return ((TMP_Text)value).GetPreferredValues(text + text2).x > affliction.size; } public static void UpdateCharacterBarTexts(CharacterStaminaBar characterStaminaBar) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)characterStaminaBar.ObservedCharacter == (Object)null) { return; } int instanceID = ((Object)characterStaminaBar).GetInstanceID(); float size = Mathf.Max(0f, characterStaminaBar.ObservedCharacter.data.currentStamina * characterStaminaBar.fullBarRectTransform.sizeDelta.x); UpdateBarText(GetCharacterStaminaKey(instanceID), size, PluginConfig.StaminaInfoRoundStaminaBars.Value, trimWholeDecimal: false, lastKnownData); float size2 = Mathf.Max(0f, characterStaminaBar.ObservedCharacter.data.extraStamina * characterStaminaBar.fullBarRectTransform.sizeDelta.x); bool value = PluginConfig.StaminaInfoShowTeammateExtraStaminaOutsideBar.Value; ApplyCharacterExtraStaminaTextLayout(characterStaminaBar, value); UpdateBarText(GetCharacterExtraStaminaKey(instanceID), size2, PluginConfig.StaminaInfoRoundStaminaBars.Value, trimWholeDecimal: false, lastKnownData, value ? "+" : string.Empty); foreach (CharacterBarAffliction characterBarAffliction in characterStaminaBar.characterBarAfflictions) { if (!((Object)(object)characterBarAffliction == (Object)null)) { characterBarAffliction.FetchDesiredSize(); UpdateBarText(GetCharacterAfflictionKey(instanceID, characterBarAffliction), characterBarAffliction.size, PluginConfig.StaminaInfoRoundAfflictionBars.Value, trimWholeDecimal: true, lastKnownAffData); } } } private static void UpdateBarText(string key, float size, bool roundLargeValue, bool trimWholeDecimal, Dictionary cache, string prefix = "", string suffix = "", bool forceUpdate = false) { if (!barTexts.TryGetValue(key, out TextMeshProUGUI value)) { return; } bool flag = forceUpdate || !cache.ContainsKey(key) || !Mathf.Approximately(cache[key], size) || !((Component)value).gameObject.activeSelf; if (size < 15f) { ((Component)value).gameObject.SetActive(false); cache[key] = size; return; } string text = prefix + FormatBarValue(size, roundLargeValue, trimWholeDecimal); string text2 = (string.IsNullOrEmpty(suffix) ? text : (text + suffix)); if (flag || ((TMP_Text)value).text != text2) { ((TMP_Text)value).text = text2; ((Component)value).gameObject.SetActive(true); cache[key] = size; } } private static string FormatBarValue(float size, bool roundLargeValue, bool trimWholeDecimal) { if (size >= 30f) { float num = size / 6f; if (roundLargeValue) { return Mathf.Round(num).ToString(); } string text = num.ToString("F1"); if (!trimWholeDecimal) { return text; } return text.Replace(".0", ""); } return Mathf.Round(size / 6f).ToString(); } private static void HideBarTexts(StaminaBar staminaBar) { HideText(((Object)staminaBar.staminaBar).name); HideText("ExtraStamina"); HideText("HiddenHungerCountdown"); BarAffliction[] afflictions = staminaBar.afflictions; for (int i = 0; i < afflictions.Length; i++) { HideText(((Object)afflictions[i]).name); } } private static void HideCharacterBarTexts(CharacterStaminaBar characterStaminaBar) { int instanceID = ((Object)characterStaminaBar).GetInstanceID(); HideText(GetCharacterStaminaKey(instanceID)); HideText(GetCharacterExtraStaminaKey(instanceID)); foreach (CharacterBarAffliction characterBarAffliction in characterStaminaBar.characterBarAfflictions) { HideText(GetCharacterAfflictionKey(instanceID, characterBarAffliction)); } } private static void HideText(string key) { if (barTexts.TryGetValue(key, out TextMeshProUGUI value)) { ((Component)value).gameObject.SetActive(false); } } private static bool CanShowCountdown(STATUSTYPE afflictionType) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Invalid comparison between Unknown and I4 if ((int)afflictionType != 7 && (int)afflictionType != 0) { return (int)afflictionType != 5; } return false; } private static bool IsCountdownEnabled(STATUSTYPE afflictionType) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 if ((int)afflictionType != 1) { return PluginConfig.StaminaInfoShowAfflictionCountdown.Value; } return PluginConfig.StaminaInfoShowHungerCountdown.Value; } private static string GetCharacterStaminaKey(int id) { return id + "_Stamina"; } private static string GetCharacterExtraStaminaKey(int id) { return id + "_ExtraStamina"; } private static string GetCharacterAfflictionKey(int id, CharacterBarAffliction affliction) { return id + "_" + ((Object)((Component)affliction).gameObject).name; } private static void InitStaminaInfo(StaminaBar staminaBar) { guiManager = GameObject.Find("GAME/GUIManager").GetComponent(); AddTextObject(((Component)staminaBar.staminaBar).gameObject, ((Object)staminaBar.staminaBar).name); AddMaxStaminaHungerCountdownTextObject(staminaBar); AddTextObject(((Component)staminaBar.extraBarStamina).gameObject, "ExtraStamina"); BarAffliction[] afflictions = staminaBar.afflictions; foreach (BarAffliction val in afflictions) { AddTextObject(((Component)val).gameObject, ((Object)((Component)val).gameObject).name); } } public static void InitCharacterStaminaInfo(CharacterStaminaBar characterStaminaBar) { int instanceID = ((Object)characterStaminaBar).GetInstanceID(); AddTextObject(((Component)characterStaminaBar.staminaBarRectTransform).gameObject, GetCharacterStaminaKey(instanceID)); if ((Object)(object)characterStaminaBar.extraBar != (Object)null) { string characterExtraStaminaKey = GetCharacterExtraStaminaKey(instanceID); AddTextObject(((Component)characterStaminaBar.extraBar).gameObject, characterExtraStaminaKey); ApplyCharacterExtraStaminaTextLayout(characterStaminaBar, PluginConfig.StaminaInfoShowTeammateExtraStaminaOutsideBar.Value); } foreach (CharacterBarAffliction characterBarAffliction in characterStaminaBar.characterBarAfflictions) { if ((Object)(object)characterBarAffliction != (Object)null && (Object)(object)((Component)characterBarAffliction).gameObject != (Object)null) { AddTextObject(((Component)characterBarAffliction).gameObject, GetCharacterAfflictionKey(instanceID, characterBarAffliction)); } } } private static void ApplyCharacterExtraStaminaTextLayout(CharacterStaminaBar characterStaminaBar, bool showOutsideBar) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) string characterExtraStaminaKey = GetCharacterExtraStaminaKey(((Object)characterStaminaBar).GetInstanceID()); if (!barTexts.TryGetValue(characterExtraStaminaKey, out TextMeshProUGUI value)) { return; } if (showOutsideBar) { if ((Object)(object)((TMP_Text)value).transform.parent != (Object)(object)characterStaminaBar.extraBar) { ((TMP_Text)value).transform.SetParent((Transform)(object)characterStaminaBar.extraBar, false); } ((Graphic)value).color = Color.green; PositionCharacterExtraStaminaTextOutsideBar(value, characterStaminaBar); } else { Transform val = (Transform)(((object)((Transform)characterStaminaBar.extraBarStamina).Find("Stamina")) ?? ((object)characterStaminaBar.extraBarStamina)); if ((Object)(object)((TMP_Text)value).transform.parent != (Object)(object)val) { ((TMP_Text)value).transform.SetParent(val, false); } PositionCharacterExtraStaminaTextInsideBar(value); } } private static void PositionCharacterExtraStaminaTextInsideBar(TextMeshProUGUI text) { //IL_0007: 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_0027: 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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) RectTransform rectTransform = ((TMP_Text)text).rectTransform; rectTransform.anchorMin = Vector2.zero; rectTransform.anchorMax = Vector2.one; rectTransform.pivot = new Vector2(0.5f, 0.5f); rectTransform.anchoredPosition = Vector2.zero; ((Transform)rectTransform).localRotation = Quaternion.identity; ((Transform)rectTransform).localScale = Vector3.one; rectTransform.offsetMin = Vector2.zero; rectTransform.offsetMax = Vector2.zero; ((Graphic)text).color = Color.black; ((TMP_Text)text).alignment = (TextAlignmentOptions)514; } private static void PositionCharacterExtraStaminaTextOutsideBar(TextMeshProUGUI text, CharacterStaminaBar characterStaminaBar) { //IL_000e: 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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0057: 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_007f: 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_009a: 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_00b9: 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) RectTransform rectTransform = ((TMP_Text)text).rectTransform; RectTransform extraBarOutline = characterStaminaBar.extraBarOutline; float num = extraBarOutline.anchoredPosition.x + extraBarOutline.sizeDelta.x * (1f - extraBarOutline.pivot.x); rectTransform.anchorMin = new Vector2(0f, 0.5f); rectTransform.anchorMax = new Vector2(0f, 0.5f); rectTransform.pivot = new Vector2(0f, 0.5f); rectTransform.anchoredPosition = new Vector2(num + 6f, extraBarOutline.anchoredPosition.y); rectTransform.sizeDelta = new Vector2(80f, Mathf.Max(extraBarOutline.sizeDelta.y, 1f)); ((Transform)rectTransform).localRotation = Quaternion.identity; ((Transform)rectTransform).localScale = Vector3.one; ((TMP_Text)text).alignment = (TextAlignmentOptions)513; } private static void AddMaxStaminaHungerCountdownTextObject(StaminaBar staminaBar) { Transform val = ((Component)staminaBar).transform.Find("LayoutGroup/MaxStamina"); if (!((Object)(object)val == (Object)null)) { AddTextObject(((Component)val).gameObject, "HiddenHungerCountdown"); } } internal static void AddTextObject(GameObject gameObj, string barName) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0086: 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_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: 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_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)guiManager == (Object)null) { guiManager = GUIManager.instance; } if ((Object)(object)guiManager == (Object)null) { return; } TMP_FontAsset font = ((TMP_Text)guiManager.heroDayText).font; GameObject val = new GameObject("StaminaInfo"); val.transform.SetParent(gameObj.transform); TextMeshProUGUI val2 = val.AddComponent(); RectTransform component = val.GetComponent(); gameObj.SetActive(true); ((TMP_Text)val2).font = font; ((TMP_Text)val2).fontSize = PluginConfig.StaminaInfoFontSize.Value; component.anchorMin = Vector2.zero; component.anchorMax = Vector2.one; component.pivot = new Vector2(0.5f, 0.5f); component.anchoredPosition = Vector2.zero; ((Transform)component).localRotation = Quaternion.identity; CharacterBarAffliction characterBarAffliction = default(CharacterBarAffliction); ((Transform)component).localScale = (Vector3)((gameObj.TryGetComponent(ref characterBarAffliction) && characterBarAffliction.isPetrify) ? new Vector3(1.4285715f, 2f, 1f) : Vector3.one); component.offsetMin = Vector2.zero; component.offsetMax = Vector2.zero; ((TMP_Text)val2).alignment = (TextAlignmentOptions)514; ((TMP_Text)val2).verticalAlignment = (VerticalAlignmentOptions)8192; ((TMP_Text)val2).richText = true; ((TMP_Text)val2).textWrappingMode = (TextWrappingModes)0; ((TMP_Text)val2).text = ""; ((Component)val2).gameObject.SetActive(false); barTexts[barName] = val2; lastKnownData[barName] = 0f; lastKnownAffData[barName] = 0f; lastAfflictionUpdateTime[barName] = -1f; try { ((TMP_Text)val2).outlineWidth = PluginConfig.StaminaInfoOutlineWidth.Value; } catch { } } private static void ConstrainStaminaTextToFill(string key, RectTransform fillRectTransform) { if (barTexts.TryGetValue(key, out TextMeshProUGUI value)) { SetStaminaTextBounds(value, fillRectTransform); } } private static void SetStaminaTextBounds(TextMeshProUGUI text, RectTransform fillRectTransform) { //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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: 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_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) Rect rect = fillRectTransform.rect; float num = Mathf.Max(0f, ((Rect)(ref rect)).width); Transform parent = ((Transform)fillRectTransform).parent; RectTransform val = (RectTransform)(object)((parent is RectTransform) ? parent : null); if (val != null) { float num2 = num; rect = val.rect; num = Mathf.Min(num2, Mathf.Max(0f, ((Rect)(ref rect)).width)); } RectTransform rectTransform = ((TMP_Text)text).rectTransform; rectTransform.anchorMin = Vector2.zero; rectTransform.anchorMax = new Vector2(0f, 1f); rectTransform.pivot = new Vector2(0f, 0.5f); rectTransform.anchoredPosition = Vector2.zero; rectTransform.sizeDelta = new Vector2(num, 0f); } private static float GetReductionTimeRemaining(STATUSTYPE statusType) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Invalid comparison between Unknown and I4 //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Invalid comparison between Unknown and I4 //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: 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) CharacterAfflictions val = Character.observedCharacter?.refs?.afflictions; if ((Object)(object)val == (Object)null) { return 0f; } if ((int)statusType == 1) { Character observedCharacter = Character.observedCharacter; if (!((Object)(object)observedCharacter == (Object)null)) { return GetHungerIncreaseTimeRemaining(observedCharacter, val); } return 0f; } if ((int)statusType == 9) { float num = 0f; int num2 = 0; foreach (ThornOnMe physicalThorn in val.physicalThorns) { if (physicalThorn.stuckIn) { num2++; num += Time.time - GameRef.GetPopOutTime(physicalThorn); } } if (num2 == 0) { return 0f; } return Mathf.Abs(num) / (float)num2; } float currentStatus = val.GetCurrentStatus(statusType); if (currentStatus <= 0f) { return 0f; } float reductionRate = GetReductionRate(val, statusType); if (reductionRate <= 0f) { return 0f; } float cooldown = GetCooldown(val, statusType); float num3 = val.LastAddedStatus(statusType); float time = Time.time; if (cooldown > 0f && time - num3 < cooldown) { float num4 = cooldown - (time - num3); float num5 = currentStatus / reductionRate; return num4 + num5; } return currentStatus / reductionRate; } private static float GetHungerIncreaseTimeRemaining(Character character, CharacterAfflictions afflictions) { if ((Object)(object)character == (Object)null || (Object)(object)character != (Object)(object)Character.localCharacter || !character.data.fullyConscious || GameRef.GetInAirport(afflictions)) { return 0f; } float num = afflictions.hungerPerSecond * Ascents.hungerRateMultiplier; if (num <= 0f) { return 0f; } int num2; if (!GameRef.GetIsInvincible(character.data)) { num2 = ((!afflictions.canGetHungry) ? 1 : 0); if (num2 == 0) { wasHungerBlockedByVanilla[((Object)afflictions).GetInstanceID()] = false; goto IL_0081; } } else { num2 = 1; } ResetRealHungerProgressWhenBlockedStateStarts(afflictions); goto IL_0081; IL_0081: bool flag = HasRecentlyObservedRealHungerProgress(afflictions); if (num2 != 0 && !flag) { ClearFallbackHungerIncrementalStatus(afflictions); } float hungerIncrementalStatus = GetHungerIncrementalStatus(afflictions); float num3 = 0.025f - hungerIncrementalStatus; if (num3 <= 0f) { num3 = 0.025f; } return num3 / num; } private static void ResetRealHungerProgressWhenBlockedStateStarts(CharacterAfflictions afflictions) { int instanceID = ((Object)afflictions).GetInstanceID(); if (!(wasHungerBlockedByVanilla.TryGetValue(instanceID, out var value) && value)) { wasHungerBlockedByVanilla[instanceID] = true; lastRealHungerProgressTimes.Remove(instanceID); if (TryReadCurrentIncrementalHunger(afflictions, out var currentIncrementalStatus)) { lastObservedRealHungerIncrementalStatuses[instanceID] = currentIncrementalStatus; } } } private static bool HasRecentlyObservedRealHungerProgress(CharacterAfflictions afflictions) { int instanceID = ((Object)afflictions).GetInstanceID(); if (TryReadCurrentIncrementalHunger(afflictions, out var currentIncrementalStatus)) { if (lastObservedRealHungerIncrementalStatuses.TryGetValue(instanceID, out var value) && currentIncrementalStatus > value) { lastRealHungerProgressTimes[instanceID] = Time.time; } lastObservedRealHungerIncrementalStatuses[instanceID] = currentIncrementalStatus; } if (lastRealHungerProgressTimes.TryGetValue(instanceID, out var value2)) { return Time.time - value2 <= 1f; } return false; } private static float GetHungerIncrementalStatus(CharacterAfflictions afflictions) { float fallbackHungerIncrementalStatus = GetFallbackHungerIncrementalStatus(afflictions); if (TryReadCurrentIncrementalHunger(afflictions, out var currentIncrementalStatus)) { return Mathf.Max(currentIncrementalStatus, fallbackHungerIncrementalStatus); } return fallbackHungerIncrementalStatus; } private static bool TryReadCurrentIncrementalHunger(CharacterAfflictions afflictions, out float currentIncrementalStatus) { currentIncrementalStatus = 0f; if (!(currentIncrementalStatusesField?.GetValue(afflictions) is float[] array)) { return false; } int num = 1; if (num < 0 || num >= array.Length) { return false; } currentIncrementalStatus = array[num]; return true; } private static float GetReductionRate(CharacterAfflictions afflictions, STATUSTYPE statusType) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 //IL_0004: 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_0020: Expected I4, but got Unknown if ((int)statusType != 3) { return (statusType - 6) switch { 2 => afflictions.hotReductionPerSecond, 4 => afflictions.sporesReductionPerSecond, 0 => afflictions.drowsyReductionPerSecond, _ => 0f, }; } return afflictions.poisonReductionPerSecond; } private static float GetCooldown(CharacterAfflictions afflictions, STATUSTYPE statusType) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 //IL_0004: 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_0020: Expected I4, but got Unknown if ((int)statusType != 3) { return (statusType - 6) switch { 2 => afflictions.hotReductionCooldown, 4 => afflictions.sporesReductionCooldown, 0 => afflictions.drowsyReductionCooldown, _ => 0f, }; } return afflictions.poisonReductionCooldown; } private static string FormatTime(float seconds) { if (seconds < 60f) { return Mathf.CeilToInt(seconds).ToString(); } if (seconds < 3600f) { int num = Mathf.FloorToInt(seconds / 60f); int num2 = Mathf.CeilToInt(seconds % 60f); return $"{num}:{num2:D2}"; } int num3 = Mathf.FloorToInt(seconds / 3600f); int num4 = Mathf.FloorToInt(seconds % 3600f / 60f); return $"{num3}:{num4:D2}"; } } } namespace PeakOverheadStats.Compatibility { internal sealed class PllRouteProjection { public string?[] SegmentTitles { get; } = Array.Empty(); } internal static class PLLCompatibility { public static bool Enabled => false; public static bool MapActive => false; public static bool TryGetMapSeed(out int seed) { seed = 0; return false; } public static bool TryCreateRouteProjection(MapSegment[] segments, ProgressPoint[] progressPoints, out PllRouteProjection projection) { projection = new PllRouteProjection(); return false; } } internal static class TerrainCustomiserCompatibility { public static bool Enabled => false; public static bool TryGetMapSeed(out int seed) { seed = 0; return false; } } internal static class TerrainRandomiserCompatibility { public static bool Enabled => false; public static bool TryGetMapSeed(out int seed) { seed = 0; return false; } } internal enum TfaRouteStatus { NotApplicable, Pending, Ready, Unsupported } internal sealed class TfaRouteStage { internal object Source { get; } internal int SegmentIndex { get; } internal int ChainIndex { get; } internal BiomeType BiomeType { get; } internal string TitleKey { get; } internal Transform Terrain { get; } internal TfaRouteStage(object source, int segmentIndex, int chainIndex, BiomeType biomeType, string titleKey, Transform terrain) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) Source = source; SegmentIndex = segmentIndex; ChainIndex = chainIndex; BiomeType = biomeType; TitleKey = titleKey; Terrain = terrain; } } internal sealed class TfaRouteProjection { internal IReadOnlyList Stages { get; } internal TfaRouteProjection(List stages) { Stages = stages; } } internal sealed class TrueFinalAscentCompatibility { private sealed class StageContract { private const BindingFlags StaticFlags = BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic; private const BindingFlags InstanceFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; internal string? FailureReason { get; private set; } internal Type? StageType { get; } internal PropertyInfo? Active { get; } internal PropertyInfo? Seed { get; } internal PropertyInfo? Done { get; } internal PropertyInfo? Ready { get; } internal PropertyInfo? Building { get; } internal PropertyInfo? Aborted { get; } internal PropertyInfo? CurrentStage { get; } internal MethodInfo? AllStages { get; } internal FieldInfo? SegmentIndex { get; } internal FieldInfo? ChainIndex { get; } internal FieldInfo? BiomeType { get; } internal FieldInfo? Title { get; } internal FieldInfo? Terrain { get; } internal StageContract(Assembly assembly) { Type type = FindType(assembly, "FinalAscent"); Active = GetProperty(type, "Active", typeof(bool)); Seed = GetProperty(type, "Seed", typeof(int)); Type type2 = FindType(assembly, "FinalAscentBuilder"); Done = GetProperty(type2, "Done", typeof(bool)); Ready = GetProperty(type2, "Ready", typeof(bool)); Building = GetProperty(type2, "Building", typeof(bool)); Aborted = GetProperty(type2, "Aborted", typeof(bool)); StageType = FindType(assembly, "FinalAscentStage"); Type type3 = FindType(assembly, "FinalAscentSegments"); CurrentStage = GetProperty(type3, "CurrentStage", StageType); AllStages = type3?.GetMethod("AllStages", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null); if ((AllStages == null || StageType == null || !typeof(IEnumerable<>).MakeGenericType(StageType).IsAssignableFrom(AllStages.ReturnType)) && FailureReason == null) { string text = (FailureReason = "FinalAscentSegments.AllStages has an unsupported signature."); } SegmentIndex = GetField("SegmentIndex", typeof(int)); ChainIndex = GetField("ChainIndex", typeof(int)); BiomeType = GetField("Type", typeof(BiomeType)); Title = GetField("Title", typeof(string)); Terrain = GetField("Terrain", typeof(GameObject)); } private Type? FindType(Assembly assembly, string name) { Type? type = assembly.GetType("TrueFinalAscent." + name); if (type == null && FailureReason == null) { string text = (FailureReason = "TrueFinalAscent." + name + " is missing."); } return type; } private PropertyInfo? GetProperty(Type? type, string name, Type? expectedType) { PropertyInfo propertyInfo = type?.GetProperty(name, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (!(propertyInfo == null) && !(propertyInfo.PropertyType != expectedType)) { MethodInfo? getMethod = propertyInfo.GetGetMethod(nonPublic: true); if ((object)getMethod != null && getMethod.IsStatic && propertyInfo.GetIndexParameters().Length == 0) { return propertyInfo; } } if (FailureReason == null) { string text = (FailureReason = type?.Name + "." + name + " has an unsupported signature."); } return null; } private FieldInfo? GetField(string name, Type expectedType) { FieldInfo fieldInfo = StageType?.GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (fieldInfo == null || fieldInfo.FieldType != expectedType) { if (FailureReason == null) { string text = (FailureReason = "FinalAscentStage." + name + " has an unsupported type."); } return null; } return fieldInfo; } } private const string PluginGuid = "com.CptPICHU.peak.truefinalascent"; private static readonly Dictionary Contracts = new Dictionary(); private static readonly HashSet WarnedAssemblies = new HashSet(); private Assembly? cachedAssembly; private Assembly? cachedSeedAssembly; private MapHandler? cachedMapHandler; private MapSegment[]? cachedSegments; private TfaRouteProjection? cachedProjection; private StageContract? currentContract; private MapHandler? contextMapHandler; private Scene contextScene; private string? failureReason; private bool seedReady; internal TfaRouteStatus ReadSeedStatus(Scene scene, MapHandler? mapHandler, bool atTerminal, out bool assemblyChanged) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) TfaRouteProjection projection; int currentIndex; TfaRouteStatus result = ReadRoute(scene, mapHandler, atTerminal, out projection, out currentIndex); assemblyChanged = (object)cachedSeedAssembly != cachedAssembly; cachedSeedAssembly = cachedAssembly; return result; } internal bool TryGetMapSeed(out int seed) { seed = 0; if (!seedReady || currentContract?.Seed == null) { return false; } seed = (int)currentContract.Seed.GetValue(null); return true; } internal TfaRouteStatus ReadRoute(Scene scene, MapHandler? mapHandler, bool atTerminal, out TfaRouteProjection? projection, out int currentIndex) { //IL_0094: 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_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: 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_018a: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_0237: 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) projection = null; currentIndex = -1; seedReady = false; if (!Chainloader.PluginInfos.TryGetValue("com.CptPICHU.peak.truefinalascent", out var value)) { ClearProjection(); cachedAssembly = null; currentContract = null; failureReason = null; return TfaRouteStatus.NotApplicable; } if ((Object)(object)value.Instance == (Object)null) { ClearProjection(); return TfaRouteStatus.Pending; } Assembly assembly = ((object)value.Instance).GetType().Assembly; if ((object)cachedAssembly != assembly || contextScene != scene || contextMapHandler != mapHandler) { ClearProjection(); cachedAssembly = assembly; contextScene = scene; contextMapHandler = mapHandler; failureReason = null; } if (!Contracts.TryGetValue(assembly, out StageContract value2)) { value2 = new StageContract(assembly); Contracts.Add(assembly, value2); } currentContract = value2; if (value2.Active != null && !(bool)value2.Active.GetValue(null)) { ClearProjection(); return TfaRouteStatus.NotApplicable; } if (value2.FailureReason != null || failureReason != null) { return Unsupported(value, assembly, value2.FailureReason ?? failureReason); } if (!(bool)value2.Done.GetValue(null) || !(bool)value2.Ready.GetValue(null) || (bool)value2.Building.GetValue(null) || (bool)value2.Aborted.GetValue(null) || (Object)(object)mapHandler == (Object)null || !MapHandler.ExistsAndInitialized || ((Component)mapHandler).gameObject.scene != scene || mapHandler.segments == null) { ClearProjection(); return TfaRouteStatus.Pending; } MapSegment[] segments = mapHandler.segments; if ((Object)(object)cachedMapHandler != (Object)(object)mapHandler || cachedSegments != segments) { ClearProjection(); cachedMapHandler = mapHandler; cachedSegments = segments; } object value3 = value2.CurrentStage.GetValue(null); currentIndex = FindCurrentStage(value2, value3); int num; if (currentIndex >= 0) { if (Object.op_Implicit((Object)(object)cachedProjection.Stages[currentIndex].Terrain)) { object? value4 = value2.Terrain.GetValue(value3); GameObject val = (GameObject)((value4 is GameObject) ? value4 : null); if (val != null && !((Object)(object)val == (Object)null) && !(val.scene != scene)) { num = (((Object)(object)cachedProjection.Stages[currentIndex].Terrain != (Object)(object)val.transform) ? 1 : 0); goto IL_026e; } } num = 1; } else { num = 0; } goto IL_026e; IL_026e: bool flag = (byte)num != 0; if (cachedProjection == null || flag || (currentIndex < 0 && !atTerminal)) { string reason; TfaRouteStatus tfaRouteStatus = Capture(scene, segments, value2, out reason); switch (tfaRouteStatus) { case TfaRouteStatus.Unsupported: return Unsupported(value, assembly, reason); case TfaRouteStatus.Pending: ClearProjection(); return tfaRouteStatus; } currentIndex = FindCurrentStage(value2, value3); } if (currentIndex < 0 && !atTerminal) { return Unsupported(value, assembly, "CurrentStage does not match the completed stage chain."); } projection = cachedProjection; seedReady = true; return TfaRouteStatus.Ready; } private int FindCurrentStage(StageContract contract, object? currentStage) { if (cachedProjection == null || currentStage == null || !contract.StageType.IsInstanceOfType(currentStage)) { return -1; } int num = (int)contract.SegmentIndex.GetValue(currentStage); int num2 = (int)contract.ChainIndex.GetValue(currentStage); for (int i = 0; i < cachedProjection.Stages.Count; i++) { TfaRouteStage tfaRouteStage = cachedProjection.Stages[i]; if (tfaRouteStage.Source == currentStage && tfaRouteStage.SegmentIndex == num && tfaRouteStage.ChainIndex == num2) { return i; } } return -1; } private TfaRouteStatus Capture(Scene scene, MapSegment[] segments, StageContract contract, out string reason) { //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_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Invalid comparison between Unknown and I4 //IL_015c: 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_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Invalid comparison between Unknown and I4 reason = ""; if (!(contract.AllStages.Invoke(null, null) is IEnumerable enumerable)) { reason = "AllStages returned no stage sequence."; return TfaRouteStatus.Unsupported; } List list = new List(); HashSet<(int, int)> hashSet = new HashSet<(int, int)>(); VoidBiome instance = VoidBiome.instance; foreach (object item in enumerable) { if (item == null || !contract.StageType.IsInstanceOfType(item)) { reason = "AllStages contains an invalid stage object."; return TfaRouteStatus.Unsupported; } int num = (int)contract.SegmentIndex.GetValue(item); int num2 = (int)contract.ChainIndex.GetValue(item); BiomeType val = (BiomeType)contract.BiomeType.GetValue(item); if (num < 0 || num >= segments.Length || num2 < 0 || !hashSet.Add((num, num2))) { reason = $"AllStages has an invalid or repeated identity ({num}, {num2})."; return TfaRouteStatus.Unsupported; } if ((int)val != 17 && (!((Object)(object)instance != (Object)null) || segments[num] != instance.segment)) { object? value = contract.Terrain.GetValue(item); GameObject val2 = (GameObject)((value is GameObject) ? value : null); if (val2 == null || (Object)(object)val2 == (Object)null) { reason = $"Stage ({num}, {num2}) has no terrain."; return TfaRouteStatus.Unsupported; } if (val2.scene != scene) { return TfaRouteStatus.Pending; } string text = (contract.Title.GetValue(item) as string) ?? ""; if (num == 3 && num2 == 0 && (int)val == 3 && text == "THE KILN") { text = "CALDERA"; } list.Add(new TfaRouteStage(item, num, num2, val, text, val2.transform)); } } if (list.Count == 0) { reason = "The completed stage chain contains no visible route stages."; return TfaRouteStatus.Unsupported; } cachedProjection = new TfaRouteProjection(list); return TfaRouteStatus.Ready; } private TfaRouteStatus Unsupported(PluginInfo plugin, Assembly assembly, string reason) { ClearProjection(); failureReason = reason; seedReady = false; if (WarnedAssemblies.Add(assembly)) { Plugin.Logger.LogWarning((object)($"True Final Ascent {plugin.Metadata.Version} compatibility failed: {reason} " + "Using the original biome collection instead. Map seed display is disabled.")); } return TfaRouteStatus.Unsupported; } internal void ResetRoute() { ClearProjection(); seedReady = false; } private void ClearProjection() { cachedMapHandler = null; cachedSegments = null; cachedProjection = null; } } } namespace PeakOverheadStats.MonoBehaviours { internal sealed class CharacterBarAffliction : MonoBehaviour { internal STATUSTYPE afflictionType; internal bool isPetrify; private RectTransform rectTransform; private CharacterStaminaBar characterStaminaBar; internal float size; internal void FetchReferences() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown rectTransform = (RectTransform)((Component)this).transform; Transform val = ((Component)this).transform.Find("Icon"); if ((Object)(object)val != (Object)null) { ((Component)val).gameObject.SetActive(false); } characterStaminaBar = ((Component)this).GetComponentInParent(); if ((Object)(object)characterStaminaBar == (Object)null) { Transform parent = ((Component)this).transform.parent; while ((Object)(object)parent != (Object)null && (Object)(object)characterStaminaBar == (Object)null) { characterStaminaBar = ((Component)parent).GetComponent(); parent = parent.parent; } } if ((Object)(object)characterStaminaBar != (Object)null) { characterStaminaBar.AddCharacterBarAffliction(this); } } internal void FetchDesiredSize() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Invalid comparison between Unknown and I4 //IL_00b6: 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) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)characterStaminaBar == (Object)null) { return; } Character observedCharacter = characterStaminaBar.ObservedCharacter; if (!Object.op_Implicit((Object)(object)observedCharacter)) { return; } if ((int)afflictionType == 7 && !isPetrify && IsAirportScene()) { float x = characterStaminaBar.fullBarRectTransform.sizeDelta.x; float x2 = characterStaminaBar.staminaBarRectTransform.sizeDelta.x; size = Mathf.Max(0f, x - x2); if (size > 2f) { ((Component)this).gameObject.SetActive(true); } else { ((Component)this).gameObject.SetActive(false); } return; } float num = (isPetrify ? ((float)observedCharacter.data.petrifyAmount / 100f) : observedCharacter.refs.afflictions.GetCurrentStatus(afflictionType)); size = characterStaminaBar.fullBarRectTransform.sizeDelta.x * num; if (num > 0.01f) { if (size < characterStaminaBar.minAfflictionWidth) { size = characterStaminaBar.minAfflictionWidth; } ((Component)this).gameObject.SetActive(true); } else { ((Component)this).gameObject.SetActive(false); } } private static bool IsAirportScene() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) Scene activeScene = SceneManager.GetActiveScene(); return ((Scene)(ref activeScene)).name == "Airport"; } internal void UpdateVisual() { //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_0014: 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) Vector2 sizeDelta = rectTransform.sizeDelta; sizeDelta.x = Mathf.Lerp(rectTransform.sizeDelta.x, size, Mathf.Min(Time.deltaTime * 10f, 0.1f)); rectTransform.sizeDelta = sizeDelta; } } internal sealed class CharacterStaminaBar : MonoBehaviour { private const float SampleScaleLow = 0.6f; private const float DefaultTeammateScale = 0.72f; private const float SampleScaleHigh = 1f; private const float DefaultTeammateVisualYOffset = 10f; private const float ExtraBarExpandedSize = 28f; private const float TeammateExtraStaminaFillOffsetX = 5f; private const float InventorySlotsBaseX = 284f; private const float HeaderRowWidth = 600f; private const float HeaderVisualGap = -2f; private const float SelectedSlotEnvelopeScale = 1.38f; private const float LargestInventorySlotSize = 38f; private const float HeaderRowHeight = 52.44f; internal const float ExtraStaminaBarWidthScale = 0.7f; internal const float PetrifyBarHeightScale = 0.5f; private static readonly Color defaultBarColor = new Color(0.12f, 0.12f, 0.15f, 0.7f); private static readonly Color outOfStaminaColor = new Color(0.566f, 0.0089f, 0.0089f, 1f); private float minStaminaBarWidth = 20f; internal float minAfflictionWidth = 60f; internal RectTransform fullBarRectTransform; internal RectTransform staminaBarRectTransform; internal RectTransform maxStaminaBarRectTransform; internal RectTransform staminaBarOutlineRectTransform; internal RectTransform staminaBarOutlineOverflowBar; internal Image barImage; internal Image glowImage; internal RectTransform extraBar; internal RectTransform extraBarStamina; internal RectTransform extraBarOutline; internal GameObject shieldIcon; internal GameObject campfireIcon; private float staminaBarOffset; internal readonly List characterBarAfflictions = new List(); private CharacterBarAffliction? petrifyAffliction; private Coroutine? animateDisableCoroutine; private Character? _observedCharacter; private bool hadObservedCharacter; private bool outOfStamina; private bool sequencingExtraBar; private bool isEnabled; private float sinTime; private readonly float TAU = MathF.PI * 2f; private float desiredExtraStaminaSize; private float extraOutlineMaxWidth; private float extraBarDefaultVisualGap; private RectTransform headerRowRectTransform; private readonly Vector3[] outlineWorldCorners = (Vector3[])(object)new Vector3[4]; private readonly List inventorySlotUIs = new List(); private readonly List backpackSlotUIs = new List(); private InventorySlotUI? heldItemSlot; private bool inventorySlotsCreated; private bool inventorySlotsVisible; private float appliedTeammateVisualYOffset; internal Character? ObservedCharacter { get { return _observedCharacter; } set { if ((Object)(object)value != (Object)null) { hadObservedCharacter = true; } _observedCharacter = value; if ((Object)(object)value != (Object)null) { ApplyTeammateVisualOffset(); } } } internal void AnimateEnable() { if (!isEnabled && animateDisableCoroutine == null) { isEnabled = true; ((Component)this).gameObject.SetActive(true); animateDisableCoroutine = ((MonoBehaviour)this).StartCoroutine(EnableIEnumerator()); } } internal void AnimateDisable() { if (isEnabled && animateDisableCoroutine == null) { isEnabled = false; animateDisableCoroutine = ((MonoBehaviour)this).StartCoroutine(DisableIEnumerator()); } } private void OnDisable() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) ShortcutExtensions.DOKill((Component)(object)((Component)this).transform, false); ((MonoBehaviour)this).StopAllCoroutines(); animateDisableCoroutine = null; isEnabled = false; ((Component)this).transform.localScale = Vector3.zero; if (((Component)this).gameObject.activeSelf) { ((Component)this).gameObject.SetActive(false); } } internal void InitializeHeader(RectTransform playerNameRectTransform) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004d: 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_0064: 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_008f: Unknown result type (might be due to invalid IL or missing references) ((Transform)playerNameRectTransform).SetParent((Transform)(object)headerRowRectTransform, false); playerNameRectTransform.anchorMin = new Vector2(0f, 0f); playerNameRectTransform.anchorMax = new Vector2(0f, 0f); playerNameRectTransform.pivot = new Vector2(0f, 0f); playerNameRectTransform.anchoredPosition = Vector2.zero; ((Transform)playerNameRectTransform).localScale = Vector3.one; playerNameRectTransform.sizeDelta = new Vector2(playerNameRectTransform.sizeDelta.x, 52.44f); ((Component)playerNameRectTransform).gameObject.SetActive(true); ((Transform)headerRowRectTransform).localScale = Vector3.one; ((Component)headerRowRectTransform).gameObject.SetActive(true); UpdateHeaderRowPosition(); } private void Awake() { Plugin.Logger.LogDebug((object)"[UpdateStaminaBar] CharacterStaminaBar Awake"); StaminaBar val = default(StaminaBar); if (((Component)this).TryGetComponent(ref val)) { staminaBarOffset = val.staminaBarOffset; minStaminaBarWidth = val.minStaminaBarWidth; minAfflictionWidth = val.minAfflictionWidth; DisableMoraleBoostUi(val); } CacheStaminaBarReferences(); CreateHeaderRow(); if ((Object)(object)val != (Object)null) { CreateExtraStaminaBar(val); if ((Object)(object)val.extraBar != (Object)null) { ((Component)val.extraBar).gameObject.SetActive(false); } } } private void Update() { if (!Object.op_Implicit((Object)(object)ObservedCharacter) || !((Component)ObservedCharacter).gameObject.activeSelf) { if (hadObservedCharacter) { Object.Destroy((Object)(object)((Component)this).gameObject); } return; } ApplyConfiguredScale(); ApplyTeammateVisualOffset(); ApplyExtraBarScaleCompensation(); UpdateStaminaBar(); UpdateExtraStaminaBar(); if (PluginConfig.ShowInventorySlots.Value) { EnsureInventorySlotsCreated(); inventorySlotsVisible = true; UpdateInventorySlots(); } else if (inventorySlotsVisible) { ClearInventorySlots(); inventorySlotsVisible = false; } UpdateHeaderRowPosition(); } private void CreateHeaderRow() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("HeaderRow", new Type[1] { typeof(RectTransform) }); headerRowRectTransform = val.GetComponent(); ((Transform)headerRowRectTransform).SetParent(((Component)this).transform, false); headerRowRectTransform.anchorMin = new Vector2(0.5f, 0.5f); headerRowRectTransform.anchorMax = new Vector2(0.5f, 0.5f); headerRowRectTransform.pivot = new Vector2(0.5f, 0f); headerRowRectTransform.sizeDelta = new Vector2(600f, 52.44f); headerRowRectTransform.anchoredPosition = Vector2.zero; } private void UpdateHeaderRowPosition() { //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: 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) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010e: 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) if ((Object)(object)headerRowRectTransform == (Object)null || (Object)(object)staminaBarOutlineRectTransform == (Object)null || animateDisableCoroutine != null) { return; } try { headerRowRectTransform.pivot = new Vector2(0f, 0f); staminaBarOutlineRectTransform.GetWorldCorners(outlineWorldCorners); float num = float.NegativeInfinity; for (int i = 0; i < outlineWorldCorners.Length; i++) { Vector3 val = ((Component)this).transform.InverseTransformPoint(outlineWorldCorners[i]); num = Mathf.Max(num, val.y); } staminaBarRectTransform.GetWorldCorners(outlineWorldCorners); float num2 = float.PositiveInfinity; for (int j = 0; j < outlineWorldCorners.Length; j++) { Vector3 val2 = ((Component)this).transform.InverseTransformPoint(outlineWorldCorners[j]); num2 = Mathf.Min(num2, val2.x); } float num3 = num + -2f / GetConfiguredScale(); Vector3 localPosition = ((Transform)headerRowRectTransform).localPosition; ((Transform)headerRowRectTransform).localPosition = new Vector3(num2, num3, localPosition.z); } catch { headerRowRectTransform.pivot = new Vector2(0f, 0f); ((Transform)headerRowRectTransform).localPosition = new Vector3(-150f, 40f, 0f); } } private void CacheStaminaBarReferences() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown //IL_00b7: 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_00e1: Expected O, but got Unknown fullBarRectTransform = (RectTransform)((Component)this).transform.Find("FullBar"); maxStaminaBarRectTransform = (RectTransform)((Component)this).transform.Find("LayoutGroup/MaxStamina"); staminaBarOutlineRectTransform = (RectTransform)((Component)this).transform.Find("OutlineMask/Outline"); staminaBarOutlineOverflowBar = (RectTransform)((Component)this).transform.Find("OutlineOverflowLine"); Transform val = (((Object)(object)maxStaminaBarRectTransform != (Object)null) ? ((Transform)maxStaminaBarRectTransform).Find("Back") : null); if ((Object)(object)val != (Object)null) { barImage = ((Component)val).GetComponent(); if ((Object)(object)barImage != (Object)null) { ((Graphic)barImage).color = defaultBarColor; staminaBarRectTransform = (RectTransform)((Component)barImage).transform.Find("Stamina"); } } Transform val2 = (((Object)(object)staminaBarRectTransform != (Object)null) ? ((Transform)staminaBarRectTransform).Find("Glow") : null); if ((Object)(object)val2 != (Object)null) { glowImage = ((Component)val2).GetComponent(); } if ((Object)(object)staminaBarOutlineRectTransform != (Object)null) { Transform val3 = ((Transform)staminaBarOutlineRectTransform).Find("CampfireIcon"); if ((Object)(object)val3 != (Object)null) { campfireIcon = ((Component)val3).gameObject; } Transform val4 = ((Transform)staminaBarOutlineRectTransform).Find("ShieldIcon"); if ((Object)(object)val4 != (Object)null) { shieldIcon = ((Component)val4).gameObject; } } } private static void DisableMoraleBoostUi(StaminaBar original) { if ((Object)(object)original.moraleBoostAnimator != (Object)null) { ((Behaviour)original.moraleBoostAnimator).enabled = false; } if ((Object)(object)original.moraleBoostText != (Object)null) { ((Behaviour)original.moraleBoostText).enabled = false; ((Component)original.moraleBoostText).gameObject.SetActive(false); } } private void CreateExtraStaminaBar(StaminaBar original) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0090: 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_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: 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_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: 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_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014a: 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_015f: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_02e9: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: 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_030d: Unknown result type (might be due to invalid IL or missing references) //IL_031d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)fullBarRectTransform == (Object)null) { Plugin.Logger.LogDebug((object)"[CreateExtraStaminaBar] fullBar not found"); return; } GameObject val = new GameObject("FriendExtraBar"); val.transform.SetParent(((Component)this).transform, false); extraBar = val.AddComponent(); RectTransform obj = extraBar; RectTransform obj2 = extraBar; Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(0f, 0.5f); obj2.anchorMax = val2; obj.anchorMin = val2; extraBar.pivot = new Vector2(0f, 0.5f); Vector2 anchoredPosition = fullBarRectTransform.anchoredPosition; extraBar.anchoredPosition = new Vector2(anchoredPosition.x, anchoredPosition.y - 31f); extraBarDefaultVisualGap = (fullBarRectTransform.anchoredPosition.y - extraBar.anchoredPosition.y) * 0.72f; extraBar.sizeDelta = Vector2.one * 28f; if ((Object)(object)original.extraBarOutline != (Object)null) { GameObject val3 = Object.Instantiate(((Component)original.extraBarOutline).gameObject, val.transform, false); ((Object)val3).name = "FriendExtraBarOutline"; extraBarOutline = val3.GetComponent(); Vector2 anchoredPosition2 = extraBarOutline.anchoredPosition; extraBarOutline.anchoredPosition = new Vector2(anchoredPosition2.x - 46f, anchoredPosition2.y - 1f); extraOutlineMaxWidth = fullBarRectTransform.sizeDelta.x * 0.7f + 12f; extraBarOutline.sizeDelta = new Vector2(extraOutlineMaxWidth, extraBarOutline.sizeDelta.y); RemoveAllScriptsExcept(val3); RemoveCopiedStaminaInfo(val3); } if ((Object)(object)original.extraBarStamina != (Object)null) { GameObject val4 = Object.Instantiate(((Component)original.extraBarStamina).gameObject, val.transform, false); ((Object)val4).name = "FriendExtraBarStamina"; extraBarStamina = val4.GetComponent(); ((Transform)extraBarStamina).SetParent((Transform)(object)extraBarOutline, false); RectTransform obj3 = extraBarStamina; RectTransform obj4 = extraBarStamina; ((Vector2)(ref val2))..ctor(0f, 0.5f); obj4.anchorMax = val2; obj3.anchorMin = val2; extraBarStamina.pivot = new Vector2(0f, 0.5f); extraBarStamina.anchoredPosition = Vector2.zero; ((Transform)extraBarStamina).localRotation = Quaternion.identity; ((Transform)extraBarStamina).localScale = Vector3.one; extraBarStamina.offsetMin = new Vector2(0f, extraBarStamina.offsetMin.y); Transform obj5 = val4.transform.Find("Stamina"); RectTransform val5 = (RectTransform)(object)((obj5 is RectTransform) ? obj5 : null); if (val5 != null) { val5.anchoredPosition = new Vector2(val5.anchoredPosition.x + 5f, val5.anchoredPosition.y); val5.sizeDelta = new Vector2(val5.sizeDelta.x, val5.sizeDelta.y * 0.5f); } RemoveAllScriptsExcept(val4); RemoveCopiedStaminaInfo(val4); } CreateOrMovePetrifyAffliction(); val.SetActive(false); } private void CreateOrMovePetrifyAffliction() { //IL_00a9: 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_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: 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_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0105: 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_011f: 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_0071: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)petrifyAffliction == (Object)null && (Object)(object)GUIManager.instance.bar.petrifyAffliction != (Object)null) { BarAffliction val = GUIManager.instance.bar.petrifyAffliction; GameObject val2 = Object.Instantiate(((Component)val).gameObject, (Transform)(object)extraBarOutline, false); ((Object)val2).name = "FriendPetrifyAffliction"; RemoveAllScriptsExcept(val2); petrifyAffliction = val2.AddComponent(); petrifyAffliction.afflictionType = val.afflictionType; petrifyAffliction.isPetrify = true; petrifyAffliction.FetchReferences(); } if ((Object)(object)petrifyAffliction != (Object)null) { RectTransform val3 = (RectTransform)((Component)petrifyAffliction).transform; ((Transform)val3).SetParent((Transform)(object)extraBarOutline, false); Vector2 val4 = default(Vector2); ((Vector2)(ref val4))..ctor(1f, 0.5f); val3.anchorMax = val4; val3.anchorMin = val4; val3.pivot = new Vector2(1f, 0.5f); val3.anchoredPosition = new Vector2(-8f, 0f); ((Transform)val3).localRotation = Quaternion.identity; ((Transform)val3).localScale = new Vector3(0.7f, 0.5f, 1f); ((Transform)val3).SetAsLastSibling(); } } private void UpdateExtraStaminaBar() { //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0157: 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_017c: 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_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)extraBar == (Object)null || (Object)(object)extraBarStamina == (Object)null || (Object)(object)extraBarOutline == (Object)null || (Object)(object)ObservedCharacter == (Object)null) { return; } float extraStamina = ObservedCharacter.data.extraStamina; bool flag = (Object)(object)petrifyAffliction != (Object)null && (float)ObservedCharacter.data.petrifyAmount > 1f; bool flag2 = extraStamina > 0f || flag; if (!((Component)extraBar).gameObject.activeSelf && flag2) { extraBar.sizeDelta = Vector2.zero; ShortcutExtensions.DOKill((Component)(object)extraBar, false); extraBar.sizeDelta = Vector2.one * 28f; ((Component)extraBar).gameObject.SetActive(true); } if (((Component)extraBar).gameObject.activeSelf) { desiredExtraStaminaSize = Mathf.Max(0f, extraStamina * fullBarRectTransform.sizeDelta.x * 0.7f); extraBarStamina.sizeDelta = new Vector2(Mathf.Lerp(extraBarStamina.sizeDelta.x, Mathf.Max(4f, desiredExtraStaminaSize), Time.deltaTime * 10f), extraBarStamina.sizeDelta.y); ((Component)extraBarStamina).gameObject.SetActive(extraBarStamina.sizeDelta.x > 6.1f); extraBarOutline.sizeDelta = new Vector2(extraOutlineMaxWidth, extraBarOutline.sizeDelta.y); if (!flag2 && !sequencingExtraBar) { sequencingExtraBar = true; extraBar.sizeDelta = new Vector2(extraBar.sizeDelta.x, 0f); DisableExtraBar(); } } } private void DisableExtraBar() { ((Component)extraBar).gameObject.SetActive(false); sequencingExtraBar = false; } private static void RemoveAllScriptsExcept(GameObject gameObject) { MonoBehaviour[] components = gameObject.GetComponents(); foreach (MonoBehaviour val in components) { if (((object)val).GetType() != typeof(T1) && ((object)val).GetType() != typeof(T2)) { Object.DestroyImmediate((Object)(object)val); } } } private static void RemoveCopiedStaminaInfo(GameObject gameObject) { Transform[] componentsInChildren = gameObject.GetComponentsInChildren(true); foreach (Transform val in componentsInChildren) { if ((Object)(object)val != (Object)(object)gameObject.transform && ((Object)val).name == "StaminaInfo") { Object.DestroyImmediate((Object)(object)((Component)val).gameObject); } } } internal void AddCharacterBarAffliction(CharacterBarAffliction characterBarAffliction) { characterBarAfflictions.Add(characterBarAffliction); if (characterBarAffliction.isPetrify) { petrifyAffliction = characterBarAffliction; } } private void CreateInventorySlots() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) float num = 26.22f; for (int i = 0; i < 3; i++) { InventorySlotUI item = CreateInventorySlot($"InvSlot_{i}", new Vector2(32f, 32f), new Vector2(284f + (float)(i * 38), num)); inventorySlotUIs.Add(item); } heldItemSlot = CreateInventorySlot("HoldingItemSlot", new Vector2(38f, 38f), new Vector2(398f, num)); for (int j = 0; j < 4; j++) { InventorySlotUI item2 = CreateInventorySlot($"BackpackSlot_{j}", new Vector2(32f, 32f), new Vector2(454f + (float)(j * 38), num)); backpackSlotUIs.Add(item2); } } private void EnsureInventorySlotsCreated() { if (!inventorySlotsCreated) { CreateInventorySlots(); inventorySlotsCreated = true; } } private void UpdateInventorySlots() { //IL_0048: 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) Character? observedCharacter = ObservedCharacter; if (((observedCharacter == null) ? null : observedCharacter.player?.itemSlots) == null) { ClearInventorySlots(); return; } ItemSlot[] itemSlots = ObservedCharacter.player.itemSlots; Optionable currentSelectedSlot = ObservedCharacter.refs.items.currentSelectedSlot; for (int i = 0; i < inventorySlotUIs.Count && i < itemSlots.Length; i++) { bool selected = currentSelectedSlot.IsSome && currentSelectedSlot.Value == i; inventorySlotUIs[i].SetItem(itemSlots[i], selected); } Item currentItem = ObservedCharacter.data.currentItem; if ((Object)(object)heldItemSlot != (Object)null) { bool selected2 = (Object)(object)currentItem != (Object)null && currentItem.UIData != null; heldItemSlot.SetItem(currentItem, currentItem?.data, selected2); } if (!((ItemSlot)ObservedCharacter.player.backpackSlot).IsEmpty()) { BackpackData val = default(BackpackData); ((ItemSlot)ObservedCharacter.player.backpackSlot).data.TryGetDataEntry((DataEntryKey)7, ref val); ItemSlot[] itemSlots2 = val.itemSlots; for (int j = 0; j < backpackSlotUIs.Count && j < itemSlots2.Length; j++) { backpackSlotUIs[j].SetItem(itemSlots2[j], selected: false); } return; } foreach (InventorySlotUI backpackSlotUI in backpackSlotUIs) { backpackSlotUI.Clear(); } } private void ClearInventorySlots() { foreach (InventorySlotUI inventorySlotUI in inventorySlotUIs) { inventorySlotUI.Clear(); } heldItemSlot?.Clear(); foreach (InventorySlotUI backpackSlotUI in backpackSlotUIs) { backpackSlotUI.Clear(); } } private void ApplyTeammateVisualOffset() { //IL_004d: 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_005d: Unknown result type (might be due to invalid IL or missing references) float teammateVisualYOffset = GetTeammateVisualYOffset(); float num = teammateVisualYOffset - appliedTeammateVisualYOffset; if (Mathf.Abs(num) < 0.001f) { return; } appliedTeammateVisualYOffset = teammateVisualYOffset; for (int i = 0; i < ((Component)this).transform.childCount; i++) { Transform child = ((Component)this).transform.GetChild(i); RectTransform val = (RectTransform)(object)((child is RectTransform) ? child : null); if (val != null && !((Object)(object)val == (Object)(object)headerRowRectTransform)) { val.anchoredPosition += new Vector2(0f, num); } } UpdateHeaderRowPosition(); } private static float GetTeammateVisualYOffset() { return 10f + InterpolateScaleSetting(10f, -1f, -21f); } private void ApplyConfiguredScale() { //IL_001d: 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_004f: Unknown result type (might be due to invalid IL or missing references) if (isEnabled && animateDisableCoroutine == null) { float configuredScale = GetConfiguredScale(); if (!(Mathf.Abs(((Component)this).transform.localScale.x - configuredScale) < 0.001f)) { ShortcutExtensions.DOKill((Component)(object)((Component)this).transform, false); ((Component)this).transform.localScale = Vector3.one * configuredScale; } } } private void ApplyExtraBarScaleCompensation() { //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)extraBar == (Object)null) && !((Object)(object)fullBarRectTransform == (Object)null) && !(extraBarDefaultVisualGap <= 0f)) { float num = Mathf.Max(0f, extraBarDefaultVisualGap + InterpolateScaleSetting(-3f, 0f, 10f)) / Mathf.Max(0.001f, GetConfiguredScale()); extraBar.anchoredPosition = new Vector2(extraBar.anchoredPosition.x, fullBarRectTransform.anchoredPosition.y - num); } } internal static float GetConfiguredScale() { return PluginConfig.OverheadScale.Value switch { "25%" => 0.25f, "50%" => 0.5f, "100%" => 1f, _ => 0.75f, }; } internal static float GetGroupSpacing() { return Mathf.Max(0f, InterpolateScaleSetting(26.8f, 38f, 65.8f)); } private static float InterpolateScaleSetting(float valueAtScaleLow, float valueAtDefaultScale, float valueAtScaleHigh) { float configuredScale = GetConfiguredScale(); float num = (configuredScale - 0.72f) * (configuredScale - 1f) / 0.048f; float num2 = (configuredScale - 0.6f) * (configuredScale - 1f) / -0.0336f; float num3 = (configuredScale - 0.6f) * (configuredScale - 0.72f) / 0.11199998f; return valueAtScaleLow * num + valueAtDefaultScale * num2 + valueAtScaleHigh * num3; } private InventorySlotUI CreateInventorySlot(string name, Vector2 size, Vector2 position) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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_0039: 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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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_0048: 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_0063: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) }); val.transform.SetParent((Transform)(object)headerRowRectTransform, false); RectTransform component = val.GetComponent(); component.sizeDelta = size; Vector2 val2 = (component.anchorMax = Vector2.zero); Vector2 anchorMin = val2; component.anchorMin = anchorMin; component.pivot = new Vector2(0f, 0.5f); component.anchoredPosition = position; InventorySlotUI inventorySlotUI = val.AddComponent(); inventorySlotUI.Initialize(); return inventorySlotUI; } private void UpdateStaminaBar() { //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_0151: 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_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_0316: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ObservedCharacter == (Object)null || (Object)(object)ObservedCharacter.data == (Object)null || ObservedCharacter.refs == null || (Object)(object)ObservedCharacter.refs.afflictions == (Object)null || (Object)(object)fullBarRectTransform == (Object)null || (Object)(object)staminaBarRectTransform == (Object)null || (Object)(object)maxStaminaBarRectTransform == (Object)null || (Object)(object)staminaBarOutlineRectTransform == (Object)null) { return; } foreach (CharacterBarAffliction characterBarAffliction in characterBarAfflictions) { characterBarAffliction.FetchDesiredSize(); characterBarAffliction.UpdateVisual(); } float num = Mathf.Max(0f, ObservedCharacter.data.currentStamina * fullBarRectTransform.sizeDelta.x + staminaBarOffset); if (ObservedCharacter.data.currentStamina <= 0.005f && !outOfStamina) { outOfStamina = true; OutOfStaminaPulse(); } else if (ObservedCharacter.data.currentStamina > 0.005f) { outOfStamina = false; } float num2 = Time.deltaTime * 10f; staminaBarRectTransform.sizeDelta = new Vector2(Mathf.Lerp(staminaBarRectTransform.sizeDelta.x, num, num2), staminaBarRectTransform.sizeDelta.y); float num3 = Mathf.Clamp01((staminaBarRectTransform.sizeDelta.x - num) * 0.5f); sinTime += num2 * num3; if ((Object)(object)glowImage != (Object)null) { Color color = ((Graphic)glowImage).color; color.a = num3 * 0.4f - Mathf.Abs(Mathf.Sin(sinTime)) * 0.2f; ((Graphic)glowImage).color = color; } float num4 = Mathf.Max(0f, ObservedCharacter.GetMaxStamina() * fullBarRectTransform.sizeDelta.x + staminaBarOffset); maxStaminaBarRectTransform.sizeDelta = new Vector2(Mathf.Lerp(maxStaminaBarRectTransform.sizeDelta.x, num4, num2), maxStaminaBarRectTransform.sizeDelta.y); float statusSum = ObservedCharacter.refs.afflictions.statusSum; staminaBarOutlineRectTransform.sizeDelta = new Vector2(14f + Mathf.Max(1f, statusSum) * fullBarRectTransform.sizeDelta.x, staminaBarOutlineRectTransform.sizeDelta.y); if ((Object)(object)staminaBarOutlineOverflowBar != (Object)null) { ((Component)staminaBarOutlineOverflowBar).gameObject.SetActive(statusSum > 1.005f); } ((Component)staminaBarRectTransform).gameObject.SetActive(staminaBarRectTransform.sizeDelta.x > minStaminaBarWidth); ((Component)maxStaminaBarRectTransform).gameObject.SetActive(maxStaminaBarRectTransform.sizeDelta.x > minStaminaBarWidth); if (sinTime > TAU) { sinTime -= TAU; } if ((Object)(object)shieldIcon != (Object)null) { shieldIcon.SetActive(GameRef.GetIsInvincible(ObservedCharacter.data)); } if ((Object)(object)campfireIcon != (Object)null) { campfireIcon.SetActive(!ObservedCharacter.refs.afflictions.canGetHungry); } } private void OutOfStaminaPulse() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)barImage == (Object)null)) { ((Graphic)barImage).color = outOfStaminaColor; ((Graphic)barImage).color = defaultBarColor; } } private IEnumerator EnableIEnumerator() { ((Component)this).transform.localScale = Vector3.zero; TweenSettingsExtensions.SetEase>(ShortcutExtensions.DOScale(((Component)this).transform, GetConfiguredScale(), 0.5f), (Ease)24); yield return (object)new WaitForSeconds(0.5f); animateDisableCoroutine = null; } private IEnumerator DisableIEnumerator() { ((Component)this).transform.localScale = Vector3.one * GetConfiguredScale(); TweenSettingsExtensions.SetEase>(ShortcutExtensions.DOScale(((Component)this).transform, 0f, 0.5f), (Ease)17); yield return (object)new WaitForSeconds(0.5f); ((Component)this).gameObject.SetActive(false); animateDisableCoroutine = null; } } public class InventorySlotUI : MonoBehaviour { private const float SelectedTargetScale = 1.1f; private const float SelectedEnvelopeScale = 1.38f; private const float SelectedElasticAmplitude = 1.70158f; private const float SelectedElasticPeriod = 0f; private RectTransform rectTransform; private RawImage icon; private GameObject? fuelBar; private Image? fuelBarFill; private Item? currentItem; private ItemInstanceData? currentData; private Vector2 startingSizeDelta; private float visualScale = 1f; private Tween? selectionTween; private bool selectionInitialized; private bool isSelected; private bool cookedStateInitialized; private bool hasCookedData; private int cookedValue; private bool fuelStateInitialized; private bool fuelBarVisible; private float fuelValue = 1f; public void Initialize() { //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_0049: Unknown result type (might be due to invalid IL or missing references) rectTransform = ((Component)this).GetComponent(); startingSizeDelta = rectTransform.sizeDelta; CreateFuelBar(); icon = CreateIconImage(); ((Graphic)icon).color = new Color(1f, 1f, 1f, 0f); ((Graphic)icon).raycastTarget = false; GameObject? obj = fuelBar; if (obj != null) { obj.transform.SetAsLastSibling(); } } public void SetItem(ItemSlot slot, bool selected) { bool flag = slot.IsEmpty(); SetItem(flag ? null : slot.prefab, flag ? null : slot.data, selected); } internal void SetItem(Item? item, ItemInstanceData? data, bool selected) { //IL_007c: Unknown result type (might be due to invalid IL or missing references) if (item?.UIData == null) { ClearItemVisuals(); SetSelected(selected: false); return; } bool flag = currentItem != item || currentData != data; currentItem = item; currentData = data; if (flag || !((Behaviour)icon).enabled) { icon.texture = (Texture)(object)item.UIData.GetIcon(); ((Behaviour)icon).enabled = true; ((Graphic)icon).color = Color.white; cookedStateInitialized = false; fuelStateInitialized = false; } UpdateCookedColor(); UpdateFuelBar(); SetSelected(selected, flag && selected); } public void Clear() { ClearItemVisuals(); SetSelected(selected: false); } private void SetSelected(bool selected, bool replayAnimation = false) { bool flag = selected && (Object)(object)currentItem != (Object)null; if (!replayAnimation && selectionInitialized && isSelected == flag) { return; } selectionInitialized = true; isSelected = flag; Tween? obj = selectionTween; if (obj != null) { TweenExtensions.Kill(obj, false); } if (flag) { selectionTween = (Tween?)(object)TweenSettingsExtensions.SetEase>(DOTween.To((DOGetter)(() => visualScale), (DOSetter)ApplyVisualScale, 1.1f, 0.5f), (Ease)24, 1.70158f, 0f); } else if ((Object)(object)currentItem != (Object)null) { selectionTween = (Tween?)(object)TweenSettingsExtensions.SetEase>(DOTween.To((DOGetter)(() => visualScale), (DOSetter)ApplyVisualScale, 1f, 0.2f), (Ease)9); } else { ApplyVisualScale(1f); } } private void ApplyVisualScale(float value) { //IL_001d: 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) visualScale = Mathf.Clamp(value, 1f, 1.38f); rectTransform.sizeDelta = startingSizeDelta * visualScale; } private void UpdateCookedColor() { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) ItemInstanceData val = currentData; bool flag = false; int num = 0; IntItemData val2 = default(IntItemData); if (val != null && val.TryGetDataEntry((DataEntryKey)1, ref val2)) { flag = true; num = val2.Value; } if (!cookedStateInitialized || hasCookedData != flag || cookedValue != num) { cookedStateInitialized = true; hasCookedData = flag; cookedValue = num; ((Graphic)icon).color = (flag ? ItemCooking.GetCookColor(num) : Color.white); } } private void UpdateFuelBar() { if (!((Object)(object)fuelBar == (Object)null)) { ItemInstanceData val = currentData; bool flag = false; float num = 1f; FloatItemData val2 = default(FloatItemData); if (val != null && val.TryGetDataEntry((DataEntryKey)11, ref val2)) { flag = true; num = val2.Value; } if (!fuelStateInitialized || fuelBarVisible != flag) { fuelBar.SetActive(flag); } if ((Object)(object)fuelBarFill != (Object)null && (!fuelStateInitialized || fuelBarVisible != flag || !Mathf.Approximately(fuelValue, num))) { fuelBarFill.fillAmount = num; } fuelStateInitialized = true; fuelBarVisible = flag; fuelValue = num; } } private void ClearItemVisuals() { //IL_0071: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)currentItem == (Object)null) || currentData != null || ((Behaviour)icon).enabled || (!((Object)(object)fuelBar == (Object)null) && fuelBar.activeSelf)) { ((Behaviour)icon).enabled = false; icon.texture = null; ((Graphic)icon).color = new Color(1f, 1f, 1f, 0f); currentItem = null; currentData = null; cookedStateInitialized = false; hasCookedData = false; cookedValue = 0; fuelStateInitialized = false; fuelBarVisible = false; fuelValue = 1f; if ((Object)(object)fuelBar != (Object)null) { fuelBar.SetActive(false); } if ((Object)(object)fuelBarFill != (Object)null) { fuelBarFill.fillAmount = 1f; } } } private RawImage CreateIconImage() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0041: 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) //IL_0056: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Icon", new Type[1] { typeof(RectTransform) }); val.transform.SetParent(((Component)this).transform, false); RectTransform component = val.GetComponent(); component.anchorMin = Vector2.zero; component.anchorMax = Vector2.one; component.sizeDelta = Vector2.zero; component.anchoredPosition = Vector2.zero; return val.AddComponent(); } private void CreateFuelBar() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Expected O, but got Unknown //IL_0104: 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_011a: 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_0140: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("FuelBar", new Type[1] { typeof(RectTransform) }); val.transform.SetParent(((Component)this).transform, false); val.transform.SetAsFirstSibling(); RectTransform component = val.GetComponent(); component.anchorMin = new Vector2(0f, 0f); component.anchorMax = new Vector2(1f, 0f); component.sizeDelta = new Vector2(0f, 4f); component.anchoredPosition = new Vector2(0f, 2f); Image obj = val.AddComponent(); ((Graphic)obj).color = new Color(0f, 0f, 0f, 0.5f); Sprite sprite = (obj.sprite = CreateWhiteSprite()); obj.type = (Type)1; GameObject val3 = new GameObject("Fill", new Type[1] { typeof(RectTransform) }); val3.transform.SetParent(val.transform, false); RectTransform component2 = val3.GetComponent(); component2.anchorMin = Vector2.zero; component2.anchorMax = Vector2.one; component2.sizeDelta = Vector2.zero; component2.anchoredPosition = Vector2.zero; fuelBarFill = val3.AddComponent(); ((Graphic)fuelBarFill).color = Color.yellow; fuelBarFill.sprite = sprite; fuelBarFill.type = (Type)3; fuelBarFill.fillMethod = (FillMethod)0; fuelBarFill.fillOrigin = 0; fuelBar = val; fuelBar.SetActive(false); } private Sprite CreateWhiteSprite() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown Texture2D val = new Texture2D(1, 1); val.SetPixel(0, 0, Color.white); val.Apply(); return Sprite.Create(val, new Rect(0f, 0f, 1f, 1f), Vector2.one * 0.5f); } private void OnDisable() { Tween? obj = selectionTween; if (obj != null) { TweenExtensions.Kill(obj, false); } selectionTween = null; ApplyVisualScale(1f); selectionInitialized = false; } } internal sealed class MapBiomeInfo { internal BiomeType BiomeType { get; } internal Transform OccurrenceRoot { get; } internal List SegmentIndices { get; } = new List(); internal MapBiomeInfo(BiomeType biomeType, Transform occurrenceRoot) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) BiomeType = biomeType; OccurrenceRoot = occurrenceRoot; } } internal sealed class MapBiomeCapture { internal List MapBiomes { get; } = new List(); internal Transform?[] SegmentRoots { get; } internal int[] SegmentBiomeIndices { get; } internal MapBiomeCapture(int segmentCount) { SegmentRoots = (Transform?[])(object)new Transform[segmentCount]; SegmentBiomeIndices = new int[segmentCount]; Array.Fill(SegmentBiomeIndices, -1); } } internal static class MapBiomeCollector { private static readonly HashSet MesaKnownVariants = new HashSet { "ScorpionsHell", "CactusHell", "CactusForest", "DynamiteHell", "TornadoHell", "TumblerHell" }; private static readonly HashSet RootsKnownVariants = new HashSet { "CaveMania", "DeepWater", "BombBeetle", "DeepWoods", "Clearcut" }; private static readonly HashSet RootsStructuralNames = new HashSet { "Redwoods", "Redwood", "Variant" }; internal static MapBiomeCapture Capture(Scene scene) { //IL_0000: 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_00ba: Unknown result type (might be due to invalid IL or missing references) if (!TryGetMapHandler(scene, out MapHandler mapHandler)) { return new MapBiomeCapture(0); } MapBiomeCapture mapBiomeCapture = new MapBiomeCapture(mapHandler.segments.Length); Dictionary dictionary = new Dictionary(); VoidBiome instance = VoidBiome.instance; for (int i = 0; i < mapHandler.segments.Length; i++) { MapSegment val = mapHandler.segments[i]; if (TryGetOccurrence(scene, val, instance, out Transform segmentRoot, out Transform occurrenceRoot)) { mapBiomeCapture.SegmentRoots[i] = segmentRoot; int instanceID = ((Object)occurrenceRoot).GetInstanceID(); if (dictionary.TryGetValue(instanceID, out var value)) { mapBiomeCapture.SegmentBiomeIndices[i] = value; mapBiomeCapture.MapBiomes[value].SegmentIndices.Add(i); continue; } value = mapBiomeCapture.MapBiomes.Count; dictionary.Add(instanceID, value); mapBiomeCapture.SegmentBiomeIndices[i] = value; MapBiomeInfo mapBiomeInfo = new MapBiomeInfo(val.biome, occurrenceRoot); mapBiomeInfo.SegmentIndices.Add(i); mapBiomeCapture.MapBiomes.Add(mapBiomeInfo); } } return mapBiomeCapture; } internal static bool TryGetCurrentMapBiome(Scene scene, MapBiomeCapture capture, out MapBiomeInfo mapBiome, out int segmentIndex) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) mapBiome = null; segmentIndex = -1; if (!TryGetMapHandler(scene, out MapHandler mapHandler)) { return false; } MapSegment currentMapSegment = MapHandler.CurrentMapSegment; segmentIndex = Array.IndexOf(mapHandler.segments, currentMapSegment); if (segmentIndex < 0 || segmentIndex >= capture.SegmentBiomeIndices.Length) { return false; } int num = capture.SegmentBiomeIndices[segmentIndex]; if (num < 0 || num >= capture.MapBiomes.Count) { return false; } mapBiome = capture.MapBiomes[num]; return true; } internal static bool TryGetCurrentVariant(MapBiomeInfo mapBiome, Transform? segmentRoot, out string variant) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return TryGetCurrentVariant(mapBiome.BiomeType, segmentRoot, mapBiome.OccurrenceRoot, out variant); } internal static bool TryGetCurrentVariant(BiomeType biomeType, Transform? root, out string variant) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return TryGetCurrentVariant(biomeType, root, root, out variant); } private static bool TryGetCurrentVariant(BiomeType biomeType, Transform? segmentRoot, Transform? occurrenceRoot, out string variant) { //IL_0007: 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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Invalid comparison between Unknown and I4 //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Invalid comparison between Unknown and I4 variant = ""; if (!HasVariant(biomeType)) { return true; } if ((Object)(object)segmentRoot == (Object)null || !((Component)segmentRoot).gameObject.activeInHierarchy) { return false; } bool flag = biomeType - 6 <= 1; if (flag) { List list = CollectActiveVariants(segmentRoot, occurrenceRoot ?? segmentRoot, biomeType); HashSet hashSet = (((int)biomeType == 6) ? MesaKnownVariants : RootsKnownVariants); foreach (string item in list) { if (!hashSet.Contains(item)) { continue; } variant = item; flag = true; goto IL_0116; } foreach (string item2 in list) { if (!item2.Equals("Default", StringComparison.Ordinal)) { continue; } variant = item2; flag = true; goto IL_0116; } if (list.Count == 0) { return false; } variant = list[0]; return true; } List list2 = CollectActiveVariants(segmentRoot, occurrenceRoot ?? segmentRoot, biomeType); if (list2.Count == 0) { return false; } variant = list2[0]; return true; IL_0116: return flag; } internal static bool HasVariant(BiomeType biomeType) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 //IL_0004: 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: Invalid comparison between Unknown and I4 if ((int)biomeType <= 2 || biomeType - 6 <= 1) { return true; } return false; } internal static string CleanVariant(BiomeType biomeType, string variant) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Invalid comparison between Unknown and I4 if ((int)biomeType == 6) { if (variant.Equals("NoVariant", StringComparison.Ordinal)) { return "Default"; } if (variant.Equals("CacusHell", StringComparison.Ordinal)) { return "CactusHell"; } return variant; } if ((int)biomeType != 7) { return variant; } string[] array = variant.Split(' ', '-'); if (array.Length <= 1) { return variant; } for (int i = 0; i < array.Length; i++) { string text = array[i]; if (text.Length > 0) { text = char.ToUpperInvariant(text[0]) + text.Substring(1).ToLowerInvariant(); } if (RootsStructuralNames.Contains(text)) { text = ""; } array[i] = text; } return string.Join("", array); } private static List CollectActiveVariants(Transform segmentRoot, Transform occurrenceRoot, BiomeType biomeType) where T : Component { //IL_0007: 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) List list = new List(); AddActiveVariants(segmentRoot, biomeType, list); if (list.Count == 0 && (Object)(object)occurrenceRoot != (Object)(object)segmentRoot) { AddActiveVariants(occurrenceRoot, biomeType, list); } return list; static void AddActiveVariants(Transform root, BiomeType type, List result) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) T[] componentsInChildren = ((Component)root).GetComponentsInChildren(true); foreach (T val in componentsInChildren) { if (((Component)val).gameObject.activeInHierarchy) { string text = CleanVariant(type, ((Object)(object)val).name); if (!string.IsNullOrWhiteSpace(text) && !result.Contains(text)) { result.Add(text); } } } } } private static bool TryGetMapHandler(Scene scene, out MapHandler mapHandler) { //IL_0023: 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) mapHandler = null; if (!MapHandler.ExistsAndInitialized) { return false; } mapHandler = Singleton.Instance; if (Object.op_Implicit((Object)(object)mapHandler) && ((Component)mapHandler).gameObject.scene == scene) { return mapHandler.segments != null; } return false; } private static bool TryGetOccurrence(Scene scene, MapSegment? segment, VoidBiome? voidBiome, out Transform segmentRoot, out Transform occurrenceRoot) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) segmentRoot = null; occurrenceRoot = null; if (segment == null) { return false; } if ((Object)(object)voidBiome != (Object)null && segment == voidBiome.segment && !voidBiome.isActive) { return false; } GameObject segmentParent = segment.segmentParent; if (!Object.op_Implicit((Object)(object)segmentParent) || segmentParent.scene != scene) { return false; } segmentRoot = segmentParent.transform; occurrenceRoot = segmentRoot.parent ?? segmentRoot; return true; } } internal sealed class MapStats : MonoBehaviour { private sealed class RouteEntry { internal string Name { get; } internal RouteEntry(string name) { Name = name; } } private enum MapSeedSource { None, TerrainRandomiser, TerrainCustomiser, Pll, Tfa, Conflict } private const float RefreshInterval = 1f; private const int MaxVisibleRouteEntries = 6; private const string CurrentSegmentColorTag = "#FFD54F"; internal const float MapTextRightMargin = 4f; private static readonly IReadOnlyDictionary> SimplifiedChineseVariantNames = new Dictionary> { [(BiomeType)0] = new Dictionary { ["Default"] = "默认", ["SnakeBeach"] = "蛇岩", ["RedBeach"] = "赤沙", ["BlueBeach"] = "蓝沙", ["JellyHell"] = "水母地狱", ["BlackSand"] = "黑沙" }, [(BiomeType)1] = new Dictionary { ["Default"] = "默认", ["Lava"] = "熔岩管", ["Pillars"] = "巨柱", ["Thorny"] = "巨棘藤", ["Bombs"] = "爆菇", ["Ivy"] = "紫毒藤", ["SkyJungle"] = "浮岛" }, [(BiomeType)7] = new Dictionary { ["Default"] = "默认", ["CaveMania"] = "洞窟丛生", ["DeepWater"] = "赤水孢泽", ["BombBeetle"] = "爆菇甲虫", ["DeepWoods"] = "幽深密林", ["Clearcut"] = "皆伐菌原" }, [(BiomeType)2] = new Dictionary { ["Default"] = "默认", ["Lava"] = "熔岩管", ["Spiky"] = "冰刺", ["GeyserHell"] = "间歇泉地狱" }, [(BiomeType)6] = new Dictionary { ["Default"] = "默认", ["ScorpionsHell"] = "毒蝎地狱", ["CactusHell"] = "峭壁仙人掌地狱", ["CactusForest"] = "高原仙人掌林", ["DynamiteHell"] = "炸药地狱", ["TornadoHell"] = "龙卷风地狱", ["TumblerHell"] = "风滚草地狱" } }; internal static string currentLevelName = ""; internal static int currentLevelIndex = -1; private static int todayLevelIndex = -1; private static bool mapSeedConflictWarningLogged; private static bool ambiguousPeakWarningLogged; private int? currentMapSeed; private MapSeedSource mapSeedSource; private MapHandler? cachedSeedMapHandler; private Scene cachedSeedScene; private TMP_Text tmpText; private TMP_Text routeText; private TMP_Text variantText; private RectTransform hudCanvasRect; private MapBaker mapBaker; private MapHandler mapHandler; private NextLevelService nextLevelService; private MapBiomeCapture? cachedCapture; private MapSegment[]? cachedSegments; private MapSegment[] cachedSegmentReferences = Array.Empty(); private BiomeType[] cachedSegmentBiomes = Array.Empty(); private GameObject?[] cachedSegmentParents = Array.Empty(); private MapSegment? cachedCurrentSegment; private MapBiomeInfo? cachedVariantOccurrence; private string cachedVariant = ""; private bool variantResolved; private float cachedRouteWidth = -1f; private bool cachedIsInNadir; private ProgressPoint[]? cachedProgressPoints; private ProgressPoint[] cachedProgressPointReferences = Array.Empty(); private ProgressPoint? cachedPeakProgressPoint; private bool cachedPeakReached; private bool cachedPllMapActive; private string?[] cachedPllSegmentTitles = Array.Empty(); private bool cachedDisplayBiomes; private float nextRefreshTime; private bool routeNamesDirty = true; private readonly TrueFinalAscentCompatibility tfaCompatibility = new TrueFinalAscentCompatibility(); private TfaRouteStatus cachedTfaStatus; private TfaRouteProjection? cachedTfaProjection; private int cachedTfaCurrentIndex = -1; private TfaRouteStage? cachedTfaVariantStage; private void Awake() { mapBaker = SingletonAsset.Instance; mapHandler = Singleton.Instance; nextLevelService = GameHandler.GetService(); LocalizedText.OnLangugageChanged = (Action)Delegate.Combine(LocalizedText.OnLangugageChanged, new Action(OnLanguageChanged)); } private void Start() { tmpText = ((Component)this).GetComponent(); ConfigureText(tmpText, autoSizeTextContainer: true); } internal void InitializeRouteText(TMP_Text text, TMP_Text currentVariantText, RectTransform canvasRect) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) routeText = text; variantText = currentVariantText; hudCanvasRect = canvasRect; ConfigureRouteText(routeText, 20f); ConfigureRouteText(variantText, 16f); ((Graphic)variantText).color = Color32.op_Implicit(new Color32(byte.MaxValue, (byte)213, (byte)79, byte.MaxValue)); routeText.text = string.Empty; variantText.text = string.Empty; } private void Update() { if (!(Time.unscaledTime < nextRefreshTime)) { nextRefreshTime = Time.unscaledTime + 1f; RefreshRouteText(); RefreshHeaderText(); } } private void RefreshHeaderText() { UpdateMapSeed(); if (nextLevelService.Data.IsSome && todayLevelIndex == -1) { todayLevelIndex = (nextLevelService.NextLevelIndexOrFallback + NextLevelService.debugLevelIndexOffset) % mapBaker.ScenePaths.Length; Plugin.Logger.LogInfo((object)$"todayLevelIndex set to {todayLevelIndex}"); } if (currentLevelIndex == -1) { int num = LevelNameToIndex(currentLevelName); if (num != -1) { currentLevelIndex = num; } else if (todayLevelIndex != -1) { currentLevelIndex = todayLevelIndex; } Plugin.Logger.LogInfo((object)$"currentLevelIndex set to {currentLevelIndex}"); } StringBuilder stringBuilder = new StringBuilder(64); if (PluginConfig.DisplayLevel.Value && currentLevelIndex != -1) { currentLevelName = GetLevelName(currentLevelIndex); stringBuilder.Append('('); stringBuilder.Append(currentLevelName); stringBuilder.Append(')'); } if (PluginConfig.DisplayMapSeed.Value) { int? num2 = currentMapSeed; if (num2.HasValue) { int valueOrDefault = num2.GetValueOrDefault(); stringBuilder.Append('<'); stringBuilder.Append(valueOrDefault); stringBuilder.Append('>'); } } string text = stringBuilder.ToString(); if (!string.Equals(tmpText.text, text, StringComparison.Ordinal)) { tmpText.text = text; } } private void UpdateMapSeed() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: 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_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) if (!PluginConfig.DisplayMapSeed.Value) { return; } MapHandler val = (MapHandler.ExistsAndInitialized ? Singleton.Instance : null); Scene activeScene = SceneManager.GetActiveScene(); int num; if ((Object)(object)val != (Object)null) { if (!val.inNadir) { ProgressPoint? uniquePeakProgressPoint = GetUniquePeakProgressPoint(GetProgressPoints()); num = ((uniquePeakProgressPoint != null && uniquePeakProgressPoint.Reached) ? 1 : 0); } else { num = 1; } } else { num = 0; } bool atTerminal = (byte)num != 0; bool assemblyChanged; TfaRouteStatus tfaRouteStatus = tfaCompatibility.ReadSeedStatus(activeScene, val, atTerminal, out assemblyChanged); MapSeedSource mapSeedSource = tfaRouteStatus switch { TfaRouteStatus.Ready => MapSeedSource.Tfa, TfaRouteStatus.NotApplicable => GetMapSeedSource(), _ => MapSeedSource.None, }; if (mapSeedSource != this.mapSeedSource || assemblyChanged || cachedSeedMapHandler != val || cachedSeedScene != activeScene) { currentMapSeed = null; } this.mapSeedSource = mapSeedSource; cachedSeedMapHandler = val; cachedSeedScene = activeScene; if ((tfaRouteStatus == TfaRouteStatus.Pending || tfaRouteStatus == TfaRouteStatus.Unsupported) ? true : false) { currentMapSeed = null; } else if (!currentMapSeed.HasValue) { int seed = 0; if (this.mapSeedSource == MapSeedSource.Tfa && tfaCompatibility.TryGetMapSeed(out seed)) { currentMapSeed = seed; Plugin.Logger.LogInfo((object)$"Current map seed from {GetMapSeedSourceName(this.mapSeedSource)}: {seed}"); } } } private static MapSeedSource GetMapSeedSource() { return MapSeedSource.None; } private static string GetMapSeedSourceName(MapSeedSource source) { if (source == MapSeedSource.Tfa) { return "True Final Ascent"; } return "unknown source"; } private void RefreshRouteText() { //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) if (!PluginConfig.DisplayBiomes.Value) { SetTextIfChanged(routeText, string.Empty); SetTextIfChanged(variantText, string.Empty); cachedDisplayBiomes = false; return; } float routeWidth = GetRouteWidth(); if (!Mathf.Approximately(cachedRouteWidth, routeWidth)) { SetRouteRectWidth(routeWidth); } if ((Object)(object)mapHandler == (Object)null || !MapHandler.ExistsAndInitialized || mapHandler.segments == null || mapHandler.segments.Length == 0) { tfaCompatibility.ResetRoute(); ClearRouteCache(routeWidth); return; } MapSegment[] segments = mapHandler.segments; MapSegment currentMapSegment = MapHandler.CurrentMapSegment; bool inNadir = mapHandler.inNadir; ProgressPoint[] progressPoints = GetProgressPoints(); ProgressPoint uniquePeakProgressPoint = GetUniquePeakProgressPoint(progressPoints); bool flag = uniquePeakProgressPoint != null && uniquePeakProgressPoint.Reached; TfaRouteProjection projection; int currentIndex; TfaRouteStatus tfaRouteStatus = tfaCompatibility.ReadRoute(SceneManager.GetActiveScene(), mapHandler, inNadir || flag, out projection, out currentIndex); if (tfaRouteStatus != cachedTfaStatus) { ClearRouteCache(routeWidth); cachedTfaStatus = tfaRouteStatus; } switch (tfaRouteStatus) { case TfaRouteStatus.Pending: ClearRouteCache(routeWidth); return; case TfaRouteStatus.Ready: RefreshTfaRouteText(projection, currentIndex, routeWidth, inNadir, progressPoints, uniquePeakProgressPoint, flag); return; } bool mapActive = PLLCompatibility.MapActive; if (RouteSnapshotChanged(segments, currentMapSegment, inNadir, progressPoints, uniquePeakProgressPoint, flag, mapActive, routeWidth)) { CopyRouteSnapshot(segments, currentMapSegment, inNadir, progressPoints, uniquePeakProgressPoint, flag, mapActive, routeWidth); cachedCapture = MapBiomeCollector.Capture(SceneManager.GetActiveScene()); ResetVariantCache(); if (!MapBiomeCollector.TryGetCurrentMapBiome(SceneManager.GetActiveScene(), cachedCapture, out MapBiomeInfo _, out int _)) { SetTextIfChanged(routeText, string.Empty); SetTextIfChanged(variantText, string.Empty); routeNamesDirty = true; return; } cachedPllSegmentTitles = Array.Empty(); if (mapActive) { if (!PLLCompatibility.TryCreateRouteProjection(segments, progressPoints, out PllRouteProjection projection2)) { SetTextIfChanged(routeText, string.Empty); SetTextIfChanged(variantText, string.Empty); routeNamesDirty = true; return; } cachedPllSegmentTitles = projection2.SegmentTitles; } float currentEntryRightFromRouteRight; string value = BuildRouteDisplay(routeWidth, currentMapSegment, inNadir, uniquePeakProgressPoint, flag, out currentEntryRightFromRouteRight); SetTextIfChanged(routeText, value); UpdateVariantLayout(currentEntryRightFromRouteRight); } RefreshVariantText(); } private void RefreshTfaRouteText(TfaRouteProjection projection, int currentIndex, float width, bool isInNadir, ProgressPoint[] progressPoints, ProgressPoint? peakPoint, bool peakReached) { //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Invalid comparison between Unknown and I4 //IL_00f4: Unknown result type (might be due to invalid IL or missing references) if (!cachedDisplayBiomes || routeNamesDirty || cachedTfaProjection != projection || cachedTfaCurrentIndex != currentIndex || !Mathf.Approximately(cachedRouteWidth, width) || cachedIsInNadir != isInNadir || cachedProgressPoints != progressPoints || cachedPeakProgressPoint != peakPoint || cachedPeakReached != peakReached) { cachedTfaProjection = projection; cachedTfaCurrentIndex = currentIndex; cachedRouteWidth = width; cachedIsInNadir = isInNadir; cachedProgressPoints = progressPoints; cachedPeakProgressPoint = peakPoint; cachedPeakReached = peakReached; cachedDisplayBiomes = true; routeNamesDirty = false; ResetVariantCache(); List list = new List(); int num = -1; foreach (TfaRouteStage stage2 in projection.Stages) { if ((int)stage2.BiomeType == 5) { num = list.Count; } string name = (string.IsNullOrWhiteSpace(stage2.TitleKey) ? GetBiomeName(stage2.BiomeType, 0) : LocalizedText.GetText(stage2.TitleKey, true)); list.Add(new RouteEntry(name)); } if (num < 0 && peakPoint != null) { num = list.Count; string localizedTitle = peakPoint.localizedTitle; list.Add(new RouteEntry(string.IsNullOrWhiteSpace(localizedTitle) ? LocalizedText.GetText("PEAK", true) : localizedTitle)); } int currentIndex2 = currentIndex; if (isInNadir) { list.Add(new RouteEntry(LocalizedText.GetText("AREA_VOID", true))); currentIndex2 = list.Count - 1; } else if (peakReached && num >= 0) { currentIndex2 = num; } float currentEntryRightFromRouteRight; string value = BuildRouteDisplay(list, currentIndex2, width, out currentEntryRightFromRouteRight); SetTextIfChanged(routeText, value); UpdateVariantLayout(currentEntryRightFromRouteRight); } TfaRouteStage stage = ((!isInNadir && !peakReached && currentIndex >= 0 && currentIndex < projection.Stages.Count) ? projection.Stages[currentIndex] : null); RefreshTfaVariantText(stage); } private void RefreshTfaVariantText(TfaRouteStage? stage) { //IL_001a: 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_00a4: Unknown result type (might be due to invalid IL or missing references) if (cachedTfaVariantStage != stage) { ResetVariantCache(); cachedTfaVariantStage = stage; } if (stage == null || !MapBiomeCollector.HasVariant(stage.BiomeType) || !Object.op_Implicit((Object)(object)stage.Terrain) || !((Component)stage.Terrain).gameObject.activeInHierarchy) { variantResolved = false; SetTextIfChanged(variantText, string.Empty); return; } if (!variantResolved) { variantResolved = MapBiomeCollector.TryGetCurrentVariant(stage.BiomeType, stage.Terrain, out cachedVariant); } string value = ((variantResolved && !string.IsNullOrWhiteSpace(cachedVariant)) ? ("(" + LocalizeVariant(stage.BiomeType, cachedVariant) + ")") : ""); SetTextIfChanged(variantText, value); } private void RefreshVariantText() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) if (cachedCapture == null || !MapBiomeCollector.TryGetCurrentMapBiome(SceneManager.GetActiveScene(), cachedCapture, out MapBiomeInfo mapBiome, out int segmentIndex)) { SetTextIfChanged(variantText, string.Empty); return; } if (!MapBiomeCollector.HasVariant(mapBiome.BiomeType)) { SetTextIfChanged(variantText, string.Empty); return; } if (cachedVariantOccurrence != mapBiome) { cachedVariantOccurrence = mapBiome; cachedVariant = ""; variantResolved = false; } if (!variantResolved) { Transform segmentRoot = ((segmentIndex >= 0 && segmentIndex < cachedCapture.SegmentRoots.Length) ? cachedCapture.SegmentRoots[segmentIndex] : null); variantResolved = MapBiomeCollector.TryGetCurrentVariant(mapBiome, segmentRoot, out cachedVariant); } string text = LocalizeVariant(mapBiome.BiomeType, cachedVariant); string value = ((variantResolved && !string.IsNullOrWhiteSpace(cachedVariant)) ? ("(" + text + ")") : ""); SetTextIfChanged(variantText, value); } private void ClearRouteCache(float routeWidth) { SetTextIfChanged(routeText, string.Empty); SetTextIfChanged(variantText, string.Empty); cachedCapture = null; cachedSegments = null; cachedSegmentReferences = Array.Empty(); cachedSegmentBiomes = Array.Empty(); cachedSegmentParents = Array.Empty(); cachedCurrentSegment = null; cachedProgressPoints = null; cachedProgressPointReferences = Array.Empty(); cachedPeakProgressPoint = null; cachedPeakReached = false; cachedPllMapActive = false; cachedPllSegmentTitles = Array.Empty(); cachedTfaProjection = null; cachedTfaCurrentIndex = -1; cachedRouteWidth = routeWidth; cachedDisplayBiomes = true; routeNamesDirty = false; ResetVariantCache(); } private bool RouteSnapshotChanged(MapSegment[] segments, MapSegment currentSegment, bool isInNadir, ProgressPoint[] progressPoints, ProgressPoint? peakPoint, bool peakReached, bool pllMapActive, float width) { //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Invalid comparison between I4 and Unknown if (!cachedDisplayBiomes || routeNamesDirty || cachedSegments != segments || !Mathf.Approximately(cachedRouteWidth, width) || cachedCurrentSegment != currentSegment || cachedIsInNadir != isInNadir || cachedProgressPoints != progressPoints || cachedPeakProgressPoint != peakPoint || cachedPeakReached != peakReached || cachedPllMapActive != pllMapActive || cachedSegmentReferences.Length != segments.Length || cachedProgressPointReferences.Length != progressPoints.Length) { return true; } for (int i = 0; i < segments.Length; i++) { MapSegment val = segments[i]; if (cachedSegmentReferences[i] != val || (int)cachedSegmentBiomes[i] != (int)val.biome || cachedSegmentParents[i] != val.segmentParent) { return true; } } for (int j = 0; j < progressPoints.Length; j++) { if (cachedProgressPointReferences[j] != progressPoints[j]) { return true; } } return false; } private void CopyRouteSnapshot(MapSegment[] segments, MapSegment currentSegment, bool isInNadir, ProgressPoint[] progressPoints, ProgressPoint? peakPoint, bool peakReached, bool pllMapActive, float width) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected I4, but got Unknown cachedSegmentReferences = (MapSegment[])(object)new MapSegment[segments.Length]; cachedSegments = segments; cachedSegmentBiomes = (BiomeType[])(object)new BiomeType[segments.Length]; cachedSegmentParents = (GameObject?[])(object)new GameObject[segments.Length]; for (int i = 0; i < segments.Length; i++) { cachedSegmentReferences[i] = segments[i]; cachedSegmentBiomes[i] = (BiomeType)(int)segments[i].biome; cachedSegmentParents[i] = segments[i].segmentParent; } cachedProgressPointReferences = (ProgressPoint[])(object)new ProgressPoint[progressPoints.Length]; Array.Copy(progressPoints, cachedProgressPointReferences, progressPoints.Length); cachedCurrentSegment = currentSegment; cachedIsInNadir = isInNadir; cachedProgressPoints = progressPoints; cachedPeakProgressPoint = peakPoint; cachedPeakReached = peakReached; cachedPllMapActive = pllMapActive; cachedRouteWidth = width; cachedDisplayBiomes = true; routeNamesDirty = false; } private string BuildRouteDisplay(float width, MapSegment currentSegment, bool isInNadir, ProgressPoint? peakPoint, bool peakReached, out float currentEntryRightFromRouteRight) { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Invalid comparison between Unknown and I4 //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Invalid comparison between Unknown and I4 //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Invalid comparison between Unknown and I4 //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Invalid comparison between Unknown and I4 currentEntryRightFromRouteRight = 0f; if (cachedCapture == null) { return ""; } List list = new List(); int num = -1; bool flag = false; int num2 = -1; int num3 = Array.IndexOf(cachedSegmentReferences, currentSegment); int num4 = ((num3 >= 0 && num3 < cachedCapture.SegmentBiomeIndices.Length) ? cachedCapture.SegmentBiomeIndices[num3] : (-1)); for (int i = 0; i < cachedCapture.MapBiomes.Count; i++) { MapBiomeInfo mapBiomeInfo = cachedCapture.MapBiomes[i]; if ((int)mapBiomeInfo.BiomeType == 17) { continue; } if ((int)mapBiomeInfo.BiomeType == 5) { flag = true; num2 = list.Count; } BiomeType biomeType = mapBiomeInfo.BiomeType; if (((int)biomeType == 3 || (int)biomeType == 8) ? true : false) { bool num5 = i == num4; int num6 = (num5 ? (GetOccurrenceSegmentOrdinal(mapBiomeInfo, num3) % 2) : 0); string occurrenceName = GetOccurrenceName(mapBiomeInfo, 0); string occurrenceName2 = GetOccurrenceName(mapBiomeInfo, 1); list.Add(new RouteEntry(occurrenceName)); list.Add(new RouteEntry(occurrenceName2)); if (num5) { num = list.Count - ((num6 == 1) ? 1 : 2); } } else { list.Add(new RouteEntry(GetOccurrenceName(mapBiomeInfo, 0))); if (i == num4) { num = list.Count - 1; } } } if (!flag && peakPoint != null) { num2 = list.Count; string localizedTitle = peakPoint.localizedTitle; list.Add(new RouteEntry(string.IsNullOrWhiteSpace(localizedTitle) ? LocalizedText.GetText("PEAK", true) : localizedTitle)); } if (isInNadir) { list.Add(new RouteEntry(LocalizedText.GetText("AREA_VOID", true))); num = list.Count - 1; } else if (peakReached && num2 >= 0) { num = num2; } if (num < 0 || num >= list.Count) { return ""; } return BuildRouteDisplay(list, num, width, out currentEntryRightFromRouteRight); } private string GetOccurrenceName(MapBiomeInfo biome, int ordinal) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) if (ordinal >= 0 && ordinal < biome.SegmentIndices.Count) { int num = biome.SegmentIndices[ordinal]; if (num >= 0 && num < cachedPllSegmentTitles.Length && !string.IsNullOrWhiteSpace(cachedPllSegmentTitles[num])) { return cachedPllSegmentTitles[num]; } } return GetBiomeName(biome.BiomeType, ordinal); } private static int GetOccurrenceSegmentOrdinal(MapBiomeInfo biome, int segmentIndex) { int num = biome.SegmentIndices.IndexOf(segmentIndex); if (num >= 0) { return num; } return 0; } private string BuildRouteDisplay(List entries, int currentIndex, float width, out float currentEntryRightFromRouteRight) { int num = currentIndex; int num2 = currentIndex; while (num2 - num + 1 < 6) { bool flag = false; if (num2 + 1 < entries.Count && FitsRoute(entries, currentIndex, num, num2 + 1, width)) { num2++; flag = true; } if (num2 - num + 1 < 6 && num > 0 && FitsRoute(entries, currentIndex, num - 1, num2, width)) { num--; flag = true; } if (!flag) { break; } } string text = FormatRouteRange(entries, currentIndex, num, num2); if (MeasureText(text) > width) { text = FormatCurrentEntryToWidth(entries[currentIndex], width); } currentEntryRightFromRouteRight = GetCurrentEntryRightFromRouteRight(text); return text; } private bool FitsRoute(List entries, int currentIndex, int start, int end, float width) { return MeasureText(FormatRouteRange(entries, currentIndex, start, end)) <= width; } private string FormatRouteRange(List entries, int currentIndex, int start, int end) { StringBuilder stringBuilder = new StringBuilder(128); if (start > 0) { stringBuilder.Append("…(+").Append(start).Append(") · "); } for (int i = start; i <= end; i++) { if (i > start) { stringBuilder.Append(" · "); } stringBuilder.Append(FormatEntry(entries[i], i == currentIndex)); } int num = entries.Count - end - 1; if (num > 0) { stringBuilder.Append(" · …(+").Append(num).Append(')'); } return stringBuilder.ToString(); } private string FormatCurrentEntryToWidth(RouteEntry entry, float width) { string text = FormatEntry(entry, current: true); if (MeasureText(text) <= width) { return text; } for (int num = entry.Name.Length - 1; num >= 0; num--) { string text2 = FormatEntry(entry, current: true, entry.Name.Substring(0, num) + "…"); if (MeasureText(text2) <= width) { return text2; } } return FormatEntry(entry, current: true, "…"); } private static string FormatEntry(RouteEntry entry, bool current, string? nameOverride = null) { string text = nameOverride ?? entry.Name; if (!current) { return text; } return "[" + text + "]"; } private float GetCurrentEntryRightFromRouteRight(string routeDisplay) { string value = ""; int num = routeDisplay.IndexOf(value, StringComparison.Ordinal); if (num < 0) { return 0f; } int num2 = routeDisplay.IndexOf("", num, StringComparison.Ordinal); if (num2 < 0) { return 0f; } int num3 = num2 + "".Length; if (num3 >= routeDisplay.Length) { return 0f; } return MeasureText(routeDisplay.Substring(num3)); } private float MeasureText(string text) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) return routeText.GetPreferredValues(text).x; } private float GetRouteWidth() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) Rect rect = hudCanvasRect.rect; return Mathf.Max(0f, ((Rect)(ref rect)).width - 4f); } private void SetRouteRectWidth(float width) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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) RectTransform rectTransform = routeText.rectTransform; Vector2 anchoredPosition = rectTransform.anchoredPosition; anchoredPosition.x = -4f; rectTransform.anchoredPosition = anchoredPosition; rectTransform.SetSizeWithCurrentAnchors((Axis)0, width); RectTransform rectTransform2 = variantText.rectTransform; Rect rect = hudCanvasRect.rect; rectTransform2.SetSizeWithCurrentAnchors((Axis)0, ((Rect)(ref rect)).width); } private void UpdateVariantLayout(float currentEntryRightFromRouteRight) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) RectTransform rectTransform = variantText.rectTransform; Vector2 anchoredPosition = rectTransform.anchoredPosition; anchoredPosition.x = 0f - (4f + currentEntryRightFromRouteRight); rectTransform.anchoredPosition = anchoredPosition; } private void ResetVariantCache() { cachedVariantOccurrence = null; cachedTfaVariantStage = null; cachedVariant = ""; variantResolved = false; } private static string LocalizeVariant(BiomeType biomeType, string variant) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 //IL_000e: Unknown result type (might be due to invalid IL or missing references) if ((int)LocalizedText.CURRENT_LANGUAGE == 9 && SimplifiedChineseVariantNames.TryGetValue(biomeType, out IReadOnlyDictionary value) && value.TryGetValue(variant, out var value2)) { return value2; } return variant; } private static ProgressPoint[] GetProgressPoints() { return Singleton.Instance?.progressPoints ?? Array.Empty(); } private static ProgressPoint? GetUniquePeakProgressPoint(ProgressPoint[] progressPoints) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Invalid comparison between Unknown and I4 ProgressPoint val = null; foreach (ProgressPoint val2 in progressPoints) { if (val2 == null || (int)val2.biome != 5) { continue; } if (val != null) { if (!ambiguousPeakWarningLogged) { ambiguousPeakWarningLogged = true; Plugin.Logger.LogWarning((object)"Multiple Peak progress points were found; the biome route will not append an ambiguous Peak entry."); } return null; } val = val2; } return val; } private unsafe static string GetBiomeName(BiomeType biome, int part) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Invalid comparison between Unknown and I4 if ((int)biome != 3) { if ((int)biome != 8) { if ((int)biome == 17) { return LocalizedText.GetText("AREA_VOID", true); } return LocalizedText.GetText(((object)(*(BiomeType*)(&biome))/*cast due to .constrained prefix*/).ToString(), true); } return LocalizedText.GetText((part == 0) ? "GLOOM" : "THE CITADEL", true); } return LocalizedText.GetText((part == 0) ? "CALDERA" : "THE KILN", true); } private static void ConfigureText(TMP_Text text, bool autoSizeTextContainer) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) text.autoSizeTextContainer = autoSizeTextContainer; text.textWrappingMode = (TextWrappingModes)0; text.alignment = (TextAlignmentOptions)260; text.lineSpacing = -20f; text.fontSize = 20f; text.outlineColor = new Color32((byte)0, (byte)0, (byte)0, byte.MaxValue); text.outlineWidth = 0.055f; } private static void ConfigureRouteText(TMP_Text text, float fontSize) { ConfigureText(text, autoSizeTextContainer: false); text.richText = true; text.fontSize = fontSize; text.overflowMode = (TextOverflowModes)0; text.alignment = (TextAlignmentOptions)260; } private static void SetTextIfChanged(TMP_Text text, string value) { if (!string.Equals(text.text, value, StringComparison.Ordinal)) { text.text = value; } } private void OnLanguageChanged() { routeNamesDirty = true; } private void OnDestroy() { LocalizedText.OnLangugageChanged = (Action)Delegate.Remove(LocalizedText.OnLangugageChanged, new Action(OnLanguageChanged)); } private string GetLevelName(int levelIndex) { levelIndex %= mapBaker.ScenePaths.Length; return Path.GetFileNameWithoutExtension(mapBaker.ScenePaths[levelIndex]); } private int LevelNameToIndex(string levelName) { for (int i = 0; i < mapBaker.ScenePaths.Length; i++) { if (string.Equals(GetLevelName(i), levelName, StringComparison.OrdinalIgnoreCase)) { return i; } } return -1; } } internal sealed class OverheadNameplate : MonoBehaviour { private const float NameTextClearance = 25f; private CharacterStaminaBar? staminaBar; internal void Refresh(PlayerName name, bool visible) { Character localCharacter = Character.localCharacter; Character val = (((Object)(object)name.characterInteractable != (Object)null) ? name.characterInteractable.character : null); if ((Object)(object)localCharacter == (Object)null || (Object)(object)val == (Object)null || (Object)(object)val == (Object)(object)localCharacter || !ShouldShow(localCharacter, val)) { Hide(); return; } if ((Object)(object)name.text == (Object)null) { Hide(); return; } EnsureStaminaBar(((TMP_Text)name.text).transform, val); if ((Object)(object)staminaBar != (Object)null) { staminaBar.ObservedCharacter = val; staminaBar.AnimateEnable(); } } internal void Hide() { if ((Object)(object)staminaBar != (Object)null) { staminaBar.AnimateDisable(); } } private static bool ShouldShow(Character local, Character target) { //IL_0020: 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_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: 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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) float value = PluginConfig.TeammateStaminaBarProximity.Value; if (Vector3.Distance(((Character)(((Object)(object)Character.observedCharacter != (Object)null) ? ((object)Character.observedCharacter) : ((object)local))).Center, target.Center) > value) { return false; } Camera val = (((Object)(object)MainCamera.instance != (Object)null) ? ((Component)MainCamera.instance).GetComponent() : null); if ((Object)(object)val == (Object)null) { return true; } Vector3 val2 = val.WorldToViewportPoint(target.Center); if (val2.z > 0f && val2.x >= -0.1f && val2.x <= 1.1f && val2.y >= -0.1f) { return val2.y <= 1.1f; } return false; } private void EnsureStaminaBar(Transform parent, Character observedCharacter) { //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_018d: 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_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: Expected O, but got Unknown //IL_02f8: Unknown result type (might be due to invalid IL or missing references) //IL_0302: Unknown result type (might be due to invalid IL or missing references) //IL_0318: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)staminaBar != (Object)null && (Object)(object)((Component)staminaBar).gameObject != (Object)null && (Object)(object)((Component)staminaBar).transform.parent == (Object)(object)parent) { RemoveDuplicates(parent, ((Component)staminaBar).gameObject); return; } if ((Object)(object)staminaBar != (Object)null) { Object.Destroy((Object)(object)((Component)staminaBar).gameObject); staminaBar = null; } if ((Object)(object)GUIManager.instance == (Object)null || (Object)(object)GUIManager.instance.bar == (Object)null) { return; } Transform val = Object.Instantiate(((Component)GUIManager.instance.bar).transform, parent); Transform[] componentsInChildren = ((Component)val).GetComponentsInChildren(true); foreach (Transform val2 in componentsInChildren) { if (((Object)val2).name == "StaminaInfo") { Object.Destroy((Object)(object)((Component)val2).gameObject); } } val.SetAsFirstSibling(); Object.Destroy((Object)(object)((Component)val).GetComponent()); CharacterStaminaBar characterStaminaBar = ((Component)val).gameObject.AddComponent(); BarAffliction[] componentsInChildren2 = ((Component)val).GetComponentsInChildren(true); foreach (BarAffliction val3 in componentsInChildren2) { CharacterBarAffliction characterBarAffliction = ((Component)val3).gameObject.AddComponent(); characterBarAffliction.afflictionType = val3.afflictionType; characterBarAffliction.isPetrify = val3.isPetrify; characterBarAffliction.FetchReferences(); characterStaminaBar.AddCharacterBarAffliction(characterBarAffliction); Object.Destroy((Object)(object)val3); } GameObject val4 = new GameObject("CharacterName", new Type[2] { typeof(RectTransform), typeof(TextMeshProUGUI) }); RectTransform component = val4.GetComponent(); ((Transform)component).SetParent(val, false); TextMeshProUGUI component2 = val4.GetComponent(); TextMeshProUGUI heroDayText = GUIManager.instance.heroDayText; if ((Object)(object)heroDayText != (Object)null) { ((TMP_Text)component2).font = ((TMP_Text)heroDayText).font; ((TMP_Text)component2).fontSharedMaterial = ((TMP_Text)heroDayText).fontSharedMaterial; } string input = Regex.Replace(observedCharacter.characterName ?? "", "(|)", ""); ((TMP_Text)component2).text = input.TrimToByteLength(18); ((Object)component).name = "CharacterName: " + ((TMP_Text)component2).text; ((TMP_Text)component2).textWrappingMode = (TextWrappingModes)0; ((TMP_Text)component2).overflowMode = (TextOverflowModes)1; ((TMP_Text)component2).alignment = (TextAlignmentOptions)513; ((TMP_Text)component2).fontSize = 32f; ((TMP_Text)component2).autoSizeTextContainer = false; ((TMP_Text)component2).rectTransform.sizeDelta = new Vector2(260f, ((TMP_Text)component2).rectTransform.sizeDelta.y); Color color = Color.white; if (observedCharacter.refs != null && (Object)(object)observedCharacter.refs.customization != (Object)null) { color = observedCharacter.refs.customization.PlayerColor; } color.a = 1f; ((Graphic)component2).color = color; ((TMP_Text)component2).outlineColor = new Color32((byte)0, (byte)0, (byte)0, byte.MaxValue); ((TMP_Text)component2).outlineWidth = 0.055f; val4.SetActive(true); characterStaminaBar.InitializeHeader(component); characterStaminaBar.ObservedCharacter = observedCharacter; RectTransform val5 = (RectTransform)val; val5.pivot = new Vector2(0.5f, val5.pivot.y); val5.anchoredPosition = new Vector2(0f, 25f); staminaBar = characterStaminaBar; RemoveDuplicates(parent, ((Component)staminaBar).gameObject); staminaBar.AnimateEnable(); } private static void RemoveDuplicates(Transform parent, GameObject keep) { for (int num = parent.childCount - 1; num >= 0; num--) { Transform child = parent.GetChild(num); if ((Object)(object)((Component)child).gameObject != (Object)(object)keep && (Object)(object)((Component)child).GetComponent() != (Object)null) { Object.Destroy((Object)(object)((Component)child).gameObject); } } } } internal sealed class TimerHeightStats : MonoBehaviour { private const float TargetLookupRetryInterval = 1f; private const float VanillaFogSpeed = 0.4f; private MapSegment? cachedTargetSegment; private GameObject? cachedCampfireRoot; private Campfire? cachedTargetCampfire; private float nextTargetLookupTime; private ProgressPoint? cachedNextProgressPoint; private int cachedNextProgressPointIndex = -1; private bool cachedIsInNadir; private PeakGatePortal? nadirPeakPortal; private int? targetHeight; private float lastFogUpdateTime = -1f; private int lastFogHeight; private float lastFogTime = -1f; private float lastFogRate; private float lastRisingFieldRate; private float lastRisingFieldMultiplier; private float lastRisingFieldHeight; private float lastRisingFieldTime; private float lastRisingFieldUpdateTime = -1f; private bool hasRisingFieldStats; private TMP_Text tmpText; private DayNightManager _dayNightManager; private MapHandler _mapHandler; private OrbFogHandler _orbFogHandler; private LavaRising? activeRisingField; private static string GetTimeString(float totalSeconds) { int num = Mathf.FloorToInt(totalSeconds); int num2 = num / 3600; int num3 = num % 3600 / 60; int num4 = num % 60; return $"{num2:00}:{num3:00}:{num4:00}"; } private static string FormatTime(float seconds) { if (seconds < 60f) { return Mathf.CeilToInt(seconds) + "s"; } if (seconds < 3600f) { int num = Mathf.FloorToInt(seconds / 60f); int num2 = Mathf.CeilToInt(seconds % 60f); return $"{num}:{num2:D2}"; } int num3 = Mathf.FloorToInt(seconds / 3600f); int num4 = Mathf.FloorToInt(seconds % 3600f / 60f); return $"{num3}:{num4:D2}"; } private void Awake() { _dayNightManager = Object.FindFirstObjectByType(); _mapHandler = Singleton.Instance; _orbFogHandler = Singleton.Instance; } private void Start() { //IL_0062: Unknown result type (might be due to invalid IL or missing references) tmpText = ((Component)this).GetComponent(); tmpText.autoSizeTextContainer = true; tmpText.textWrappingMode = (TextWrappingModes)0; tmpText.alignment = (TextAlignmentOptions)258; tmpText.lineSpacing = -40f; tmpText.fontSize = 26f; tmpText.outlineColor = new Color32((byte)0, (byte)0, (byte)0, byte.MaxValue); tmpText.outlineWidth = 0.055f; } private void Update() { try { Character localCharacter = Character.localCharacter; Character observedCharacter = Character.observedCharacter; if (Object.op_Implicit((Object)(object)tmpText) && Object.op_Implicit((Object)(object)localCharacter) && Object.op_Implicit((Object)(object)observedCharacter)) { CharacterStats stats = observedCharacter.refs.stats; StringBuilder stringBuilder = new StringBuilder(128); AppendTimerText(stringBuilder); AppendDayNightStatus(stringBuilder); AppendHeightInfo(stringBuilder, stats); AppendHazardStats(stringBuilder, stats); tmpText.text = stringBuilder.ToString(); } } catch (Exception ex) { Plugin.Logger.LogInfo((object)ex.ToString()); } } private void AppendTimerText(StringBuilder sb) { if (PluginConfig.DisplayTimer.Value) { string timeString = GetTimeString(GameRef.GetTimeSinceRunStarted(RunManager.Instance)); sb.Append(timeString); } } private void AppendDayNightStatus(StringBuilder sb) { if (PluginConfig.DisplayDayNightCountdown.Value) { if (sb.Length > 0 && PluginConfig.DisplayTimer.Value) { sb.Append(" | "); } var (arg, num) = CalculateDayNightStatus(_dayNightManager.timeOfDay, _dayNightManager.dayStart, _dayNightManager.dayEnd); sb.AppendFormat("({0}: {1:P0})", arg, num); } } private (string status, float countdown) CalculateDayNightStatus(float timeOfDay, float dayStart, float dayEnd) { float num = dayEnd - dayStart; float num2 = 24f - num; if (timeOfDay >= dayStart && timeOfDay < dayEnd) { return (status: "Day", countdown: 1f - (timeOfDay - dayStart) / num); } float num3 = ((timeOfDay < dayStart) ? (timeOfDay + 24f) : timeOfDay); return (status: "Night", countdown: 1f - (num3 - dayEnd) / num2); } private void AppendHeightInfo(StringBuilder sb, CharacterStats stats) { if (PluginConfig.DisplayHeight.Value) { UpdateCachedTargetHeight(); if (sb.Length > 0 && (PluginConfig.DisplayTimer.Value || PluginConfig.DisplayDayNightCountdown.Value)) { sb.AppendLine(); } if (!targetHeight.HasValue) { sb.AppendFormat("{0}m", stats.heightInMeters); } else { sb.AppendFormat("{0}m/{1}m", stats.heightInMeters, targetHeight.Value); } } } private void UpdateCachedTargetHeight() { //IL_012d: 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_022d: Unknown result type (might be due to invalid IL or missing references) MapSegment currentMapSegment = MapHandler.CurrentMapSegment; GameObject val = ((currentMapSegment != null) ? currentMapSegment.segmentCampfire : null); bool inNadir = _mapHandler.inNadir; MountainProgressHandler instance = Singleton.Instance; ProgressPoint val2 = null; int num = -1; ProgressPoint[] array = instance?.progressPoints; if (array != null && array.Length > 0) { int num2 = instance.maxProgressPointReached + 1; if (num2 >= 0 && num2 < array.Length) { num = num2; val2 = array[num2]; } } bool num3 = cachedTargetSegment != currentMapSegment || (Object)(object)cachedCampfireRoot != (Object)(object)val || cachedIsInNadir != inNadir; bool flag = cachedNextProgressPointIndex != num || cachedNextProgressPoint != val2; bool flag2 = num3 || flag; if (num3) { cachedTargetSegment = currentMapSegment; cachedCampfireRoot = val; cachedIsInNadir = inNadir; cachedTargetCampfire = null; nextTargetLookupTime = 0f; nadirPeakPortal = null; } if (flag) { cachedNextProgressPointIndex = num; cachedNextProgressPoint = val2; } if (inNadir) { if (flag2 || (Object)(object)nadirPeakPortal == (Object)null) { PeakGatePortal val3 = GetNadirPeakPortal(); targetHeight = (((Object)(object)val3 != (Object)null) ? new int?(ConvertTargetHeight(((Component)val3).transform.position.y)) : ((int?)null)); } return; } bool flag3 = (Object)(object)cachedTargetCampfire == (Object)null && cachedTargetCampfire != null; bool flag4 = Time.unscaledTime >= nextTargetLookupTime && (Object)(object)cachedTargetCampfire == (Object)null; if (flag3 || flag4) { cachedTargetCampfire = ((val != null) ? val.GetComponentInChildren(true) : null); nextTargetLookupTime = (((Object)(object)cachedTargetCampfire != (Object)null) ? float.PositiveInfinity : (Time.unscaledTime + 1f)); } if (flag2 || flag3 || flag4) { float? num4 = (((Object)(object)cachedTargetCampfire != (Object)null) ? new float?(((Component)cachedTargetCampfire).transform.position.y) : ((float?)null)); float? num5 = (((Object)(object)val2?.transform != (Object)null) ? new float?(val2.transform.position.y) : ((float?)null)); float? num6 = ((num4.HasValue && num5.HasValue) ? new float?(Mathf.Max(num4.Value, num5.Value)) : (num4 ?? num5)); targetHeight = (num6.HasValue ? new int?(ConvertTargetHeight(num6.Value)) : ((int?)null)); } } private static int ConvertTargetHeight(float heightInUnits) { return Mathf.RoundToInt(CharacterStats.unitsToMeters * heightInUnits); } private PeakGatePortal? GetNadirPeakPortal() { if ((Object)(object)nadirPeakPortal != (Object)null) { return nadirPeakPortal; } MapSegment? obj = cachedTargetSegment; nadirPeakPortal = ((obj != null) ? obj.segmentParent.GetComponentInChildren(true) : null); return nadirPeakPortal; } private void AppendHazardStats(StringBuilder sb, CharacterStats stats) { //IL_00b8: Unknown result type (might be due to invalid IL or missing references) if (!PluginConfig.DisplayFog.Value && !PluginConfig.DisplayLava.Value) { return; } LavaRising val = FindRisingFieldForCurrentRegion(); LavaRising val2 = ((PluginConfig.DisplayLava.Value && (Object)(object)val != (Object)null && val.started && !val.ended && (Object)(object)val.lava != (Object)null) ? val : null); SetActiveRisingField(val2); bool flag = (Object)(object)val2 != (Object)null; bool flag2 = PluginConfig.DisplayFog.Value && (Object)(object)val == (Object)null && (Object)(object)_orbFogHandler != (Object)null && _orbFogHandler.isMoving; if (!flag && !flag2) { return; } string arg; string value; float num; if (flag) { UpdateRisingFieldStats(val2, stats); if (!hasRisingFieldStats) { return; } arg = GetRisingFieldColor(val2.risingFieldType); value = ((lastRisingFieldTime > 0f) ? $"(<#{arg}>{Mathf.CeilToInt(lastRisingFieldHeight)}m/{FormatTime(Mathf.CeilToInt(lastRisingFieldTime))})" : $"(<#{arg}>{Mathf.CeilToInt(lastRisingFieldHeight)}m)"); num = lastRisingFieldMultiplier; } else { object fogSphere = GameRef.GetFogSphere(_orbFogHandler); if (fogSphere == null) { return; } UpdateFogStats(stats, fogSphere); if (Mathf.Approximately(lastFogRate, 0f)) { return; } arg = "00BCFF"; value = ((lastFogTime > 0f) ? $"(<#{arg}>{lastFogHeight}m/{FormatTime(Mathf.CeilToInt(lastFogTime))})" : $"(<#{arg}>{lastFogHeight}m)"); num = lastFogRate / 0.4f; } if (sb.Length > 0 && (PluginConfig.DisplayTimer.Value || PluginConfig.DisplayDayNightCountdown.Value || PluginConfig.DisplayHeight.Value)) { sb.Append(" | "); } sb.Append(value); sb.Append($" [<#{arg}>{num:F2}x]"); } private void UpdateFogStats(CharacterStats stats, object sphere) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) if (!(lastFogUpdateTime >= 0f) || !(Time.time - lastFogUpdateTime <= 1f)) { (float radius, float rate) displayState = FogMovementTracker.GetDisplayState(_orbFogHandler); float item = displayState.radius; float item2 = displayState.rate; Vector3 fogPoint = GameRef.GetFogPoint(sphere); Character character = GameRef.GetCharacter(stats); Vector3 val = (((Object)(object)character != (Object)null) ? character.Center : Vector3.zero) - fogPoint; float magnitude = ((Vector3)(ref val)).magnitude; float num = magnitude - item; lastFogRate = item2; lastFogUpdateTime = Time.time; float num2 = ((magnitude > 0.0001f) ? (fogPoint.y + val.y / magnitude * item) : fogPoint.y); lastFogHeight = Mathf.RoundToInt(num2 * CharacterStats.unitsToMeters); lastFogTime = ((num < 0f && lastFogRate > 0f) ? Mathf.Abs(num / lastFogRate) : 0f); } } private LavaRising? FindRisingFieldForCurrentRegion() { //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_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_0013: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) Segment currentSegment = _mapHandler.GetCurrentSegment(); RisingFieldType expectedRisingFieldType = GetExpectedRisingFieldType(currentSegment); foreach (LavaRising item in LavaRising.ALL_LAVA) { if (Object.op_Implicit((Object)(object)item) && ((Behaviour)item).isActiveAndEnabled && item.requiredSegment == currentSegment && item.risingFieldType == expectedRisingFieldType) { return item; } } return null; } private RisingFieldType GetExpectedRisingFieldType(Segment currentMapSegment) { //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_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Invalid comparison between Unknown and I4 //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Invalid comparison between Unknown and I4 //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Invalid comparison between Unknown and I4 BiomeType currentBiome = _mapHandler.GetCurrentBiome(); if ((int)currentMapSegment != 6 && (int)currentBiome != 17) { if ((int)currentBiome == 8) { return (RisingFieldType)1; } return (RisingFieldType)0; } return (RisingFieldType)2; } private void SetActiveRisingField(LavaRising? risingField) { if (!((Object)(object)activeRisingField == (Object)(object)risingField)) { activeRisingField = risingField; lastRisingFieldRate = 0f; lastRisingFieldMultiplier = 0f; lastRisingFieldHeight = 0f; lastRisingFieldTime = 0f; lastRisingFieldUpdateTime = -1f; hasRisingFieldStats = false; if ((Object)(object)risingField != (Object)null) { RisingFieldMovementTracker.EnsureTracking(risingField); } } } private void UpdateRisingFieldStats(LavaRising risingField, CharacterStats stats) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) if (!(lastRisingFieldUpdateTime >= 0f) || !(Time.time - lastRisingFieldUpdateTime <= 1f)) { (float timeTraveled, float rate) displayState = RisingFieldMovementTracker.GetDisplayState(risingField); float item = displayState.timeTraveled; float item2 = displayState.rate; float num = GameRef.GetStartHeight(risingField) * CharacterStats.unitsToMeters; float num2 = risingField.topTransform.position.y * CharacterStats.unitsToMeters; float num3 = ((risingField.travelTime > 0.0001f) ? ((num2 - num) / risingField.travelTime) : 0f); lastRisingFieldRate = num3 * item2; lastRisingFieldMultiplier = item2; float num4 = ((risingField.travelTime > 0.0001f) ? Mathf.Clamp01(item / risingField.travelTime) : 0f); lastRisingFieldHeight = Mathf.Lerp(num, num2, num4); float num5 = stats.heightInMeters - lastRisingFieldHeight; lastRisingFieldTime = ((num5 > 0f && lastRisingFieldRate > 0.001f) ? (num5 / lastRisingFieldRate) : 0f); lastRisingFieldUpdateTime = Time.time; hasRisingFieldStats = true; } } private static string GetRisingFieldColor(RisingFieldType fieldType) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 if ((int)fieldType != 1) { if ((int)fieldType == 2) { return "D8D8FF"; } return "FF4500"; } return "B266FF"; } } [HarmonyWrapSafe] internal static class FogMovementTracker { private const float MinimumFogRadius = 30f; private const float RateSampleWindow = 0.5f; private const float MinimumSampleInterval = 0.0001f; private static OrbFogHandler? trackedHandler; private static bool hasSample; private static float previousSize; private static float previousSampleTime; private static float accumulatedSizeDelta; private static float accumulatedSampleTime; private static float measuredRate; private static bool hasMeasuredRate; private static bool hasSynchronizedSample; private static float previousSynchronizedSize; private static float previousSynchronizedTime; private static float synchronizedSize; private static float synchronizedTime; private static float synchronizedRate; private static bool hasSynchronizedRate; internal static (float radius, float rate) GetDisplayState(OrbFogHandler handler) { if (!PhotonNetwork.IsMasterClient && (Object)(object)trackedHandler == (Object)(object)handler && hasSynchronizedRate) { float num = Mathf.Max(0f, Time.time - synchronizedTime); return (radius: Mathf.Max(30f, synchronizedSize - synchronizedRate * num), rate: synchronizedRate); } float item = (((Object)(object)trackedHandler == (Object)(object)handler && hasMeasuredRate) ? measuredRate : handler.speed); return (radius: handler.currentSize, rate: item); } private static void Reset(OrbFogHandler handler) { trackedHandler = handler; ResetLocalSample(handler); hasSynchronizedSample = false; previousSynchronizedSize = 0f; previousSynchronizedTime = 0f; synchronizedSize = 0f; synchronizedTime = 0f; synchronizedRate = 0f; hasSynchronizedRate = false; } private static void ResetLocalSample(OrbFogHandler handler) { hasSample = true; previousSize = handler.currentSize; previousSampleTime = Time.time; accumulatedSizeDelta = 0f; accumulatedSampleTime = 0f; measuredRate = 0f; hasMeasuredRate = false; } private static void ObserveSynchronizedFog(OrbFogHandler handler, float size, bool isMoving) { if ((Object)(object)trackedHandler != (Object)(object)handler) { Reset(handler); } if (!isMoving) { Reset(handler); return; } float time = Time.time; if (hasSynchronizedSample) { float num = time - previousSynchronizedTime; if (num > 0.0001f) { synchronizedRate = (previousSynchronizedSize - size) / num; hasSynchronizedRate = true; } } hasSynchronizedSample = true; previousSynchronizedSize = size; previousSynchronizedTime = time; synchronizedSize = size; synchronizedTime = time; ResetLocalSample(handler); } private static void Sample(OrbFogHandler handler) { if ((Object)(object)trackedHandler != (Object)(object)handler || !handler.isMoving) { Reset(handler); return; } if (!hasSample) { Reset(handler); return; } float time = Time.time; float num = time - previousSampleTime; if (!(num <= 0.0001f)) { accumulatedSizeDelta += previousSize - handler.currentSize; accumulatedSampleTime += num; previousSize = handler.currentSize; previousSampleTime = time; if (!(accumulatedSampleTime < 0.5f)) { measuredRate = accumulatedSizeDelta / accumulatedSampleTime; hasMeasuredRate = true; accumulatedSizeDelta = 0f; accumulatedSampleTime = 0f; } } } [HarmonyPatch(typeof(OrbFogHandler), "Update")] [HarmonyPostfix] private static void OrbFogHandlerUpdatePostfix(OrbFogHandler __instance) { Sample(__instance); } [HarmonyPatch(typeof(OrbFogHandler), "RPCA_SyncFog")] [HarmonyPostfix] private static void OrbFogHandlerSyncFogPostfix(OrbFogHandler __instance) { ObserveSynchronizedFog(__instance, __instance.currentSize, __instance.isMoving); } [HarmonyPatch(typeof(OrbFogHandler), "RPC_InitFog")] [HarmonyPostfix] private static void OrbFogHandlerInitFogPostfix(OrbFogHandler __instance) { Reset(__instance); } [HarmonyPatch(typeof(OrbFogHandler), "StartMovingRPC")] [HarmonyPostfix] private static void OrbFogHandlerStartMovingPostfix(OrbFogHandler __instance) { Reset(__instance); } [HarmonyPatch(typeof(OrbFogHandler), "SetFogOrigin")] [HarmonyPostfix] private static void OrbFogHandlerSetFogOriginPostfix(OrbFogHandler __instance) { Reset(__instance); } } [HarmonyWrapSafe] internal static class RisingFieldMovementTracker { private sealed class SampleState { internal float PreviousTimeTraveled; internal float PreviousSampleTime; internal float AccumulatedTravelDelta; internal float AccumulatedSampleTime; internal float MeasuredRate; internal bool HasMeasuredRate; internal bool HasSynchronizedSample; internal float PreviousSynchronizedTimeTraveled; internal float PreviousSynchronizedTime; internal float SynchronizedTimeTraveled; internal float SynchronizedTime; internal float SynchronizedRate; internal bool HasSynchronizedRate; } private const float RateSampleWindow = 0.5f; private const float MinimumSampleInterval = 0.0001f; private static readonly Dictionary sampleStates = new Dictionary(); internal static (float timeTraveled, float rate) GetDisplayState(LavaRising handler) { if (sampleStates.TryGetValue(handler, out SampleState value)) { if (!PhotonNetwork.IsMasterClient && value.HasSynchronizedRate) { float num = Mathf.Max(0f, Time.time - value.SynchronizedTime); return (timeTraveled: Mathf.Clamp(value.SynchronizedTimeTraveled + value.SynchronizedRate * num, 0f, Mathf.Max(0f, handler.travelTime)), rate: value.SynchronizedRate); } if (value.HasMeasuredRate) { return (timeTraveled: handler.timeTraveled, rate: value.MeasuredRate); } } return (timeTraveled: handler.timeTraveled, rate: (handler.started && !handler.ended) ? 1f : 0f); } internal static void Reset(LavaRising handler) { sampleStates[handler] = new SampleState { PreviousTimeTraveled = handler.timeTraveled, PreviousSampleTime = Time.time }; } internal static void EnsureTracking(LavaRising handler) { if (!sampleStates.ContainsKey(handler)) { Reset(handler); } } private static void ObserveSynchronizedField(LavaRising handler) { if (!handler.started || handler.ended) { sampleStates.Remove(handler); return; } EnsureTracking(handler); SampleState sampleState = sampleStates[handler]; float time = Time.time; float timeTraveled = handler.timeTraveled; if (sampleState.HasSynchronizedSample && timeTraveled < sampleState.PreviousSynchronizedTimeTraveled) { sampleState.HasSynchronizedSample = false; sampleState.HasSynchronizedRate = false; } if (sampleState.HasSynchronizedSample) { float num = time - sampleState.PreviousSynchronizedTime; if (num > 0.0001f) { sampleState.SynchronizedRate = (timeTraveled - sampleState.PreviousSynchronizedTimeTraveled) / num; sampleState.HasSynchronizedRate = true; } } sampleState.HasSynchronizedSample = true; sampleState.PreviousSynchronizedTimeTraveled = timeTraveled; sampleState.PreviousSynchronizedTime = time; sampleState.SynchronizedTimeTraveled = timeTraveled; sampleState.SynchronizedTime = time; sampleState.PreviousTimeTraveled = timeTraveled; sampleState.PreviousSampleTime = time; sampleState.AccumulatedTravelDelta = 0f; sampleState.AccumulatedSampleTime = 0f; sampleState.MeasuredRate = 0f; sampleState.HasMeasuredRate = false; } private static void Sample(LavaRising handler) { if (!handler.started || handler.ended) { sampleStates.Remove(handler); return; } if (!sampleStates.TryGetValue(handler, out SampleState value)) { Reset(handler); return; } float time = Time.time; float num = time - value.PreviousSampleTime; if (!(num <= 0.0001f)) { value.AccumulatedTravelDelta += handler.timeTraveled - value.PreviousTimeTraveled; value.AccumulatedSampleTime += num; value.PreviousTimeTraveled = handler.timeTraveled; value.PreviousSampleTime = time; if (!(value.AccumulatedSampleTime < 0.5f)) { value.MeasuredRate = value.AccumulatedTravelDelta / value.AccumulatedSampleTime; value.HasMeasuredRate = true; value.AccumulatedTravelDelta = 0f; value.AccumulatedSampleTime = 0f; } } } [HarmonyPatch(typeof(LavaRising), "Update")] [HarmonyPostfix] private static void LavaRisingUpdatePostfix(LavaRising __instance) { Sample(__instance); } [HarmonyPatch(typeof(LavaRising), "RecieveLavaData")] [HarmonyPostfix] private static void LavaRisingReceiveDataPostfix(LavaRising __instance) { ObserveSynchronizedField(__instance); } [HarmonyPatch(typeof(LavaRising), "OnDisable")] [HarmonyPostfix] private static void LavaRisingOnDisablePostfix(LavaRising __instance) { sampleStates.Remove(__instance); } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public string AssemblyName { get; } public IgnoresAccessChecksToAttribute(string assemblyName) { AssemblyName = assemblyName; } } }