Decompiled source of VanillaUIRefresh v1.0.0

VanillaUIRefresh.dll

Decompiled an hour 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 GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using Unity.Netcode;
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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("VanillaUIRefresh")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("VanillaUIRefresh")]
[assembly: AssemblyTitle("VanillaUIRefresh")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[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 HideCustomSoundsText
{
	[BepInPlugin("com.mavka.VanillaUIRefresh", "VanillaUIRefresh", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private void Awake()
		{
			Harmony.CreateAndPatchAll(typeof(MenuTextPatch), (string)null);
			Harmony.CreateAndPatchAll(typeof(CrosshairDotPatch), (string)null);
			Harmony.CreateAndPatchAll(typeof(HoldWheelPatch), (string)null);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Clean UI & Minimal Dot 1.3.8 загружен!");
		}
	}
	public class MenuTextPatch
	{
		[HarmonyPatch(typeof(MenuManager), "Update")]
		[HarmonyPostfix]
		private static void CleanMenu(MenuManager __instance)
		{
			if ((Object)(object)__instance.menuNotification != (Object)null && __instance.menuNotification.activeSelf && (Object)(object)__instance.menuNotificationText != (Object)null && !string.IsNullOrEmpty(((TMP_Text)__instance.menuNotificationText).text))
			{
				string text = ((TMP_Text)__instance.menuNotificationText).text.ToLower();
				if (text.Contains("compatible") || text.Contains("steam servers") || text.Contains("local network"))
				{
					__instance.menuNotification.SetActive(false);
				}
			}
			TextMeshProUGUI[] array = Object.FindObjectsOfType<TextMeshProUGUI>();
			TextMeshProUGUI[] array2 = array;
			foreach (TextMeshProUGUI val in array2)
			{
				if (!((Object)(object)val != (Object)null) || !((Component)val).gameObject.activeInHierarchy || string.IsNullOrEmpty(((TMP_Text)val).text))
				{
					continue;
				}
				string text2 = ((TMP_Text)val).text.ToLower();
				if (text2.Contains("customsounds") || text2.Contains("custom sounds"))
				{
					if (text2.Contains("host"))
					{
						int num = ((TMP_Text)val).text.IndexOf('\n');
						if (num > 0)
						{
							((TMP_Text)val).text = ((TMP_Text)val).text.Substring(0, num);
						}
					}
					else
					{
						((Component)val).gameObject.SetActive(false);
					}
				}
				if (text2.Trim() == "accessibility")
				{
					((Component)val).gameObject.SetActive(false);
				}
			}
		}
	}
	public class CrosshairDotPatch
	{
		private static Sprite squareSprite;

		private static Sprite GetSquareSprite()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)squareSprite != (Object)null)
			{
				return squareSprite;
			}
			Texture2D val = new Texture2D(4, 4, (TextureFormat)5, false);
			((Texture)val).filterMode = (FilterMode)0;
			for (int i = 0; i < 4; i++)
			{
				for (int j = 0; j < 4; j++)
				{
					val.SetPixel(j, i, Color.white);
				}
			}
			val.Apply();
			squareSprite = Sprite.Create(val, new Rect(0f, 0f, 4f, 4f), new Vector2(0.5f, 0.5f));
			return squareSprite;
		}

		[HarmonyPatch(typeof(PlayerControllerB), "LateUpdate")]
		[HarmonyPostfix]
		private static void ReplaceCursorWithDot(PlayerControllerB __instance)
		{
			//IL_0094: 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)
			if (!((NetworkBehaviour)__instance).IsOwner)
			{
				return;
			}
			if ((Object)(object)__instance.cursorTip != (Object)null && ((Behaviour)__instance.cursorTip).enabled)
			{
				((Behaviour)__instance.cursorTip).enabled = false;
			}
			if ((Object)(object)__instance.cursorIcon != (Object)null)
			{
				Sprite val = GetSquareSprite();
				if ((Object)(object)__instance.cursorIcon.sprite != (Object)(object)val)
				{
					__instance.cursorIcon.sprite = val;
				}
				((Graphic)__instance.cursorIcon).rectTransform.sizeDelta = new Vector2(7f, 7f);
				((Graphic)__instance.cursorIcon).color = new Color(1f, 1f, 1f, 0.4f);
			}
		}
	}
	public class HoldWheelPatch
	{
		private static Sprite smoothCircleRingSprite;

		private static Image holdWheelFill;

		private static Sprite GetSmoothCircleRingSprite()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: 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_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)smoothCircleRingSprite != (Object)null)
			{
				return smoothCircleRingSprite;
			}
			int num = 128;
			Texture2D val = new Texture2D(num, num, (TextureFormat)5, false);
			((Texture)val).filterMode = (FilterMode)1;
			float num2 = (float)(num - 1) / 2f;
			float num3 = 60f;
			float num4 = 48f;
			for (int i = 0; i < num; i++)
			{
				for (int j = 0; j < num; j++)
				{
					float num5 = Vector2.Distance(new Vector2((float)j, (float)i), new Vector2(num2, num2));
					float num6 = Mathf.Clamp01(num3 + 0.5f - num5);
					float num7 = Mathf.Clamp01(num5 - (num4 - 0.5f));
					float num8 = num6 * num7;
					val.SetPixel(j, i, new Color(1f, 1f, 1f, num8));
				}
			}
			val.Apply();
			smoothCircleRingSprite = Sprite.Create(val, new Rect(0f, 0f, (float)num, (float)num), new Vector2(0.5f, 0.5f));
			return smoothCircleRingSprite;
		}

		[HarmonyPatch(typeof(PlayerControllerB), "LateUpdate")]
		[HarmonyPostfix]
		private static void CustomizeHoldWheel(PlayerControllerB __instance)
		{
			//IL_020e: 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)
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Invalid comparison between Unknown and I4
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Invalid comparison between Unknown and I4
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			if (!((NetworkBehaviour)__instance).IsOwner)
			{
				return;
			}
			if ((Object)(object)holdWheelFill == (Object)null)
			{
				Image[] array = Object.FindObjectsOfType<Image>();
				Image[] array2 = array;
				foreach (Image val in array2)
				{
					if (!((Component)val).gameObject.activeInHierarchy || (int)val.type != 3 || (int)val.fillMethod != 4 || !(val.fillAmount > 0.01f) || !(val.fillAmount < 0.99f))
					{
						continue;
					}
					holdWheelFill = val;
					((Component)holdWheelFill).transform.localScale = new Vector3(0.36f, 0.36f, 1f);
					if (!((Object)(object)((Component)val).transform.parent != (Object)null))
					{
						break;
					}
					Image[] componentsInChildren = ((Component)((Component)val).transform.parent).GetComponentsInChildren<Image>(true);
					Image[] array3 = componentsInChildren;
					foreach (Image val2 in array3)
					{
						if ((Object)(object)val2 != (Object)(object)holdWheelFill)
						{
							((Behaviour)val2).enabled = false;
						}
					}
					break;
				}
			}
			if ((Object)(object)holdWheelFill == (Object)null)
			{
				return;
			}
			if ((Object)(object)((Component)holdWheelFill).transform.parent != (Object)null)
			{
				Image[] componentsInChildren2 = ((Component)((Component)holdWheelFill).transform.parent).GetComponentsInChildren<Image>(true);
				Image[] array4 = componentsInChildren2;
				foreach (Image val3 in array4)
				{
					if ((Object)(object)val3 != (Object)(object)holdWheelFill && ((Behaviour)val3).enabled)
					{
						((Behaviour)val3).enabled = false;
					}
				}
			}
			Sprite val4 = GetSmoothCircleRingSprite();
			if ((Object)(object)holdWheelFill.sprite != (Object)(object)val4)
			{
				holdWheelFill.sprite = val4;
			}
			((Graphic)holdWheelFill).color = new Color(1f, 1f, 1f, 0.35f);
			((Component)holdWheelFill).transform.localEulerAngles = Vector3.zero;
			((Component)holdWheelFill).transform.localScale = new Vector3(0.36f, 0.36f, 1f);
		}
	}
}