using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalConfig;
using LethalConfig.ConfigItems;
using Microsoft.CodeAnalysis;
using OoLunar.StaminaUI.Patches;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("StaminaUI")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("A continuation of An0n_Patches.")]
[assembly: AssemblyFileVersion("1.2.1.0")]
[assembly: AssemblyInformationalVersion("1.2.1+de563f1fafd85bf4e7aa21837193500ea2337f37")]
[assembly: AssemblyProduct("StaminaUI")]
[assembly: AssemblyTitle("StaminaUI")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.1.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 OoLunar.StaminaUI
{
[BepInPlugin("StaminaUI", "StaminaUI", "1.2.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public sealed class StaminaUIPlugin : BaseUnityPlugin
{
private readonly Harmony _harmony = new Harmony("StaminaUI");
internal static ManualLogSource StaticLogger;
internal static ConfigEntry<string>? TextColorHex;
private void Awake()
{
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Expected O, but got Unknown
((BaseUnityPlugin)this).Logger.LogDebug((object)"StaminaUI started loading!");
StaticLogger = ((BaseUnityPlugin)this).Logger;
TextColorHex = ((BaseUnityPlugin)this).Config.Bind<string>("UI", "TextColorHex", "FF0000", "Text color in hex format (e.g., FF0000 for red, 00FF00 for green, 0000FF for blue). Supports 6-digit hex (RRGGBB) or 8-digit hex (RRGGBBAA) for alpha.");
try
{
if (Chainloader.PluginInfos.ContainsKey("ainavt.lc.lethalconfig"))
{
LethalConfigManager.AddConfigItem((BaseConfigItem)new TextInputFieldConfigItem(TextColorHex, false));
}
}
catch (Exception ex)
{
((BaseUnityPlugin)this).Logger.LogWarning((object)("Failed to initialize LethalConfig integration: " + ex.Message));
}
Type[] types = typeof(StaminaUIPlugin).Assembly.GetTypes();
foreach (Type type in types)
{
if (type.GetCustomAttribute<LethalPatchAttribute>() != null)
{
_harmony.PatchAll(type);
}
}
((BaseUnityPlugin)this).Logger.LogDebug((object)"|\\_/|\n`o.o'\n=(_)=\n U");
((BaseUnityPlugin)this).Logger.LogInfo((object)"ᓚᘏᗢ --- N O Nyang E --- ᓚᘏᗢ");
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "StaminaUI";
public const string PLUGIN_NAME = "StaminaUI";
public const string PLUGIN_VERSION = "1.2.1";
}
}
namespace OoLunar.StaminaUI.Patches
{
[HarmonyPatch]
[LethalPatch]
internal class HUDManagerPatch : MonoBehaviour
{
private static bool _instantiating = true;
private static TextMeshProUGUI? _hudPercentagesText;
private static string? _lastAppliedHexColor;
private static Color ParseHexColor(string hex)
{
//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
//IL_01e1: 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_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: 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_00f6: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_017b: 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)
if (string.IsNullOrWhiteSpace(hex))
{
ManualLogSource staticLogger = StaminaUIPlugin.StaticLogger;
if (staticLogger != null)
{
staticLogger.LogWarning((object)"Hex color is null or empty. Using default red color.");
}
return new Color(1f, 0f, 0f, 1f);
}
string text = hex.Trim().TrimStart('#');
if (text.Length != 6 && text.Length != 8)
{
ManualLogSource staticLogger2 = StaminaUIPlugin.StaticLogger;
if (staticLogger2 != null)
{
staticLogger2.LogWarning((object)("Invalid hex color format: " + hex + ". Expected 6 or 8 characters. Using default red color."));
}
return new Color(1f, 0f, 0f, 1f);
}
if (!Regex.IsMatch(text, "^[0-9A-Fa-f]+$"))
{
ManualLogSource staticLogger3 = StaminaUIPlugin.StaticLogger;
if (staticLogger3 != null)
{
staticLogger3.LogWarning((object)("Invalid hex color characters: " + hex + ". Using default red color."));
}
return new Color(1f, 0f, 0f, 1f);
}
try
{
int num = Convert.ToInt32(text.Substring(0, 2), 16);
int num2 = Convert.ToInt32(text.Substring(2, 2), 16);
int num3 = Convert.ToInt32(text.Substring(4, 2), 16);
int num4 = ((text.Length == 8) ? Convert.ToInt32(text.Substring(6, 2), 16) : 255);
return new Color((float)num / 255f, (float)num2 / 255f, (float)num3 / 255f, (float)num4 / 255f);
}
catch (Exception ex)
{
ManualLogSource staticLogger4 = StaminaUIPlugin.StaticLogger;
if (staticLogger4 != null)
{
staticLogger4.LogWarning((object)("Failed to parse hex color '" + hex + "': " + ex.Message + ". Using default red color."));
}
return new Color(1f, 0f, 0f, 1f);
}
}
private static void ApplyConfiguredColor(TextMeshProUGUI text, string hexColor)
{
//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_0011: 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_0013: 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_0015: 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)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
Color val = ParseHexColor(hexColor);
((TMP_Text)text).enableVertexGradient = false;
((TMP_Text)text).colorGradient = new VertexGradient(val, val, val, val);
((Graphic)text).color = val;
((TMP_Text)text).faceColor = Color32.op_Implicit(val);
if ((Object)(object)((TMP_Text)text).fontSharedMaterial != (Object)null)
{
((TMP_Text)text).fontSharedMaterial = Object.Instantiate<Material>(((TMP_Text)text).fontSharedMaterial);
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(StartOfRound), "SceneManager_OnLoadComplete1")]
public static void CreateHudPercentages()
{
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
if (_instantiating)
{
GameObject val = GameObject.Find("Systems/UI/Canvas/IngamePlayerHUD/TopLeftCorner/WeightUI");
GameObject val2 = GameObject.Find("Systems/UI/Canvas/IngamePlayerHUD/TopLeftCorner");
GameObject val3 = Object.Instantiate<GameObject>(val, val2.transform);
((Object)val3).name = "HPSP";
GameObject gameObject = ((Component)val3.transform.GetChild(0)).gameObject;
gameObject.GetComponent<RectTransform>().anchoredPosition = new Vector2(-45f, 10f);
_hudPercentagesText = gameObject.GetComponent<TextMeshProUGUI>();
string text = StaminaUIPlugin.TextColorHex?.Value ?? "FF0000";
ApplyConfiguredColor(_hudPercentagesText, text);
_lastAppliedHexColor = text;
((TMP_Text)_hudPercentagesText).fontSize = 12f;
((TMP_Text)_hudPercentagesText).margin = new Vector4(0f, -36f, 100f, 0f);
((TMP_Text)_hudPercentagesText).alignment = (TextAlignmentOptions)260;
((TMP_Text)_hudPercentagesText).text = "";
_instantiating = false;
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(GameNetworkManager), "Disconnect")]
public static void UnInstantiate()
{
_instantiating = true;
}
[HarmonyPostfix]
[HarmonyPatch(typeof(HUDManager), "Update")]
public static void Update()
{
PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
if (!((Object)(object)localPlayerController == (Object)null) && !_instantiating && !((Object)(object)_hudPercentagesText == (Object)null))
{
string text = StaminaUIPlugin.TextColorHex?.Value ?? "FF0000";
if (!string.Equals(_lastAppliedHexColor, text, StringComparison.OrdinalIgnoreCase))
{
ApplyConfiguredColor(_hudPercentagesText, text);
_lastAppliedHexColor = text;
}
float num = Mathf.RoundToInt((float)localPlayerController.health);
int num2 = Math.Max(Mathf.RoundToInt((localPlayerController.sprintMeter * 100f - 10f) / 90f * 100f), 0);
((TMP_Text)_hudPercentagesText).text = $"\n\n\n\n{num2}%";
}
}
}
[AttributeUsage(AttributeTargets.Class)]
public sealed class LethalPatchAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}