Decompiled source of RandomRecipient v0.0.3

plugins\RoundsWithFriends.dll

Decompiled 4 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using ExitGames.Client.Photon;
using HarmonyLib;
using InControl;
using Jotunn.Utils;
using Landfall.Network;
using On;
using Photon.Pun;
using Photon.Pun.UtilityScripts;
using Photon.Realtime;
using RWF.Algorithms;
using RWF.GameModes;
using RWF.Patches;
using RWF.UI;
using Sonigon;
using Sonigon.Internal;
using SoundImplementation;
using Steamworks;
using TMPro;
using UnboundLib;
using UnboundLib.Extensions;
using UnboundLib.GameModes;
using UnboundLib.Networking;
using UnboundLib.Utils;
using UnboundLib.Utils.UI;
using UnityEngine;
using UnityEngine.Audio;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using UnityEngine.UI.ProceduralImage;
using UnityEngine.Video;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyFileVersion("0.0.3")]
[assembly: AssemblyInformationalVersion("0.0.3")]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.3.0")]
[module: UnverifiableCode]
namespace MapEditor.Patches
{
	[HarmonyPatch(typeof(ListMenu), "SelectButton")]
	public class ListMenu_Patch_SelectButton
	{
		private static void Prefix(ListMenuButton buttonToSelect)
		{
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: 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_0058: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)buttonToSelect != (Object)null && ((Object)((Component)buttonToSelect).gameObject).name.Contains("(short)"))
			{
				ListMenu.instance.bar.transform.localScale = new Vector3(((Component)buttonToSelect).GetComponent<RectTransform>().sizeDelta.x, ListMenu.instance.bar.transform.localScale.y);
			}
			else
			{
				ListMenu.instance.bar.transform.localScale = new Vector3(4000f, ListMenu.instance.bar.transform.localScale.y);
			}
		}
	}
}
namespace RWF
{
	internal class WindowGUIBuilder
	{
		private float x;

		private float y;

		private Rect elementRect;

		private float rowHeight;

		private float rowY;

		public WindowGUIBuilder()
		{
			x = 0f;
			y = GUI.skin.window.border.top;
		}

		public void NextRow(float height, float verticalPadding = 0f)
		{
			NextRow(height, verticalPadding, verticalPadding);
		}

		public void NextRow(float height, float verticalPaddingTop, float verticalPaddingBottom)
		{
			x = 0f;
			y += verticalPaddingTop;
			rowY = y;
			rowHeight = height - verticalPaddingTop - verticalPaddingBottom;
			y += rowHeight - verticalPaddingTop;
		}

		public WindowGUIBuilder NextElement(float width, float horizontalPadding = 0f)
		{
			return NextElement(width, horizontalPadding, horizontalPadding);
		}

		public WindowGUIBuilder NextElement(float width, float horizontalPaddingLeft, float horizontalPaddingRight)
		{
			//IL_0026: 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)
			x += horizontalPaddingLeft;
			elementRect = new Rect(x, rowY, width - horizontalPaddingLeft - horizontalPaddingRight, rowHeight);
			x += width - horizontalPaddingLeft;
			return this;
		}

		public void Label(string text, TextAnchor alignment = 3)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			GUI.skin.label.alignment = alignment;
			GUI.Label(new Rect(((Rect)(ref elementRect)).x, rowY, ((Rect)(ref elementRect)).width, ((Rect)(ref elementRect)).height), text);
		}

		public float HorizontalSlider(float value, float min, float max)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.BeginArea(elementRect);
			GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
			GUILayout.FlexibleSpace();
			float result = GUILayout.HorizontalSlider(value, min, max, Array.Empty<GUILayoutOption>());
			GUILayout.FlexibleSpace();
			GUILayout.EndVertical();
			GUILayout.EndArea();
			return result;
		}

		public bool Button(string text)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return GUI.Button(elementRect, text);
		}
	}
	public class DebugWindow : MonoBehaviour
	{
		private Rect windowRect = new Rect(10f, 10f, 260f, 160f);

		public void OnGUI()
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected O, but got Unknown
			//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)
			GUI.skin.label.margin = new RectOffset(0, 0, 0, 0);
			GUI.skin.label.padding = new RectOffset(0, 0, 0, 0);
			windowRect = GUI.Window(0, windowRect, new WindowFunction(WindowFunction), "RWF Debug");
		}

		public void WindowFunction(int windowID)
		{
			//IL_0283: Unknown result type (might be due to invalid IL or missing references)
			WindowGUIBuilder windowGUIBuilder = new WindowGUIBuilder();
			windowGUIBuilder.NextRow(35f, 10f, 0f);
			windowGUIBuilder.NextElement(70f, 10f, 0f).Label("points", (TextAnchor)3);
			float num = windowGUIBuilder.NextElement(150f, 10f).HorizontalSlider(RWFMod.instance.debugOptions.points, 1f, 5f);
			windowGUIBuilder.NextElement(40f, 10f, 12f).Label($"{RWFMod.instance.debugOptions.points}", (TextAnchor)5);
			windowGUIBuilder.NextRow(35f, 10f, 0f);
			windowGUIBuilder.NextElement(70f, 10f, 0f).Label("rounds", (TextAnchor)3);
			float num2 = windowGUIBuilder.NextElement(150f, 10f).HorizontalSlider(RWFMod.instance.debugOptions.rounds, 1f, 5f);
			windowGUIBuilder.NextElement(40f, 10f, 12f).Label($"{RWFMod.instance.debugOptions.rounds}", (TextAnchor)5);
			windowGUIBuilder.NextRow(60f, 20f, 10f);
			bool flag = windowGUIBuilder.NextElement(260f, 10f).Button("Lag Tester");
			windowGUIBuilder.NextRow(60f, 20f, 10f);
			if (windowGUIBuilder.NextElement(260f, 10f).Button("Show Spawn Mesh"))
			{
				RWFMod.instance.debugOptions.showSpawns = !RWFMod.instance.debugOptions.showSpawns;
			}
			if (flag)
			{
				PhotonLagSimulationGui component = ((Component)RWFMod.instance).gameObject.GetComponent<PhotonLagSimulationGui>();
				((Behaviour)component).enabled = !((Behaviour)component).enabled;
			}
			if (PhotonNetwork.OfflineMode || PhotonNetwork.IsMasterClient || PhotonNetwork.CurrentRoom == null)
			{
				if (Mathf.RoundToInt(num) != RWFMod.instance.debugOptions.points)
				{
					RWFMod.instance.debugOptions.points = Mathf.RoundToInt(num);
					RWFMod.instance.SyncDebugOptions();
				}
				if (Mathf.RoundToInt(num2) != RWFMod.instance.debugOptions.rounds)
				{
					RWFMod.instance.debugOptions.rounds = Mathf.RoundToInt(num2);
					RWFMod.instance.SyncDebugOptions();
				}
			}
			GUI.DragWindow(new Rect(0f, 0f, ((Rect)(ref windowRect)).width, ((Rect)(ref windowRect)).height));
		}
	}
	internal static class CameraExtensions
	{
		private static float correction => (float)(Screen.width - FixedScreen.fixedWidth) / 2f;

		internal static Vector3 FixedWorldToScreenPoint(this Camera camera, Vector3 worldPoint)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: 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)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = camera.WorldToScreenPoint(worldPoint);
			if (!FixedScreen.isUltraWide)
			{
				return camera.WorldToScreenPoint(worldPoint);
			}
			return new Vector3(val.x - correction, val.y, val.z);
		}

		internal static Vector3 FixedScreenToWorldPoint(this Camera camera, Vector3 fixedScreenPoint)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			if (!FixedScreen.isUltraWide)
			{
				return camera.ScreenToWorldPoint(fixedScreenPoint);
			}
			return new Vector3(fixedScreenPoint.x + correction, fixedScreenPoint.y, fixedScreenPoint.z);
		}
	}
	internal static class FixedScreen
	{
		private const float ratio = 1.7777778f;

		private const float eps = 0.1f;

		internal static bool isUltraWide => (float)Screen.width / (float)Screen.height - 1.7777778f >= 0.1f;

		internal static int fixedWidth
		{
			get
			{
				if (!isUltraWide)
				{
					return Screen.width;
				}
				return Mathf.RoundToInt((float)Screen.height * 1.7777778f);
			}
		}
	}
	public static class CardBarHandlerExtensions
	{
		public static void Rebuild(this CardBarHandler instance)
		{
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			while (((Component)instance).transform.childCount > 3)
			{
				Object.DestroyImmediate((Object)(object)((Component)((Component)instance).transform.GetChild(3)).gameObject);
			}
			int count = PlayerManager.instance.players.Count;
			GameObject gameObject = ((Component)((Component)instance).transform.GetChild(0)).gameObject;
			int num = -50;
			List<CardBar> list = new List<CardBar>();
			int i;
			for (i = 0; i < count; i++)
			{
				GameObject val = Object.Instantiate<GameObject>(gameObject, ((Component)instance).transform);
				val.SetActive(true);
				((Object)val).name = "Bar" + (i + 1);
				val.transform.localScale = Vector3.one;
				val.transform.localPosition = gameObject.transform.localPosition + new Vector3(0f, (float)(num * i), 0f);
				Color backgroundColor = PlayerSkinBank.GetPlayerSkinColors(PlayerExtensions.colorID(PlayerManager.instance.players.Find((Player p) => p.playerID == i))).backgroundColor;
				((Graphic)((Component)val.transform.GetChild(0).GetChild(0)).gameObject.GetComponent<ProceduralImage>()).color = new Color(backgroundColor.r, backgroundColor.g, backgroundColor.b, 0.9f);
				list.Add(val.GetComponent<CardBar>());
			}
			gameObject.SetActive(false);
			((Component)((Component)instance).transform.GetChild(1)).gameObject.SetActive(false);
			ExtensionMethods.SetFieldValue((object)instance, "cardBars", (object)list.ToArray());
		}
	}
	public class CharacterCreatorAdditionalData
	{
		public List<GameObject> objectsToEnable;
	}
	public static class CharacterCreatorExtensions
	{
		private static readonly ConditionalWeakTable<CharacterCreator, CharacterCreatorAdditionalData> additionalData = new ConditionalWeakTable<CharacterCreator, CharacterCreatorAdditionalData>();

		public static CharacterCreatorAdditionalData GetData(this CharacterCreator instance)
		{
			return additionalData.GetOrCreateValue(instance);
		}

		public static void SetObjectsToEnable(this CharacterCreator instance, List<GameObject> objects)
		{
			instance.GetData().objectsToEnable = objects;
		}

		public static List<GameObject> GetObjectsToEnable(this CharacterCreator instance)
		{
			return instance.GetData().objectsToEnable ?? new List<GameObject>();
		}
	}
	public static class CodeInstructionExtensions
	{
		public static bool GetsProperty(this CodeInstruction code, PropertyInfo property)
		{
			if ((object)property == null)
			{
				throw new ArgumentNullException("property");
			}
			return CodeInstructionExtensions.Calls(code, property.GetMethod);
		}

		public static bool SetsProperty(this CodeInstruction code, PropertyInfo property)
		{
			if ((object)property == null)
			{
				throw new ArgumentNullException("property");
			}
			return CodeInstructionExtensions.Calls(code, property.SetMethod);
		}
	}
	public static class Collider2DExtensions
	{
		internal static List<Vector2> GetVertices(this Collider2D collider, float offset = 0f)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: 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_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: 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_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_028d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0290: 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_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_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			if (collider is PolygonCollider2D)
			{
				return ((PolygonCollider2D)collider).points.Select((Vector2 p) => Vector2.op_Implicit(((Component)collider).transform.TransformPoint(Vector2.op_Implicit(p)))).Select(delegate(Vector2 p)
				{
					//IL_0000: Unknown result type (might be due to invalid IL or missing references)
					//IL_0001: Unknown result type (might be due to invalid IL or missing references)
					//IL_0008: Unknown result type (might be due to invalid IL or missing references)
					//IL_000d: Unknown result type (might be due to invalid IL or missing references)
					//IL_0010: Unknown result type (might be due to invalid IL or missing references)
					//IL_0015: Unknown result type (might be due to invalid IL or missing references)
					//IL_001a: Unknown result type (might be due to invalid IL or missing references)
					//IL_001f: Unknown result type (might be due to invalid IL or missing references)
					//IL_0022: 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_0032: Unknown result type (might be due to invalid IL or missing references)
					Bounds bounds2 = collider.bounds;
					Vector2 val2 = p - Vector2.op_Implicit(((Bounds)(ref bounds2)).center);
					return p + ((Vector2)(ref val2)).normalized * offset;
				}).ToList();
			}
			if (collider is BoxCollider2D)
			{
				Vector2 val = ((BoxCollider2D)collider).size * 0.5f;
				return new List<Vector2>
				{
					Vector2.op_Implicit(((Component)collider).transform.TransformPoint(Vector2.op_Implicit(new Vector2(val.x, val.y)))) + new Vector2(offset, offset),
					Vector2.op_Implicit(((Component)collider).transform.TransformPoint(Vector2.op_Implicit(new Vector2(val.x, 0f - val.y)))) + new Vector2(offset, 0f - offset),
					Vector2.op_Implicit(((Component)collider).transform.TransformPoint(Vector2.op_Implicit(new Vector2(0f - val.x, val.y)))) + new Vector2(0f - offset, offset),
					Vector2.op_Implicit(((Component)collider).transform.TransformPoint(Vector2.op_Implicit(new Vector2(0f - val.x, 0f - val.y)))) + new Vector2(0f - offset, 0f - offset)
				};
			}
			List<Vector2> list = new List<Vector2>();
			Bounds bounds = collider.bounds;
			list.Add(Vector2.op_Implicit(((Bounds)(ref bounds)).min) - offset * Vector2.one);
			bounds = collider.bounds;
			list.Add(Vector2.op_Implicit(((Bounds)(ref bounds)).max) + offset * Vector2.one);
			bounds = collider.bounds;
			float num = ((Bounds)(ref bounds)).min.x - offset;
			bounds = collider.bounds;
			list.Add(new Vector2(num, ((Bounds)(ref bounds)).max.y + offset));
			bounds = collider.bounds;
			float num2 = ((Bounds)(ref bounds)).max.x + offset;
			bounds = collider.bounds;
			list.Add(new Vector2(num2, ((Bounds)(ref bounds)).min.y - offset));
			return list;
		}
	}
	public static class ArmsRaceExtensions
	{
		public static void SetPlayersNeededToStart(this GM_ArmsRace instance, int num)
		{
			ExtensionMethods.SetFieldValue((object)instance, "playersNeededToStart", (object)num);
		}

		public static int GetPlayersNeededToStart(this GM_ArmsRace instance)
		{
			return (int)ExtensionMethods.GetFieldValue((object)instance, "playersNeededToStart");
		}
	}
	public static class ObjectExtensions
	{
		private static readonly ConditionalWeakTable<MonoBehaviour, HashSet<Tuple<int, string>>> pendingRequests = new ConditionalWeakTable<MonoBehaviour, HashSet<Tuple<int, string>>>();

		public static Coroutine SyncMethod(this MonoBehaviour instance, string methodName, int[] actors, params object[] data)
		{
			return instance.StartCoroutine(instance.SyncMethodCoroutine(methodName, actors, data));
		}

		public static Coroutine SyncMethod(this MonoBehaviour instance, string methodName, int actor, params object[] data)
		{
			return instance.SyncMethod(methodName, new int[1] { actor }, data);
		}

		private static IEnumerator SyncMethodCoroutine(this MonoBehaviour instance, string methodName, int[] actors, params object[] data)
		{
			if (PhotonNetwork.OfflineMode || PhotonNetwork.CurrentRoom == null)
			{
				NetworkingManager.RPC(((object)instance).GetType(), methodName, data);
				yield break;
			}
			if (actors == null)
			{
				actors = (from p in PhotonNetwork.CurrentRoom.Players.Values.ToList()
					select p.ActorNumber).ToArray();
			}
			int[] array = actors;
			foreach (int item in array)
			{
				instance.GetPendingRequests().Add(new Tuple<int, string>(item, methodName));
			}
			NetworkingManager.RPC(((object)instance).GetType(), methodName, data);
			while ((from r in instance.GetPendingRequests()
				where r.Item2 == methodName
				select r).Any((Tuple<int, string> r) => actors.Contains(r.Item1)))
			{
				yield return null;
			}
		}

		public static HashSet<Tuple<int, string>> GetPendingRequests(this MonoBehaviour instance)
		{
			return pendingRequests.GetOrCreateValue(instance);
		}

		public static void ClearPendingRequests(this MonoBehaviour instance, int actor)
		{
			HashSet<Tuple<int, string>> orCreateValue = pendingRequests.GetOrCreateValue(instance);
			foreach (Tuple<int, string> item in from t in orCreateValue.ToList()
				where t.Item1 == actor
				select t)
			{
				orCreateValue.Remove(new Tuple<int, string>(actor, item.Item2));
			}
		}

		public static void RemovePendingRequest(this MonoBehaviour instance, int actor, string methodName)
		{
			pendingRequests.GetOrCreateValue(instance).Remove(new Tuple<int, string>(actor, methodName));
		}

		public static void ExecuteAfterGameModeInitialized(this MonoBehaviour instance, string handlerID, Action action)
		{
			instance.StartCoroutine(ExecuteAfter());
			IEnumerator ExecuteAfter()
			{
				while (!RWFMod.instance.IsGameModeInitialized(handlerID))
				{
					yield return null;
				}
				action();
			}
		}
	}
	public static class NetworkConnectionHandlerExtensions
	{
		public static void SetSearchingQuickMatch(this NetworkConnectionHandler instance, bool value)
		{
			ExtensionMethods.SetFieldValue((object)instance, "m_SearchingQuickMatch", (object)value);
		}

		public static bool IsSearchingQuickMatch(this NetworkConnectionHandler instance)
		{
			return (bool)ExtensionMethods.GetFieldValue((object)instance, "m_SearchingQuickMatch");
		}

		public static void SetSearchingTwitch(this NetworkConnectionHandler instance, bool value)
		{
			ExtensionMethods.SetFieldValue((object)instance, "m_SearchingTwitch", (object)value);
		}

		public static bool IsSearchingTwitch(this NetworkConnectionHandler instance)
		{
			return (bool)ExtensionMethods.GetFieldValue((object)instance, "m_SearchingTwitch");
		}

		public static void SetForceRegion(this NetworkConnectionHandler instance, bool value)
		{
			ExtensionMethods.SetFieldValue((object)instance, "m_ForceRegion", (object)value);
		}

		public static void HostPrivate(this NetworkConnectionHandler instance)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Expected O, but got Unknown
			instance.SetSearchingQuickMatch(value: false);
			instance.SetSearchingTwitch(value: false);
			TimeHandler.instance.gameStartTime = 1f;
			RoomOptions options = new RoomOptions();
			options.MaxPlayers = (byte)RWFMod.instance.MaxPlayers;
			options.IsOpen = true;
			options.IsVisible = false;
			Action action = delegate
			{
				ExtensionMethods.InvokeMethod((object)instance, "CreateRoom", new object[1] { options });
			};
			((MonoBehaviour)instance).StartCoroutine((IEnumerator)ExtensionMethods.InvokeMethod((object)instance, "DoActionWhenConnected", new object[1] { action }));
		}
	}
	public static class PhotonPlayerExtensions
	{
		private static readonly string charkey = RWFMod.GetCustomPropertyKey("characters");

		public static void SetProperty(this Player instance, string key, object value)
		{
			string customPropertyKey = RWFMod.GetCustomPropertyKey(key);
			Hashtable customProperties = instance.CustomProperties;
			if (!((Dictionary<object, object>)(object)customProperties).ContainsKey((object)customPropertyKey))
			{
				((Dictionary<object, object>)(object)customProperties).Add((object)customPropertyKey, value);
			}
			else
			{
				customProperties[(object)customPropertyKey] = value;
			}
			instance.SetCustomProperties(customProperties, (Hashtable)null, (WebFlags)null);
		}

		public static T GetProperty<T>(this Player instance, string key)
		{
			string customPropertyKey = RWFMod.GetCustomPropertyKey(key);
			Hashtable customProperties = instance.CustomProperties;
			if (!((Dictionary<object, object>)(object)customProperties).ContainsKey((object)customPropertyKey))
			{
				return default(T);
			}
			return (T)customProperties[(object)customPropertyKey];
		}

		public static void SetModded(this Player instance)
		{
			instance.SetProperty("modded", true);
		}

		public static bool IsModded(this Player instance)
		{
			return instance.GetProperty<bool>("modded");
		}

		public static LobbyCharacter[] GetCharacters(this Player instance)
		{
			return instance.GetProperty<LobbyCharacter[]>(charkey);
		}

		public static LobbyCharacter GetCharacter(this Player instance, int localID)
		{
			if (instance.GetCharacters().Length > localID)
			{
				return instance.GetCharacters()[localID];
			}
			return null;
		}

		public static void SetCharacters(this Player instance, LobbyCharacter[] characters)
		{
			instance.SetProperty(charkey, characters);
		}

		public static void SetCharacter(this Player instance, LobbyCharacter character)
		{
			if (!((Dictionary<object, object>)(object)instance.CustomProperties).ContainsKey((object)charkey))
			{
				instance.SetProperty(charkey, new LobbyCharacter[2]);
			}
			LobbyCharacter[] characters = instance.GetCharacters();
			characters[character.localID] = character;
			instance.SetCharacters(characters);
		}
	}
	[Serializable]
	public class PlayerAdditionalData
	{
		public int localID;

		private int uniqueID;

		public LobbyCharacter character;

		public PlayerAdditionalData()
		{
			localID = 0;
			uniqueID = 1;
			character = null;
		}
	}
	public static class PlayerExtensions
	{
		public static readonly ConditionalWeakTable<Player, PlayerAdditionalData> data = new ConditionalWeakTable<Player, PlayerAdditionalData>();

		public static PlayerAdditionalData GetAdditionalData(this Player player)
		{
			return data.GetOrCreateValue(player);
		}

		public static void AddData(this Player player, PlayerAdditionalData value)
		{
			try
			{
				data.Add(player, value);
			}
			catch (Exception)
			{
			}
		}

		public static void AssignCharacter(this Player instance, LobbyCharacter character, int playerID)
		{
			instance.GetAdditionalData().character = character;
			PhotonNetwork.LocalPlayer.SetCharacter(character);
			instance.AssignLocalID(character.localID);
			instance.AssignUniqueID(character.uniqueID);
			PlayerExtensions.AssignColorID(instance, character.colorID);
			instance.AssignTeamID(character.teamID);
			instance.AssignPlayerID(playerID);
			PlayerManager.instance.PlayerJoined(instance);
		}

		public static void AssignUniqueID(this Player instance, int uniqueID)
		{
			ExtensionMethods.SetFieldValue((object)instance.GetAdditionalData(), "uniqueID", (object)uniqueID);
		}

		public static int GetUniqueID(this Player instance)
		{
			int num = (int)ExtensionMethods.GetFieldValue((object)instance.GetAdditionalData(), "uniqueID");
			if (num >= 0)
			{
				return instance.data.view.ControllerActorNr;
			}
			return num;
		}

		public static int GetRandomPlayerUniqueID(this Player instance)
		{
			return RandomPlayerManager.GetInstance().GetPlayer().GetUniqueID();
		}

		public static Player RandomPlayer()
		{
			Random random = new Random();
			return PlayerManager.instance.players[random.Next(PlayerManager.instance.players.Count)];
		}

		public static void AssignLocalID(this Player instance, int localID)
		{
			instance.GetAdditionalData().localID = localID;
		}
	}
	public class RandomPlayerManager
	{
		private List<Player> recipients = new List<Player>();

		private static RandomPlayerManager instance;

		private int[] winningTeamIDs = new int[0];

		public static RandomPlayerManager GetInstance()
		{
			if (instance == null)
			{
				instance = new RandomPlayerManager();
			}
			return instance;
		}

		public void SetLastWinner(int[] ids)
		{
			winningTeamIDs = ids;
		}

		public Player GetPlayer()
		{
			if (recipients.Count > 0)
			{
				Player result = recipients[0];
				recipients.RemoveAt(0);
				return result;
			}
			GeneratePlayerOrder();
			return GetPlayer();
		}

		public void GeneratePlayerOrder()
		{
			recipients.Clear();
			Random random = new Random();
			List<Player> list = new List<Player>();
			foreach (Player player in PlayerManager.instance.players)
			{
				list.Add(player);
			}
			list.RemoveAll((Player p) => Extensions.Contains(winningTeamIDs, p.teamID));
			while (list.Count > 0)
			{
				int index = random.Next(list.Count);
				recipients.Add(list[index]);
				list.RemoveAt(index);
			}
		}
	}
	[Serializable]
	public class PlayerActionsAdditionalData
	{
		public PlayerAction increaseColorID;

		public PlayerAction decreaseColorID;

		public PlayerActionsAdditionalData()
		{
			increaseColorID = null;
			decreaseColorID = null;
		}
	}
	public static class PlayerActionsExtension
	{
		public static readonly ConditionalWeakTable<PlayerActions, PlayerActionsAdditionalData> data = new ConditionalWeakTable<PlayerActions, PlayerActionsAdditionalData>();

		public static PlayerActionsAdditionalData GetAdditionalData(this PlayerActions playerActions)
		{
			return data.GetOrCreateValue(playerActions);
		}

		public static void AddData(this PlayerActions playerActions, PlayerActionsAdditionalData value)
		{
			try
			{
				data.Add(playerActions, value);
			}
			catch (Exception)
			{
			}
		}
	}
	public static class PlayerAssignerExtensions
	{
		public static IEnumerator CreatePlayer(this PlayerAssigner instance, LobbyCharacter character, InputDevice inputDevice)
		{
			if ((bool)ExtensionMethods.GetFieldValue((object)instance, "waitingForRegisterResponse") || instance.players.Count >= instance.maxPlayers)
			{
				yield break;
			}
			if (!PhotonNetwork.OfflineMode && !PhotonNetwork.IsMasterClient)
			{
				((Component)instance).GetComponent<PhotonView>().RPC("RPCM_RequestTeamAndPlayerID", (RpcTarget)2, new object[1] { PhotonNetwork.LocalPlayer.ActorNumber });
				ExtensionMethods.SetFieldValue((object)instance, "waitingForRegisterResponse", (object)true);
			}
			while ((bool)ExtensionMethods.GetFieldValue((object)instance, "waitingForRegisterResponse"))
			{
				yield return null;
			}
			if (!PhotonNetwork.OfflineMode)
			{
				if (PhotonNetwork.IsMasterClient)
				{
					ExtensionMethods.SetFieldValue((object)instance, "playerIDToSet", (object)PlayerManager.instance.players.Count);
					ExtensionMethods.SetFieldValue((object)instance, "teamIDToSet", (object)character.teamID);
				}
			}
			else
			{
				ExtensionMethods.SetFieldValue((object)instance, "playerIDToSet", (object)PlayerManager.instance.players.Count);
				ExtensionMethods.SetFieldValue((object)instance, "teamIDToSet", (object)character.teamID);
			}
			SoundPlayerStatic.Instance.PlayPlayerAdded();
			Vector3 val = Vector3.up * 100f;
			CharacterData component = PhotonNetwork.Instantiate(((Object)instance.playerPrefab).name, val, Quaternion.identity, (byte)0, (object[])null).GetComponent<CharacterData>();
			if (inputDevice != null)
			{
				component.input.inputType = (InputType)0;
				component.playerActions = PlayerActions.CreateWithControllerBindings();
			}
			else
			{
				component.input.inputType = (InputType)1;
				component.playerActions = PlayerActions.CreateWithKeyboardBindings();
			}
			((PlayerActionSet)component.playerActions).Device = inputDevice;
			instance.players.Add(component);
			PlayerManager.RegisterPlayer(component.player);
			yield return SyncMethodStatic.SyncMethod(typeof(PlayerAssignerExtensions), "RPCA_AssignCharacter", null, component.view.ViewID, character, (int)ExtensionMethods.GetFieldValue((object)instance, "playerIDToSet"));
		}

		[UnboundRPC]
		private static void RPCA_AssignCharacter(int viewID, LobbyCharacter character, int playerID)
		{
			((MonoBehaviour)PlayerAssigner.instance).StartCoroutine(AssignCharacterCoroutine(viewID, character, playerID));
		}

		private static IEnumerator AssignCharacterCoroutine(int viewID, LobbyCharacter character, int playerID)
		{
			yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)PhotonView.Find(viewID) != (Object)null && (Object)(object)((Component)PhotonView.Find(viewID)).GetComponent<Player>() != (Object)null));
			((Component)PhotonView.Find(viewID)).GetComponent<Player>().AssignCharacter(character, playerID);
			NetworkingManager.RPC(typeof(PlayerAssignerExtensions), "CreatePlayerResponse", new object[2]
			{
				PhotonNetwork.LocalPlayer.ActorNumber,
				character
			});
		}

		[UnboundRPC]
		public static void CreatePlayerResponse(int respondingPlayer, LobbyCharacter targetedCharacter)
		{
			if (targetedCharacter.IsMine)
			{
				SyncMethodStatic.RemovePendingRequest(typeof(PlayerAssignerExtensions), respondingPlayer, "RPCA_AssignCharacter");
			}
		}
	}
	[Serializable]
	public class PlayerManagerAdditionalData
	{
		public PickOrder pickOrder;

		public PlayerManagerAdditionalData()
		{
			pickOrder = null;
		}
	}
	public static class PlayerManagerExtensions
	{
		public static readonly ConditionalWeakTable<PlayerManager, PlayerManagerAdditionalData> data = new ConditionalWeakTable<PlayerManager, PlayerManagerAdditionalData>();

		public static PlayerManagerAdditionalData GetAdditionalData(this PlayerManager playerManager)
		{
			return data.GetOrCreateValue(playerManager);
		}

		public static void AddData(this PlayerManager playerManager, PlayerManagerAdditionalData value)
		{
			try
			{
				data.Add(playerManager, value);
			}
			catch (Exception)
			{
			}
		}

		public static void SetPlayersKinematic(this PlayerManager playerManager, bool kinematic)
		{
			foreach (Player player in playerManager.players)
			{
				ExtensionMethods.SetFieldValue((object)player.data.playerVel, "isKinematic", (object)kinematic);
			}
		}

		public static void ResetPickOrder(this PlayerManager playerManager)
		{
			playerManager.GetAdditionalData().pickOrder = new PickOrder(playerManager.players);
		}

		public static List<Player> GetPickOrder(this PlayerManager playerManager, int[] winningTeamIDs = null)
		{
			return playerManager.GetAdditionalData().pickOrder.GetPickOrder(winningTeamIDs ?? new int[0]);
		}

		public static Player GetPlayerWithUniqueID(this PlayerManager instance, int uniqueID)
		{
			for (int i = 0; i < instance.players.Count; i++)
			{
				if (instance.players[i].GetUniqueID() == uniqueID)
				{
					return instance.players[i];
				}
			}
			return null;
		}

		public static void AddPlayerJoinedAction(this PlayerManager instance, Action<Player> action)
		{
			ExtensionMethods.SetPropertyValue((object)instance, "PlayerJoinedAction", (object)Delegate.Combine(instance.PlayerJoinedAction, action));
		}

		public static Player GetClosestPlayerInOtherTeam(this PlayerManager instance, Vector3 position, int team, bool needVision = false)
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: 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_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			float num = float.MaxValue;
			List<Player> list = (from p in instance.players
				where p.teamID != team
				where !p.data.dead
				select p).ToList();
			Player result = null;
			for (int i = 0; i < list.Count; i++)
			{
				float num2 = Vector2.Distance(Vector2.op_Implicit(position), Vector2.op_Implicit(((Component)list[i]).transform.position));
				if ((!needVision || instance.CanSeePlayer(Vector2.op_Implicit(position), list[i]).canSee) && num2 < num)
				{
					num = num2;
					result = list[i];
				}
			}
			return result;
		}
	}
	public static class PointVisualizerExtensions
	{
		public class PointVisualizerAdditionalData
		{
			public Dictionary<int, Vector3> teamBallVelocity;

			public Dictionary<int, GameObject> teamBall;
		}

		private static readonly ConditionalWeakTable<PointVisualizer, PointVisualizerAdditionalData> additionalData = new ConditionalWeakTable<PointVisualizer, PointVisualizerAdditionalData>();

		public static PointVisualizerAdditionalData GetData(this PointVisualizer instance)
		{
			return additionalData.GetOrCreateValue(instance);
		}

		public static void ResetBalls(this PointVisualizer instance, int numTeams)
		{
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: 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_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: 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_0262: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			while (((Component)instance).transform.GetChild(1).childCount > 2)
			{
				Object.DestroyImmediate((Object)(object)((Component)((Component)instance).transform.GetChild(1).GetChild(2)).gameObject);
			}
			PointVisualizerAdditionalData data = instance.GetData();
			data.teamBallVelocity = new Dictionary<int, Vector3>();
			data.teamBall = new Dictionary<int, GameObject>();
			for (int i = 0; i < numTeams; i++)
			{
				data.teamBallVelocity.Add(i, Vector3.zero);
			}
			GameObject gameObject = ((Component)((Component)instance).transform.GetChild(1).Find("Orange")).gameObject;
			GameObject gameObject2 = ((Component)((Component)instance).transform.GetChild(1).Find("Blue")).gameObject;
			data.teamBall.Add(0, gameObject);
			data.teamBall.Add(1, gameObject2);
			float num = (float)ExtensionMethods.GetFieldValue((object)instance, "ballBaseSize");
			gameObject.GetComponent<RectTransform>().sizeDelta = Vector2.one * num;
			gameObject2.GetComponent<RectTransform>().sizeDelta = Vector2.one * num;
			int num2 = -150 - 150 * (numTeams - 2);
			gameObject.GetComponent<RectTransform>().anchoredPosition = Vector2.op_Implicit(new Vector3((float)num2, 0f, 0f));
			gameObject2.GetComponent<RectTransform>().anchoredPosition = Vector2.op_Implicit(new Vector3((float)(num2 + 300), 0f, 0f));
			for (int j = 0; j < numTeams; j++)
			{
				GameObject val = null;
				if (j <= 1)
				{
					val = ((j == 0) ? gameObject : gameObject2);
				}
				else if (j > 1)
				{
					val = Object.Instantiate<GameObject>(gameObject, ((Component)instance).transform.GetChild(1));
					val.transform.localScale = Vector3.one;
					val.GetComponent<RectTransform>().anchoredPosition = Vector2.op_Implicit(new Vector3((float)(num2 + 300 * j), 0f, 0f));
				}
				val.transform.Find("Fill").localRotation = Quaternion.Euler(new Vector3(0f, 0f, 180f));
				((Graphic)((Component)val.transform.Find("Fill")).GetComponent<ProceduralImage>()).color = PlayerSkinBank.GetPlayerSkinColors(PlayerExtensions.colorID(PlayerManager.instance.GetPlayersInTeam(j)[0])).color;
				((Graphic)((Component)val.transform.Find("Border")).GetComponent<ProceduralImage>()).color = PlayerSkinBank.GetPlayerSkinColors(PlayerExtensions.colorID(PlayerManager.instance.GetPlayersInTeam(j)[0])).color;
				((Behaviour)((Component)val.transform.Find("Mid")).GetComponent<ProceduralImage>()).enabled = false;
				if (j > 1)
				{
					data.teamBall.Add(j, val);
				}
			}
			ExtensionMethods.GetOrAddComponent<GridLayoutGroup>(((Component)((Component)instance).transform.GetChild(1)).gameObject, false).constraintCount = Mathf.Clamp(numTeams, 1, 8);
		}

		public static IEnumerator DoWinSequence(this PointVisualizer instance, Dictionary<int, int> teamPoints, Dictionary<int, int> teamRounds, int winnerTeamID)
		{
			yield return (object)new WaitForSecondsRealtime(0.35f);
			SoundManager.Instance.Play(instance.soundWinRound, ((Component)instance).transform.GetChild(1));
			int teamCount = teamPoints.Count;
			Vector3 pointPos = (Vector3)ExtensionMethods.InvokeMethod((object)UIHandler.instance.roundCounterSmall, "GetPointPos", new object[1] { winnerTeamID });
			instance.ResetBalls(teamCount);
			instance.bg.SetActive(true);
			((Component)((Component)instance).transform.GetChild(1).Find("Orange")).gameObject.SetActive(true);
			((Component)((Component)instance).transform.GetChild(1).Find("Blue")).gameObject.SetActive(true);
			for (int i = 0; i < teamCount; i++)
			{
				((Component)((Component)instance).transform.GetChild(1).GetChild(i)).gameObject.SetActive(true);
			}
			yield return (object)new WaitForSecondsRealtime(0.2f);
			GamefeelManager.instance.AddUIGameFeelOverTime(10f, 0.1f);
			instance.DoShowPoints(teamPoints, winnerTeamID);
			yield return (object)new WaitForSecondsRealtime(0.35f);
			SoundManager.Instance.Play(instance.sound_UI_Arms_Race_A_Ball_Shrink_Go_To_Left_Corner, ((Component)instance).transform);
			float c4 = 0f;
			float ballSmallSize = (float)ExtensionMethods.GetFieldValue((object)instance, "ballSmallSize");
			float bigBallScale = (float)ExtensionMethods.GetFieldValue((object)instance, "bigBallScale");
			while (c4 < instance.timeToScale)
			{
				RectTransform component = instance.GetData().teamBall[winnerTeamID].GetComponent<RectTransform>();
				component.sizeDelta = Vector2.LerpUnclamped(component.sizeDelta, Vector2.one * ballSmallSize, instance.scaleCurve.Evaluate(c4 / instance.timeToScale));
				c4 += Time.unscaledDeltaTime;
				yield return null;
			}
			yield return (object)new WaitForSecondsRealtime(instance.timeBetween);
			c4 = 0f;
			while (c4 < instance.timeToMove)
			{
				Transform transform = instance.GetData().teamBall[winnerTeamID].transform;
				transform.position = Vector3.LerpUnclamped(transform.position, pointPos, instance.scaleCurve.Evaluate(c4 / instance.timeToMove));
				c4 += Time.unscaledDeltaTime;
				yield return null;
			}
			SoundManager.Instance.Play(instance.sound_UI_Arms_Race_B_Ball_Go_Down_Then_Expand, ((Component)instance).transform);
			instance.GetData().teamBall[winnerTeamID].transform.position = pointPos;
			yield return (object)new WaitForSecondsRealtime(instance.timeBetween);
			c4 = 0f;
			while (c4 < instance.timeToMove)
			{
				for (int j = 0; j < teamCount; j++)
				{
					if (j != winnerTeamID)
					{
						Transform transform2 = instance.GetData().teamBall[j].transform;
						transform2.position = Vector3.LerpUnclamped(transform2.position, ((Component)CardChoiceVisuals.instance).transform.position, instance.scaleCurve.Evaluate(c4 / instance.timeToMove));
					}
				}
				c4 += Time.unscaledDeltaTime;
				yield return null;
			}
			for (int k = 0; k < teamCount; k++)
			{
				if (k != winnerTeamID)
				{
					instance.GetData().teamBall[k].transform.position = ((Component)CardChoiceVisuals.instance).transform.position;
				}
			}
			yield return (object)new WaitForSecondsRealtime(instance.timeBetween);
			c4 = 0f;
			while (c4 < instance.timeToScale)
			{
				for (int l = 0; l < teamCount; l++)
				{
					if (l != winnerTeamID)
					{
						RectTransform component2 = instance.GetData().teamBall[l].GetComponent<RectTransform>();
						component2.sizeDelta = Vector2.LerpUnclamped(component2.sizeDelta, Vector2.one * bigBallScale, instance.scaleCurve.Evaluate(c4 / instance.timeToScale));
					}
				}
				c4 += Time.unscaledDeltaTime;
				yield return null;
			}
			SoundManager.Instance.Play(instance.sound_UI_Arms_Race_C_Ball_Pop_Shake, ((Component)instance).transform);
			GamefeelManager.instance.AddUIGameFeelOverTime(10f, 0.2f);
			UIHandler.instance.roundCounterSmall.UpdateRounds(teamRounds);
			UIHandler.instance.roundCounterSmall.UpdatePoints(teamPoints);
			for (int m = 0; m < teamPoints.Count; m++)
			{
				((Image)((Component)instance.GetData().teamBall[m].transform.Find("Fill")).GetComponent<ProceduralImage>()).fillAmount = 0f;
			}
			ExtensionMethods.InvokeMethod((object)instance, "Close", Array.Empty<object>());
		}

		public static IEnumerator DoSequence(this PointVisualizer instance, Dictionary<int, int> teamPoints, Dictionary<int, int> teamRounds, int winnerTeamID)
		{
			yield return (object)new WaitForSecondsRealtime(0.45f);
			SoundManager.Instance.Play(instance.soundWinRound, ((Component)instance).transform);
			instance.ResetBalls(teamPoints.Count);
			instance.bg.SetActive(true);
			((Component)((Component)instance).transform.GetChild(1).Find("Orange")).gameObject.SetActive(true);
			((Component)((Component)instance).transform.GetChild(1).Find("Blue")).gameObject.SetActive(true);
			for (int i = 0; i < teamPoints.Count; i++)
			{
				((Component)((Component)instance).transform.GetChild(1).GetChild(i)).gameObject.SetActive(true);
			}
			yield return (object)new WaitForSecondsRealtime(0.2f);
			GamefeelManager.instance.AddUIGameFeelOverTime(10f, 0.1f);
			instance.DoShowPoints(teamPoints, winnerTeamID);
			yield return (object)new WaitForSecondsRealtime(1.8f);
			for (int j = 0; j < teamPoints.Count; j++)
			{
				instance.GetData().teamBall[j].GetComponent<CurveAnimation>().PlayOut();
			}
			yield return (object)new WaitForSecondsRealtime(0.25f);
			ExtensionMethods.InvokeMethod((object)instance, "Close", Array.Empty<object>());
		}

		public static void DoShowPoints(this PointVisualizer instance, Dictionary<int, int> teamPoints, int winnerTeamID)
		{
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < teamPoints.Count; i++)
			{
				ProceduralImage component = ((Component)instance.GetData().teamBall[i].transform.Find("Fill")).GetComponent<ProceduralImage>();
				((Image)component).fillMethod = (FillMethod)4;
				if (i == winnerTeamID)
				{
					((Image)component).fillAmount = ((teamPoints[i] == 0) ? 1f : ((float)teamPoints[i] / (float)(int)GameModeManager.CurrentHandler.Settings["pointsToWinRound"]));
				}
				else
				{
					((Image)component).fillAmount = (float)teamPoints[i] / (float)(int)GameModeManager.CurrentHandler.Settings["pointsToWinRound"];
				}
			}
			((Graphic)instance.text).color = PlayerSkinBank.GetPlayerSkinColors(PlayerExtensions.colorID(PlayerManager.instance.GetPlayersInTeam(winnerTeamID)[0])).winText;
			((TMP_Text)instance.text).text = "POINT TO " + (GameModeManager.CurrentHandler.AllowTeams ? "TEAM " : "") + ExtraPlayerSkins.GetTeamColorName(PlayerExtensions.colorID(PlayerManager.instance.GetPlayersInTeam(winnerTeamID)[0])).ToUpper();
		}

		public static IEnumerator DoWinSequence(this PointVisualizer instance, Dictionary<int, int> teamPoints, Dictionary<int, int> teamRounds, int[] winnerTeamIDs)
		{
			yield return (object)new WaitForSecondsRealtime(0.35f);
			SoundManager.Instance.Play(instance.soundWinRound, ((Component)instance).transform.GetChild(1));
			int teamCount = teamPoints.Count;
			instance.ResetBalls(teamCount);
			instance.bg.SetActive(true);
			((Component)((Component)instance).transform.GetChild(1).Find("Orange")).gameObject.SetActive(true);
			((Component)((Component)instance).transform.GetChild(1).Find("Blue")).gameObject.SetActive(true);
			for (int i = 0; i < teamCount; i++)
			{
				((Component)((Component)instance).transform.GetChild(1).GetChild(i)).gameObject.SetActive(true);
			}
			yield return (object)new WaitForSecondsRealtime(0.2f);
			GamefeelManager.instance.AddUIGameFeelOverTime(10f, 0.1f);
			instance.DoShowPoints(teamPoints, winnerTeamIDs);
			yield return (object)new WaitForSecondsRealtime(0.35f);
			SoundManager.Instance.Play(instance.sound_UI_Arms_Race_A_Ball_Shrink_Go_To_Left_Corner, ((Component)instance).transform);
			float c2 = 0f;
			float ballSmallSize = (float)ExtensionMethods.GetFieldValue((object)instance, "ballSmallSize");
			float bigBallScale = (float)ExtensionMethods.GetFieldValue((object)instance, "bigBallScale");
			int[] array;
			while (c2 < instance.timeToScale)
			{
				array = winnerTeamIDs;
				foreach (int key in array)
				{
					RectTransform component = instance.GetData().teamBall[key].GetComponent<RectTransform>();
					component.sizeDelta = Vector2.LerpUnclamped(component.sizeDelta, Vector2.one * ballSmallSize, instance.scaleCurve.Evaluate(c2 / instance.timeToScale));
				}
				c2 += Time.unscaledDeltaTime;
				yield return null;
			}
			yield return (object)new WaitForSecondsRealtime(instance.timeBetween);
			c2 = 0f;
			while (c2 < instance.timeToMove)
			{
				array = winnerTeamIDs;
				foreach (int num in array)
				{
					Transform transform = instance.GetData().teamBall[num].transform;
					transform.position = Vector3.LerpUnclamped(transform.position, (Vector3)ExtensionMethods.InvokeMethod((object)UIHandler.instance.roundCounterSmall, "GetPointPos", new object[1] { num }), instance.scaleCurve.Evaluate(c2 / instance.timeToMove));
				}
				c2 += Time.unscaledDeltaTime;
				yield return null;
			}
			SoundManager.Instance.Play(instance.sound_UI_Arms_Race_B_Ball_Go_Down_Then_Expand, ((Component)instance).transform);
			array = winnerTeamIDs;
			foreach (int num2 in array)
			{
				instance.GetData().teamBall[num2].transform.position = (Vector3)ExtensionMethods.InvokeMethod((object)UIHandler.instance.roundCounterSmall, "GetPointPos", new object[1] { num2 });
			}
			yield return (object)new WaitForSecondsRealtime(instance.timeBetween);
			c2 = 0f;
			while (c2 < instance.timeToMove)
			{
				for (int k = 0; k < teamCount; k++)
				{
					if (!winnerTeamIDs.Contains(k))
					{
						Transform transform2 = instance.GetData().teamBall[k].transform;
						transform2.position = Vector3.LerpUnclamped(transform2.position, ((Component)CardChoiceVisuals.instance).transform.position, instance.scaleCurve.Evaluate(c2 / instance.timeToMove));
					}
				}
				c2 += Time.unscaledDeltaTime;
				yield return null;
			}
			for (int l = 0; l < teamCount; l++)
			{
				if (!winnerTeamIDs.Contains(l))
				{
					instance.GetData().teamBall[l].transform.position = ((Component)CardChoiceVisuals.instance).transform.position;
				}
			}
			yield return (object)new WaitForSecondsRealtime(instance.timeBetween);
			c2 = 0f;
			while (c2 < instance.timeToScale)
			{
				for (int m = 0; m < teamCount; m++)
				{
					if (!winnerTeamIDs.Contains(m))
					{
						RectTransform component2 = instance.GetData().teamBall[m].GetComponent<RectTransform>();
						component2.sizeDelta = Vector2.LerpUnclamped(component2.sizeDelta, Vector2.one * bigBallScale, instance.scaleCurve.Evaluate(c2 / instance.timeToScale));
					}
				}
				c2 += Time.unscaledDeltaTime;
				yield return null;
			}
			SoundManager.Instance.Play(instance.sound_UI_Arms_Race_C_Ball_Pop_Shake, ((Component)instance).transform);
			GamefeelManager.instance.AddUIGameFeelOverTime(10f, 0.2f);
			UIHandler.instance.roundCounterSmall.UpdateRounds(teamRounds);
			UIHandler.instance.roundCounterSmall.UpdatePoints(teamPoints);
			for (int n = 0; n < teamPoints.Count; n++)
			{
				((Image)((Component)instance.GetData().teamBall[n].transform.Find("Fill")).GetComponent<ProceduralImage>()).fillAmount = 0f;
			}
			ExtensionMethods.InvokeMethod((object)instance, "Close", Array.Empty<object>());
		}

		public static IEnumerator DoSequence(this PointVisualizer instance, Dictionary<int, int> teamPoints, Dictionary<int, int> teamRounds, int[] winnerTeamIDs)
		{
			yield return (object)new WaitForSecondsRealtime(0.45f);
			SoundManager.Instance.Play(instance.soundWinRound, ((Component)instance).transform);
			instance.ResetBalls(teamPoints.Count);
			instance.bg.SetActive(true);
			((Component)((Component)instance).transform.GetChild(1).Find("Orange")).gameObject.SetActive(true);
			((Component)((Component)instance).transform.GetChild(1).Find("Blue")).gameObject.SetActive(true);
			for (int i = 0; i < teamPoints.Count; i++)
			{
				((Component)((Component)instance).transform.GetChild(1).GetChild(i)).gameObject.SetActive(true);
			}
			yield return (object)new WaitForSecondsRealtime(0.2f);
			GamefeelManager.instance.AddUIGameFeelOverTime(10f, 0.1f);
			instance.DoShowPoints(teamPoints, winnerTeamIDs);
			yield return (object)new WaitForSecondsRealtime(1.8f);
			for (int j = 0; j < teamPoints.Count; j++)
			{
				instance.GetData().teamBall[j].GetComponent<CurveAnimation>().PlayOut();
			}
			yield return (object)new WaitForSecondsRealtime(0.25f);
			ExtensionMethods.InvokeMethod((object)instance, "Close", Array.Empty<object>());
		}

		public static void DoShowPoints(this PointVisualizer instance, Dictionary<int, int> teamPoints, int[] winnerTeamIDs)
		{
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: 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)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < teamPoints.Count; i++)
			{
				ProceduralImage component = ((Component)instance.GetData().teamBall[i].transform.Find("Fill")).GetComponent<ProceduralImage>();
				((Image)component).fillMethod = (FillMethod)4;
				if (winnerTeamIDs.Contains(i))
				{
					((Image)component).fillAmount = ((teamPoints[i] == 0) ? 1f : ((float)teamPoints[i] / (float)(int)GameModeManager.CurrentHandler.Settings["pointsToWinRound"]));
				}
				else
				{
					((Image)component).fillAmount = (float)teamPoints[i] / (float)(int)GameModeManager.CurrentHandler.Settings["pointsToWinRound"];
				}
			}
			Color color = Color32.op_Implicit(new Color32((byte)230, (byte)230, (byte)230, byte.MaxValue));
			string text = "TIE\nNO POINTS";
			if (winnerTeamIDs.Count() > 0)
			{
				text = "POINT TO" + (GameModeManager.CurrentHandler.AllowTeams ? (" TEAM" + ((winnerTeamIDs.Count() > 1) ? "S" : "")) : "");
				for (int j = 0; j < winnerTeamIDs.Count(); j++)
				{
					if (winnerTeamIDs.Count() > 1 && j == winnerTeamIDs.Count() - 1)
					{
						text += "\n<size=50%><voffset=0.5em>AND</voffset></size>";
					}
					int num = PlayerExtensions.colorID(PlayerManager.instance.GetPlayersInTeam(winnerTeamIDs[j]).First());
					text = text + "\n<color=#" + ColorUtility.ToHtmlStringRGBA(ExtraPlayerSkins.GetPlayerSkinColors(num).color) + ">" + ExtraPlayerSkins.GetTeamColorName(num).ToUpper() + "</color>";
				}
			}
			float fontSize = ((winnerTeamIDs.Count() > 2) ? (100f / (float)(winnerTeamIDs.Count() - 1)) : 100f);
			((Graphic)instance.text).color = color;
			((TMP_Text)instance.text).text = text;
			((TMP_Text)instance.text).fontSize = fontSize;
		}
	}
	public class RoundCounterAdditionalData
	{
		public Dictionary<int, int> teamPoints;

		public Dictionary<int, int> teamRounds;
	}
	public static class RoundCounterExtensions
	{
		private static readonly ConditionalWeakTable<RoundCounter, RoundCounterAdditionalData> additionalData = new ConditionalWeakTable<RoundCounter, RoundCounterAdditionalData>();

		public static RoundCounterAdditionalData GetData(this RoundCounter instance)
		{
			return additionalData.GetOrCreateValue(instance);
		}

		public static void UpdatePoints(this RoundCounter instance, Dictionary<int, int> teamPoints)
		{
			if (teamPoints.ContainsKey(0))
			{
				instance.p1Points = teamPoints[0];
			}
			if (teamPoints.ContainsKey(1))
			{
				instance.p2Points = teamPoints[1];
			}
			instance.GetData().teamPoints = teamPoints.ToDictionary((KeyValuePair<int, int> e) => e.Key, (KeyValuePair<int, int> e) => e.Value);
			ExtensionMethods.InvokeMethod((object)instance, "ReDraw", Array.Empty<object>());
		}

		public static void UpdateRounds(this RoundCounter instance, Dictionary<int, int> teamRounds)
		{
			if (teamRounds.ContainsKey(0))
			{
				instance.p1Rounds = teamRounds[0];
			}
			if (teamRounds.ContainsKey(1))
			{
				instance.p2Rounds = teamRounds[1];
			}
			instance.GetData().teamRounds = teamRounds.ToDictionary((KeyValuePair<int, int> e) => e.Key, (KeyValuePair<int, int> e) => e.Value);
			ExtensionMethods.InvokeMethod((object)instance, "ReDraw", Array.Empty<object>());
		}
	}
	public static class TransformExtension
	{
		public static string GetPath(this Transform current)
		{
			if ((Object)(object)current.parent == (Object)null)
			{
				return "/" + ((Object)current).name;
			}
			return current.parent.GetPath() + "/" + ((Object)current).name;
		}
	}
	public class UIHandlerAdditionalData
	{
		public bool disableTexts;
	}
	public static class UIHandlerExtensions
	{
		private static readonly ConditionalWeakTable<UIHandler, UIHandlerAdditionalData> additionalData = new ConditionalWeakTable<UIHandler, UIHandlerAdditionalData>();

		public static UIHandlerAdditionalData GetData(this UIHandler instance)
		{
			return additionalData.GetOrCreateValue(instance);
		}

		public static void ShowRoundCounterSmall(this UIHandler instance, Dictionary<int, int> teamPoints, Dictionary<int, int> teamRounds)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			((Component)instance.roundCounterSmall).gameObject.SetActive(true);
			instance.roundCounterSmall.UpdateRounds(teamRounds);
			instance.roundCounterSmall.UpdatePoints(teamPoints);
			if ((int)instance.roundCounterAnimSmall.currentState != 0)
			{
				instance.roundCounterAnimSmall.PlayIn();
			}
		}

		public static void DisplayRoundStartText(this UIHandler instance, string text)
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			Transform obj = ((Component)GameObject.Find("/Game/UI").transform.Find("UI_Game").Find("Canvas")).gameObject.transform.Find("RoundStartText");
			GeneralParticleSystem componentInChildren = ((Component)obj).GetComponentInChildren<GeneralParticleSystem>();
			TextMeshProUGUI component = ((Component)obj).GetComponent<TextMeshProUGUI>();
			ScalePulse component2 = ((Component)obj).GetComponent<ScalePulse>();
			componentInChildren.particleSettings.color = Color.white;
			componentInChildren.duration = 60f;
			componentInChildren.loop = true;
			componentInChildren.Play();
			((TMP_Text)component).text = text;
			((MonoBehaviour)instance).StopAllCoroutines();
			((MonoBehaviour)instance).StartCoroutine(component2.StartPulse());
		}

		public static void HideRoundStartText(this UIHandler instance)
		{
			Transform obj = ((Component)GameObject.Find("/Game/UI").transform.Find("UI_Game").Find("Canvas")).gameObject.transform.Find("RoundStartText");
			GeneralParticleSystem componentInChildren = ((Component)obj).GetComponentInChildren<GeneralParticleSystem>();
			((Component)obj).GetComponent<ScalePulse>();
			componentInChildren.loop = false;
		}

		public static void DisableTexts(this UIHandler instance, float duration)
		{
			instance.GetData().disableTexts = true;
			ExtensionMethods.ExecuteAfterSeconds((MonoBehaviour)(object)instance, duration, (Action)delegate
			{
				instance.GetData().disableTexts = false;
			});
		}
	}
	public class LobbyCharacter
	{
		public Player networkPlayer;

		public int colorID;

		public int teamID;

		public int faceID;

		public bool ready;

		public int localID;

		public int uniqueID => -(actorID * RWFMod.instance.MaxCharactersPerClient + localID) - 1;

		public string NickName
		{
			get
			{
				if (localID != 0)
				{
					return networkPlayer.NickName + $" {localID + 1}";
				}
				return networkPlayer.NickName;
			}
		}

		public int actorID => networkPlayer.ActorNumber;

		public bool IsMine => actorID == PhotonNetwork.LocalPlayer.ActorNumber;

		public static LobbyCharacter GetLobbyCharacter(int uniqueID)
		{
			return (from p in PhotonNetwork.CurrentRoom.Players.Values.Select((Player p) => p.GetProperty<LobbyCharacter[]>("players")).SelectMany((LobbyCharacter[] p) => p)
				where p != null && p.uniqueID == uniqueID
				select p).FirstOrDefault();
		}

		public static object Deserialize(byte[] data)
		{
			if (PhotonNetwork.CurrentRoom == null || data == null || data[6] == 1 || !PhotonNetwork.CurrentRoom.Players.ContainsKey(data[0]))
			{
				return null;
			}
			return new LobbyCharacter(PhotonNetwork.CurrentRoom.Players[data[0]], data[1], data[2])
			{
				teamID = data[3],
				ready = (data[5] == 1),
				faceID = data[4]
			};
		}

		public static byte[] Serialize(object lobbyCharacter)
		{
			if (lobbyCharacter != null)
			{
				LobbyCharacter lobbyCharacter2 = (LobbyCharacter)lobbyCharacter;
				return new byte[7]
				{
					(byte)lobbyCharacter2.actorID,
					(byte)lobbyCharacter2.colorID,
					(byte)lobbyCharacter2.localID,
					(byte)lobbyCharacter2.teamID,
					(byte)lobbyCharacter2.faceID,
					lobbyCharacter2.ready ? ((byte)1) : ((byte)0),
					0
				};
			}
			return new byte[7] { 0, 0, 0, 0, 0, 0, 1 };
		}

		public LobbyCharacter(Player networkPlayer, int colorID, int localID)
		{
			this.networkPlayer = networkPlayer;
			this.colorID = colorID;
			this.localID = localID;
			faceID = PlayerPrefs.GetInt("SelectedFace" + localID);
		}

		public void SetReady(bool ready)
		{
			this.ready = ready;
		}
	}
	public static class SyncMethodStatic
	{
		private static readonly ConditionalWeakTable<Type, HashSet<Tuple<int, string>>> pendingRequests = new ConditionalWeakTable<Type, HashSet<Tuple<int, string>>>();

		public static Coroutine SyncMethod(Type staticType, string methodName, int[] actors, params object[] data)
		{
			return ((MonoBehaviour)RWFMod.instance).StartCoroutine(SyncMethodCoroutine(staticType, methodName, actors, data));
		}

		public static Coroutine SyncMethod(Type staticType, string methodName, int actor, params object[] data)
		{
			return SyncMethod(staticType, methodName, new int[1] { actor }, data);
		}

		private static IEnumerator SyncMethodCoroutine(Type staticType, string methodName, int[] actors, params object[] data)
		{
			if (PhotonNetwork.OfflineMode || PhotonNetwork.CurrentRoom == null)
			{
				NetworkingManager.RPC(staticType, methodName, data);
				yield break;
			}
			if (actors == null)
			{
				actors = (from p in PhotonNetwork.CurrentRoom.Players.Values.ToList()
					select p.ActorNumber).ToArray();
			}
			int[] array = actors;
			foreach (int item in array)
			{
				GetPendingRequests(staticType).Add(new Tuple<int, string>(item, methodName));
			}
			NetworkingManager.RPC(staticType, methodName, data);
			while ((from r in GetPendingRequests(staticType)
				where r.Item2 == methodName
				select r).Any((Tuple<int, string> r) => actors.Contains(r.Item1)))
			{
				yield return null;
			}
		}

		public static HashSet<Tuple<int, string>> GetPendingRequests(Type staticType)
		{
			return pendingRequests.GetOrCreateValue(staticType);
		}

		public static void ClearPendingRequests(Type staticType, int actor)
		{
			HashSet<Tuple<int, string>> orCreateValue = pendingRequests.GetOrCreateValue(staticType);
			foreach (Tuple<int, string> item in from t in orCreateValue.ToList()
				where t.Item1 == actor
				select t)
			{
				orCreateValue.Remove(new Tuple<int, string>(actor, item.Item2));
			}
		}

		public static void RemovePendingRequest(Type staticType, int actor, string methodName)
		{
			pendingRequests.GetOrCreateValue(staticType).Remove(new Tuple<int, string>(actor, methodName));
		}
	}
	public static class PrivateRoomPrefabs
	{
		private static GameObject _PrivateRoomCharacterSelectionInstance;

		public static GameObject PrivateRoomCharacterSelectionInstance
		{
			get
			{
				//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
				//IL_0102: Unknown result type (might be due to invalid IL or missing references)
				//IL_011c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0126: Unknown result type (might be due to invalid IL or missing references)
				//IL_014b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0150: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)_PrivateRoomCharacterSelectionInstance != (Object)null)
				{
					return _PrivateRoomCharacterSelectionInstance;
				}
				GameObject val = Object.Instantiate<GameObject>(((Component)GameObject.Find("Game/UI/UI_MainMenu/Canvas/ListSelector/CharacterSelect/Group").transform.GetChild(0)).gameObject);
				Object.DontDestroyOnLoad((Object)(object)val);
				val.SetActive(true);
				((Object)val).name = "PrivateRoomCharacterSelector";
				ExtensionMethods.GetOrAddComponent<RectTransform>(val, false);
				ExtensionMethods.GetOrAddComponent<PhotonView>(val, false);
				ExtensionMethods.GetOrAddComponent<ContentSizeFitter>(val, false).horizontalFit = (FitMode)2;
				Object.Destroy((Object)(object)val.GetComponent<CharacterSelectionInstance>());
				PrivateRoomCharacterSelectionInstance orAddComponent = ExtensionMethods.GetOrAddComponent<PrivateRoomCharacterSelectionInstance>(val, false);
				Object.Destroy((Object)(object)((Component)((Component)orAddComponent).transform.GetChild(2)).gameObject);
				Object.Destroy((Object)(object)((Component)((Component)orAddComponent).transform.GetChild(1)).gameObject);
				GameObject val2 = new GameObject("PlayerName", new Type[1] { typeof(TextMeshProUGUI) });
				val2.transform.SetParent(val.transform);
				val2.transform.localScale = Vector3.one;
				val2.transform.localPosition = new Vector3(0f, 80f, 0f);
				((Graphic)val2.GetComponent<TextMeshProUGUI>()).color = new Color(0.556f, 0.556f, 0.556f, 1f);
				((TMP_Text)val2.GetComponent<TextMeshProUGUI>()).fontSize = 25f;
				((TMP_Text)val2.GetComponent<TextMeshProUGUI>()).alignment = (TextAlignmentOptions)514;
				val.transform.localPosition = Vector2.op_Implicit(Vector2.zero);
				PhotonNetwork.PrefabPool.RegisterPrefab(((Object)val).name, val);
				_PrivateRoomCharacterSelectionInstance = val;
				return _PrivateRoomCharacterSelectionInstance;
			}
			private set
			{
			}
		}
	}
	internal class PrivateRoomHandler : MonoBehaviourPunCallbacks
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static Func<LobbyCharacter, bool> <>9__29_0;

			public static Func<Player, LobbyCharacter[]> <>9__31_0;

			public static Func<LobbyCharacter[], IEnumerable<LobbyCharacter>> <>9__31_1;

			public static Func<LobbyCharacter, bool> <>9__31_2;

			public static Func<KeyValuePair<int, InputDevice>, int> <>9__34_1;

			public static Func<LobbyCharacter, int> <>9__38_0;

			public static Func<LobbyCharacter, int> <>9__38_1;

			public static UnityAction <>9__45_0;

			public static UnityAction <>9__45_1;

			public static Func<LobbyCharacter, int> <>9__46_0;

			public static Func<LobbyCharacter, int> <>9__46_1;

			public static Func<LobbyCharacter, int> <>9__51_0;

			public static Func<LobbyCharacter, bool> <>9__57_1;

			public static Func<LobbyCharacter, int> <>9__57_3;

			public static Func<LobbyCharacter, int> <>9__57_4;

			public static Func<LobbyCharacter, int> <>9__58_0;

			public static Func<LobbyCharacter, bool> <>9__63_0;

			public static Func<LobbyCharacter, float> <>9__67_0;

			public static Func<LobbyCharacter, int> <>9__67_1;

			public static Func<LobbyCharacter, float> <>9__67_2;

			internal bool <get_NumCharactersReady>b__29_0(LobbyCharacter p)
			{
				return p.ready;
			}

			internal LobbyCharacter[] <get_PrivateRoomCharacters>b__31_0(Player p)
			{
				return p.GetProperty<LobbyCharacter[]>("players");
			}

			internal IEnumerable<LobbyCharacter> <get_PrivateRoomCharacters>b__31_1(LobbyCharacter[] p)
			{
				return p;
			}

			internal bool <get_PrivateRoomCharacters>b__31_2(LobbyCharacter p)
			{
				return p != null;
			}

			internal int <FindLobbyCharacter>b__34_1(KeyValuePair<int, InputDevice> kv)
			{
				return kv.Key;
			}

			internal int <get_GameCanStart>b__38_0(LobbyCharacter p)
			{
				return p.colorID;
			}

			internal int <get_GameCanStart>b__38_1(LobbyCharacter p)
			{
				return p.colorID;
			}

			internal void <BuildUI>b__45_0()
			{
			}

			internal void <BuildUI>b__45_1()
			{
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				if (PhotonNetwork.CurrentRoom != null)
				{
					((ClientSteamLobby)typeof(NetworkConnectionHandler).GetField("m_SteamLobby", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null)).ShowInviteScreenWhenConnected();
				}
			}

			internal int <HandleTeamRules>b__46_0(LobbyCharacter p)
			{
				return p.colorID;
			}

			internal int <HandleTeamRules>b__46_1(LobbyCharacter p)
			{
				return p.uniqueID;
			}

			internal int <Update>b__51_0(LobbyCharacter p)
			{
				return p.colorID;
			}

			internal bool <ToggleReady>b__57_1(LobbyCharacter p)
			{
				return p != null;
			}

			internal int <ToggleReady>b__57_3(LobbyCharacter p)
			{
				return p.colorID;
			}

			internal int <ToggleReady>b__57_4(LobbyCharacter p)
			{
				return p.colorID;
			}

			internal int <UnreadyAllPlayers>b__58_0(LobbyCharacter p)
			{
				return p.actorID;
			}

			internal bool <StartGameCountdown>b__63_0(LobbyCharacter p)
			{
				return p.ready;
			}

			internal float <StartGamePreparation>b__67_0(LobbyCharacter _)
			{
				return Random.Range(0f, 1f);
			}

			internal int <StartGamePreparation>b__67_1(LobbyCharacter p)
			{
				return p.teamID;
			}

			internal float <StartGamePreparation>b__67_2(LobbyCharacter _)
			{
				return Random.Range(0f, 1f);
			}
		}

		private const int ReadyStartGameCountdown = 3;

		private const string DefaultHeaderText = "ROUNDS WITH FRIENDS";

		private static readonly Color disabledTextColor = Color32.op_Implicit(new Color32((byte)150, (byte)150, (byte)150, (byte)16));

		private static readonly Color enabledTextColor = Color32.op_Implicit(new Color32((byte)230, (byte)230, (byte)230, byte.MaxValue));

		public static PrivateRoomHandler instance;

		private static string PrevHandlerID;

		private static GameSettings PrevSettings;

		private GameObject grid;

		private GameObject header;

		private GameObject gamemodeHeader;

		private GameObject gameModeButton;

		private TextMeshProUGUI headerText;

		private TextMeshProUGUI gamemodeHeaderText;

		private TextMeshProUGUI inviteText;

		private TextMeshProUGUI gamemodeText;

		private VersusDisplay versusDisplay;

		private bool _lockReadies;

		private Coroutine countdownCoroutine;

		internal Dictionary<int, InputDevice> devicesToUse;

		private bool lockReadies
		{
			get
			{
				return instance._lockReadies;
			}
			set
			{
				if (PhotonNetwork.IsMasterClient)
				{
					NetworkingManager.RPC(typeof(PrivateRoomHandler), "RPCA_LockReadies", new object[1] { value });
				}
				else
				{
					NetworkingManager.RPC(typeof(PrivateRoomHandler), "RPCH_RequestLockReadies", new object[0]);
				}
			}
		}

		public ListMenuPage MainPage { get; private set; }

		public int NumCharacters => PrivateRoomCharacters.Count();

		public int NumCharactersReady => PrivateRoomCharacters.Where((LobbyCharacter p) => p.ready).Count();

		public LobbyCharacter[] PrivateRoomCharacters => (from p in (from p in PhotonNetwork.CurrentRoom.Players.Values.ToList()
				select p.GetProperty<LobbyCharacter[]>("players")).SelectMany((LobbyCharacter[] p) => p)
			where p != null
			select p).ToArray();

		public bool IsOpen
		{
			get
			{
				bool? obj;
				if (this == null)
				{
					obj = null;
				}
				else
				{
					GameObject obj2 = grid;
					obj = ((obj2 != null) ? new bool?(obj2.activeSelf) : null);
				}
				bool? flag = obj;
				return flag.GetValueOrDefault();
			}
		}

		private bool GameCanStart
		{
			get
			{
				if (NumCharacters > 0 && NumCharactersReady == NumCharacters)
				{
					if (!RWFMod.DEBUG)
					{
						object obj = default(object);
						object obj2 = default(object);
						object obj3 = default(object);
						object obj4 = default(object);
						if (PhotonNetwork.CurrentRoom.PlayerCount > 1 && PhotonNetwork.CurrentRoom.PlayerCount <= (GameModeManager.CurrentHandler.Settings.TryGetValue("maxClients", ref obj) ? ((int)obj) : RWFMod.instance.MaxClients) && PrivateRoomCharacters.Select((LobbyCharacter p) => p.colorID).Distinct().Count() > 1 && NumCharactersReady >= (GameModeManager.CurrentHandler.Settings.TryGetValue("playersRequiredToStartGame", ref obj2) ? ((int)obj2) : RWFMod.instance.MinPlayers) && NumCharactersReady <= (GameModeManager.CurrentHandler.Settings.TryGetValue("maxPlayers", ref obj3) ? ((int)obj3) : 32))
						{
							return PrivateRoomCharacters.Select((LobbyCharacter p) => p.colorID).Distinct().Count() <= (GameModeManager.CurrentHandler.Settings.TryGetValue("maxTeams", ref obj4) ? ((int)obj4) : RWFMod.instance.MaxTeams);
						}
						return false;
					}
					return true;
				}
				return false;
			}
		}

		public LobbyCharacter FindLobbyCharacter(int actorID, int localID)
		{
			return PrivateRoomCharacters.Where((LobbyCharacter p) => p.actorID == actorID && p.localID == localID).FirstOrDefault();
		}

		public LobbyCharacter FindLobbyCharacter(int uniqueID)
		{
			return PrivateRoomCharacters.Where((LobbyCharacter p) => p.uniqueID == uniqueID).FirstOrDefault();
		}

		public LobbyCharacter FindLobbyCharacter(InputDevice device)
		{
			if (!devicesToUse.Values.Contains(device))
			{
				return null;
			}
			int localID = (from kv in devicesToUse
				where kv.Value == device
				select kv.Key).FirstOrDefault();
			int actorNumber = PhotonNetwork.LocalPlayer.ActorNumber;
			return FindLobbyCharacter(actorNumber, localID);
		}

		private static void SaveSettings()
		{
			PrevHandlerID = GameModeManager.CurrentHandlerID;
			PrevSettings = GameModeManager.CurrentHandler.Settings;
		}

		public static void RestoreSettings()
		{
			((MonoBehaviour)(object)instance).SyncMethod("SetGameSettings", null, PrevHandlerID, PrevSettings);
			PrevHandlerID = null;
			PrevSettings = null;
		}

		private void Awake()
		{
			instance = this;
			_ = PrivateRoomPrefabs.PrivateRoomCharacterSelectionInstance;
		}

		private void Start()
		{
			Init();
			BuildUI();
		}

		private void OnEnable()
		{
			devicesToUse = new Dictionary<int, InputDevice>();
			lockReadies = false;
			PhotonNetwork.LocalPlayer.SetProperty("players", new LobbyCharacter[RWFMod.instance.MaxCharactersPerClient]);
			((MonoBehaviourPunCallbacks)this).OnEnable();
		}

		private void Init()
		{
			devicesToUse = new Dictionary<int, InputDevice>();
			lockReadies = false;
		}

		private void BuildUI()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Expected O, but got Unknown
			//IL_008a: 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_00a4: Expected O, but got Unknown
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: 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_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Expected O, but got Unknown
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_032a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0348: Unknown result type (might be due to invalid IL or missing references)
			//IL_0366: Unknown result type (might be due to invalid IL or missing references)
			//IL_038d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0394: Expected O, but got Unknown
			//IL_03b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d6: Expected O, but got Unknown
			//IL_03f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_05de: Expected O, but got Unknown
			//IL_05fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_062d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0658: 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_0682: Unknown result type (might be due to invalid IL or missing references)
			//IL_0687: Unknown result type (might be due to invalid IL or missing references)
			//IL_068d: Expected O, but got Unknown
			//IL_070a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0703: Unknown result type (might be due to invalid IL or missing references)
			//IL_072a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0731: Expected O, but got Unknown
			//IL_074f: Unknown result type (might be due to invalid IL or missing references)
			//IL_077b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0822: Unknown result type (might be due to invalid IL or missing references)
			//IL_086c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0876: Expected O, but got Unknown
			//IL_08b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ba: Expected O, but got Unknown
			//IL_07db: Unknown result type (might be due to invalid IL or missing references)
			//IL_07e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_07e6: Expected O, but got Unknown
			RectTransform obj = ((Component)this).gameObject.AddComponent<RectTransform>();
			obj.anchorMin = Vector2.zero;
			obj.anchorMax = Vector2.one;
			GameObject val = new GameObject("Main");
			val.transform.SetParent(((Component)this).transform);
			val.transform.localScale = Vector3.one;
			grid = new GameObject("Group");
			grid.transform.SetParent(val.transform);
			grid.transform.localScale = Vector3.one;
			header = new GameObject("Header");
			header.transform.SetParent(grid.transform);
			header.transform.localScale = Vector3.one;
			GameObject val2 = Object.Instantiate<GameObject>(RoundsResources.FlickeringTextPrefab, header.transform);
			val2.transform.localScale = Vector3.one;
			val2.transform.localPosition = Vector3.zero;
			header.AddComponent<RectTransform>();
			LayoutElement obj2 = header.AddComponent<LayoutElement>();
			headerText = val2.GetComponent<TextMeshProUGUI>();
			((TMP_Text)headerText).text = "ROUNDS WITH FRIENDS";
			((TMP_Text)headerText).fontSize = 80f;
			((TMP_Text)headerText).fontStyle = (FontStyles)1;
			((TMP_Text)headerText).enableWordWrapping = false;
			((TMP_Text)headerText).overflowMode = (TextOverflowModes)0;
			obj2.ignoreLayout = false;
			obj2.minHeight = 92f;
			SetTextParticles(((Component)headerText).gameObject, (float?)5f, (Color?)new Color(0f, 0.22f, 0.5f, 1f), (Color?)new Color(0.5f, 0.5f, 0f, 1f), (Color?)new Color(0f, 0.5094f, 0.23f, 1f));
			gamemodeHeader = new GameObject("GameModeHeader");
			gamemodeHeader.transform.SetParent(grid.transform);
			gamemodeHeader.transform.localScale = Vector3.one;
			GameObject val3 = Object.Instantiate<GameObject>(RoundsResources.FlickeringTextPrefab, gamemodeHeader.transform);
			val3.transform.localScale = Vector3.one;
			val3.transform.localPosition = Vector3.zero;
			gamemodeHeader.AddComponent<RectTransform>();
			LayoutElement obj3 = gamemodeHeader.AddComponent<LayoutElement>();
			gamemodeHeaderText = val3.GetComponent<TextMeshProUGUI>();
			TextMeshProUGUI obj4 = gamemodeHeaderText;
			IGameModeHandler currentHandler = GameModeManager.CurrentHandler;
			((TMP_Text)obj4).text = ((currentHandler == null) ? null : currentHandler.Name?.ToUpper()) ?? "CONNECTING...";
			((TMP_Text)gamemodeHeaderText).fontSize = 60f;
			((TMP_Text)gamemodeHeaderText).fontStyle = (FontStyles)1;
			((TMP_Text)gamemodeHeaderText).enableWordWrapping = false;
			((TMP_Text)gamemodeHeaderText).overflowMode = (TextOverflowModes)0;
			obj3.ignoreLayout = false;
			obj3.minHeight = 92f;
			SetTextParticles(((Component)gamemodeHeaderText).gameObject, (float?)5f, (Color?)new Color(0.5f, 0.087f, 0f, 1f), (Color?)new Color(0.25f, 0.25f, 0f, 1f), (Color?)new Color(0.554f, 0.3694f, 0f, 1f));
			GameObject val4 = new GameObject("Players", new Type[1] { typeof(PlayerDisplay) });
			val4.transform.SetParent(grid.transform);
			val4.transform.localScale = Vector3.one;
			versusDisplay = ExtensionMethods.GetOrAddComponent<VersusDisplay>(val4, false);
			GameObject val5 = new GameObject("Keybinds");
			val5.transform.SetParent(grid.transform);
			val5.transform.localScale = Vector3.one;
			KeybindHints.ControllerBasedHints controllerBasedHints = Object.Instantiate<GameObject>(KeybindHints.KeybindPrefab, val5.transform).AddComponent<KeybindHints.ControllerBasedHints>();
			controllerBasedHints.hints = new string[2] { "[A/D]", "[LEFT STICK]" };
			controllerBasedHints.action = "CHANGE TEAM";
			((Component)controllerBasedHints).gameObject.SetActive(true);
			((Component)controllerBasedHints).gameObject.AddComponent<KeybindHints.DisableIfSet>();
			KeybindHints.ControllerBasedHints controllerBasedHints2 = Object.Instantiate<GameObject>(KeybindHints.KeybindPrefab, val5.transform).AddComponent<KeybindHints.ControllerBasedHints>();
			controllerBasedHints2.hints = new string[2] { "[SPACE]", "[START]" };
			controllerBasedHints2.action = "JOIN/READY";
			((Component)controllerBasedHints2).gameObject.SetActive(true);
			((Component)controllerBasedHints2).gameObject.AddComponent<KeybindHints.DisableIfSet>();
			KeybindHints.ControllerBasedHints controllerBasedHints3 = Object.Instantiate<GameObject>(KeybindHints.KeybindPrefab, val5.transform).AddComponent<KeybindHints.ControllerBasedHints>();
			controllerBasedHints3.hints = new string[2] { "[ESC]", "[B]" };
			controllerBasedHints3.action = "UNREADY/LEAVE";
			((Component)controllerBasedHints3).gameObject.SetActive(true);
			((Component)controllerBasedHints3).gameObject.AddComponent<KeybindHints.DisableIfSet>();
			KeybindHints.ControllerBasedHints controllerBasedHints4 = Object.Instantiate<GameObject>(KeybindHints.KeybindPrefab, val5.transform).AddComponent<KeybindHints.ControllerBasedHints>();
			controllerBasedHints4.hints = new string[2] { "[Q/E]", "[LB/RB]" };
			controllerBasedHints4.action = "CHANGE FACE";
			((Component)controllerBasedHints4).gameObject.SetActive(true);
			((Component)controllerBasedHints4).gameObject.AddComponent<KeybindHints.DisableIfSet>();
			val5.AddComponent<RectTransform>();
			LayoutElement obj5 = val5.AddComponent<LayoutElement>();
			HorizontalLayoutGroup obj6 = val5.AddComponent<HorizontalLayoutGroup>();
			((LayoutGroup)obj6).childAlignment = (TextAnchor)4;
			((HorizontalOrVerticalLayoutGroup)obj6).spacing = 450f;
			obj5.ignoreLayout = false;
			obj5.minHeight = 50f;
			GameObject val6 = new GameObject("Divider1");
			val6.transform.SetParent(grid.transform);
			val6.transform.localScale = Vector3.one;
			GameObject val7 = new GameObject("Invite");
			val7.transform.SetParent(grid.transform);
			val7.transform.localScale = Vector3.one;
			GameObject text = GetText("INVITE");
			text.transform.SetParent(val7.transform);
			text.transform.localScale = Vector3.one;
			inviteText = text.GetComponent<TextMeshProUGUI>();
			((Graphic)inviteText).color = ((PhotonNetwork.CurrentRoom != null) ? enabledTextColor : disabledTextColor);
			GameObject obj7 = grid;
			object obj8 = <>c.<>9__45_0;
			if (obj8 == null)
			{
				UnityAction val8 = delegate
				{
				};
				<>c.<>9__45_0 = val8;
				obj8 = (object)val8;
			}
			gameModeButton = MenuHandler.CreateButton("select game mode", obj7, (UnityAction)obj8, 60, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			LayoutElement component = gameModeButton.GetComponent<LayoutElement>();
			component.minHeight = 92f;
			component.minWidth = 5000f;
			gameModeButton.GetComponent<ListMenuButton>().setBarHeight = 92f;
			gamemodeText = gameModeButton.GetComponentInChildren<TextMeshProUGUI>();
			((Graphic)gamemodeText).color = ((PhotonNetwork.CurrentRoom != null) ? enabledTextColor : disabledTextColor);
			((Behaviour)gameModeButton.GetComponent<Button>()).enabled = false;
			GameObject val9 = new GameObject("Back");
			val9.transform.SetParent(grid.transform);
			val9.transform.localScale = Vector3.one;
			GameObject text2 = GetText("BACK");
			text2.transform.SetParent(val9.transform);
			text2.transform.localScale = Vector3.one;
			val7.AddComponent<RectTransform>();
			val7.AddComponent<CanvasRenderer>();
			val7.AddComponent<LayoutElement>().minHeight = 92f;
			Button obj9 = val7.AddComponent<Button>();
			ListMenuButton val10 = val7.AddComponent<ListMenuButton>();
			val10.setBarHeight = 92f;
			ButtonClickedEvent onClick = obj9.onClick;
			object obj10 = <>c.<>9__45_1;
			if (obj10 == null)
			{
				UnityAction val11 = delegate
				{
					//IL_0024: Unknown result type (might be due to invalid IL or missing references)
					if (PhotonNetwork.CurrentRoom != null)
					{
						((ClientSteamLobby)typeof(NetworkConnectionHandler).GetField("m_SteamLobby", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null)).ShowInviteScreenWhenConnected();
					}
				};
				<>c.<>9__45_1 = val11;
				obj10 = (object)val11;
			}
			((UnityEvent)onClick).AddListener((UnityAction)obj10);
			GameObject val12 = Object.Instantiate<GameObject>(RWFMod.gmUIBundle.LoadAsset<GameObject>("GamemodeMenu"), grid.transform.parent);
			val12.GetComponent<RectTransform>().anchoredPosition = new Vector2(3840f, 0f);
			GamemodeMenuManager menuManager = val12.AddComponent<GamemodeMenuManager>();
			menuManager.lobbyMenuObject = grid;
			menuManager.Init();
			((UnityEvent)gameModeButton.GetComponent<Button>().onClick).AddListener((UnityAction)delegate
			{
				if (PhotonNetwork.IsMasterClient)
				{
					menuManager.Open();
				}
			});
			val6.AddComponent<RectTransform>();
			val9.AddComponent<RectTransform>();
			val9.AddComponent<CanvasRenderer>();
			val9.AddComponent<LayoutElement>().minHeight = 92f;
			((UnityEvent)val9.AddComponent<Button>().onClick).AddListener((UnityAction)delegate
			{
				((Component)this).gameObject.GetComponentInParent<Canvas>().sortingLayerName = "MostFront";
				NetworkConnectionHandler.instance.NetworkRestart();
				KeybindHints.ClearHints();
			});
			val9.AddComponent<ListMenuButton>().setBarHeight = 92f;
			grid.AddComponent<RectTransform>();
			grid.AddComponent<ContentSizeFitter>().verticalFit = (FitMode)1;
			grid.AddComponent<CanvasRenderer>();
			((LayoutGroup)grid.AddComponent<VerticalLayoutGroup>()).childAlignment = (TextAnchor)4;
			val.AddComponent<RectTransform>();
			MainPage = val.AddComponent<ListMenuPage>();
			MainPage.firstSelected = val10;
			MainPage.Close();
		}

		public void HandleTeamRules()
		{
			if (GameModeManager.CurrentHandler.AllowTeams || PrivateRoomCharacters.Select((LobbyCharacter p) => p.colorID).Distinct().Count() == NumCharacters)
			{
				return;
			}
			int num = 1;
			foreach (LobbyCharacter character in PrivateRoomCharacters.OrderBy((LobbyCharacter p) => p.uniqueID))
			{
				int colorID = character.colorID;
				int newColorID = character.colorID;
				while (PrivateRoomCharacters.Where((LobbyCharacter p) => p.uniqueID != character.uniqueID && p.colorID == newColorID).Any())
				{
					newColorID = Math.mod(newColorID + num, RWFMod.MaxColorsHardLimit);
					if (newColorID == colorID)
					{
						break;
					}
				}
				num *= -1;
				if (colorID != newColorID)
				{
					versusDisplay.PlayerSelectorGO(character.uniqueID).GetComponent<PhotonView>().RPC("RPCA_ChangeTeam", (RpcTarget)0, new object[1] { newColorID });
				}
			}
		}

		private void ResetHeaderText()
		{
			((TMP_Text)headerText).text = "ROUNDS WITH FRIENDS";
			((TMP_Text)headerText).fontSize = 80f;
			((TMP_Text)headerText).fontStyle = (FontStyles)1;
			((TMP_Text)headerText).enableWordWrapping = false;
			((TMP_Text)headerText).overflowMode = (TextOverflowModes)0;
		}

		private void SetHeaderText(string text, float fontSize = 80f)
		{
			((TMP_Text)headerText).text = text;
			((TMP_Text)headerText).fontSize = fontSize;
		}

		private void SetTextParticles(GameObject text, float? size = null, Color? color = null, Color? randomAddedColor = null, Color? randomColor = null)
		{
			//IL_0044: 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_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			GeneralParticleSystem val = ((text != null) ? text.GetComponentInChildren<GeneralParticleSystem>() : null);
			if (!((Object)(object)val == (Object)null))
			{
				if (size.HasValue)
				{
					val.particleSettings.size = size.Value;
				}
				if (color.HasValue)
				{
					val.particleSettings.color = color.Value;
				}
				if (randomAddedColor.HasValue)
				{
					val.particleSettings.randomAddedColor = randomAddedColor.Value;
				}
				if (randomColor.HasValue)
				{
					val.particleSettings.randomColor = randomColor.Value;
				}
			}
		}

		public GameObject GetText(string str)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: 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_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Expected O, but got Unknown
			GameObject val = new GameObject("Text");
			val.AddComponent<CanvasRenderer>();
			TextMeshProUGUI obj = val.AddComponent<TextMeshProUGUI>();
			((TMP_Text)obj).text = str;
			((Graphic)obj).color = Color32.op_Implicit(new Color32((byte)230, (byte)230, (byte)230, byte.MaxValue));
			((TMP_Text)obj).font = RoundsResources.MenuFont;
			((TMP_Text)obj).fontSize = 60f;
			((TMP_Text)obj).fontWeight = (FontWeight)400;
			((TMP_Text)obj).alignment = (TextAlignmentOptions)514;
			((TMP_Text)obj).rectTransform.sizeDelta = new Vector2(2050f, 92f);
			return val;
		}

		private void Update()
		{
			if (IsOpen && PhotonNetwork.IsMasterClient && !lockReadies)
			{
				try
				{
					HandleTeamRules();
				}
				catch
				{
				}
				if (countdownCoroutine == null && GameCanStart)
				{
					countdownCoroutine = ((MonoBehaviour)this).StartCoroutine(StartGameCountdown());
				}
				else if (countdownCoroutine != null && (NumCharactersReady != NumCharacters || PhotonNetwork.CurrentRoom.PlayerCount <= 1 || PrivateRoomCharacters.Select((LobbyCharacter p) => p.colorID).Distinct().Count() <= 1))
				{
					((MonoBehaviour)this).StopCoroutine(countdownCoroutine);
					countdownCoroutine = null;
					NetworkingManager.RPC(typeof(PrivateRoomHandler), "RPCA_DisplayCountdown", new object[1] { "ROUNDS WITH FRIENDS" });
				}
			}
		}

		public override void OnJoinedRoom()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			if (!IsOpen)
			{
				return;
			}
			((Graphic)inviteText).color = enabledTextColor;
			((Graphic)gamemodeText).color = enabledTextColor;
			if (PhotonNetwork.IsMasterClient)
			{
				gameModeButton.gameObject.SetActive(true);
				((Behaviour)gameModeButton.GetComponent<Button>()).enabled = true;
			}
			else
			{
				gameModeButton.gameObject.SetActive(false);
				((Behaviour)gameModeButton.GetComponent<Button>()).enabled = false;
			}
			((Component)this).gameObject.GetComponentInParent<Canvas>().sortingLayerName = "UI";
			PhotonNetwork.LocalPlayer.SetProperty("players", new LobbyCharacter[RWFMod.instance.MaxCharactersPerClient]);
			if (RWFMod.DEBUG && PhotonNetwork.IsMasterClient)
			{
				RWFMod.Log("\n\n\tRoom join command:\n\tjoin:" + PhotonNetwork.CloudRegion + ":" + PhotonNetwork.CurrentRoom.Name + "\n");
			}
			if (PhotonNetwork.IsMasterClient)
			{
				if (GameModeManager.CurrentHandler == null)
				{
					GameModeManager.SetGameMode("Team Deathmatch");
				}
				TextMeshProUGUI obj = instance.gamemodeHeaderText;
				IGameModeHandler currentHandler = GameModeManager.CurrentHandler;
				((TMP_Text)obj).text = ((currentHandler == null) ? null : currentHandler.Name?.ToUpper()) ?? "";
			}
			if (RWFMod.IsSteamConnected)
			{
				PhotonNetwork.LocalPlayer.NickName = SteamFriends.GetPersonaName();
			}
			else
			{
				PhotonNetwork.LocalPlayer.NickName = $"Player {PhotonNetwork.LocalPlayer.ActorNumber}";
			}
			PlayerDisplay.instance.disableCountdown = 2f;
			((MonoBehaviourPunCallbacks)this).OnJoinedRoom();
		}

		public override void OnMasterClientSwitched(Player newMaster)
		{
			NetworkConnectionHandler.instance.NetworkRestart();
			((MonoBehaviourPunCallbacks)this).OnMasterClientSwitched(newMaster);
		}

		public override void OnPlayerEnteredRoom(Player newPlayer)
		{
			if (PhotonNetwork.IsMasterClient)
			{
				NetworkingManager.RPC_Others(typeof(PrivateRoomHandler), "SetGameSettings", new object[2]
				{
					GameModeManager.CurrentHandlerID,
					GameModeManager.CurrentHandler.Settings
				});
				if (RWFMod.DEBUG && ((Behaviour)((Component)RWFMod.instance).gameObject.GetComponent<DebugWindow>()).enabled)
				{
					RWFMod.instance.SyncDebugOptions();
				}
				lockReadies = false;
			}
			((MonoBehaviourPunCallbacks)this).OnPlayerEnteredRoom(newPlayer);
		}

		public override void OnPlayerLeftRoom(Player otherPlayer)
		{
			((MonoBehaviour)(object)this).ClearPendingRequests(otherPlayer.ActorNumber);
			((MonoBehaviourPunCallbacks)this).OnPlayerLeftRoom(otherPlayer);
		}

		internal IEnumerator RemovePlayer(LobbyCharacter character)
		{
			LobbyCharacter[] property = PhotonNetwork.LocalPlayer.GetProperty<LobbyCharacter[]>("players");
			property[character.localID] = null;
			PhotonNetwork.LocalPlayer.SetProperty("players", property);
			devicesToUse.Remove(character.localID);
			SoundPlayerStatic.Instance.PlayPlayerBallDisappear();
			yield break;
		}

		internal IEnumerator ToggleReady(InputDevice deviceReadied, bool doNotReady = false)
		{
			if (DevConsole.isTyping)
			{
				yield break;
			}
			while (PhotonNetwork.CurrentRoom == null)
			{
				yield return null;
			}
			if (lockReadies)
			{
				yield break;
			}
			LobbyCharacter[] localCharacters = PhotonNetwork.LocalPlayer.GetProperty<LobbyCharacter[]>("players");
			if (localCharacters == null)
			{
				yield break;
			}
			bool flag = !devicesToUse.Where((KeyValuePair<int, InputDevice> kv) => kv.Value == deviceReadied).Any();
			if (flag && localCharacters.Where((LobbyCharacter p) => p != null).Count() >= RWFMod.instance.MaxCharactersPerClient)
			{
				yield break;
			}
			if (flag)
			{
				int num = (from i in Enumerable.Range(0, RWFMod.instance.MaxCharactersPerClient)
					where localCharacters[i] == null
					select i).First();
				int colorID = PlayerPrefs.GetInt(RWFMod.GetCustomPropertyKey("PreferredColor" + num));
				if (!GameModeManager.CurrentHandler.AllowTeams && PrivateRoomCharacters.Select((LobbyCharacter p) => p.colorID).Distinct().Contains(colorID))
				{
					colorID = (from c in Enumerable.Range(0, RWFMod.MaxColorsHardLimit).Except(Priv