Decompiled source of CrouchHUD v1.0.0

LCCrouchHUD.dll

Decompiled 4 months ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("LCCrouchHUD")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Add crouch icon to HUD")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("LCCrouchHUD")]
[assembly: AssemblyTitle("LCCrouchHUD")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace LCCrouchHUD
{
	[BepInPlugin("LCCrouchHUD", "LCCrouchHUD", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public static ManualLogSource Log;

		private readonly Harmony _harmony = new Harmony("LCCrouchHUD");

		public static Sprite crouchIcon;

		public static Image crouchImage;

		private void Awake()
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			Log.LogInfo((object)"Plugin LCCrouchHUD is loaded!");
			byte[] array = File.ReadAllBytes(Path.Combine(Path.GetDirectoryName(Uri.UnescapeDataString(new UriBuilder(Assembly.GetExecutingAssembly().CodeBase).Path)), "crouch.png"));
			Texture2D val = new Texture2D(64, 64, (TextureFormat)5, false);
			ImageConversion.LoadImage(val, array);
			((Texture)val).filterMode = (FilterMode)0;
			crouchIcon = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0f, 0f));
			_harmony.PatchAll();
		}
	}
	[HarmonyPatch(typeof(HUDManager))]
	internal class HUDManagerPatches
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void Start(ref HUDManager __instance)
		{
			//IL_0010: 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_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: 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_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = GameObject.Find("Systems/UI/Canvas/IngamePlayerHUD/TopLeftCorner/Self");
			GameObject val2 = new GameObject("CrouchIcon");
			val2.transform.SetParent(val.transform, false);
			val2.transform.SetAsLastSibling();
			val2.transform.localRotation = Quaternion.Euler(0f, 180f, 0f);
			RectTransform val3 = val2.AddComponent<RectTransform>();
			Plugin.crouchImage = val2.AddComponent<Image>();
			Plugin.crouchImage.sprite = Plugin.crouchIcon;
			val3.sizeDelta = new Vector2(20f, 20f);
			val2.transform.position = val.transform.position + new Vector3(0.14f, -0.14f, 0f);
			((Behaviour)Plugin.crouchImage).enabled = false;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(HUDManager), "Update")]
		public static void Update()
		{
			if (GameNetworkManager.Instance.localPlayerController.isCrouching)
			{
				((Behaviour)Plugin.crouchImage).enabled = true;
			}
			else
			{
				((Behaviour)Plugin.crouchImage).enabled = false;
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "LCCrouchHUD";

		public const string PLUGIN_NAME = "LCCrouchHUD";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}