using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
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 PeakStatsEx.Compatibility;
using PeakStatsEx.MonoBehaviours;
using Photon.Pun;
using TMPro;
using TerrainCustomiser;
using TerrainRandomiser;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using Zorro.Core;
using Zorro.Core.Editor;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("com.github.LengSword.PeakStatsEx")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.2.4.0")]
[assembly: AssemblyInformationalVersion("1.2.4+11e9cd8b02b753dcde315f535dbe616d9ebb174f")]
[assembly: AssemblyProduct("com.github.LengSword.PeakStatsEx")]
[assembly: AssemblyTitle("PeakStatsEx")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.4.0")]
[module: UnverifiableCode]
[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 BepInEx
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
internal sealed class BepInAutoPluginAttribute : Attribute
{
public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
{
}
}
}
namespace BepInEx.Preloader.Core.Patching
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
internal sealed class PatcherAutoPluginAttribute : Attribute
{
public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
{
}
}
}
namespace PeakStatsEx
{
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("com.github.LengSword.PeakStatsEx", "PeakStatsEx", "1.2.4")]
public class Plugin : BaseUnityPlugin
{
public const string Id = "com.github.LengSword.PeakStatsEx";
internal static ManualLogSource Logger { get; private set; }
public static string Name => "PeakStatsEx";
public static string Version => "1.2.4";
private void Awake()
{
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Expected O, but got Unknown
Logger = ((BaseUnityPlugin)this).Logger;
Logger.LogInfo((object)("Plugin " + Name + " is loaded!"));
PluginConfig.Initialize(((BaseUnityPlugin)this).Config, Logger);
Harmony val = new Harmony("com.github.LengSword.PeakStatsEx");
val.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();
}
FixBarGroup();
void CreateMapStats()
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Expected O, but got Unknown
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: 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_0067: 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)
Transform transform = ((Component)((Component)__instance).GetComponentInChildren<AscentUI>()).transform;
RectTransform val = (RectTransform)Object.Instantiate<Transform>(transform, transform.parent);
((Object)val).name = "Map & Level UI";
Object.Destroy((Object)(object)((Component)val).GetComponent<AscentUI>());
((Component)val).gameObject.AddComponent<MapStats>();
Vector2 val2 = default(Vector2);
((Vector2)(ref val2))..ctor(1f, 1f);
val.anchorMin = val2;
Vector2 pivot = (val.anchorMax = val2);
val.pivot = pivot;
val.anchoredPosition = new Vector2(0f, 5f);
}
void CreateTimerAndHeightStats()
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Expected O, but got Unknown
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: 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_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
Transform transform = ((Component)((Component)__instance).GetComponentInChildren<AscentUI>()).transform;
RectTransform val = (RectTransform)Object.Instantiate<Transform>(transform, transform.parent);
((Object)val).name = "Timer & Height UI";
Object.Destroy((Object)(object)((Component)val).GetComponent<AscentUI>());
((Component)val).gameObject.AddComponent<TimerHeightStats>();
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;
}
void FixBarGroup()
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
RectTransform val = (RectTransform)((Component)__instance.bar).transform.parent;
val.sizeDelta = new Vector2(600f, 1200f);
Vector2 anchoredPosition = val.anchoredPosition;
anchoredPosition.y = 660f;
val.anchoredPosition = anchoredPosition;
((HorizontalOrVerticalLayoutGroup)((Component)val).GetComponent<VerticalLayoutGroup>()).spacing = 25f;
}
}
[HarmonyPatch(typeof(PlayerHandler), "RegisterCharacter")]
[HarmonyPostfix]
private static void PlayerHandlerRegisterCharacterHook(Character character)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)character != (Object)null && (Object)(object)((MonoBehaviourPun)character).photonView != (Object)null && ((MonoBehaviourPun)character).photonView.IsMine)
{
Scene activeScene = SceneManager.GetActiveScene();
if (((Scene)(ref activeScene)).name != "Airport")
{
((Component)character).gameObject.AddComponent<ProximityStaminaManager>();
}
}
}
[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);
string text = Encoding.UTF8.GetString(array, 0, byteLength);
return text.TrimEnd('\ufffd');
}
}
public static class PluginConfig
{
internal static ConfigEntry<bool> DisplayTimer { get; private set; }
internal static ConfigEntry<bool> DisplayHeight { get; private set; }
internal static ConfigEntry<bool> DisplayLevel { get; private set; }
internal static ConfigEntry<bool> DisplayBiomes { get; private set; }
internal static ConfigEntry<bool> DisplaySelfStaminaBar { get; private set; }
internal static ConfigEntry<bool> DisplayDayNightCountdown { get; private set; }
internal static ConfigEntry<bool> DisplayFog { get; private set; }
internal static ConfigEntry<bool> DisplayLava { get; private set; }
internal static ConfigEntry<bool> DisplayTerrainRandomiserSeed { get; private set; }
internal static ConfigEntry<bool> DisplayTerrainCustomiserSeed { get; private set; }
internal static ConfigEntry<bool> DisplayTeammateStaminaBars { get; private set; }
internal static ConfigEntry<float> TeammateStaminaBarProximity { get; private set; }
internal static ConfigEntry<int> TeammateStaminaBarLimit { get; private set; }
internal static ConfigEntry<float> TeammateStaminaBarScale { get; private set; }
internal static ConfigEntry<bool> ShowInventorySlots { get; private set; }
internal static ConfigEntry<bool> ShowStaminaInfo { get; private set; }
internal static ConfigEntry<float> StaminaInfoFontSize { get; private set; }
internal static ConfigEntry<float> StaminaInfoOutlineWidth { get; private set; }
internal static ConfigEntry<bool> StaminaInfoRoundStaminaBars { get; private set; }
internal static ConfigEntry<bool> StaminaInfoRoundAfflictionBars { get; private set; }
internal static ConfigEntry<bool> StaminaInfoShowAfflictionCountdown { 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
DisplayTeammateStaminaBars = config.Bind<bool>("General", "Display Teammate Stamina Bars", true, "Displays your teammates' stamina bars at the bottom left of your screen");
TeammateStaminaBarProximity = config.Bind<float>("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<float>(1f, 10000f), Array.Empty<object>()));
TeammateStaminaBarLimit = config.Bind<int>("General", "Teammate Stamina Bar Limit", 4, new ConfigDescription("Max teammate stamina bars", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 16), Array.Empty<object>()));
TeammateStaminaBarScale = config.Bind<float>("General", "Teammate Stamina Bar Scale (Default: 0.72)", 0.72f, new ConfigDescription("Teammate stamina bars scale", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.2f, 1f), Array.Empty<object>()));
ShowInventorySlots = config.Bind<bool>("General", "Show Inventory Slots", true, "Show teammate inventory slots");
ShowStaminaInfo = config.Bind<bool>("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<bool>("Stats", "Display Timer", true, "Displays how long you've been climbing for, at the top of your screen");
DisplayHeight = config.Bind<bool>("Stats", "Display Height", true, "Displays how far you've climbed, in meters, at the top of your screen");
DisplayLevel = config.Bind<bool>("Stats", "Display Level", true, "Displays current map level name, at the top right of your screen");
DisplayBiomes = config.Bind<bool>("Stats", "Display Biomes", true, "Displays current map biomes name, at the top right of your screen");
DisplayDayNightCountdown = config.Bind<bool>("Stats", "Display Day Night Countdown", true, "Displays current day and night countdown, at the top of your screen");
DisplayFog = config.Bind<bool>("Stats", "Display Fog Stats", true, "Displays current fog stats, at the top of your screen");
DisplayLava = config.Bind<bool>("Stats", "Display Lava Stats", true, "Displays current lava stats, at the top of your screen");
DisplayTerrainRandomiserSeed = config.Bind<bool>("Stats", "Display Terrain Randomiser Seed", true, "Displays current terrain randomiser seed, at the top right of your screen");
DisplayTerrainCustomiserSeed = config.Bind<bool>("Stats", "Display Terrain Customiser Seed", true, "Displays current terrain customiser seed, at the top right of your screen");
StaminaInfoFontSize = config.Bind<float>("StaminaInfo", "Bar Font Size", 20f, "Customize the Font Size for stamina bar text.");
StaminaInfoOutlineWidth = config.Bind<float>("StaminaInfo", "Bar Outline Width", 0.08f, "Customize the Outline Width for stamina bar text.");
StaminaInfoRoundStaminaBars = config.Bind<bool>("StaminaInfo", "Round Stamina Bars", true, "If true, rounds to the nearest whole number for the stamina and extra stamina bars.");
StaminaInfoRoundAfflictionBars = config.Bind<bool>("StaminaInfo", "Round Affliction Bars", false, "If true, rounds to the nearest whole number for affliction bars.");
StaminaInfoShowAfflictionCountdown = config.Bind<bool>("StaminaInfo", "Show Affliction Countdown", false, "If true, show self affliction bars with countdown.");
DisplaySelfStaminaBar = config.Bind<bool>("Debug", "Display Self Stamina Bar", false, "Displays your stamina bar at the bottom left of your screen");
logger.LogInfo((object)"Plugin Config Loaded.");
}
}
[HarmonyWrapSafe]
internal sealed class StaminaInfoPatch
{
internal static GUIManager guiManager = null;
internal static Dictionary<string, TextMeshProUGUI> barTexts = new Dictionary<string, TextMeshProUGUI>();
internal static Dictionary<string, float> lastKnownData = new Dictionary<string, float>();
internal static Dictionary<string, float> lastKnownAffData = new Dictionary<string, float>();
internal static Dictionary<string, float> lastAfflictionUpdateTime = new Dictionary<string, float>();
private const float LargeBarThreshold = 30f;
private const float SmallBarThreshold = 15f;
private const float BarUnitSize = 6f;
private const float AfflictionRefreshInterval = 0.5f;
internal static Dictionary<int, float> LastUpdateTime { get; set; } = new Dictionary<int, float>();
[HarmonyPatch(typeof(StaminaBar), "Update")]
[HarmonyPostfix]
private static void StaminaInfoStaminaBarUpdate(StaminaBar __instance)
{
try
{
if ((Object)(object)guiManager == (Object)null)
{
barTexts = new Dictionary<string, TextMeshProUGUI>();
lastKnownData = new Dictionary<string, float>();
lastKnownAffData = new Dictionary<string, float>();
lastAfflictionUpdateTime = new Dictionary<string, float>();
InitStaminaInfo(__instance);
}
if (!PluginConfig.ShowStaminaInfo.Value)
{
HideBarTexts(__instance);
}
else 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);
}
else 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));
}
}
private static void UpdateBarTexts(StaminaBar staminaBar)
{
//IL_006c: 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)
UpdateBarText(((Object)staminaBar.staminaBar).name, staminaBar.desiredStaminaSize, PluginConfig.StaminaInfoRoundStaminaBars.Value, trimWholeDecimal: false, lastKnownData);
UpdateBarText("ExtraStamina", staminaBar.desiredExtraStaminaSize, PluginConfig.StaminaInfoRoundStaminaBars.Value, trimWholeDecimal: false, lastKnownData);
BarAffliction[] afflictions = staminaBar.afflictions;
foreach (BarAffliction val in afflictions)
{
string name = ((Object)val).name;
bool flag = CanShowCountdown(val.afflictionType);
bool flag2 = flag && val.size > 0f && (!lastAfflictionUpdateTime.ContainsKey(name) || Time.time - lastAfflictionUpdateTime[name] > 0.5f);
string suffix = string.Empty;
if (flag && PluginConfig.StaminaInfoShowAfflictionCountdown.Value)
{
float reductionTimeRemaining = GetReductionTimeRemaining(val.afflictionType);
if (reductionTimeRemaining > 0f)
{
suffix = "(" + FormatTime(reductionTimeRemaining) + ")";
}
}
UpdateBarText(name, val.size, PluginConfig.StaminaInfoRoundAfflictionBars.Value, trimWholeDecimal: true, lastKnownAffData, suffix, flag2);
if (flag2)
{
lastAfflictionUpdateTime[name] = Time.time;
}
}
}
public static void UpdateCharacterBarTexts(CharacterStaminaBar characterStaminaBar)
{
//IL_0031: 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)
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);
UpdateBarText(GetCharacterExtraStaminaKey(instanceID), size2, PluginConfig.StaminaInfoRoundStaminaBars.Value, trimWholeDecimal: false, lastKnownData);
foreach (CharacterBarAffliction characterBarAffliction in characterStaminaBar.characterBarAfflictions)
{
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<string, float> cache, string suffix = "", bool forceUpdate = false)
{
if (!barTexts.TryGetValue(key, out TextMeshProUGUI value) || (!forceUpdate && cache.ContainsKey(key) && Mathf.Approximately(cache[key], size) && ((Component)value).gameObject.activeSelf))
{
return;
}
if (size < 15f)
{
((Component)value).gameObject.SetActive(false);
cache[key] = size;
return;
}
string text;
if (size >= 30f)
{
float num = size / 6f;
if (roundLargeValue)
{
text = Mathf.Round(num).ToString();
}
else
{
text = num.ToString("F1");
if (trimWholeDecimal)
{
text = text.Replace(".0", "");
}
}
}
else
{
text = Mathf.Round(size / 6f).ToString();
}
((TMP_Text)value).text = (string.IsNullOrEmpty(suffix) ? text : (text + suffix));
((Component)value).gameObject.SetActive(true);
cache[key] = size;
}
private static void HideBarTexts(StaminaBar staminaBar)
{
HideText(((Object)staminaBar.staminaBar).name);
HideText("ExtraStamina");
BarAffliction[] afflictions = staminaBar.afflictions;
foreach (BarAffliction val in afflictions)
{
HideText(((Object)val).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 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)
{
GameObject val = GameObject.Find("GAME/GUIManager");
guiManager = val.GetComponent<GUIManager>();
AddTextObject(((Component)staminaBar.staminaBar).gameObject, ((Object)staminaBar.staminaBar).name);
AddTextObject(((Component)staminaBar.extraBarStamina).gameObject, "ExtraStamina");
BarAffliction[] afflictions = staminaBar.afflictions;
foreach (BarAffliction val2 in afflictions)
{
AddTextObject(((Component)val2).gameObject, ((Object)((Component)val2).gameObject).name);
}
}
public static void InitCharacterStaminaInfo(CharacterStaminaBar characterStaminaBar)
{
int instanceID = ((Object)characterStaminaBar).GetInstanceID();
AddTextObject(((Component)characterStaminaBar.staminaBarRectTransform).gameObject, GetCharacterStaminaKey(instanceID));
AddTextObject(((Component)characterStaminaBar.extraBarStamina).gameObject, GetCharacterExtraStaminaKey(instanceID));
foreach (CharacterBarAffliction characterBarAffliction in characterStaminaBar.characterBarAfflictions)
{
AddTextObject(((Component)characterBarAffliction).gameObject, GetCharacterAfflictionKey(instanceID, characterBarAffliction));
}
}
internal static void AddTextObject(GameObject gameObj, string barName)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
//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)
TMP_FontAsset font = ((TMP_Text)guiManager.heroDayText).font;
GameObject val = new GameObject("StaminaInfo");
val.transform.SetParent(gameObj.transform);
TextMeshProUGUI val2 = val.AddComponent<TextMeshProUGUI>();
RectTransform component = val.GetComponent<RectTransform>();
gameObj.SetActive(true);
((TMP_Text)val2).font = font;
((TMP_Text)val2).fontSize = PluginConfig.StaminaInfoFontSize.Value;
component.offsetMin = new Vector2(0f, 0f);
component.offsetMax = new Vector2(0f, 0f);
((TMP_Text)val2).alignment = (TextAlignmentOptions)514;
((TMP_Text)val2).verticalAlignment = (VerticalAlignmentOptions)8192;
((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 float GetReductionTimeRemaining(STATUSTYPE statusType)
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Invalid comparison between Unknown and I4
//IL_00a5: 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_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: 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 == 9)
{
float num = 0f;
int num2 = 0;
foreach (ThornOnMe physicalThorn in val.physicalThorns)
{
if (physicalThorn.stuckIn)
{
num2++;
num += Time.time - physicalThorn.popOutTime;
}
}
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 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 PeakStatsEx.MonoBehaviours
{
internal sealed class CharacterBarAffliction : MonoBehaviour
{
internal STATUSTYPE afflictionType;
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;
((Component)((Component)this).transform.Find("Icon")).gameObject.SetActive(false);
characterStaminaBar = ((Component)this).GetComponentInParent<CharacterStaminaBar>();
characterStaminaBar.AddCharacterBarAffliction(this);
}
internal void FetchDesiredSize()
{
//IL_0023: 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)
CharacterStaminaBar characterStaminaBar = this.characterStaminaBar;
Character observedCharacter = characterStaminaBar.ObservedCharacter;
if (!Object.op_Implicit((Object)(object)observedCharacter))
{
return;
}
float currentStatus = observedCharacter.refs.afflictions.GetCurrentStatus(afflictionType);
size = this.characterStaminaBar.fullBarRectTransform.sizeDelta.x * currentStatus;
if (currentStatus > 0.01f)
{
if (size < 15f)
{
size = 15f;
}
((Component)this).gameObject.SetActive(true);
}
else
{
((Component)this).gameObject.SetActive(false);
}
}
internal void UpdateVisual()
{
//IL_000d: 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_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
RectTransform val = rectTransform;
Vector2 sizeDelta = rectTransform.sizeDelta;
sizeDelta.x = Mathf.Lerp(rectTransform.sizeDelta.x, size, Mathf.Min(Time.deltaTime * 10f, 0.1f));
val.sizeDelta = sizeDelta;
}
}
internal sealed class CharacterStaminaBar : MonoBehaviour
{
private static readonly Color defaultBarColor = new Color(0.1035f, 0.2656f, 0.3019f, 1f);
private static readonly Color outOfStaminaColor = new Color(0.566f, 0.0089f, 0.0089f, 1f);
internal RectTransform fullBarRectTransform;
internal RectTransform staminaBarRectTransform;
internal RectTransform maxStaminaBarRectTransform;
internal RectTransform staminaBarOutlineRectTransform;
internal RectTransform staminaBarOutlineOverflowBar;
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<CharacterBarAffliction> characterBarAfflictions = new List<CharacterBarAffliction>();
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 readonly List<InventorySlotUI> inventorySlotUIs = new List<InventorySlotUI>();
private readonly List<InventorySlotUI> backpackSlotUIs = new List<InventorySlotUI>();
private InventorySlotUI? heldItemSlot;
internal Character? ObservedCharacter
{
get
{
return _observedCharacter;
}
set
{
if ((Object)(object)value != (Object)null)
{
hadObservedCharacter = true;
}
_observedCharacter = value;
}
}
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 Awake()
{
Plugin.Logger.LogDebug((object)"[UpdateStaminaBar] CharacterStaminaBar Awake");
StaminaBar val = default(StaminaBar);
if (((Component)this).TryGetComponent<StaminaBar>(ref val))
{
staminaBarOffset = val.staminaBarOffset;
}
CacheStaminaBarReferences();
CreateInventorySlots();
CreateExtraStaminaBar();
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;
}
UpdateStaminaBar();
UpdateExtraStaminaBar();
if (PluginConfig.ShowInventorySlots.Value)
{
UpdateInventorySlots();
}
else
{
ClearInventorySlots();
}
}
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_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: 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");
barImage = ((Component)((Transform)maxStaminaBarRectTransform).Find("Back")).GetComponent<Image>();
staminaBarRectTransform = (RectTransform)((Component)barImage).transform.Find("Stamina");
glowImage = ((Component)((Transform)staminaBarRectTransform).Find("Glow")).GetComponent<Image>();
campfireIcon = ((Component)((Transform)staminaBarOutlineRectTransform).Find("CampfireIcon")).gameObject;
shieldIcon = ((Component)((Transform)staminaBarOutlineRectTransform).Find("ShieldIcon")).gameObject;
}
private void CreateExtraStaminaBar()
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Expected O, but got Unknown
//IL_006c: 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_0075: 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_008d: 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_00a2: 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)
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: 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_0136: Unknown result type (might be due to invalid IL or missing references)
//IL_013e: Unknown result type (might be due to invalid IL or missing references)
//IL_014b: Unknown result type (might be due to invalid IL or missing references)
//IL_0158: Unknown result type (might be due to invalid IL or missing references)
//IL_0169: Unknown result type (might be due to invalid IL or missing references)
//IL_0196: Unknown result type (might be due to invalid IL or missing references)
//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
//IL_0203: Unknown result type (might be due to invalid IL or missing references)
//IL_0213: Unknown result type (might be due to invalid IL or missing references)
//IL_0223: 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;
}
StaminaBar component = ((Component)this).GetComponent<StaminaBar>();
GameObject val = new GameObject("FriendExtraBar");
val.transform.SetParent(((Component)this).transform, false);
extraBar = val.AddComponent<RectTransform>();
RectTransform val2 = extraBar;
RectTransform obj = extraBar;
Vector2 val3 = default(Vector2);
((Vector2)(ref val3))..ctor(0f, 0.5f);
obj.anchorMax = val3;
Vector2 anchorMin = val3;
val2.anchorMin = anchorMin;
extraBar.pivot = new Vector2(0f, 0.5f);
Vector2 anchoredPosition = fullBarRectTransform.anchoredPosition;
extraBar.anchoredPosition = new Vector2(anchoredPosition.x, anchoredPosition.y - 31f);
extraBar.sizeDelta = new Vector2(28f, 28f);
if ((Object)(object)component?.extraBarOutline != (Object)null)
{
GameObject val4 = Object.Instantiate<GameObject>(((Component)component.extraBarOutline).gameObject, val.transform, false);
((Object)val4).name = "FriendExtraBarOutline";
extraBarOutline = val4.GetComponent<RectTransform>();
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<Image, RectTransform>(val4);
}
if ((Object)(object)component?.extraBarStamina != (Object)null)
{
GameObject val5 = Object.Instantiate<GameObject>(((Component)component.extraBarStamina).gameObject, val.transform, false);
((Object)val5).name = "FriendExtraBarStamina";
extraBarStamina = val5.GetComponent<RectTransform>();
extraBarStamina.sizeDelta = new Vector2(extraBarStamina.sizeDelta.x, extraBarStamina.sizeDelta.y * 0.5f);
RemoveAllScriptsExcept<Image, RectTransform>(val5);
}
val.SetActive(false);
}
private void UpdateExtraStaminaBar()
{
//IL_0070: 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_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_0109: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: Unknown result type (might be due to invalid IL or missing references)
//IL_0143: Unknown result type (might be due to invalid IL or missing references)
//IL_015f: Unknown result type (might be due to invalid IL or missing references)
//IL_0169: Unknown result type (might be due to invalid IL or missing references)
//IL_0196: Unknown result type (might be due to invalid IL or missing references)
//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
//IL_01cb: Expected O, but got Unknown
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 = extraStamina > 0f;
if (!((Component)extraBar).gameObject.activeSelf && flag)
{
extraBar.sizeDelta = Vector2.zero;
ShortcutExtensions.DOKill((Component)(object)extraBar, false);
TweenSettingsExtensions.SetEase<TweenerCore<Vector2, Vector2, VectorOptions>>(DOTweenModuleUI.DOSizeDelta(extraBar, new Vector2(28f, 28f), 0.25f, false), (Ease)9);
((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);
extraBarOutline.sizeDelta = new Vector2(extraOutlineMaxWidth, extraBarOutline.sizeDelta.y);
if (!flag && !sequencingExtraBar)
{
sequencingExtraBar = true;
TweenSettingsExtensions.OnComplete<Sequence>(TweenSettingsExtensions.Append(DOTween.Sequence(), (Tween)(object)DOTweenModuleUI.DOSizeDelta(extraBar, new Vector2(extraBar.sizeDelta.x, 0f), 0.2f, false)), new TweenCallback(DisableExtraBar));
}
}
shieldIcon.SetActive(ObservedCharacter.data.isInvincible);
campfireIcon.SetActive(!ObservedCharacter.refs.afflictions.canGetHungry);
}
private void DisableExtraBar()
{
((Component)extraBar).gameObject.SetActive(false);
sequencingExtraBar = false;
}
private static void RemoveAllScriptsExcept<T1, T2>(GameObject go)
{
MonoBehaviour[] components = go.GetComponents<MonoBehaviour>();
MonoBehaviour[] array = components;
foreach (MonoBehaviour val in array)
{
if (((object)val).GetType() != typeof(T1) && ((object)val).GetType() != typeof(T2))
{
Object.DestroyImmediate((Object)(object)val);
}
}
}
internal void AddCharacterBarAffliction(CharacterBarAffliction characterBarAffliction)
{
characterBarAfflictions.Add(characterBarAffliction);
}
private void CreateInventorySlots()
{
//IL_0026: 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_0063: 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_007c: 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_00bf: 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_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
GUIManager instance = GUIManager.instance;
Sprite sprite = instance.items[0].selectedSlotIcon.sprite;
Color color = ((Graphic)instance.items[0].selectedSlotIcon).color;
Transform label = FindNicknameLabel();
float num = GetNicknameLabelWidth(label) + 184f;
for (int i = 0; i < 3; i++)
{
InventorySlotUI item = CreateInventorySlot($"InvSlot_{i}", new Vector2(32f, 32f), new Vector2(num + (float)(i * 38), 43f), sprite, color);
inventorySlotUIs.Add(item);
}
heldItemSlot = CreateInventorySlot("HoldingItemSlot", new Vector2(38f, 38f), new Vector2(num + 114f, 43f), sprite, color);
for (int j = 0; j < 4; j++)
{
InventorySlotUI item2 = CreateInventorySlot($"BackpackSlot_{j}", new Vector2(32f, 32f), new Vector2(num + 170f + (float)(j * 38), 43f), sprite, color);
backpackSlotUIs.Add(item2);
}
}
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)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Expected O, but got Unknown
Character? observedCharacter = ObservedCharacter;
if (((observedCharacter == null) ? null : observedCharacter.player?.itemSlots) == null)
{
ClearInventorySlots();
return;
}
ItemSlot[] itemSlots = ObservedCharacter.player.itemSlots;
Optionable<byte> 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)
{
ItemSlot slot = new ItemSlot(byte.MaxValue)
{
prefab = currentItem
};
heldItemSlot.SetItem(slot, selected: true);
}
if (!((ItemSlot)ObservedCharacter.player.backpackSlot).IsEmpty())
{
BackpackData val = default(BackpackData);
((ItemSlot)ObservedCharacter.player.backpackSlot).data.TryGetDataEntry<BackpackData>((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();
}
private InventorySlotUI CreateInventorySlot(string name, Vector2 size, Vector2 position, Sprite borderSprite, Color borderColor)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Expected O, but got Unknown
//IL_0034: 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_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: 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_0073: 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)
GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) });
val.transform.SetParent(((Component)this).transform, false);
RectTransform component = val.GetComponent<RectTransform>();
component.sizeDelta = size;
Vector2 val2 = default(Vector2);
((Vector2)(ref val2))..ctor(0f, 0.5f);
component.anchorMax = val2;
Vector2 anchorMin = val2;
component.anchorMin = anchorMin;
component.pivot = new Vector2(0f, 0.5f);
component.anchoredPosition = position;
InventorySlotUI inventorySlotUI = val.AddComponent<InventorySlotUI>();
inventorySlotUI.Initialize(borderSprite, borderColor);
return inventorySlotUI;
}
private Transform? FindNicknameLabel()
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Expected O, but got Unknown
foreach (Transform item in ((Component)this).transform)
{
Transform val = item;
if (((Object)val).name.StartsWith("CharacterName"))
{
return val;
}
}
return null;
}
private float GetNicknameLabelWidth(Transform? label)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
if (!Object.op_Implicit((Object)(object)label))
{
return 100f;
}
return ((Component)label).GetComponent<RectTransform>().sizeDelta.x;
}
private void UpdateStaminaBar()
{
//IL_0078: 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_010b: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_0125: Unknown result type (might be due to invalid IL or missing references)
//IL_0153: Unknown result type (might be due to invalid IL or missing references)
//IL_0158: Unknown result type (might be due to invalid IL or missing references)
//IL_0184: Unknown result type (might be due to invalid IL or missing references)
//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
//IL_0225: 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_0241: Unknown result type (might be due to invalid IL or missing references)
//IL_0275: Unknown result type (might be due to invalid IL or missing references)
//IL_029c: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)ObservedCharacter == (Object)null)
{
Plugin.Logger.LogDebug((object)"[UpdateStaminaBar] observedCharacter not found");
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;
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);
((Component)staminaBarOutlineOverflowBar).gameObject.SetActive(statusSum > 1.005f);
((Component)staminaBarRectTransform).gameObject.SetActive(staminaBarRectTransform.sizeDelta.x > 0f);
((Component)maxStaminaBarRectTransform).gameObject.SetActive(maxStaminaBarRectTransform.sizeDelta.x > 0f);
if (sinTime > TAU)
{
sinTime -= TAU;
}
}
private void OutOfStaminaPulse()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
((Graphic)barImage).color = outOfStaminaColor;
DOTweenModuleUI.DOColor(barImage, defaultBarColor, 0.5f);
}
private IEnumerator EnableIEnumerator()
{
((Component)this).transform.localScale = Vector3.zero;
TweenSettingsExtensions.SetEase<TweenerCore<Vector3, Vector3, VectorOptions>>(ShortcutExtensions.DOScale(((Component)this).transform, PluginConfig.TeammateStaminaBarScale.Value, 0.5f), (Ease)24);
yield return (object)new WaitForSeconds(0.5f);
animateDisableCoroutine = null;
}
private IEnumerator DisableIEnumerator()
{
((Component)this).transform.localScale = Vector3.one * 0.72f;
TweenSettingsExtensions.SetEase<TweenerCore<Vector3, Vector3, VectorOptions>>(ShortcutExtensions.DOScale(((Component)this).transform, 0f, 0.5f), (Ease)17);
yield return (object)new WaitForSeconds(0.5f);
((Component)this).gameObject.SetActive(false);
animateDisableCoroutine = null;
}
}
public class InventorySlotUI : MonoBehaviour
{
private RectTransform rectTransform;
private RawImage icon;
private Image fill;
private GameObject? fuelBar;
private Image? fuelBarFill;
private Vector2 startingSizeDelta;
private Item? currentItem;
private ItemInstanceData? currentData;
public void Initialize(Sprite selectedSprite, Color selectedColor)
{
//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_004e: 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)
rectTransform = ((Component)this).GetComponent<RectTransform>();
startingSizeDelta = rectTransform.sizeDelta;
CreateFuelBar();
icon = ((Component)this).gameObject.AddComponent<RawImage>();
((Graphic)icon).color = new Color(1f, 1f, 1f, 0f);
((Graphic)icon).raycastTarget = false;
fill = CreateFillImage("Fill", selectedSprite, selectedColor);
((Behaviour)fill).enabled = false;
}
public void SetItem(ItemSlot slot, bool selected)
{
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
if (!slot.IsEmpty() && slot.prefab?.UIData != null)
{
currentItem = slot.prefab;
currentData = slot.data;
if (currentItem?.UIData != null)
{
icon.texture = (Texture)(object)currentItem.UIData.GetIcon();
((Behaviour)icon).enabled = true;
((Graphic)icon).color = Color.white;
}
UpdateCookedColor();
UpdateFuelBar();
}
else
{
Clear();
}
SetSelected(selected);
}
public void Clear()
{
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
((Behaviour)fill).enabled = false;
((Behaviour)icon).enabled = false;
icon.texture = null;
((Graphic)icon).color = new Color(1f, 1f, 1f, 0f);
currentItem = null;
currentData = null;
if (Object.op_Implicit((Object)(object)fuelBar))
{
fuelBar.SetActive(false);
}
}
private void SetSelected(bool isSelected)
{
//IL_015c: Unknown result type (might be due to invalid IL or missing references)
//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0106: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: 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_0037: 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)
if ((Object)(object)currentItem != (Object)null || isSelected)
{
if (isSelected)
{
ShortcutExtensions.DOKill((Component)(object)rectTransform, false);
TweenSettingsExtensions.SetEase<TweenerCore<Vector2, Vector2, VectorOptions>>(DOTweenModuleUI.DOSizeDelta(rectTransform, startingSizeDelta * 1.2f, 0.5f, false), (Ease)24);
((Behaviour)fill).enabled = true;
((Component)fill).transform.localScale = Vector3.zero;
ShortcutExtensions.DOKill((Component)(object)((Component)fill).transform, false);
TweenSettingsExtensions.SetEase<TweenerCore<Vector3, Vector3, VectorOptions>>(ShortcutExtensions.DOScale(((Component)fill).transform, 1f, 0.25f), (Ease)9);
}
else
{
ShortcutExtensions.DOKill((Component)(object)rectTransform, false);
TweenSettingsExtensions.SetEase<TweenerCore<Vector2, Vector2, VectorOptions>>(DOTweenModuleUI.DOSizeDelta(rectTransform, startingSizeDelta, 0.2f, false), (Ease)9);
((Behaviour)fill).enabled = false;
}
}
else if (isSelected)
{
ShortcutExtensions.DOKill((Component)(object)rectTransform, false);
Sequence val = DOTween.Sequence();
TweenSettingsExtensions.Append(val, (Tween)(object)TweenSettingsExtensions.SetEase<TweenerCore<Vector2, Vector2, VectorOptions>>(DOTweenModuleUI.DOSizeDelta(rectTransform, startingSizeDelta * 1.2f, 0.075f, false), (Ease)9));
TweenSettingsExtensions.Append(val, (Tween)(object)TweenSettingsExtensions.SetEase<TweenerCore<Vector2, Vector2, VectorOptions>>(DOTweenModuleUI.DOSizeDelta(rectTransform, startingSizeDelta, 0.125f, false), (Ease)2));
}
else
{
ShortcutExtensions.DOKill((Component)(object)rectTransform, false);
rectTransform.sizeDelta = startingSizeDelta;
}
}
private void UpdateCookedColor()
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
ItemInstanceData val = currentData;
IntItemData val2 = default(IntItemData);
if (val != null && val.TryGetDataEntry<IntItemData>((DataEntryKey)1, ref val2))
{
((Graphic)icon).color = ItemCooking.GetCookColor(val2.Value);
}
}
private void UpdateFuelBar()
{
if ((Object)(object)fuelBar == (Object)null)
{
return;
}
if ((Object)(object)Character.observedCharacter != (Object)(object)Character.localCharacter)
{
fuelBar.SetActive(false);
return;
}
ItemInstanceData val = currentData;
FloatItemData val2 = default(FloatItemData);
if (val != null && val.TryGetDataEntry<FloatItemData>((DataEntryKey)11, ref val2))
{
fuelBar.SetActive(true);
if ((Object)(object)fuelBarFill != (Object)null)
{
fuelBarFill.fillAmount = val2.Value;
}
}
else
{
fuelBar.SetActive(false);
if ((Object)(object)fuelBarFill != (Object)null)
{
fuelBarFill.fillAmount = 1f;
}
}
}
private Image CreateFillImage(string name, Sprite sprite, Color color)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Expected O, but got Unknown
//IL_0034: 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_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: 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(((Component)this).transform, false);
RectTransform component = val.GetComponent<RectTransform>();
component.anchorMin = Vector2.zero;
component.anchorMax = Vector2.one;
component.sizeDelta = Vector2.zero;
component.anchoredPosition = Vector2.zero;
Image val2 = val.AddComponent<Image>();
val2.sprite = sprite;
val2.type = (Type)1;
((Graphic)val2).color = color;
((Graphic)val2).raycastTarget = false;
return val2;
}
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_004d: 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_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: 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)
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Expected O, but got Unknown
//IL_010e: 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_0126: Unknown result type (might be due to invalid IL or missing references)
//IL_0132: Unknown result type (might be due to invalid IL or missing references)
//IL_014f: 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<RectTransform>();
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 val2 = val.AddComponent<Image>();
((Graphic)val2).color = new Color(0f, 0f, 0f, 0.5f);
Sprite sprite = (val2.sprite = CreateWhiteSprite());
val2.type = (Type)1;
GameObject val4 = new GameObject("Fill", new Type[1] { typeof(RectTransform) });
val4.transform.SetParent(val.transform, false);
RectTransform component2 = val4.GetComponent<RectTransform>();
component2.anchorMin = Vector2.zero;
component2.anchorMax = Vector2.one;
component2.sizeDelta = Vector2.zero;
component2.anchoredPosition = Vector2.zero;
fuelBarFill = val4.AddComponent<Image>();
((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_0008: Expected O, but got Unknown
//IL_000b: 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_0035: 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)
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()
{
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
RectTransform obj = rectTransform;
if (obj != null)
{
ShortcutExtensions.DOKill((Component)(object)obj, false);
}
Image obj2 = fill;
if (obj2 != null)
{
Transform transform = ((Component)obj2).transform;
if (transform != null)
{
ShortcutExtensions.DOKill((Component)(object)transform, false);
}
}
if (Object.op_Implicit((Object)(object)rectTransform))
{
rectTransform.sizeDelta = startingSizeDelta;
}
if (Object.op_Implicit((Object)(object)fill))
{
((Behaviour)fill).enabled = false;
}
}
}
internal sealed class MapStats : MonoBehaviour
{
internal static string currentLevelName = "";
internal static int currentLevelIndex = -1;
private static string currentBiomesNames = "";
private static int todayLevelIndex = -1;
private static int currentMapSeed = -1;
private TMP_Text tmpText;
private MapBaker mapBaker;
private MapHandler mapHandler;
private NextLevelService nextLevelService;
private void Awake()
{
mapBaker = SingletonAsset<MapBaker>.Instance;
mapHandler = Singleton<MapHandler>.Instance;
nextLevelService = GameHandler.GetService<NextLevelService>();
if (TerrainRandomiserCompatibility.Enabled)
{
currentMapSeed = TerrainRandomiserCompatibility.GetRandomizerSeed();
Plugin.Logger.LogInfo((object)$"Current map seed from TerrainRandomiser: {currentMapSeed}");
}
else if (TerrainCustomiserCompatibility.Enabled)
{
currentMapSeed = TerrainCustomiserCompatibility.GetCustomiserSeed();
Plugin.Logger.LogInfo((object)$"Current map seed from TerrainCustomiser: {currentMapSeed}");
}
}
private void Start()
{
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
tmpText = ((Component)this).GetComponent<TMP_Text>();
tmpText.autoSizeTextContainer = true;
tmpText.textWrappingMode = (TextWrappingModes)0;
tmpText.alignment = (TextAlignmentOptions)260;
tmpText.lineSpacing = -20f;
tmpText.fontSize = 22f;
tmpText.outlineColor = new Color32((byte)0, (byte)0, (byte)0, byte.MaxValue);
tmpText.outlineWidth = 0.055f;
}
private unsafe void Update()
{
try
{
Character localCharacter = Character.localCharacter;
if (!Object.op_Implicit((Object)(object)tmpText) || !Object.op_Implicit((Object)(object)localCharacter))
{
return;
}
if (nextLevelService.Data.IsSome && todayLevelIndex == -1)
{
int num = nextLevelService.NextLevelIndexOrFallback + NextLevelService.debugLevelIndexOffset;
todayLevelIndex = num % mapBaker.ScenePaths.Length;
Plugin.Logger.LogInfo((object)$"todayLevelIndex set to {todayLevelIndex}");
}
if (currentLevelIndex == -1)
{
int num2 = LevelNameToIndex(currentLevelName);
if (num2 != -1)
{
currentLevelIndex = num2;
}
else if (todayLevelIndex != -1)
{
currentLevelIndex = todayLevelIndex;
}
Plugin.Logger.LogInfo((object)$"currentLevelIndex set to {currentLevelIndex}");
}
string text = string.Empty;
if (PluginConfig.DisplayLevel.Value && currentLevelIndex != -1)
{
currentLevelName = GetLevelName(currentLevelIndex);
text = text + "(" + currentLevelName + ")";
}
if (PluginConfig.DisplayBiomes.Value)
{
IEnumerable<string> values = from x in mapHandler.biomes
where (int)x != 0 && (int)x != 3 && (int)x != 5
select LocalizedText.GetText(((object)(*(BiomeType*)(&x))/*cast due to .constrained prefix*/).ToString(), true);
currentBiomesNames = string.Join(", ", values);
text = text + "[" + currentBiomesNames + "]";
}
if ((PluginConfig.DisplayTerrainRandomiserSeed.Value || PluginConfig.DisplayTerrainCustomiserSeed.Value) && currentMapSeed != -1)
{
text += $"<{currentMapSeed}>";
}
tmpText.text = text;
}
catch (Exception ex)
{
Plugin.Logger.LogInfo((object)ex.ToString());
}
}
private string GetLevelName(int levelIndex)
{
levelIndex %= mapBaker.ScenePaths.Length;
return PathUtil.WithoutExtensions(PathUtil.GetFileName(mapBaker.ScenePaths[levelIndex]));
}
private int LevelNameToIndex(string levelName)
{
for (int i = 0; i < mapBaker.ScenePaths.Length; i++)
{
string levelName2 = GetLevelName(i);
if (string.Equals(levelName2, levelName, StringComparison.OrdinalIgnoreCase))
{
return i;
}
}
return -1;
}
}
internal sealed class ProximityStaminaManager : MonoBehaviour
{
private readonly Dictionary<Character, CharacterStaminaBar> staminaBars = new Dictionary<Character, CharacterStaminaBar>();
private static CharacterStaminaBar CreateStaminaBar(Character observedCharacter)
{
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_00f2: Expected O, but got Unknown
//IL_0179: 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_01b8: Unknown result type (might be due to invalid IL or missing references)
//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
Transform transform = ((Component)GUIManager.instance.bar).transform;
Transform val = Object.Instantiate<Transform>(transform, transform.parent);
Transform[] componentsInChildren = ((Component)val).GetComponentsInChildren<Transform>(true);
Transform[] array = componentsInChildren;
foreach (Transform val2 in array)
{
if (((Object)val2).name == "StaminaInfo")
{
Object.Destroy((Object)(object)((Component)val2).gameObject);
}
}
val.SetAsFirstSibling();
Object.Destroy((Object)(object)((Component)val).GetComponent<StaminaBar>());
CharacterStaminaBar characterStaminaBar = ((Component)val).gameObject.AddComponent<CharacterStaminaBar>();
characterStaminaBar.ObservedCharacter = observedCharacter;
BarAffliction[] componentsInChildren2 = ((Component)val).GetComponentsInChildren<BarAffliction>(true);
BarAffliction[] array2 = componentsInChildren2;
foreach (BarAffliction val3 in array2)
{
CharacterBarAffliction characterBarAffliction = ((Component)val3).gameObject.AddComponent<CharacterBarAffliction>();
characterBarAffliction.afflictionType = val3.afflictionType;
characterBarAffliction.FetchReferences();
Object.Destroy((Object)(object)val3);
}
RectTransform val4 = (RectTransform)Object.Instantiate<Transform>(((Component)((Component)GUIManager.instance).GetComponentInChildren<AscentUI>()).transform, val);
AscentUI component = ((Component)val4).GetComponent<AscentUI>();
TextMeshProUGUI text = component.text;
Object.Destroy((Object)(object)component);
string characterName = observedCharacter.characterName;
characterName = Regex.Replace(characterName, "(<color=#\\w{6}>|</color>)", "");
string text2 = (((TMP_Text)text).text = characterName.TrimToByteLength(18));
string text4 = text2;
((Object)val4).name = "CharacterName: " + text4;
((TMP_Text)text).textWrappingMode = (TextWrappingModes)0;
((TMP_Text)text).fontSize = 32f;
((TMP_Text)text).autoSizeTextContainer = true;
((Graphic)text).color = observedCharacter.refs.customization.PlayerColor;
((TMP_Text)text).outlineColor = new Color32((byte)0, (byte)0, (byte)0, byte.MaxValue);
((TMP_Text)text).outlineWidth = 0.055f;
Vector2 val5 = default(Vector2);
((Vector2)(ref val5))..ctor(0f, 1f);
val4.anchorMin = val5;
val4.anchorMax = val5;
val4.pivot = Vector2.zero;
val4.anchoredPosition = Vector2.zero;
characterStaminaBar.AnimateEnable();
return characterStaminaBar;
}
private void Update()
{
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_0101: 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)
if (!Object.op_Implicit((Object)(object)Character.localCharacter) || (!PluginConfig.DisplayTeammateStaminaBars.Value && !PluginConfig.DisplaySelfStaminaBar.Value))
{
foreach (KeyValuePair<Character, CharacterStaminaBar> staminaBar in staminaBars)
{
staminaBar.Value.AnimateDisable();
}
return;
}
int value = PluginConfig.TeammateStaminaBarLimit.Value;
float value2 = PluginConfig.TeammateStaminaBarProximity.Value;
Character val = (MainCameraMovement.IsSpectating ? MainCameraMovement.specCharacter : Character.localCharacter);
Vector3 center = val.Center;
List<(float, CharacterStaminaBar)> list = new List<(float, CharacterStaminaBar)>();
foreach (Character allCharacter in Character.AllCharacters)
{
bool flag = PluginConfig.DisplaySelfStaminaBar.Value || !allCharacter.IsLocal;
if (((Behaviour)allCharacter).isActiveAndEnabled && flag)
{
if (!staminaBars.TryGetValue(allCharacter, out CharacterStaminaBar value3))
{
staminaBars.TryAdd(allCharacter, value3 = CreateStaminaBar(allCharacter));
}
float item = Vector3.Distance(center, allCharacter.Center);
list.Add((item, value3));
}
}
List<(float, CharacterStaminaBar)> list2 = list.OrderBy<(float, CharacterStaminaBar), float>(((float distance, CharacterStaminaBar bar) x) => x.distance).ToList();
for (int num = 0; num < list2.Count; num++)
{
if (num < value && list2[num].Item1 < value2)
{
list2[num].Item2.AnimateEnable();
}
else
{
list2[num].Item2.AnimateDisable();
}
}
}
}
internal sealed class TimerHeightStats : MonoBehaviour
{
private const float ORIGINAL_LAVA_TRAVEL_TIME = 1200f;
private const float ORIGINAL_FOG_SPEED = 0.4f;
private static int currentSegment = -1;
private static int campfireHeight;
private float lastFogUpdateTime = -1f;
private float lastFogHeight = -1f;
private float lastFogTime = -1f;
private float lastLavaUpdateTime = -1f;
private float lastLavaHeight = -1f;
private float lastLavaTime = -1f;
private TMP_Text tmpText;
private DayNightManager _dayNightManager;
private MapHandler _mapHandler;
private OrbFogHandler _orbFogHandler;
private LavaRising _lavaRising;
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<DayNightManager>();
_mapHandler = Singleton<MapHandler>.Instance;
_orbFogHandler = Singleton<OrbFogHandler>.Instance;
_lavaRising = Singleton<LavaRising>.Instance;
}
private void Start()
{
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
tmpText = ((Component)this).GetComponent<TMP_Text>();
tmpText.autoSizeTextContainer = true;
tmpText.textWrappingMode = (TextWrappingModes)0;
tmpText.alignment = (TextAlignmentOptions)258;
tmpText.lineSpacing = -40f;
tmpText.fontSize = 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;
if (Object.op_Implicit((Object)(object)tmpText) && Object.op_Implicit((Object)(object)localCharacter))
{
UpdateCachedCampfireHeight();
CharacterStats stats = Character.observedCharacter.refs.stats;
StringBuilder stringBuilder = new StringBuilder(128);
AppendTimerText(stringBuilder);
AppendDayNightStatus(stringBuilder);
AppendHeightInfo(stringBuilder, stats);
AppendFogOrLavaStats(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(RunManager.Instance.timeSinceRunStarted);
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);
sb.AppendFormat("({0}: {1:P0})", arg, num);
}
}
private (string status, float countdown) CalculateDayNightStatus(float timeOfDay)
{
if (timeOfDay >= 5f && timeOfDay < 21f)
{
return (status: "Day", countdown: 1f - (timeOfDay - 5f) / 16f);
}
float num = ((timeOfDay < 5f) ? (timeOfDay + 24f) : timeOfDay);
return (status: "Night", countdown: 1f - (num - 21f) / 8f);
}
private void AppendHeightInfo(StringBuilder sb, CharacterStats stats)
{
if (PluginConfig.DisplayHeight.Value)
{
if (sb.Length > 0 && (PluginConfig.DisplayTimer.Value || PluginConfig.DisplayDayNightCountdown.Value))
{
sb.AppendLine();
}
if (campfireHeight == -1)
{
sb.AppendFormat("{0}m", stats.heightInMeters);
}
else
{
sb.AppendFormat("{0}m/{1}m", stats.heightInMeters, campfireHeight);
}
}
}
private void UpdateCachedCampfireHeight()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected I4, but got Unknown
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
int num = (int)_mapHandler.GetCurrentSegment();
if (currentSegment != num)
{
currentSegment = num;
MapSegment val = _mapHandler.segments[currentSegment];
if ((Object)(object)((val != null) ? val.segmentCampfire : null) != (Object)null)
{
Campfire componentInChildren = val.segmentCampfire.GetComponentInChildren<Campfire>();
campfireHeight = Mathf.RoundToInt(CharacterStats.unitsToMeters * ((Component)componentInChildren).transform.position.y);
}
else
{
campfireHeight = -1;
}
}
}
private void AppendFogOrLavaStats(StringBuilder sb, CharacterStats stats)
{
//IL_00ea: 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_0227: Unknown result type (might be due to invalid IL or missing references)
if (!PluginConfig.DisplayFog.Value && !PluginConfig.DisplayLava.Value)
{
return;
}
bool flag = PluginConfig.DisplayFog.Value && (Object)(object)_orbFogHandler != (Object)null && _orbFogHandler.isMoving;
bool flag2 = PluginConfig.DisplayLava.Value && (Object)(object)_lavaRising != (Object)null && _lavaRising.started && !_lavaRising.ended;
if (!flag && !flag2)
{
return;
}
string value = string.Empty;
string value2 = string.Empty;
if (flag && campfireHeight != -1)
{
if ((lastFogUpdateTime < 0f || Time.time - lastFogUpdateTime > 1f) && (Object)(object)_orbFogHandler?.sphere != (Object)null)
{
float num = Vector3.Distance(_orbFogHandler.sphere.fogPoint, stats.character.Center);
float num2 = num - _orbFogHandler.currentSize;
lastFogUpdateTime = Time.time;
lastFogHeight = stats.heightInMeters - Math.Abs(num2);
if (num2 < 0f && _orbFogHandler.speed > 0f)
{
lastFogTime = Mathf.Abs(num2 / _orbFogHandler.speed);
}
else
{
lastFogTime = 0f;
}
}
if (lastFogHeight > 0f)
{
value = ((lastFogTime > 0f) ? $"(<#00BCFF>{Mathf.CeilToInt(lastFogHeight)}m/{FormatTime(Mathf.CeilToInt(lastFogTime))}</color>)" : $"(<#00BCFF>{Mathf.CeilToInt(lastFogHeight)}m</color>)");
}
}
if (flag2 && campfireHeight == -1)
{
if (Time.time - lastLavaUpdateTime > 1f && (Object)(object)_lavaRising?.lava != (Object)null)
{
float num3 = ((Component)_lavaRising.lava).transform.position.y * CharacterStats.unitsToMeters;
float num4 = stats.heightInMeters - num3;
if (lastLavaUpdateTime >= 0f && num4 > 0f)
{
float num5 = Time.time - lastLavaUpdateTime;
float num6 = num3 - lastLavaHeight;
float num7 = num6 / Mathf.Max(0.0001f, num5);
if (num7 > 0.001f)
{
lastLavaTime = num4 / num7;
}
else
{
lastLavaTime = 0f;
}
}
lastLavaHeight = num3;
lastLavaUpdateTime = Time.time;
}
if (lastLavaHeight > 0f)
{
value2 = ((lastLavaTime > 0f) ? $"(<#FF4500>{Mathf.CeilToInt(lastLavaHeight)}m/{FormatTime(Mathf.CeilToInt(lastLavaTime))}</color>)" : $"(<#FF4500>{Mathf.CeilToInt(lastLavaHeight)}m</color>)");
}
}
if (string.IsNullOrEmpty(value) && string.IsNullOrEmpty(value2))
{
return;
}
if (sb.Length > 0 && (PluginConfig.DisplayTimer.Value || PluginConfig.DisplayDayNightCountdown.Value || PluginConfig.DisplayHeight.Value))
{
sb.Append(" | ");
}
if (!string.IsNullOrEmpty(value))
{
sb.Append(value);
if ((Object)(object)_orbFogHandler != (Object)null)
{
float num8 = _orbFogHandler.speed / 0.4f;
sb.Append($" [<#00BCFF>{num8:F2}x</color>]");
}
}
else if (!string.IsNullOrEmpty(value2))
{
sb.Append(value2);
if ((Object)(object)_lavaRising != (Object)null)
{
float num9 = 1200f / _lavaRising.travelTime;
sb.Append($" [<#FF4500>{num9:F2}x</color>]");
}
}
}
}
}
namespace PeakStatsEx.Compatibility
{
internal static class TerrainCustomiserCompatibility
{
private const string PluginGuid = "com.snosz.terraincustomiser";
private const string PlayerInfoManagerTypeName = "TerrainCustomiser.Managers.PlayerInfoManager";
private const BindingFlags StaticFieldFlags = BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
private const BindingFlags InstanceFieldFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
internal static bool Enabled => Chainloader.PluginInfos.ContainsKey("com.snosz.terraincustomiser");
[MethodImpl(MethodImplOptions.NoInlining)]
internal static int GetCustomiserSeed()
{
object obj = typeof(Plugin).Assembly.GetType("TerrainCustomiser.Managers.PlayerInfoManager")?.GetField("currentMapSyncData", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(null);
object obj2 = obj?.GetType().GetField("seed", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(obj);
if (obj2 is int)
{
return (int)obj2;
}
return -1;
}
}
internal static class TerrainRandomiserCompatibility
{
internal static bool Enabled => Chainloader.PluginInfos.ContainsKey("com.snosz.terrainrandomiser");
[MethodImpl(MethodImplOptions.NoInlining)]
internal static bool IsEnableRandomizer()
{
if (Object.op_Implicit((Object)(object)Plugin.Instance))
{
return Plugin.Instance.mapSettings.enableRandomiser;
}
return false;
}
[MethodImpl(MethodImplOptions.NoInlining)]
internal static int GetRandomizerSeed()
{
if (!IsEnableRandomizer())
{
return -1;
}
return Plugin.Instance.mapSettings.seed;
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}