Decompiled source of staminaUI v1.0.2

mod.dll

Decompiled a week ago
using System;
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.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using OoLunar.LethalCompanyPatched.Patches;
using TMPro;
using UnityEngine;

[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("LethalCompanyPatched")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("A continuation of An0n_Patches.")]
[assembly: AssemblyFileVersion("1.2.1.0")]
[assembly: AssemblyInformationalVersion("1.2.1+c15686531b301909d355ec33c628197f201b636a")]
[assembly: AssemblyProduct("LethalCompanyPatched")]
[assembly: AssemblyTitle("LethalCompanyPatched")]
[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.LethalCompanyPatched
{
	[BepInPlugin("LethalCompanyPatched", "LethalCompanyPatched", "1.2.1")]
	public sealed class LethalCompanyPatchedPlugin : BaseUnityPlugin
	{
		private readonly Harmony _harmony = new Harmony("LethalCompanyPatched");

		internal static ManualLogSource StaticLogger;

		private void Awake()
		{
			((BaseUnityPlugin)this).Logger.LogDebug((object)"LethalCompanyPatched started loading!");
			StaticLogger = ((BaseUnityPlugin)this).Logger;
			Type[] types = typeof(LethalCompanyPatchedPlugin).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 = "LethalCompanyPatched";

		public const string PLUGIN_NAME = "LethalCompanyPatched";

		public const string PLUGIN_VERSION = "1.2.1";
	}
}
namespace OoLunar.LethalCompanyPatched.Patches
{
	[HarmonyPatch]
	[LethalPatch]
	internal class HUDManagerPatch : MonoBehaviour
	{
		private static bool _instantiating = true;

		private static TextMeshProUGUI? _hudPercentagesText;

		[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_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: 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>();
				((TMP_Text)_hudPercentagesText).faceColor = Color32.op_Implicit(new Color(255f, 0f, 0f, 255f));
				((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))
			{
				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)
		{
		}
	}
}