Decompiled source of VanillaUIRefresh Updated v1.0.1

VanillaUIRefresh.dll

Decompiled 2 hours 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", "2.6.3")]
	public class Plugin : BaseUnityPlugin
	{
		private void Awake()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			Harmony val = new Harmony("com.mavka.VanillaUIRefresh");
			try
			{
				val.PatchAll(typeof(MenuTextPatch));
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)("MenuTextPatch: " + ex.Message));
			}
			try
			{
				val.PatchAll(typeof(HudTipsCleanerPatch));
			}
			catch (Exception ex2)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)("HudTipsCleanerPatch: " + ex2.Message));
			}
			try
			{
				val.PatchAll(typeof(VanillaCursorScalePatch));
			}
			catch (Exception ex3)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)("VanillaCursorScalePatch: " + ex3.Message));
			}
			try
			{
				val.PatchAll(typeof(HoldWheelPatch));
			}
			catch (Exception ex4)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)("HoldWheelPatch: " + ex4.Message));
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)"VanillaUIRefresh 2.6.3 успешно загружен!");
		}
	}
	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>();
			foreach (TextMeshProUGUI val in array)
			{
				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 HudTipsCleanerPatch
	{
		[HarmonyPatch(typeof(HUDManager), "DisplayTip")]
		[HarmonyPrefix]
		private static bool FilterHudTips(string headerText, string bodyText)
		{
			string text = (headerText ?? "").ToLower();
			string text2 = (bodyText ?? "").ToLower();
			if (text.Contains("lclegday") || text2.Contains("lclegday") || text2.Contains("saved stamina"))
			{
				return false;
			}
			if (text.Contains("minimumquotafinder") && (text2.Contains("disabled") || text2.Contains("not on the ship") || text2.Contains("no items")))
			{
				return false;
			}
			return true;
		}

		[HarmonyPatch(typeof(HUDManager), "Update")]
		[HarmonyPostfix]
		private static void HideControlTipsUI(HUDManager __instance)
		{
			if ((Object)(object)__instance == (Object)null || __instance.controlTipLines == null)
			{
				return;
			}
			for (int i = 0; i < __instance.controlTipLines.Length; i++)
			{
				if ((Object)(object)__instance.controlTipLines[i] != (Object)null && ((Component)__instance.controlTipLines[i]).gameObject.activeSelf)
				{
					((Component)__instance.controlTipLines[i]).gameObject.SetActive(false);
				}
			}
		}
	}
	public class VanillaCursorScalePatch
	{
		private static Vector3 baseCursorScale = Vector3.zero;

		[HarmonyPatch(typeof(PlayerControllerB), "LateUpdate")]
		[HarmonyPostfix]
		private static void UpdateVanillaCursor(PlayerControllerB __instance)
		{
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
			if (!((NetworkBehaviour)__instance).IsOwner)
			{
				return;
			}
			if ((Object)(object)__instance.cursorTip != (Object)null)
			{
				string text = ((TMP_Text)__instance.cursorTip).text ?? "";
				string text2 = "";
				bool flag = false;
				if ((Object)(object)__instance.hoveringOverTrigger != (Object)null)
				{
					text2 = (__instance.hoveringOverTrigger.interactable ? (__instance.hoveringOverTrigger.hoverTip ?? "") : (__instance.hoveringOverTrigger.disabledHoverTip ?? ""));
					DoorLock val = ((Component)__instance.hoveringOverTrigger).GetComponentInParent<DoorLock>() ?? ((Component)__instance.hoveringOverTrigger).GetComponentInChildren<DoorLock>();
					if ((Object)(object)val != (Object)null && val.isLocked)
					{
						flag = true;
					}
				}
				string text3 = (text + " " + text2).ToLower();
				if (flag || text3.Contains("locked") || text3.Contains("закрыт") || text3.Contains("заперт"))
				{
					if (string.IsNullOrEmpty(text))
					{
						((TMP_Text)__instance.cursorTip).text = (string.IsNullOrEmpty(text2) ? "Locked" : text2);
					}
					if (!((Component)__instance.cursorTip).gameObject.activeSelf)
					{
						((Component)__instance.cursorTip).gameObject.SetActive(true);
					}
					((Behaviour)__instance.cursorTip).enabled = true;
				}
				else
				{
					((Behaviour)__instance.cursorTip).enabled = false;
				}
			}
			if ((Object)(object)__instance.cursorIcon == (Object)null)
			{
				return;
			}
			if (baseCursorScale == Vector3.zero)
			{
				baseCursorScale = ((Transform)((Graphic)__instance.cursorIcon).rectTransform).localScale;
			}
			if ((Object)(object)__instance.hoveringOverTrigger != (Object)null && (Object)(object)__instance.hoveringOverTrigger.hoverIcon != (Object)null && (Object)(object)__instance.cursorIcon.sprite != (Object)(object)__instance.hoveringOverTrigger.hoverIcon)
			{
				__instance.cursorIcon.sprite = __instance.hoveringOverTrigger.hoverIcon;
			}
			if ((Object)(object)HUDManager.Instance != (Object)null && HUDManager.Instance.holdFillAmount > 0.01f)
			{
				if (!((Component)__instance.cursorIcon).gameObject.activeSelf)
				{
					((Component)__instance.cursorIcon).gameObject.SetActive(true);
				}
				if (!((Behaviour)__instance.cursorIcon).enabled)
				{
					((Behaviour)__instance.cursorIcon).enabled = true;
				}
			}
			((Transform)((Graphic)__instance.cursorIcon).rectTransform).localScale = baseCursorScale * 0.82f;
		}
	}
	public class HoldWheelPatch
	{
		private static Sprite fillRingSprite;

		private static Sprite outlineRingSprite;

		private static Image holdWheelFill;

		private static Sprite CreateRingSprite(float outerR, float innerR)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			int num = 128;
			Texture2D val = new Texture2D(num, num, (TextureFormat)5, false);
			((Texture)val).filterMode = (FilterMode)1;
			float num2 = (float)(num - 1) / 2f;
			for (int i = 0; i < num; i++)
			{
				for (int j = 0; j < num; j++)
				{
					float num3 = Vector2.Distance(new Vector2((float)j, (float)i), new Vector2(num2, num2));
					float num4 = Mathf.Clamp01(outerR + 0.5f - num3) * Mathf.Clamp01(num3 - (innerR - 0.5f));
					val.SetPixel(j, i, new Color(1f, 1f, 1f, num4));
				}
			}
			val.Apply();
			return Sprite.Create(val, new Rect(0f, 0f, (float)num, (float)num), new Vector2(0.5f, 0.5f));
		}

		[HarmonyPatch(typeof(PlayerControllerB), "LateUpdate")]
		[HarmonyPostfix]
		private static void CustomizeHoldWheel(PlayerControllerB __instance)
		{
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Invalid comparison between Unknown and I4
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Invalid comparison between Unknown and I4
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			if (!((NetworkBehaviour)__instance).IsOwner)
			{
				return;
			}
			if (fillRingSprite == null)
			{
				fillRingSprite = CreateRingSprite(60f, 48f);
			}
			if (outlineRingSprite == null)
			{
				outlineRingSprite = CreateRingSprite(63f, 45f);
			}
			if ((Object)(object)holdWheelFill == (Object)null)
			{
				Image[] array = Object.FindObjectsOfType<Image>();
				foreach (Image val in array)
				{
					if (((Component)val).gameObject.activeInHierarchy && (int)val.type == 3 && (int)val.fillMethod == 4 && val.fillAmount > 0.01f && val.fillAmount < 0.99f)
					{
						holdWheelFill = val;
						break;
					}
				}
			}
			if ((Object)(object)holdWheelFill == (Object)null)
			{
				return;
			}
			if ((Object)(object)holdWheelFill.sprite != (Object)(object)fillRingSprite)
			{
				holdWheelFill.sprite = fillRingSprite;
			}
			((Component)holdWheelFill).transform.localEulerAngles = Vector3.zero;
			((Component)holdWheelFill).transform.localScale = new Vector3(0.62f, 0.62f, 1f);
			if (!((Object)(object)((Component)holdWheelFill).transform.parent != (Object)null))
			{
				return;
			}
			bool flag = false;
			Image[] componentsInChildren = ((Component)((Component)holdWheelFill).transform.parent).GetComponentsInChildren<Image>(true);
			foreach (Image val2 in componentsInChildren)
			{
				if ((Object)(object)val2 == (Object)(object)holdWheelFill)
				{
					continue;
				}
				if (!flag)
				{
					if ((Object)(object)val2.sprite != (Object)(object)outlineRingSprite)
					{
						val2.sprite = outlineRingSprite;
					}
					((Graphic)val2).color = new Color(0.1f, 0.1f, 0.1f, 0.65f);
					((Component)val2).transform.localEulerAngles = Vector3.zero;
					((Component)val2).transform.localScale = new Vector3(0.62f, 0.62f, 1f);
					flag = true;
				}
				else
				{
					((Graphic)val2).color = Color.clear;
				}
			}
		}
	}
}