Decompiled source of ControlCompanyFilter v1.0.0

ControlCompanyFilter.dll

Decompiled 10 months ago
using System;
using System.Collections;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using ControlCompanyFilter.Patches;
using HarmonyLib;
using Steamworks.Data;
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: AssemblyTitle("ControlCompanyFilter")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ControlCompanyFilter")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("dfed064e-ab44-4aa7-b361-7a59370d39a8")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ControlCompanyFilter
{
	[BepInPlugin("ControlCompany.ControlCompanyFilter", "ControlCompanyFilter", "1.0.0")]
	public class ControlCompanyFilterPlugin : BaseUnityPlugin
	{
		private const string modGUID = "ControlCompany.ControlCompanyFilter";

		private const string modName = "ControlCompanyFilter";

		private const string modVersion = "1.0.0";

		private readonly Harmony harmony = new Harmony("ControlCompany.ControlCompanyFilter");

		public static ControlCompanyFilterPlugin Instance;

		internal ManualLogSource logger;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			logger = Logger.CreateLogSource("ControlCompany.ControlCompanyFilter");
			ApplyPatches();
		}

		private void ApplyPatches()
		{
			harmony.PatchAll(typeof(ControlCompanyFilterPlugin));
			harmony.PatchAll(typeof(LobbyListPatch));
		}
	}
}
namespace ControlCompanyFilter.Patches
{
	internal class LobbyListPatch
	{
		public const char SERVER_NAME_FILTER = '\u200b';

		[HarmonyPatch(typeof(LobbySlot), "Awake")]
		[HarmonyPostfix]
		private static void LobbySlotPostfix(LobbySlot __instance)
		{
			if ((Object)(object)__instance != (Object)null)
			{
				((MonoBehaviour)__instance).StartCoroutine(MarkLobbySlot(__instance));
			}
		}

		private static IEnumerator MarkLobbySlot(LobbySlot lobbySlot)
		{
			yield return (object)new WaitForEndOfFrame();
			string lobbyName = ((Lobby)(ref lobbySlot.thisLobby)).GetData("name");
			if (!string.IsNullOrEmpty(lobbyName) && Enumerable.Contains(lobbyName, '\u200b'))
			{
				Transform obj = ((Component)lobbySlot).transform.Find("Outline");
				Image outlineImage = ((obj != null) ? ((Component)obj).GetComponent<Image>() : null);
				Transform obj2 = ((Component)lobbySlot).transform.Find("JoinButton/SelectionHighlight");
				Image joinButtonSelectionHighlight = ((obj2 != null) ? ((Component)obj2).GetComponent<Image>() : null);
				if (Object.op_Implicit((Object)(object)outlineImage))
				{
					((Graphic)outlineImage).color = GetColorFromRGBA(202, 181, 0, 255);
				}
				if (Object.op_Implicit((Object)(object)joinButtonSelectionHighlight))
				{
					((Graphic)joinButtonSelectionHighlight).color = GetColorFromRGBA(255, 178, 0, 9);
				}
				TextMeshProUGUI serverNameText = lobbySlot.LobbyName;
				TextMeshProUGUI numPlayersText = lobbySlot.playerCount;
				Color textColor = (((Graphic)serverNameText).color = GetColorFromRGBA(219, 181, 0, 255));
				((Graphic)numPlayersText).color = textColor;
				Image lobbySlotImage = ((Component)lobbySlot).GetComponent<Image>();
				((Graphic)lobbySlotImage).color = GetColorFromRGBA(77, 67, 0, 255);
				if (!((Object)((Component)lobbySlot).transform).name.Contains("Challenge"))
				{
					GameObject rectTransformGO = new GameObject("cc", new Type[1] { typeof(RectTransform) });
					RectTransform rectTransform = rectTransformGO.GetComponent<RectTransform>();
					TextMeshProUGUI ccText = ((Component)rectTransform).gameObject.AddComponent<TextMeshProUGUI>();
					((TMP_Text)ccText).fontSize = 26f;
					((TMP_Text)ccText).text = "CONTROL COMPANY";
					((TMP_Text)ccText).alignment = (TextAlignmentOptions)4097;
					((TMP_Text)ccText).font = ((TMP_Text)numPlayersText).font;
					((Graphic)ccText).color = GetColorFromRGBA(89, 89, 0, 255);
					((Transform)rectTransform).SetParent(((Component)lobbySlot).transform);
					rectTransform.anchorMin = new Vector2(0f, 1f);
					rectTransform.anchorMax = new Vector2(0f, 1f);
					rectTransform.pivot = new Vector2(0f, 1f);
					((Transform)rectTransform).localScale = new Vector3(0.8497399f, 0.8497399f, 0.8497399f);
					((Transform)rectTransform).localPosition = new Vector3(130f, -10f, -7f);
					rectTransform.sizeDelta = new Vector2(269f, 24f);
				}
			}
		}

		private static Color GetColorFromRGBA(int r, int b, int g, int a)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: 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)
			return new Color((float)r / 255f, (float)b / 255f, (float)g / 255f, (float)a / 255f);
		}
	}
}