using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
[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.jkqt.StaminaInfo")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: AssemblyInformationalVersion("1.0.2+4d353238c3492eba72b814b2babd66542907bba5")]
[assembly: AssemblyProduct("com.github.jkqt.StaminaInfo")]
[assembly: AssemblyTitle("StaminaInfo")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.2.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.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]
[Microsoft.CodeAnalysis.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]
[Microsoft.CodeAnalysis.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 StaminaInfo
{
[BepInPlugin("com.github.jkqt.StaminaInfo", "StaminaInfo", "1.0.2")]
public class Plugin : BaseUnityPlugin
{
private static class StaminaInfoStaminaBarUpdatePatch
{
[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>();
InitStaminaInfo(__instance);
}
else if ((Object)(object)Character.observedCharacter != (Object)null)
{
UpdateBarTexts(__instance);
}
}
catch (Exception ex)
{
Log.LogError((object)(ex.Message + ex.StackTrace));
}
}
}
private static Dictionary<string, TextMeshProUGUI> barTexts;
private static Dictionary<string, float> lastKnownData;
private static GUIManager guiManager;
private static ConfigEntry<float> configFontSize;
private static ConfigEntry<float> configOutlineWidth;
private static ConfigEntry<bool> configRoundStamina;
private static ConfigEntry<bool> configRoundAffliction;
public const string Id = "com.github.jkqt.StaminaInfo";
internal static ManualLogSource Log { get; private set; }
public static string Name => "StaminaInfo";
public static string Version => "1.0.2";
private void Awake()
{
Log = ((BaseUnityPlugin)this).Logger;
configFontSize = ((BaseUnityPlugin)this).Config.Bind<float>("StaminaInfo", "Font Size", 20f, "Customize the Font Size for stamina bar text.");
configOutlineWidth = ((BaseUnityPlugin)this).Config.Bind<float>("StaminaInfo", "Outline Width", 0.08f, "Customize the Outline Width for stamina bar text.");
configRoundStamina = ((BaseUnityPlugin)this).Config.Bind<bool>("StaminaInfo", "Round Stamina Bars", true, "If true, rounds to the nearest whole number for the stamina and extra stamina bars.");
configRoundAffliction = ((BaseUnityPlugin)this).Config.Bind<bool>("StaminaInfo", "Round Affliction Bars", false, "If true, rounds to the nearest whole number for affliction bars.");
Harmony.CreateAndPatchAll(typeof(StaminaInfoStaminaBarUpdatePatch), (string)null);
Log.LogInfo((object)("Plugin " + Name + " is loaded!"));
}
private static void UpdateBarTexts(StaminaBar staminaBar)
{
if (lastKnownData[((Object)staminaBar.staminaBar).name] != staminaBar.desiredStaminaSize)
{
if (staminaBar.desiredStaminaSize >= 30f)
{
if (configRoundStamina.Value)
{
((TMP_Text)barTexts[((Object)staminaBar.staminaBar).name]).text = Mathf.Round(staminaBar.desiredStaminaSize / 6f).ToString();
}
else
{
((TMP_Text)barTexts[((Object)staminaBar.staminaBar).name]).text = (staminaBar.desiredStaminaSize / 6f).ToString("F1");
}
((Component)barTexts[((Object)staminaBar.staminaBar).name]).gameObject.SetActive(true);
}
else if (staminaBar.desiredStaminaSize >= 15f)
{
((TMP_Text)barTexts[((Object)staminaBar.staminaBar).name]).text = Mathf.Round(staminaBar.desiredStaminaSize / 6f).ToString();
((Component)barTexts[((Object)staminaBar.staminaBar).name]).gameObject.SetActive(true);
}
else
{
((Component)barTexts[((Object)staminaBar.staminaBar).name]).gameObject.SetActive(false);
}
lastKnownData[((Object)staminaBar.staminaBar).name] = staminaBar.desiredStaminaSize;
}
if (lastKnownData["ExtraStamina"] != staminaBar.desiredExtraStaminaSize)
{
if (staminaBar.desiredExtraStaminaSize >= 30f)
{
if (configRoundStamina.Value)
{
((TMP_Text)barTexts["ExtraStamina"]).text = Mathf.Round(staminaBar.desiredExtraStaminaSize / 6f).ToString();
}
else
{
((TMP_Text)barTexts["ExtraStamina"]).text = (staminaBar.desiredExtraStaminaSize / 6f).ToString("F1");
}
((Component)barTexts["ExtraStamina"]).gameObject.SetActive(true);
}
else if (staminaBar.desiredExtraStaminaSize >= 15f)
{
((TMP_Text)barTexts["ExtraStamina"]).text = Mathf.Round(staminaBar.desiredExtraStaminaSize / 6f).ToString();
((Component)barTexts["ExtraStamina"]).gameObject.SetActive(true);
}
else
{
((Component)barTexts["ExtraStamina"]).gameObject.SetActive(false);
}
lastKnownData["ExtraStamina"] = staminaBar.desiredExtraStaminaSize;
}
BarAffliction[] afflictions = staminaBar.afflictions;
foreach (BarAffliction val in afflictions)
{
if (lastKnownData[((Object)val).name] == val.size)
{
continue;
}
if (val.size >= 30f)
{
if (configRoundAffliction.Value)
{
((TMP_Text)barTexts[((Object)val).name]).text = Mathf.Round(val.size / 6f).ToString();
}
else
{
((TMP_Text)barTexts[((Object)val).name]).text = (val.size / 6f).ToString("F1").Replace(".0", "");
}
}
else if (val.size >= 15f)
{
((TMP_Text)barTexts[((Object)val).name]).text = Mathf.Round(val.size / 6f).ToString();
}
lastKnownData[((Object)val).name] = val.size;
}
}
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);
}
}
private 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 = configFontSize.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 = "";
barTexts.Add(barName, val2);
lastKnownData.Add(barName, 0f);
((TMP_Text)val2).outlineWidth = configOutlineWidth.Value;
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}