Decompiled source of MoreStrafts UISpawnAddon v2.0.1

plugins/MoreStrafts_UISpawnAddon.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using DG.Tweening;
using DG.Tweening.Core;
using DG.Tweening.Plugins.Options;
using FishNet;
using FishNet.Object;
using FishNet.Object.Synchronizing;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Steamworks;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("0.0.0.0")]
[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 moreStrafts.UISpawnAddon
{
	[BepInPlugin("com.morestrafts.uispawn.addon", "MoreStrafts UI and Spawn Fixes Addon", "2.1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class UISpawnAddonPlugin : BaseUnityPlugin
	{
		public static ManualLogSource Log;

		private void Awake()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			Harmony val = new Harmony("com.morestrafts.uispawn.addon");
			val.PatchAll();
			MethodInfo methodInfo = AccessTools.Method(typeof(PlayerListItem), "Update", (Type[])null, (Type[])null);
			if (methodInfo != null)
			{
				val.Unpatch((MethodBase)methodInfo, (HarmonyPatchType)1, "com.nitrogenia.morestrafts");
			}
			MethodInfo methodInfo2 = AccessTools.Method(typeof(ClientInstance), "RpcLogic___DressAboubiObservers_2497120398", (Type[])null, (Type[])null);
			if (methodInfo2 != null)
			{
				val.Unpatch((MethodBase)methodInfo2, (HarmonyPatchType)1, "com.nitrogenia.morestrafts");
			}
			MethodInfo methodInfo3 = AccessTools.Method(typeof(ClientInstance), "RpcLogic___RunIntoLobby_3316948804", (Type[])null, (Type[])null);
			if (methodInfo3 != null)
			{
				val.Unpatch((MethodBase)methodInfo3, (HarmonyPatchType)1, "com.nitrogenia.morestrafts");
			}
			MethodInfo methodInfo4 = AccessTools.Method(typeof(ClientInstance), "RpcLogic___MenuAnimationObservers_1692629761", (Type[])null, (Type[])null);
			if (methodInfo4 != null)
			{
				val.Unpatch((MethodBase)methodInfo4, (HarmonyPatchType)1, "com.nitrogenia.morestrafts");
			}
			MethodInfo methodInfo5 = AccessTools.Method(typeof(MatchPoitnsHUD), "UpdateVisuals", new Type[2]
			{
				typeof(int),
				typeof(Dictionary<int, int>)
			}, (Type[])null);
			if (methodInfo5 != null)
			{
				val.Unpatch((MethodBase)methodInfo5, (HarmonyPatchType)1, "com.nitrogenia.morestrafts");
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)"MoreStrafts UI and Spawn Fixes Addon v2.1.0 loaded!");
		}
	}
	public static class GridLayout
	{
		private static bool _previewsExpanded;

		private static bool _pedestalsHidden;

		private static bool _customLayoutActive;

		private static int _lastPreviewCount;

		private static HashSet<int> _laidOut = new HashSet<int>();

		private static AboubiPreviewLobby[] _originalPreviews;

		private static bool _3dCached;

		private static float _3dMinX;

		private static float _3dMaxX;

		private static float _3dBaseY;

		private static float _3dBaseZ;

		private static float _3dColSpacing;

		private static Vector3[] _originalPreviewPositions;

		public static bool IsCustomLayoutActive()
		{
			return _customLayoutActive;
		}

		public static int PlayerCount()
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			int num = 0;
			try
			{
				if (SteamLobby.Instance?.players != null)
				{
					num = SteamLobby.Instance.players.Count;
				}
				CSteamID val = default(CSteamID);
				((CSteamID)(ref val))..ctor(SteamLobby.Instance.CurrentLobbyID);
				if (((CSteamID)(ref val)).IsValid())
				{
					int numLobbyMembers = SteamMatchmaking.GetNumLobbyMembers(val);
					if (numLobbyMembers > num)
					{
						num = numLobbyMembers;
					}
				}
			}
			catch
			{
			}
			return num;
		}

		public static void GetLayout(int playerCount, out int row1, out int row2)
		{
			switch (playerCount)
			{
			case 5:
				row1 = 5;
				row2 = 0;
				break;
			case 6:
				row1 = 3;
				row2 = 3;
				break;
			case 7:
				row1 = 4;
				row2 = 3;
				break;
			case 8:
				row1 = 4;
				row2 = 4;
				break;
			case 9:
				row1 = 5;
				row2 = 4;
				break;
			default:
				row1 = 5;
				row2 = Math.Max(0, playerCount - 5);
				break;
			}
		}

		private static void GetRowCol(int idx, int row1Count, int row2Count, out int row, out int col, out int rowSize)
		{
			if (row2Count == 0 || idx < row1Count)
			{
				row = 0;
				col = idx;
				rowSize = row1Count;
			}
			else
			{
				row = 1;
				col = idx - row1Count;
				rowSize = row2Count;
			}
		}

		public static Vector3 GetUIPosition(Transform[] positions, int slotIndex, int playerCount)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			GetLayout(playerCount, out var row, out var row2);
			GetRowCol(Math.Max(0, slotIndex), row, row2, out var row3, out var col, out var rowSize);
			float num = float.MaxValue;
			float num2 = float.MinValue;
			float y = positions[0].position.y;
			float z = positions[0].position.z;
			for (int i = 0; i < positions.Length; i++)
			{
				float x = positions[i].position.x;
				if (x < num)
				{
					num = x;
				}
				if (x > num2)
				{
					num2 = x;
				}
			}
			float num3 = (num + num2) / 2f;
			float num4 = (num2 - num) / 4f;
			float num5 = num3 - (float)(rowSize - 1) * num4 / 2f;
			float num6 = (float)Screen.height / 1080f;
			float num7 = num5 + (float)col * num4;
			float num8 = ((row2 == 0) ? (y - 60f * num6) : (y + 60f * num6 - (float)row3 * 250f * num6));
			return new Vector3(num7, num8, z);
		}

		private static Vector3 Get3DPosition(int idx, int playerCount)
		{
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			GetLayout(playerCount, out var row, out var row2);
			GetRowCol(idx, row, row2, out var row3, out var col, out var rowSize);
			float num = (_3dMinX + _3dMaxX) / 2f - (float)(rowSize - 1) * _3dColSpacing / 2f + (float)col * _3dColSpacing;
			float num2 = ((row2 == 0) ? _3dBaseY : (_3dBaseY + 1f - (float)row3 * 1.5f));
			return new Vector3(num, num2, _3dBaseZ);
		}

		private static void SetCenteredPosition(Transform t, Vector2 pos)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: 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)
			RectTransform component = ((Component)t).GetComponent<RectTransform>();
			if (!((Object)(object)component == (Object)null))
			{
				Vector2 val = default(Vector2);
				((Vector2)(ref val))..ctor(0.5f, 0.5f);
				component.pivot = val;
				Vector2 anchorMin = (component.anchorMax = val);
				component.anchorMin = anchorMin;
				component.anchoredPosition = pos;
			}
		}

		public static void ApplyItemLayout(PlayerListItem item, int playerCount)
		{
			//IL_0041: 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_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_024b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0315: Unknown result type (might be due to invalid IL or missing references)
			int instanceID = ((Object)item).GetInstanceID();
			if (_laidOut.Contains(instanceID))
			{
				return;
			}
			_laidOut.Add(instanceID);
			GetLayout(playerCount, out var _, out var row2);
			float num = ((row2 == 0) ? 0.7f : 0.55f);
			((Component)item).transform.localScale = Vector3.one * num;
			if ((Object)(object)item.PlayerIcon != (Object)null)
			{
				((Component)item.PlayerIcon).gameObject.SetActive(false);
			}
			Traverse val = Traverse.Create((object)item);
			if ((Object)(object)item.PlayerNameText != (Object)null)
			{
				SetCenteredPosition(((TMP_Text)item.PlayerNameText).transform, new Vector2(-110f, 60f));
				((TMP_Text)item.PlayerNameText).fontSize = 22f;
				((TMP_Text)item.PlayerNameText).alignment = (TextAlignmentOptions)514;
				RectTransform component = ((Component)item.PlayerNameText).GetComponent<RectTransform>();
				if ((Object)(object)component != (Object)null)
				{
					component.sizeDelta = new Vector2(200f, 30f);
				}
			}
			if ((Object)(object)item.PlayerReadyText != (Object)null)
			{
				SetCenteredPosition(((TMP_Text)item.PlayerReadyText).transform, new Vector2(0f, 34f));
				((TMP_Text)item.PlayerReadyText).fontSize = 16f;
				((TMP_Text)item.PlayerReadyText).alignment = (TextAlignmentOptions)514;
				RectTransform component2 = ((Component)item.PlayerReadyText).GetComponent<RectTransform>();
				if ((Object)(object)component2 != (Object)null)
				{
					component2.sizeDelta = new Vector2(200f, 25f);
				}
			}
			TMP_Dropdown value = val.Field("teamIdDropdown").GetValue<TMP_Dropdown>();
			if ((Object)(object)value != (Object)null)
			{
				SetCenteredPosition(((Component)value).transform, new Vector2(0f, -10f));
				value.ClearOptions();
				List<string> list = new List<string>();
				for (int i = 1; i <= playerCount; i++)
				{
					list.Add(i.ToString());
				}
				value.AddOptions(list);
				int teamId = ScoreManager.Instance.GetTeamId(item.PlayerIdNumber);
				if (teamId >= 0 && teamId < list.Count)
				{
					value.value = teamId;
				}
				value.RefreshShownValue();
			}
			GameObject value2 = val.Field("kickbutton").GetValue<GameObject>();
			GameObject value3 = val.Field("banbutton").GetValue<GameObject>();
			if ((Object)(object)value2 != (Object)null)
			{
				SetCenteredPosition(value2.transform, new Vector2(-30f, -40f));
			}
			if ((Object)(object)value3 != (Object)null)
			{
				SetCenteredPosition(value3.transform, new Vector2(30f, -40f));
			}
			GameObject value4 = val.Field("mutebutton").GetValue<GameObject>();
			GameObject value5 = val.Field("textmutebutton").GetValue<GameObject>();
			GameObject value6 = val.Field("addButton").GetValue<GameObject>();
			if ((Object)(object)value4 != (Object)null)
			{
				SetCenteredPosition(value4.transform, new Vector2(-40f, -80f));
			}
			if ((Object)(object)value5 != (Object)null)
			{
				SetCenteredPosition(value5.transform, new Vector2(0f, -80f));
			}
			if ((Object)(object)value6 != (Object)null)
			{
				SetCenteredPosition(value6.transform, new Vector2(40f, -80f));
			}
			GameObject value7 = val.Field("cosmeticbutton").GetValue<GameObject>();
			if ((Object)(object)value7 != (Object)null)
			{
				value7.SetActive(false);
			}
		}

		public static void EnsurePreviewsExpanded(LobbyController lc)
		{
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: 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_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			if (_previewsExpanded || (Object)(object)lc == (Object)null)
			{
				return;
			}
			AboubiPreviewLobby[] previews = lc.previews;
			if (previews == null || previews.Length == 0)
			{
				return;
			}
			AboubiPreviewLobby val = null;
			if (!_3dCached)
			{
				_3dMinX = float.MaxValue;
				_3dMaxX = float.MinValue;
				_originalPreviewPositions = (Vector3[])(object)new Vector3[previews.Length];
				for (int i = 0; i < previews.Length; i++)
				{
					if ((Object)(object)previews[i] != (Object)null)
					{
						Vector3 position = ((Component)previews[i]).transform.position;
						_originalPreviewPositions[i] = position;
						if (position.x < _3dMinX)
						{
							_3dMinX = position.x;
						}
						if (position.x > _3dMaxX)
						{
							_3dMaxX = position.x;
						}
						_3dBaseY = position.y;
						_3dBaseZ = position.z;
					}
				}
				_3dColSpacing = (_3dMaxX - _3dMinX) / 4f;
				_3dCached = true;
			}
			for (int j = 0; j < previews.Length; j++)
			{
				if ((Object)(object)previews[j] != (Object)null && (Object)(object)val == (Object)null)
				{
					val = previews[j];
				}
			}
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			_originalPreviews = (AboubiPreviewLobby[])previews.Clone();
			AboubiPreviewLobby[] array = (AboubiPreviewLobby[])(object)new AboubiPreviewLobby[10];
			for (int k = 0; k < 10; k++)
			{
				if (k < previews.Length && (Object)(object)previews[k] != (Object)null)
				{
					array[k] = previews[k];
					continue;
				}
				GameObject val2 = Object.Instantiate<GameObject>(((Component)val).gameObject, ((Component)val).transform.parent);
				((Object)val2).name = $"LobbyPreview_P{k}";
				array[k] = val2.GetComponent<AboubiPreviewLobby>();
				if ((Object)(object)array[k].previewObject != (Object)null)
				{
					array[k].previewObject.SetActive(false);
				}
			}
			lc.previews = array;
			_previewsExpanded = true;
		}

		public static void RepositionPreviews(LobbyController lc, int pc)
		{
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)lc == (Object)null || lc.previews == null)
			{
				return;
			}
			List<int> list = new List<int>();
			SteamLobby instance = SteamLobby.Instance;
			if (instance?.players != null)
			{
				foreach (NetworkObject player in instance.players)
				{
					ClientInstance component = ((Component)player).GetComponent<ClientInstance>();
					if ((Object)(object)component != (Object)null)
					{
						list.Add(component.PlayerId);
					}
				}
			}
			list.Sort();
			GetLayout(pc, out var _, out var row2);
			float num = ((row2 == 0) ? 0.5f : 0.35f);
			for (int i = 0; i < lc.previews.Length; i++)
			{
				if (!((Object)(object)lc.previews[i] == (Object)null))
				{
					ShortcutExtensions.DOKill((Component)(object)((Component)lc.previews[i]).transform, false);
					if ((Object)(object)lc.previews[i].previewObject != (Object)null)
					{
						lc.previews[i].previewObject.SetActive(false);
					}
				}
			}
			for (int j = 0; j < list.Count; j++)
			{
				int num2 = list[j];
				if (num2 < 0 || num2 >= lc.previews.Length)
				{
					continue;
				}
				AboubiPreviewLobby val = lc.previews[num2];
				if (!((Object)(object)val == (Object)null))
				{
					Vector3 val2 = Get3DPosition(j, pc);
					((Component)val).transform.position = val2;
					((Component)val).transform.localScale = Vector3.one * num;
					Traverse.Create((object)val).Field("initialPosition").SetValue((object)val2);
					if ((Object)(object)val.previewObject != (Object)null)
					{
						val.previewObject.SetActive(true);
					}
				}
			}
			_lastPreviewCount = pc;
		}

		public static void HidePedestals()
		{
			if (_pedestalsHidden)
			{
				return;
			}
			try
			{
				MenuHUDTween[] value = Traverse.Create((object)SteamLobby.Instance).Field("lobby3D").GetValue<MenuHUDTween[]>();
				if (value == null)
				{
					return;
				}
				int num = 0;
				MenuHUDTween[] array = value;
				foreach (MenuHUDTween val in array)
				{
					if ((Object)(object)val == (Object)null)
					{
						continue;
					}
					for (int j = 0; j < ((Component)val).transform.childCount; j++)
					{
						Transform child = ((Component)val).transform.GetChild(j);
						if (((Object)child).name == "PlayerSlot")
						{
							MeshRenderer component = ((Component)child).GetComponent<MeshRenderer>();
							if ((Object)(object)component != (Object)null)
							{
								((Renderer)component).enabled = false;
								num++;
							}
						}
					}
				}
				if (num > 0)
				{
					_pedestalsHidden = true;
				}
			}
			catch
			{
			}
		}

		private static void ShowPedestals()
		{
			_pedestalsHidden = false;
			try
			{
				MenuHUDTween[] value = Traverse.Create((object)SteamLobby.Instance).Field("lobby3D").GetValue<MenuHUDTween[]>();
				if (value == null)
				{
					return;
				}
				MenuHUDTween[] array = value;
				foreach (MenuHUDTween val in array)
				{
					if ((Object)(object)val == (Object)null)
					{
						continue;
					}
					for (int j = 0; j < ((Component)val).transform.childCount; j++)
					{
						Transform child = ((Component)val).transform.GetChild(j);
						if (((Object)child).name == "PlayerSlot")
						{
							MeshRenderer component = ((Component)child).GetComponent<MeshRenderer>();
							if ((Object)(object)component != (Object)null)
							{
								((Renderer)component).enabled = true;
							}
						}
					}
				}
			}
			catch
			{
			}
		}

		public static void CleanupAndRelayout(LobbyController lc)
		{
			List<PlayerListItem> list = (((Object)(object)lc.PlayerListViewContent != (Object)null) ? lc.PlayerListViewContent.GetComponentsInChildren<PlayerListItem>(true).ToList() : null);
			Transform value = Traverse.Create((object)lc).Field("tabScreen").GetValue<Transform>();
			List<PlayerListItem> list2 = (((Object)(object)value != (Object)null) ? ((Component)value).GetComponentsInChildren<PlayerListItem>(true).ToList() : null);
			SteamLobby value2 = Traverse.Create((object)lc).Field("manager").GetValue<SteamLobby>();
			if (list == null || value2?.players == null)
			{
				return;
			}
			RemoveDisconnected(list, value2.players);
			if (list2 != null)
			{
				RemoveDisconnected(list2, value2.players);
			}
			int count = value2.players.Count;
			if (count <= 4)
			{
				RevertToVanilla(lc);
				return;
			}
			_laidOut.Clear();
			RelayoutItems(list, lc.clientPosition, count);
			if (list2 != null)
			{
				RelayoutItems(list2, lc.tabclientPosition, count);
			}
			RepositionPreviews(lc, count);
		}

		private static void RemoveDisconnected(List<PlayerListItem> items, List<NetworkObject> players)
		{
			for (int num = items.Count - 1; num >= 0; num--)
			{
				PlayerListItem item = items[num];
				if ((Object)(object)item == (Object)null || !players.Any(delegate(NetworkObject p)
				{
					ClientInstance component = ((Component)p).GetComponent<ClientInstance>();
					return (Object)(object)component != (Object)null && component.ConnectionID == item.ConnectionID;
				}))
				{
					if ((Object)(object)item != (Object)null)
					{
						Object.Destroy((Object)(object)((Component)item).gameObject);
					}
					items.RemoveAt(num);
				}
			}
		}

		private static void RelayoutItems(List<PlayerListItem> items, Transform[] positions, int pc)
		{
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			List<PlayerListItem> list = (from i in items
				where (Object)(object)i != (Object)null
				orderby i.PlayerIdNumber
				select i).ToList();
			for (int j = 0; j < list.Count; j++)
			{
				ApplyItemLayout(list[j], pc);
				((Component)list[j]).transform.position = GetUIPosition(positions, j, pc);
			}
		}

		public static void FullRelayout(LobbyController lc)
		{
			int num = PlayerCount();
			if (num > 4)
			{
				_customLayoutActive = true;
				List<PlayerListItem> list = (((Object)(object)lc.PlayerListViewContent != (Object)null) ? lc.PlayerListViewContent.GetComponentsInChildren<PlayerListItem>(true).ToList() : null);
				Transform value = Traverse.Create((object)lc).Field("tabScreen").GetValue<Transform>();
				List<PlayerListItem> list2 = (((Object)(object)value != (Object)null) ? ((Component)value).GetComponentsInChildren<PlayerListItem>(true).ToList() : null);
				_laidOut.Clear();
				if (list != null)
				{
					RelayoutItems(list, lc.clientPosition, num);
				}
				if (list2 != null)
				{
					RelayoutItems(list2, lc.tabclientPosition, num);
				}
				EnsurePreviewsExpanded(lc);
				RepositionPreviews(lc, num);
				HidePedestals();
			}
		}

		public static void RevertToVanilla(LobbyController lc)
		{
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_0294: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
			List<PlayerListItem> list = (((Object)(object)lc.PlayerListViewContent != (Object)null) ? lc.PlayerListViewContent.GetComponentsInChildren<PlayerListItem>(true).ToList() : null);
			Transform value = Traverse.Create((object)lc).Field("tabScreen").GetValue<Transform>();
			List<PlayerListItem> list2 = (((Object)(object)value != (Object)null) ? ((Component)value).GetComponentsInChildren<PlayerListItem>(true).ToList() : null);
			if (list != null)
			{
				foreach (PlayerListItem item in list)
				{
					if ((Object)(object)item != (Object)null)
					{
						Object.Destroy((Object)(object)((Component)item).gameObject);
					}
				}
			}
			if (list2 != null)
			{
				foreach (PlayerListItem item2 in list2)
				{
					if ((Object)(object)item2 != (Object)null)
					{
						Object.Destroy((Object)(object)((Component)item2).gameObject);
					}
				}
			}
			_customLayoutActive = false;
			_laidOut.Clear();
			_lastPreviewCount = 0;
			if (_3dCached && lc.previews != null)
			{
				List<int> list3 = new List<int>();
				SteamLobby instance = SteamLobby.Instance;
				if (instance?.players != null)
				{
					foreach (NetworkObject player in instance.players)
					{
						ClientInstance component = ((Component)player).GetComponent<ClientInstance>();
						if ((Object)(object)component != (Object)null)
						{
							list3.Add(component.PlayerId);
						}
					}
				}
				list3.Sort();
				for (int i = 0; i < lc.previews.Length; i++)
				{
					if (!((Object)(object)lc.previews[i] == (Object)null))
					{
						ShortcutExtensions.DOKill((Component)(object)((Component)lc.previews[i]).transform, false);
						if ((Object)(object)lc.previews[i].previewObject != (Object)null)
						{
							lc.previews[i].previewObject.SetActive(false);
						}
					}
				}
				Vector3 val2 = default(Vector3);
				for (int j = 0; j < list3.Count && j < 4; j++)
				{
					int num = list3[j];
					if (num < 0 || num >= lc.previews.Length)
					{
						continue;
					}
					AboubiPreviewLobby val = lc.previews[num];
					if (!((Object)(object)val == (Object)null))
					{
						if (_originalPreviewPositions != null && num < _originalPreviewPositions.Length)
						{
							val2 = _originalPreviewPositions[num];
						}
						else
						{
							float num2 = ((list3.Count <= 1) ? 0.5f : ((float)j / (float)(list3.Count - 1)));
							float num3 = Mathf.Lerp(_3dMinX, _3dMaxX, num2);
							((Vector3)(ref val2))..ctor(num3, _3dBaseY, _3dBaseZ);
						}
						((Component)val).transform.position = val2;
						((Component)val).transform.localScale = Vector3.one;
						Traverse.Create((object)val).Field("initialPosition").SetValue((object)val2);
						if ((Object)(object)val.previewObject != (Object)null)
						{
							val.previewObject.SetActive(true);
						}
					}
				}
			}
			ShowPedestals();
			MethodInfo methodInfo = AccessTools.Method(typeof(LobbyController), "UpdatePlayerList", (Type[])null, (Type[])null);
			if (methodInfo != null)
			{
				methodInfo.Invoke(lc, null);
			}
		}

		public static void Reset()
		{
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			LobbyController instance = LobbyController.Instance;
			if ((Object)(object)instance != (Object)null)
			{
				List<PlayerListItem> list = (((Object)(object)instance.PlayerListViewContent != (Object)null) ? instance.PlayerListViewContent.GetComponentsInChildren<PlayerListItem>(true).ToList() : null);
				Transform value = Traverse.Create((object)instance).Field("tabScreen").GetValue<Transform>();
				List<PlayerListItem> list2 = (((Object)(object)value != (Object)null) ? ((Component)value).GetComponentsInChildren<PlayerListItem>(true).ToList() : null);
				if (list != null)
				{
					foreach (PlayerListItem item in list)
					{
						if ((Object)(object)item != (Object)null)
						{
							Object.Destroy((Object)(object)((Component)item).gameObject);
						}
					}
				}
				if (list2 != null)
				{
					foreach (PlayerListItem item2 in list2)
					{
						if ((Object)(object)item2 != (Object)null)
						{
							Object.Destroy((Object)(object)((Component)item2).gameObject);
						}
					}
				}
				if (_originalPreviews != null && instance.previews != null)
				{
					for (int i = _originalPreviews.Length; i < instance.previews.Length; i++)
					{
						if ((Object)(object)instance.previews[i] != (Object)null)
						{
							Object.Destroy((Object)(object)((Component)instance.previews[i]).gameObject);
						}
					}
					instance.previews = _originalPreviews;
				}
				if (instance.previews != null)
				{
					for (int j = 0; j < instance.previews.Length; j++)
					{
						if (!((Object)(object)instance.previews[j] == (Object)null))
						{
							ShortcutExtensions.DOKill((Component)(object)((Component)instance.previews[j]).transform, false);
							((Component)instance.previews[j]).transform.localScale = Vector3.one;
							if (_originalPreviewPositions != null && j < _originalPreviewPositions.Length)
							{
								Vector3 val = _originalPreviewPositions[j];
								((Component)instance.previews[j]).transform.position = val;
								Traverse.Create((object)instance.previews[j]).Field("initialPosition").SetValue((object)val);
							}
							if ((Object)(object)instance.previews[j].previewObject != (Object)null)
							{
								instance.previews[j].previewObject.SetActive(false);
							}
						}
					}
				}
				ShowPedestals();
			}
			_originalPreviews = null;
			_previewsExpanded = false;
			_pedestalsHidden = false;
			_customLayoutActive = false;
			_lastPreviewCount = 0;
			_laidOut.Clear();
		}
	}
	[HarmonyPatch(typeof(LobbyController), "UpdatePlayerList")]
	internal static class UpdatePlayerListPatch
	{
		private static void Prefix(LobbyController __instance)
		{
			if (GridLayout.PlayerCount() > 4)
			{
				GridLayout.EnsurePreviewsExpanded(__instance);
			}
			else if (GridLayout.IsCustomLayoutActive())
			{
				GridLayout.Reset();
			}
		}

		private static void Postfix(LobbyController __instance)
		{
			if (GridLayout.PlayerCount() > 4)
			{
				GridLayout.FullRelayout(__instance);
			}
		}
	}
	[HarmonyPatch(typeof(LobbyController), "CreateNewObjects")]
	internal static class CreateNewObjectsPatch
	{
		private static void Postfix(LobbyController __instance)
		{
			if (GridLayout.PlayerCount() > 4)
			{
				GridLayout.FullRelayout(__instance);
			}
		}
	}
	[HarmonyPatch(typeof(PlayerListItem), "Update")]
	internal static class PlayerListItemUpdatePatch
	{
		private static bool Prefix(PlayerListItem __instance)
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			Traverse val = Traverse.Create((object)__instance);
			GameObject value = val.Field("cosmeticbutton").GetValue<GameObject>();
			PauseManager value2 = val.Field("pauseManager").GetValue<PauseManager>();
			if ((Object)(object)value != (Object)null && (Object)(object)value2 != (Object)null)
			{
				value.transform.localScale = (value2.inMainMenu ? Vector3.one : Vector3.zero);
			}
			GameManager value3 = val.Field("gameManager").GetValue<GameManager>();
			TMP_Dropdown value4 = val.Field("teamIdDropdown").GetValue<TMP_Dropdown>();
			if ((Object)(object)value3 != (Object)null && (Object)(object)value4 != (Object)null)
			{
				bool value5 = Traverse.Create((object)value3).Field("playingTeams").GetValue<bool>();
				((Component)value4).gameObject.SetActive(value5);
				bool flag = ((Object)((Component)((Component)__instance).transform.parent).gameObject).name == "-- TAB SCREEN --";
				if (InstanceFinder.NetworkManager.IsServer)
				{
					((Selectable)value4).interactable = !flag;
				}
				else if (val.Field("localSteamId").GetValue<ulong>() == __instance.PlayerSteamID)
				{
					((Selectable)value4).interactable = !flag;
				}
			}
			if (GridLayout.PlayerCount() <= 4 && !GridLayout.IsCustomLayoutActive())
			{
				return true;
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(PlayerManager), "SpawnPlayer", new Type[]
	{
		typeof(int),
		typeof(int),
		typeof(Vector3),
		typeof(Quaternion)
	})]
	internal static class SpawnPlayerOffsetPatch
	{
		private static void Prefix(PlayerManager __instance, ref Vector3 position)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			ClientInstance component = ((Component)__instance).GetComponent<ClientInstance>();
			if (!((Object)(object)component == (Object)null))
			{
				float num = (float)component.PlayerId * 36f * ((float)Math.PI / 180f);
				position += new Vector3(Mathf.Cos(num) * 0.5f, 0f, Mathf.Sin(num) * 0.5f);
			}
		}
	}
	[HarmonyPatch(typeof(PlayerListItem), "Start")]
	internal static class ExpandTeamDropdownPatch
	{
		private static void Postfix(PlayerListItem __instance)
		{
			int num = GridLayout.PlayerCount();
			int num2 = Math.Max(num, 4);
			TMP_Dropdown value = Traverse.Create((object)__instance).Field("teamIdDropdown").GetValue<TMP_Dropdown>();
			if ((Object)(object)value != (Object)null)
			{
				value.ClearOptions();
				List<string> list = new List<string>();
				for (int i = 1; i <= num2; i++)
				{
					list.Add(i.ToString());
				}
				value.AddOptions(list);
				int teamId = ScoreManager.Instance.GetTeamId(__instance.PlayerIdNumber);
				if (teamId >= 0 && teamId < list.Count)
				{
					value.value = teamId;
				}
				value.RefreshShownValue();
			}
			if (num > 4)
			{
				GridLayout.ApplyItemLayout(__instance, num);
			}
		}
	}
	[HarmonyPatch(typeof(SteamLobby), "LeaveLobby")]
	internal static class ResetOnLeavePatch
	{
		private static void Prefix()
		{
			GridLayout.Reset();
		}
	}
	[HarmonyPatch(typeof(AboubiPreviewLobby), "Start")]
	internal static class PreviewInitialPositionPatch
	{
		private static void Postfix(AboubiPreviewLobby __instance)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			Traverse.Create((object)__instance).Field("initialPosition").SetValue((object)((Component)__instance).transform.position);
		}
	}
	[HarmonyPatch(typeof(ClientInstance), "RpcLogic___DressAboubiObservers_2497120398")]
	internal static class DressAboubiEnsurePreviewsPatch
	{
		private static void Prefix(int id)
		{
			if ((Object)(object)LobbyController.Instance != (Object)null)
			{
				GridLayout.EnsurePreviewsExpanded(LobbyController.Instance);
			}
		}
	}
	[HarmonyPatch(typeof(ClientInstance), "RpcLogic___RunIntoLobby_3316948804")]
	internal static class RunIntoLobbyEnsurePreviewsPatch
	{
		private static void Prefix(int id)
		{
			if ((Object)(object)LobbyController.Instance != (Object)null)
			{
				GridLayout.EnsurePreviewsExpanded(LobbyController.Instance);
			}
		}
	}
	[HarmonyPatch(typeof(ClientInstance), "RpcLogic___MenuAnimationObservers_1692629761")]
	internal static class MenuAnimationEnsurePreviewsPatch
	{
		private static void Prefix(int id)
		{
			if ((Object)(object)LobbyController.Instance != (Object)null)
			{
				GridLayout.EnsurePreviewsExpanded(LobbyController.Instance);
			}
		}
	}
	[HarmonyPatch(typeof(LobbyController), "Start")]
	internal static class LobbyControllerStartPatch
	{
		private static void Postfix()
		{
			GridLayout.Reset();
			TabScreenScorePatch.Reset();
		}
	}
	[HarmonyPatch(typeof(TabScreen), "Update")]
	internal static class TabScreenScorePatch
	{
		private static bool _vanillaHidden;

		private static HashSet<int> _setupItems = new HashSet<int>();

		private static Dictionary<int, TextMeshProUGUI> _scoreTexts = new Dictionary<int, TextMeshProUGUI>();

		private static void Postfix(TabScreen __instance)
		{
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)PauseManager.Instance == (Object)null || PauseManager.Instance.inMainMenu)
			{
				return;
			}
			if (!_vanillaHidden)
			{
				Traverse obj = Traverse.Create((object)__instance);
				HideVanillaScore(obj.Field("scoreOne").GetValue<TextMeshProUGUI>());
				HideVanillaScore(obj.Field("scoreTwo").GetValue<TextMeshProUGUI>());
				HideVanillaScore(obj.Field("scoreThree").GetValue<TextMeshProUGUI>());
				HideVanillaScore(obj.Field("scoreFour").GetValue<TextMeshProUGUI>());
				TextMeshProUGUI value = obj.Field("scoreOne").GetValue<TextMeshProUGUI>();
				if ((Object)(object)value != (Object)null)
				{
					Transform parent = ((TMP_Text)value).transform.parent;
					for (int i = 0; i < parent.childCount; i++)
					{
						TextMeshProUGUI component = ((Component)parent.GetChild(i)).GetComponent<TextMeshProUGUI>();
						if ((Object)(object)component != (Object)null && ((TMP_Text)component).text.ToLower().Contains("score"))
						{
							((Component)component).gameObject.SetActive(false);
						}
					}
				}
				_vanillaHidden = true;
			}
			LobbyController instance = LobbyController.Instance;
			if ((Object)(object)instance == (Object)null)
			{
				return;
			}
			Transform value2 = Traverse.Create((object)instance).Field("tabScreen").GetValue<Transform>();
			if ((Object)(object)value2 == (Object)null)
			{
				return;
			}
			PlayerListItem[] componentsInChildren = ((Component)value2).GetComponentsInChildren<PlayerListItem>(true);
			if (componentsInChildren == null || componentsInChildren.Length == 0)
			{
				return;
			}
			PlayerListItem[] array = componentsInChildren;
			Vector2 val4 = default(Vector2);
			foreach (PlayerListItem val in array)
			{
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				int instanceID = ((Object)val).GetInstanceID();
				if (!_setupItems.Contains(instanceID))
				{
					_setupItems.Add(instanceID);
					if ((Object)(object)val.PlayerReadyText != (Object)null)
					{
						((Component)val.PlayerReadyText).gameObject.SetActive(false);
					}
					GameObject val2 = new GameObject("PlayerScore");
					val2.transform.SetParent(((Component)val).transform, false);
					TextMeshProUGUI val3 = val2.AddComponent<TextMeshProUGUI>();
					((TMP_Text)val3).fontSize = 30f;
					((TMP_Text)val3).fontStyle = (FontStyles)1;
					((TMP_Text)val3).alignment = (TextAlignmentOptions)514;
					((Graphic)val3).color = new Color(0f, 1f, 1f);
					RectTransform component2 = ((Component)val3).GetComponent<RectTransform>();
					((Vector2)(ref val4))..ctor(0.5f, 0.5f);
					component2.pivot = val4;
					Vector2 anchorMin = (component2.anchorMax = val4);
					component2.anchorMin = anchorMin;
					component2.anchoredPosition = new Vector2(0f, 34f);
					component2.sizeDelta = new Vector2(150f, 40f);
					_scoreTexts[instanceID] = val3;
					int teamId = ScoreManager.Instance.GetTeamId(val.PlayerIdNumber);
					((TMP_Text)val3).text = ScoreManager.Instance.GetPoints(teamId).ToString();
				}
			}
		}

		public static void UpdateScores()
		{
			LobbyController instance = LobbyController.Instance;
			if ((Object)(object)instance == (Object)null)
			{
				return;
			}
			Transform value = Traverse.Create((object)instance).Field("tabScreen").GetValue<Transform>();
			if ((Object)(object)value == (Object)null)
			{
				return;
			}
			PlayerListItem[] componentsInChildren = ((Component)value).GetComponentsInChildren<PlayerListItem>(true);
			if (componentsInChildren == null || componentsInChildren.Length == 0)
			{
				return;
			}
			PlayerListItem[] array = componentsInChildren;
			foreach (PlayerListItem val in array)
			{
				if (!((Object)(object)val == (Object)null))
				{
					int instanceID = ((Object)val).GetInstanceID();
					if (_scoreTexts.TryGetValue(instanceID, out var value2) && (Object)(object)value2 != (Object)null)
					{
						int teamId = ScoreManager.Instance.GetTeamId(val.PlayerIdNumber);
						((TMP_Text)value2).text = ScoreManager.Instance.GetPoints(teamId).ToString();
					}
				}
			}
		}

		private static void HideVanillaScore(TextMeshProUGUI t)
		{
			if ((Object)(object)t != (Object)null)
			{
				((Component)t).gameObject.SetActive(false);
			}
		}

		public static void Reset()
		{
			_vanillaHidden = false;
			_setupItems.Clear();
			_scoreTexts.Clear();
		}
	}
	[HarmonyPatch(typeof(RoundManager), "NextRoundCall")]
	internal static class RoundManagerPatch
	{
		[CompilerGenerated]
		private sealed class <ExtendedInterfaceSetup>d__3 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public RoundManager rm;

			public bool won;

			public int pc;

			public int playerId;

			public int winningTeamId;

			private Traverse <t>5__2;

			private GameObject <container>5__3;

			private GameObject <background>5__4;

			private float <tweenTime>5__5;

			private Transform <imgOne>5__6;

			private Transform <imgTwo>5__7;

			private Object[] <swooshClips>5__8;

			private Dictionary<int, TextMeshProUGUI> <scoreTextMap>5__9;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <ExtendedInterfaceSetup>d__3(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<t>5__2 = null;
				<container>5__3 = null;
				<background>5__4 = null;
				<imgOne>5__6 = null;
				<imgTwo>5__7 = null;
				<swooshClips>5__8 = null;
				<scoreTextMap>5__9 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_08a2: Unknown result type (might be due to invalid IL or missing references)
				//IL_08b7: Unknown result type (might be due to invalid IL or missing references)
				//IL_0723: Unknown result type (might be due to invalid IL or missing references)
				//IL_072d: Expected O, but got Unknown
				//IL_082c: Unknown result type (might be due to invalid IL or missing references)
				//IL_085f: Unknown result type (might be due to invalid IL or missing references)
				//IL_087d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0887: Expected O, but got Unknown
				//IL_0143: Unknown result type (might be due to invalid IL or missing references)
				//IL_07b2: Unknown result type (might be due to invalid IL or missing references)
				//IL_07bc: Expected O, but got Unknown
				//IL_015b: Unknown result type (might be due to invalid IL or missing references)
				//IL_01db: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
				//IL_022a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0213: Unknown result type (might be due to invalid IL or missing references)
				//IL_0263: Unknown result type (might be due to invalid IL or missing references)
				//IL_0282: Unknown result type (might be due to invalid IL or missing references)
				//IL_02a1: 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)
				//IL_0379: Unknown result type (might be due to invalid IL or missing references)
				//IL_03ac: Unknown result type (might be due to invalid IL or missing references)
				//IL_06b6: Unknown result type (might be due to invalid IL or missing references)
				//IL_06c0: Expected O, but got Unknown
				//IL_046e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0475: Expected O, but got Unknown
				//IL_0503: Unknown result type (might be due to invalid IL or missing references)
				//IL_0526: Unknown result type (might be due to invalid IL or missing references)
				//IL_052d: Unknown result type (might be due to invalid IL or missing references)
				//IL_052f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0530: Unknown result type (might be due to invalid IL or missing references)
				//IL_0537: Unknown result type (might be due to invalid IL or missing references)
				//IL_0543: Unknown result type (might be due to invalid IL or missing references)
				//IL_0557: Unknown result type (might be due to invalid IL or missing references)
				//IL_057e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0585: Expected O, but got Unknown
				//IL_061b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0640: Unknown result type (might be due to invalid IL or missing references)
				//IL_0647: Unknown result type (might be due to invalid IL or missing references)
				//IL_0649: Unknown result type (might be due to invalid IL or missing references)
				//IL_064a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0651: Unknown result type (might be due to invalid IL or missing references)
				//IL_0663: Unknown result type (might be due to invalid IL or missing references)
				//IL_0677: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<t>5__2 = Traverse.Create((object)rm);
					PauseManager.Instance.onEndRoundScreen = true;
					<>2__current = null;
					<>1__state = 1;
					return true;
				case 1:
				{
					<>1__state = -1;
					foreach (GameObject extraObject in _extraObjects)
					{
						if ((Object)(object)extraObject != (Object)null)
						{
							Object.Destroy((Object)(object)extraObject);
						}
					}
					_extraObjects.Clear();
					<container>5__3 = <t>5__2.Field("container").GetValue<GameObject>();
					<background>5__4 = <t>5__2.Field("background").GetValue<GameObject>();
					TextMeshProUGUI value = <t>5__2.Field("winText").GetValue<TextMeshProUGUI>();
					GameObject value2 = <t>5__2.Field("selfPlusOne").GetValue<GameObject>();
					GameObject[] value3 = <t>5__2.Field("enemyPlusOne").GetValue<GameObject[]>();
					<tweenTime>5__5 = <t>5__2.Field("tweenTime").GetValue<float>();
					value2.transform.localScale = Vector3.zero;
					for (int i = 0; i < value3.Length; i++)
					{
						value3[i].transform.localScale = Vector3.zero;
					}
					string text = (won ? "winClip" : "loseClip");
					Object value4 = <t>5__2.Field(text).GetValue<Object>();
					if (value4 != (Object)null)
					{
						AccessTools.Method(typeof(SoundManager), "PlaySound", (Type[])null, (Type[])null).Invoke(SoundManager.Instance, new object[1] { value4 });
					}
					<container>5__3.transform.localScale = Vector3.one;
					<background>5__4.transform.localScale = Vector3.one;
					((Graphic)value).color = (won ? <t>5__2.Field("winColor").GetValue<Color>() : <t>5__2.Field("loseColor").GetValue<Color>());
					((TMP_Text)value).text = (won ? "victory" : "defeat");
					<t>5__2.Field("nextRoundImageThree").GetValue<Transform>().localScale = Vector3.zero;
					<t>5__2.Field("nextRoundImageFour").GetValue<Transform>().localScale = Vector3.zero;
					<t>5__2.Field("nextRoundImageFive").GetValue<Transform>().localScale = Vector3.zero;
					<t>5__2.Field("nextRoundImageSix").GetValue<Transform>().localScale = Vector3.zero;
					<imgOne>5__6 = <t>5__2.Field("nextRoundImageOne").GetValue<Transform>();
					<imgTwo>5__7 = <t>5__2.Field("nextRoundImageTwo").GetValue<Transform>();
					<swooshClips>5__8 = <t>5__2.Field("swooshClip").GetValue<Object[]>();
					if (<swooshClips>5__8 != null && <swooshClips>5__8.Length != 0)
					{
						AccessTools.Method(typeof(SoundManager), "PlaySound", (Type[])null, (Type[])null).Invoke(SoundManager.Instance, new object[1] { <swooshClips>5__8[0] });
					}
					TweenSettingsExtensions.SetEase<TweenerCore<Vector3, Vector3, VectorOptions>>(ShortcutExtensions.DOMove(<imgOne>5__6, <t>5__2.Field("nextRoundImageOneActivePos").GetValue<Transform>().position, <tweenTime>5__5, false), (Ease)3);
					TweenSettingsExtensions.SetEase<TweenerCore<Vector3, Vector3, VectorOptions>>(ShortcutExtensions.DOMove(<imgTwo>5__7, <t>5__2.Field("nextRoundImageTwoActivePos").GetValue<Transform>().position, <tweenTime>5__5, false), (Ease)3);
					List<int> list = new List<int>();
					for (int j = 0; j < pc; j++)
					{
						if (ClientInstance.playerInstances.ContainsKey(j))
						{
							list.Add(j);
						}
					}
					int num = (list.Count + 1) / 2;
					<scoreTextMap>5__9 = new Dictionary<int, TextMeshProUGUI>();
					Vector2 val2 = default(Vector2);
					for (int k = 0; k < list.Count; k++)
					{
						int num2 = list[k];
						bool num3 = k >= num;
						int num4 = ((k < num) ? k : (k - num));
						float num5 = ((!num3) ? (-250f) : 250f);
						float num6 = 120f - (float)num4 * 70f;
						GameObject val = new GameObject($"RoundEndName_{num2}");
						val.transform.SetParent(<container>5__3.transform, false);
						TextMeshProUGUI obj = val.AddComponent<TextMeshProUGUI>();
						((TMP_Text)obj).text = ((num2 == playerId) ? rm.names[num2].ToLower() : rm.names[num2]);
						((TMP_Text)obj).fontSize = ((num2 == playerId) ? 34f : 30f);
						((TMP_Text)obj).fontStyle = (FontStyles)((num2 == playerId) ? 1 : 0);
						((TMP_Text)obj).alignment = (TextAlignmentOptions)514;
						((Graphic)obj).color = Color.white;
						RectTransform component = ((Component)obj).GetComponent<RectTransform>();
						((Vector2)(ref val2))..ctor(0.5f, 0.5f);
						component.pivot = val2;
						Vector2 anchorMin = (component.anchorMax = val2);
						component.anchorMin = anchorMin;
						component.anchoredPosition = new Vector2(num5, num6);
						component.sizeDelta = new Vector2(400f, 40f);
						_extraObjects.Add(val);
						GameObject val4 = new GameObject($"RoundEndScore_{num2}");
						val4.transform.SetParent(<container>5__3.transform, false);
						TextMeshProUGUI val5 = val4.AddComponent<TextMeshProUGUI>();
						((TMP_Text)val5).text = ((ScoreManager.Instance.GetTeamId(num2) == winningTeamId) ? Math.Max(0, rm.scores[num2] - 1) : rm.scores[num2]).ToString();
						((TMP_Text)val5).fontSize = 26f;
						((TMP_Text)val5).alignment = (TextAlignmentOptions)514;
						((Graphic)val5).color = new Color(0f, 1f, 1f);
						RectTransform component2 = ((Component)val5).GetComponent<RectTransform>();
						((Vector2)(ref val2))..ctor(0.5f, 0.5f);
						component2.pivot = val2;
						anchorMin = (component2.anchorMax = val2);
						component2.anchorMin = anchorMin;
						component2.anchoredPosition = new Vector2(num5, num6 - 32f);
						component2.sizeDelta = new Vector2(100f, 30f);
						<scoreTextMap>5__9[num2] = val5;
						_extraObjects.Add(val4);
					}
					<>2__current = (object)new WaitForSeconds(0.75f);
					<>1__state = 2;
					return true;
				}
				case 2:
				{
					<>1__state = -1;
					Object value5 = <t>5__2.Field("plusOneClip").GetValue<Object>();
					if (value5 != (Object)null)
					{
						AccessTools.Method(typeof(SoundManager), "PlaySound", (Type[])null, (Type[])null).Invoke(SoundManager.Instance, new object[1] { value5 });
					}
					<>2__current = (object)new WaitForSeconds(1f);
					<>1__state = 3;
					return true;
				}
				case 3:
					<>1__state = -1;
					foreach (KeyValuePair<int, TextMeshProUGUI> item in <scoreTextMap>5__9)
					{
						if (item.Key < rm.scores.Length)
						{
							((TMP_Text)item.Value).text = rm.scores[item.Key].ToString();
						}
					}
					<>2__current = (object)new WaitForSeconds(1.25f);
					<>1__state = 4;
					return true;
				case 4:
					<>1__state = -1;
					if (<swooshClips>5__8 != null && <swooshClips>5__8.Length > 1)
					{
						AccessTools.Method(typeof(SoundManager), "PlaySound", (Type[])null, (Type[])null).Invoke(SoundManager.Instance, new object[1] { <swooshClips>5__8[1] });
					}
					TweenSettingsExtensions.SetEase<TweenerCore<Vector3, Vector3, VectorOptions>>(ShortcutExtensions.DOMove(<imgOne>5__6, <t>5__2.Field("nextRoundImageOneRestPos").GetValue<Transform>().position, <tweenTime>5__5, false), (Ease)3);
					TweenSettingsExtensions.SetEase<TweenerCore<Vector3, Vector3, VectorOptions>>(ShortcutExtensions.DOMove(<imgTwo>5__7, <t>5__2.Field("nextRoundImageTwoRestPos").GetValue<Transform>().position, <tweenTime>5__5, false), (Ease)3);
					<>2__current = (object)new WaitForSeconds(1f);
					<>1__state = 5;
					return true;
				case 5:
					<>1__state = -1;
					<container>5__3.transform.localScale = Vector3.zero;
					<background>5__4.transform.localScale = Vector3.zero;
					foreach (GameObject extraObject2 in _extraObjects)
					{
						if ((Object)(object)extraObject2 != (Object)null)
						{
							Object.Destroy((Object)(object)extraObject2);
						}
					}
					_extraObjects.Clear();
					SceneMotor.Instance.ShowLoadingScreen();
					PauseManager.Instance.onEndRoundScreen = false;
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		private static List<GameObject> _extraObjects = new List<GameObject>();

		private static void Postfix()
		{
			TabScreenScorePatch.UpdateScores();
		}

		private static bool Prefix(RoundManager __instance, int playerId, bool won, int winningTeamId)
		{
			int count = SteamLobby.Instance.players.Count;
			if (count <= 4)
			{
				return true;
			}
			__instance.names = new string[count];
			__instance.scores = new int[count];
			__instance.players = (ClientInstance[])(object)new ClientInstance[count];
			if (won)
			{
				Settings.Instance.IncreaseRoundsWon();
			}
			else
			{
				Settings.Instance.IncreaseRoundsLost();
			}
			for (int i = 0; i < count; i++)
			{
				__instance.players[i] = ((Component)SteamLobby.Instance.players[i]).GetComponent<ClientInstance>();
			}
			for (int j = 0; j < count; j++)
			{
				if (ClientInstance.playerInstances.TryGetValue(j, out var value))
				{
					__instance.names[j] = value.PlayerName;
				}
				else
				{
					__instance.names[j] = "";
				}
			}
			for (int k = 0; k < count; k++)
			{
				__instance.scores[k] = ScoreManager.Instance.GetPoints(ScoreManager.Instance.GetTeamId(k));
			}
			__instance.InterfaceSetupCoroutine = ExtendedInterfaceSetup(__instance, playerId, won, winningTeamId, count);
			((MonoBehaviour)__instance).StartCoroutine(__instance.InterfaceSetupCoroutine);
			return false;
		}

		[IteratorStateMachine(typeof(<ExtendedInterfaceSetup>d__3))]
		private static IEnumerator ExtendedInterfaceSetup(RoundManager rm, int playerId, bool won, int winningTeamId, int pc)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <ExtendedInterfaceSetup>d__3(0)
			{
				rm = rm,
				playerId = playerId,
				won = won,
				winningTeamId = winningTeamId,
				pc = pc
			};
		}
	}
	[HarmonyPatch(typeof(MatchPoitnsHUD), "UpdateVisuals", new Type[]
	{
		typeof(int),
		typeof(Dictionary<int, int>)
	})]
	internal static class MatchPoitnsHUDUpdateVisualsPatch
	{
		private static bool Prefix(MatchPoitnsHUD __instance, int winnerTeamId, Dictionary<int, int> roundScores)
		{
			try
			{
				if (ClientInstance.playerInstances.Count <= 1)
				{
					return false;
				}
				Traverse obj = Traverse.Create((object)__instance);
				MeshRenderer[] value = obj.Field("secondaryPointObjects").GetValue<MeshRenderer[]>();
				TMP_Text[] value2 = obj.Field("pointsTexts").GetValue<TMP_Text[]>();
				MeshRenderer value3 = obj.Field("primaryPointMesh").GetValue<MeshRenderer>();
				Material[] value4 = obj.Field("activeMaterials").GetValue<Material[]>();
				Material value5 = obj.Field("inactiveMaterial").GetValue<Material>();
				if (value == null || value2 == null || (Object)(object)value3 == (Object)null || value4 == null || (Object)(object)value5 == (Object)null)
				{
					return false;
				}
				List<int> list = new List<int>();
				foreach (int key in ScoreManager.Instance.TeamIdToPlayerIds.Keys)
				{
					foreach (int item in ((SyncIDictionary<int, List<int>>)(object)ScoreManager.Instance.TeamIdToPlayerIds)[key])
					{
						if (ClientInstance.playerInstances.ContainsKey(item))
						{
							list.Add(key);
							break;
						}
					}
				}
				int num = Math.Min(Math.Max(0, list.Count - 2), value.Length);
				for (int i = 0; i < value.Length; i++)
				{
					if (!((Object)(object)value[i] == (Object)null))
					{
						((Component)value[i]).gameObject.SetActive(i < num);
					}
				}
				for (int j = 0; j < value2.Length; j++)
				{
					if ((Object)(object)value2[j] != (Object)null)
					{
						value2[j].text = "";
					}
				}
				int val = 2 + value.Length;
				int num2 = Math.Min(list.Count, val);
				Material[] materials = ((Renderer)value3).materials;
				List<int> list2 = ScoreManager.Instance.TeamIdToPlayerIds.Keys.ToList();
				for (int k = 0; k < num2 && k < list2.Count; k++)
				{
					int num3 = list2[k];
					int roundScore = (roundScores.ContainsKey(num3) ? roundScores[num3] : 0);
					UpdateOneSlotSafe(k, num3 == winnerTeamId, roundScore, materials, value, value2, value4, value5);
				}
				((Renderer)value3).materials = materials;
			}
			catch (Exception ex)
			{
				ManualLogSource log = UISpawnAddonPlugin.Log;
				if (log != null)
				{
					log.LogWarning((object)("MatchPoitnsHUD prefix swallowed: " + ex.Message));
				}
			}
			return false;
		}

		private static void UpdateOneSlotSafe(int slot, bool isWinner, int roundScore, Material[] primaryMats, MeshRenderer[] secondaryPointObjects, TMP_Text[] pointsTexts, Material[] activeMaterials, Material inactiveMaterial)
		{
			Material val = ((roundScore > 0 && slot < activeMaterials.Length) ? activeMaterials[slot] : inactiveMaterial);
			if (slot < 2)
			{
				int num = ((slot == 0) ? 1 : 3);
				if (primaryMats != null && num < primaryMats.Length)
				{
					primaryMats[num] = val;
				}
			}
			else
			{
				int num2 = slot - 2;
				if (num2 < secondaryPointObjects.Length && (Object)(object)secondaryPointObjects[num2] != (Object)null)
				{
					Material[] materials = ((Renderer)secondaryPointObjects[num2]).materials;
					if (materials != null && materials.Length > 1)
					{
						materials[1] = val;
						((Renderer)secondaryPointObjects[num2]).materials = materials;
					}
				}
			}
			if (((roundScore == 2 && !isWinner) || roundScore > 2) && slot < pointsTexts.Length && (Object)(object)pointsTexts[slot] != (Object)null)
			{
				pointsTexts[slot].text = roundScore.ToString();
			}
			if (isWinner && primaryMats != null && primaryMats.Length > 2)
			{
				primaryMats[2] = val;
			}
		}
	}
	[HarmonyPatch(typeof(VictoryMenuUI), "Start")]
	internal static class VictoryMenuUIPatch
	{
		private static bool Prefix(VictoryMenuUI __instance)
		{
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_037c: Unknown result type (might be due to invalid IL or missing references)
			//IL_035d: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			int num = 0;
			if (SteamLobby.Instance?.players != null)
			{
				num = SteamLobby.Instance.players.Count;
			}
			if (num <= 4)
			{
				return true;
			}
			Traverse obj = Traverse.Create((object)__instance);
			GameObject value = obj.Field("positionCell").GetValue<GameObject>();
			GameObject value2 = obj.Field("cellParent").GetValue<GameObject>();
			TMP_Text value3 = obj.Field("victoryDefeatText").GetValue<TMP_Text>();
			Color value4 = obj.Field("victoryColor").GetValue<Color>();
			Color value5 = obj.Field("defeatColor").GetValue<Color>();
			List<int> list = new List<int>(ScoreManager.Instance.TeamIdToPlayerIds.Keys);
			list.Sort((int a, int b) => ScoreManager.Instance.GetPoints(b).CompareTo(ScoreManager.Instance.GetPoints(a)));
			int num2 = 0;
			int num3 = -1;
			for (int i = 0; i < list.Count; i++)
			{
				int num4 = list[i];
				int points = ScoreManager.Instance.GetPoints(num4);
				foreach (int item in ScoreManager.Instance.GetPlayerIdsForTeam(num4))
				{
					string text = "";
					ulong num5 = 0uL;
					if (ClientInstance.playerInstances.TryGetValue(item, out var value6))
					{
						text = value6.PlayerName;
						num5 = value6.PlayerSteamID;
					}
					else
					{
						if (SteamLobby.Instance?.players != null)
						{
							foreach (NetworkObject player in SteamLobby.Instance.players)
							{
								ClientInstance component = ((Component)player).GetComponent<ClientInstance>();
								if ((Object)(object)component != (Object)null && component.PlayerId == item)
								{
									text = component.PlayerName;
									num5 = component.PlayerSteamID;
									break;
								}
							}
						}
						if (string.IsNullOrEmpty(text))
						{
							continue;
						}
					}
					GameObject val = Object.Instantiate<GameObject>(value, value2.transform);
					val.SetActive(true);
					int num6 = ((num2 >= (num + 1) / 2) ? 1 : 0);
					int num7 = ((num2 < (num + 1) / 2) ? num2 : (num2 - (num + 1) / 2));
					val.transform.localPosition = new Vector3((float)num6 * 6f - 3f, (float)num7 * -3f, 0f);
					num2++;
					bool active = i == 0;
					((Component)val.transform.GetChild(0)).gameObject.SetActive(active);
					((Component)val.transform.GetChild(1)).GetComponent<TMP_Text>().text = VictoryMenuUI.ToOrdinal(num2);
					((Component)val.transform.GetChild(2)).GetComponent<TMP_Text>().text = text;
					((Component)val.transform.GetChild(3)).GetComponent<TMP_Text>().text = "Won " + points + " rounds!";
					if (num5 != 0L)
					{
						Texture2D steamImage = GetSteamImage(SteamFriends.GetLargeFriendAvatar((CSteamID)num5));
						if ((Object)(object)steamImage != (Object)null)
						{
							((Component)val.transform.GetChild(4).GetChild(0)).GetComponent<RawImage>().texture = (Texture)(object)steamImage;
						}
					}
					if (num3 < 0)
					{
						num3 = num4;
					}
				}
			}
			Settings.Instance.IncreaseGamesPlayed();
			if (ScoreManager.Instance.GetTeamId(LobbyController.Instance.LocalPlayerController.PlayerId) == num3)
			{
				Settings.Instance.IncreaseGamesWon();
				((Graphic)value3).color = value4;
				value3.text = "Victory";
			}
			else
			{
				Settings.Instance.IncreaseGamesLost();
				((Graphic)value3).color = value5;
				value3.text = "Defeat";
			}
			return false;
		}

		private static Texture2D GetSteamImage(int iImage)
		{
			//IL_002e: 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_0041: Expected O, but got Unknown
			uint num = default(uint);
			uint num2 = default(uint);
			if (!SteamUtils.GetImageSize(iImage, ref num, ref num2))
			{
				return null;
			}
			byte[] array = new byte[num * num2 * 4];
			if (!SteamUtils.GetImageRGBA(iImage, array, (int)(num * num2 * 4)))
			{
				return null;
			}
			Texture2D val = new Texture2D((int)num, (int)num2, (TextureFormat)4, false, true);
			val.LoadRawTextureData(array);
			val.Apply();
			return val;
		}
	}
}