Decompiled source of RoundWithBots v3.2.1

plugins/RoundsWithBots.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using CardChoiceSpawnUniqueCardPatch.CustomCategories;
using ClassesManagerReborn;
using HarmonyLib;
using InControl;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using ModdingUtils.AIMinion;
using ModdingUtils.AIMinion.Extensions;
using ModdingUtils.GameModes;
using ModdingUtils.Utils;
using Photon.Pun;
using PickPhaseImprovements;
using RWF;
using RWF.UI;
using RarityLib.Utils;
using RoundsWithBots.CardPickerAIs;
using RoundsWithBots.CardPickerAIs.Weighted;
using RoundsWithBots.CardPickerAIs.Weighted.WeightedCardProcessesor;
using RoundsWithBots.Extensions;
using RoundsWithBots.Menu;
using RoundsWithBots.Mods.Interfaces;
using RoundsWithBots.Patches;
using RoundsWithBots.UI;
using RoundsWithBots.Utils;
using TMPro;
using UnboundLib;
using UnboundLib.Extensions;
using UnboundLib.GameModes;
using UnboundLib.Networking;
using UnboundLib.Utils;
using UnboundLib.Utils.UI;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.1", FrameworkDisplayName = ".NET Framework 4.7.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace RoundsWithBots
{
	public class BotAIManager : MonoBehaviour, IGameStartHookHandler, IPointStartHookHandler, IRoundEndHookHandler
	{
		internal static class StalemateHandler
		{
			[CompilerGenerated]
			private sealed class <HandleStalemate>d__2 : IEnumerator<object>, IEnumerator, IDisposable
			{
				private int <>1__state;

				private object <>2__current;

				private Player[] <aliveBots>5__1;

				private Player <targetBot>5__2;

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

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

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

				[DebuggerHidden]
				void IDisposable.Dispose()
				{
					<aliveBots>5__1 = null;
					<targetBot>5__2 = null;
					<>1__state = -2;
				}

				private bool MoveNext()
				{
					//IL_007d: Unknown result type (might be due to invalid IL or missing references)
					//IL_0087: Expected O, but got Unknown
					//IL_00af: Unknown result type (might be due to invalid IL or missing references)
					//IL_00b9: Expected O, but got Unknown
					//IL_00da: Unknown result type (might be due to invalid IL or missing references)
					//IL_00e4: Expected O, but got Unknown
					//IL_005a: Unknown result type (might be due to invalid IL or missing references)
					//IL_0064: Expected O, but got Unknown
					switch (<>1__state)
					{
					default:
						return false;
					case 0:
						<>1__state = -1;
						if (PhotonNetwork.IsMasterClient || PhotonNetwork.OfflineMode)
						{
							<>2__current = (object)new WaitForSeconds(2f);
							<>1__state = 1;
							return true;
						}
						break;
					case 1:
						<>1__state = -1;
						goto IL_0098;
					case 2:
						<>1__state = -1;
						goto IL_0098;
					case 3:
						<>1__state = -1;
						goto IL_01dd;
					case 4:
						{
							<>1__state = -1;
							<aliveBots>5__1 = PlayerManager.instance.players.Where((Player player) => PlayerStatus.PlayerAliveAndSimulated(player)).ToArray();
							if (<aliveBots>5__1.Length == 0)
							{
								return false;
							}
							<targetBot>5__2 = <aliveBots>5__1[Random.Range(0, <aliveBots>5__1.Length)];
							NetworkingManager.RPC(typeof(StalemateHandler), "RPCA_SendTakeDamageOverTime", new object[4]
							{
								<targetBot>5__2.data.view.ControllerActorNr,
								<targetBot>5__2.playerID,
								<targetBot>5__2.data.maxHealth,
								RWBMenu.StalemateDamageDuration.Value
							});
							<aliveBots>5__1 = null;
							<targetBot>5__2 = null;
							goto IL_01dd;
						}
						IL_0098:
						if (!IsStalemate)
						{
							<>2__current = (object)new WaitForSeconds(0.5f);
							<>1__state = 2;
							return true;
						}
						<>2__current = (object)new WaitForSeconds(RWBMenu.StalemateTimer.Value);
						<>1__state = 3;
						return true;
						IL_01dd:
						if (IsStalemate)
						{
							<>2__current = (object)new WaitForSeconds(RWBMenu.StalemateDamageCooldown.Value);
							<>1__state = 4;
							return true;
						}
						break;
					}
					return false;
				}

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

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

			public static bool IsStalemate
			{
				get
				{
					bool flag = PlayerManager.instance.players.Any((Player player) => !player.data.GetAdditionalData().IsBot && !CharacterDataExtension.GetAdditionalData(player.data).isAIMinion && PlayerStatus.PlayerAliveAndSimulated(player));
					return !flag;
				}
			}

			[IteratorStateMachine(typeof(<HandleStalemate>d__2))]
			public static IEnumerator HandleStalemate()
			{
				//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
				return new <HandleStalemate>d__2(0);
			}

			[UnboundRPC]
			public static void RPCA_SendTakeDamageOverTime(int actorID, int playerID, float damage, float duration)
			{
				//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_002a: 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_003a: Unknown result type (might be due to invalid IL or missing references)
				Player playerWithActorAndPlayerIDs = FindPlayer.GetPlayerWithActorAndPlayerIDs(actorID, playerID);
				playerWithActorAndPlayerIDs.data.healthHandler.TakeDamageOverTime(damage * Vector2.down, Vector2.op_Implicit(((Component)playerWithActorAndPlayerIDs).gameObject.transform.position), duration, 0.5f, Color.white, (GameObject)null, (Player)null, true);
			}
		}

		[CompilerGenerated]
		private sealed class <AiPickCard>d__14 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public BotAIManager <>4__this;

			private int <i>5__1;

			private Player <player>5__2;

			private List<GameObject> <spawnCards>5__3;

			private ICardPickerAI <botCardPickerAI>5__4;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<player>5__2 = null;
				<spawnCards>5__3 = null;
				<botCardPickerAI>5__4 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0057: Unknown result type (might be due to invalid IL or missing references)
				//IL_0061: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					if (PhotonNetwork.IsMasterClient || PhotonNetwork.OfflineMode)
					{
						<>2__current = (object)new WaitUntil((Func<bool>)(() => CardChoice.instance.IsPicking && ((List<GameObject>)ExtensionMethods.GetFieldValue((object)CardChoice.instance, "spawnedCards")).Count == ((Transform[])ExtensionMethods.GetFieldValue((object)CardChoice.instance, "children")).Count() && !((List<GameObject>)ExtensionMethods.GetFieldValue((object)CardChoice.instance, "spawnedCards")).Any((GameObject card) => (Object)(object)card == (Object)null)));
						<>1__state = 1;
						return true;
					}
					return false;
				case 1:
					<>1__state = -1;
					<i>5__1 = 0;
					while (<i>5__1 < PlayerManager.instance.players.Count)
					{
						<player>5__2 = PlayerManager.instance.players[<i>5__1];
						if (<>4__this.PickerAIs.ContainsKey(CardChoice.instance.pickrID))
						{
							LoggerUtils.Log("AI picking card");
							<spawnCards>5__3 = <>4__this.GetSpawnCards();
							((Component)<spawnCards>5__3[0].GetComponent<CardInfo>()).GetComponent<PhotonView>().RPC("RPCA_ChangeSelected", (RpcTarget)0, new object[1] { true });
							<botCardPickerAI>5__4 = <>4__this.PickerAIs[CardChoice.instance.pickrID].cardPickerAI;
							<>4__this.StartCardsPicking(<spawnCards>5__3, <botCardPickerAI>5__4, <>4__this.PickerAIs[CardChoice.instance.pickrID].pickerInfo);
							break;
						}
						<player>5__2 = null;
						<i>5__1++;
					}
					return false;
				}
			}

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

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

		[CompilerGenerated]
		private sealed class <CycleThroughCards>d__11 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public float delay;

			public List<GameObject> spawnedCards;

			public BotAIManager <>4__this;

			private CardInfo <lastCardInfo>5__1;

			private int <index>5__2;

			private List<GameObject>.Enumerator <>s__3;

			private GameObject <cardObject>5__4;

			private CardInfo <cardInfo>5__5;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				int num = <>1__state;
				if (num == -3 || num == 1)
				{
					try
					{
					}
					finally
					{
						<>m__Finally1();
					}
				}
				<lastCardInfo>5__1 = null;
				<cardObject>5__4 = null;
				<cardInfo>5__5 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_011c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0126: Expected O, but got Unknown
				try
				{
					switch (<>1__state)
					{
					default:
						return false;
					case 0:
						<>1__state = -1;
						LoggerUtils.Log("Cycling through cards");
						<lastCardInfo>5__1 = null;
						<index>5__2 = 0;
						<>s__3 = spawnedCards.GetEnumerator();
						<>1__state = -3;
						break;
					case 1:
						<>1__state = -3;
						<cardInfo>5__5 = null;
						<cardObject>5__4 = null;
						break;
					}
					if (<>s__3.MoveNext())
					{
						<cardObject>5__4 = <>s__3.Current;
						<cardInfo>5__5 = <cardObject>5__4.GetComponent<CardInfo>();
						LoggerUtils.Log("Cycling through '$" + <cardInfo>5__5.cardName + "' card");
						if ((Object)(object)<lastCardInfo>5__1 != (Object)null)
						{
							<lastCardInfo>5__1.RPCA_ChangeSelected(false);
						}
						<cardInfo>5__5.RPCA_ChangeSelected(true);
						AccessTools.Field(typeof(CardChoice), "currentlySelectedCard").SetValue(CardChoice.instance, <index>5__2);
						<lastCardInfo>5__1 = <cardInfo>5__5;
						<index>5__2++;
						<>2__current = (object)new WaitForSeconds(delay);
						<>1__state = 1;
						return true;
					}
					<>m__Finally1();
					LoggerUtils.Log("Successfully gone through all cards");
					return false;
				}
				catch
				{
					//try-fault
					((IDisposable)this).Dispose();
					throw;
				}
			}

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

			private void <>m__Finally1()
			{
				<>1__state = -1;
				((IDisposable)<>s__3).Dispose();
			}

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

		[CompilerGenerated]
		private sealed class <GoToCards>d__12 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public GameObject selectedCards;

			public List<GameObject> spawnedCards;

			public float delay;

			public BotAIManager <>4__this;

			private int <selectedCardIndex>5__1;

			private int <handIndex>5__2;

			private CardInfo <cardInfo>5__3;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<cardInfo>5__3 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0167: Unknown result type (might be due to invalid IL or missing references)
				//IL_0171: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					LoggerUtils.Log($"Going to '${selectedCards}' card");
					<selectedCardIndex>5__1 = spawnedCards.IndexOf(selectedCards);
					<handIndex>5__2 = int.Parse(AccessTools.Field(typeof(CardChoice), "currentlySelectedCard").GetValue(CardChoice.instance).ToString());
					break;
				case 1:
					<>1__state = -1;
					<cardInfo>5__3 = null;
					break;
				}
				if (<handIndex>5__2 != <selectedCardIndex>5__1)
				{
					<cardInfo>5__3 = spawnedCards[<handIndex>5__2].GetComponent<CardInfo>();
					<cardInfo>5__3.RPCA_ChangeSelected(false);
					LoggerUtils.Log($"Currently on '${<cardInfo>5__3}' card");
					if (<handIndex>5__2 > <selectedCardIndex>5__1)
					{
						<handIndex>5__2--;
					}
					else if (<handIndex>5__2 < <selectedCardIndex>5__1)
					{
						<handIndex>5__2++;
					}
					<cardInfo>5__3 = spawnedCards[<handIndex>5__2].GetComponent<CardInfo>();
					<cardInfo>5__3.RPCA_ChangeSelected(true);
					AccessTools.Field(typeof(CardChoice), "currentlySelectedCard").SetValue(CardChoice.instance, <handIndex>5__2);
					<>2__current = (object)new WaitForSeconds(delay);
					<>1__state = 1;
					return true;
				}
				LoggerUtils.Log($"Successfully got to '${selectedCards}' card");
				return false;
			}

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

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

		[CompilerGenerated]
		private sealed class <OnPlayerPickStart>d__5 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public IGameModeHandler modeHandler;

			public BotAIManager <>4__this;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				if (<>1__state != 0)
				{
					return false;
				}
				<>1__state = -1;
				((MonoBehaviour)<>4__this).StartCoroutine(Instance.AiPickCard());
				return false;
			}

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

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

		[CompilerGenerated]
		private sealed class <PickCardsAtPosition>d__16 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public int position;

			public float cycleDelay;

			public float preCycleDelay;

			public float goToCardDelay;

			public float pickDelay;

			public BotAIManager <>4__this;

			private List<GameObject> <spawnCards>5__1;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<spawnCards>5__1 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0082: Unknown result type (might be due to invalid IL or missing references)
				//IL_008c: Expected O, but got Unknown
				//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00eb: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<spawnCards>5__1 = <>4__this.GetSpawnCards();
					<>2__current = <>4__this.CycleThroughCards(cycleDelay, <spawnCards>5__1);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(preCycleDelay);
					<>1__state = 2;
					return true;
				case 2:
					<>1__state = -1;
					<>2__current = <>4__this.GoToCards(<spawnCards>5__1[position], <spawnCards>5__1, goToCardDelay);
					<>1__state = 3;
					return true;
				case 3:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(pickDelay);
					<>1__state = 4;
					return true;
				case 4:
					<>1__state = -1;
					<>4__this.PickCard(<spawnCards>5__1);
					return false;
				}
			}

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

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

		[CompilerGenerated]
		private sealed class <Rematch>d__9 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public BotAIManager <>4__this;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(1f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					if (GameManager.instance.isPlaying)
					{
						RoundEndHandler.instance.OnGameOverChoose("REMATCH");
					}
					return false;
				}
			}

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

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

		public static BotAIManager Instance;

		public Dictionary<int, CardPickerAI> PickerAIs = new Dictionary<int, CardPickerAI>();

		private Coroutine stalemateHandlerCoroutine;

		private void Start()
		{
			InterfaceGameModeHooksManager.instance.RegisterHooks((object)this);
			Object.DontDestroyOnLoad((Object)(object)this);
			Instance = this;
		}

		public void SetBotsId()
		{
			LoggerUtils.Log("Getting bots player.");
			PickerAIs.Clear();
			List<int> list = (from player in PlayerManager.instance.players
				where player.data.GetAdditionalData().IsBot
				select player.playerID).ToList();
			PickerAIs = list.ToDictionary((int id) => id, (int id) => new CardPickerAI());
			if (PickerAIs.Count > 1)
			{
				PickerAIs[0].cardPickerAI = new WeightedCardsPicker();
			}
			list.ForEach(delegate(int id)
			{
				LoggerUtils.Log($"Bot '{id}' has been added to the list of bots id.");
			});
			LoggerUtils.Log("Successfully get list of bots player.");
			if (RoundsWithBots.Plugins.Any((BaseUnityPlugin plugin) => plugin.Info.Metadata.GUID == "Systems.R00t.PickPhaseImprovements"))
			{
				PickPhaseImprovementsInterrface.RegisterHandFinalizationAction(delegate
				{
					((MonoBehaviour)this).StartCoroutine(Instance.AiPickCard());
				});
			}
			else
			{
				GameModeManager.AddHook("PlayerPickStart", (Func<IGameModeHandler, IEnumerator>)OnPlayerPickStart);
			}
		}

		[IteratorStateMachine(typeof(<OnPlayerPickStart>d__5))]
		public IEnumerator OnPlayerPickStart(IGameModeHandler modeHandler)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <OnPlayerPickStart>d__5(0)
			{
				<>4__this = this,
				modeHandler = modeHandler
			};
		}

		public void OnGameStart()
		{
			Instance.SetBotsId();
			foreach (KeyValuePair<int, CardPickerAI> bot in PickerAIs)
			{
				Player val = PlayerManager.instance.players.First((Player p) => p.playerID == bot.Key);
				((TMP_Text)((Component)((Component)val).GetComponentInChildren<PlayerName>()).GetComponent<TextMeshProUGUI>()).text = "<#07e0f0>[BOT]";
			}
		}

		public void OnPointStart()
		{
			if (stalemateHandlerCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(stalemateHandlerCoroutine);
			}
			stalemateHandlerCoroutine = ((MonoBehaviour)this).StartCoroutine(StalemateHandler.HandleStalemate());
		}

		public void OnRoundEnd()
		{
			int maxRounds = (int)GameModeManager.CurrentHandler.Settings["roundsToWinGame"];
			IEnumerable<int> source = PlayerManager.instance.players.Select((Player p) => p.teamID).Distinct();
			int? num = source.Select((Func<int, int?>)((int id) => id)).FirstOrDefault((int? id) => GameModeManager.CurrentHandler.GetTeamScore(id.Value).rounds >= maxRounds);
			bool flag = PlayerManager.instance.players.All((Player p) => p.data.GetAdditionalData().IsBot || CharacterDataExtension.GetAdditionalData(p.data).isAIMinion);
			if (num.HasValue && flag)
			{
				((MonoBehaviour)this).StartCoroutine(Rematch());
			}
		}

		[IteratorStateMachine(typeof(<Rematch>d__9))]
		public IEnumerator Rematch()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <Rematch>d__9(0)
			{
				<>4__this = this
			};
		}

		public List<GameObject> GetSpawnCards()
		{
			LoggerUtils.Log("Getting spawn cards");
			return (List<GameObject>)AccessTools.Field(typeof(CardChoice), "spawnedCards").GetValue(CardChoice.instance);
		}

		[IteratorStateMachine(typeof(<CycleThroughCards>d__11))]
		public IEnumerator CycleThroughCards(float delay, List<GameObject> spawnedCards)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <CycleThroughCards>d__11(0)
			{
				<>4__this = this,
				delay = delay,
				spawnedCards = spawnedCards
			};
		}

		[IteratorStateMachine(typeof(<GoToCards>d__12))]
		public IEnumerator GoToCards(GameObject selectedCards, List<GameObject> spawnedCards, float delay)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <GoToCards>d__12(0)
			{
				<>4__this = this,
				selectedCards = selectedCards,
				spawnedCards = spawnedCards,
				delay = delay
			};
		}

		public void PickCard(List<GameObject> spawnCards)
		{
			CardChoice.instance.Pick(spawnCards[(int)ExtensionMethods.GetFieldValue((object)CardChoice.instance, "currentlySelectedCard")], true);
		}

		[IteratorStateMachine(typeof(<AiPickCard>d__14))]
		public IEnumerator AiPickCard()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <AiPickCard>d__14(0)
			{
				<>4__this = this
			};
		}

		public void StartCardsPicking(List<GameObject> spawnCards, ICardPickerAI botCardPickerAI, PickerInfo pickerInfo)
		{
			if (botCardPickerAI == null)
			{
				LoggerUtils.Log("Bot card picker AI is null, Skipping card picking");
				return;
			}
			List<CardInfo> list = spawnCards.Select((GameObject card) => card.GetComponent<CardInfo>()).ToList();
			List<CardInfo> list2 = botCardPickerAI.PickCard(list);
			CardInfo item = list2.ElementAt(Random.Range(0, list2.Count));
			int num = list.IndexOf(item);
			NetworkingManager.RPC(typeof(BotAIManager), "RPCA_PickCardsAtPosition", new object[5] { num, pickerInfo.CycleDelay, pickerInfo.PreCycleDelay, pickerInfo.GoToCardDelay, pickerInfo.PickDelay });
		}

		[IteratorStateMachine(typeof(<PickCardsAtPosition>d__16))]
		private IEnumerator PickCardsAtPosition(int position, float cycleDelay, float preCycleDelay, float goToCardDelay, float pickDelay)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <PickCardsAtPosition>d__16(0)
			{
				<>4__this = this,
				position = position,
				cycleDelay = cycleDelay,
				preCycleDelay = preCycleDelay,
				goToCardDelay = goToCardDelay,
				pickDelay = pickDelay
			};
		}

		[UnboundRPC]
		private static void RPCA_PickCardsAtPosition(int position, float cycleDelay, float preCycleDelay, float goToCardDelay, float pickDelay)
		{
			((MonoBehaviour)Instance).StartCoroutine(Instance.PickCardsAtPosition(position, cycleDelay, preCycleDelay, goToCardDelay, pickDelay));
		}
	}
	public class PickerInfo
	{
		public float CycleDelay;

		public float PreCycleDelay;

		public float GoToCardDelay;

		public float PickDelay;

		public PickerInfo(float cycleDelay, float preCycleDelay, float goToCardDelay, float pickDelay)
		{
			CycleDelay = cycleDelay;
			PreCycleDelay = preCycleDelay;
			GoToCardDelay = goToCardDelay;
			PickDelay = pickDelay;
		}

		public PickerInfo()
		{
			CycleDelay = RWBMenu.CycleDelay.Value;
			PreCycleDelay = RWBMenu.PreCycleDelay.Value;
			GoToCardDelay = RWBMenu.GoToCardDelay.Value;
			PickDelay = RWBMenu.PickDelay.Value;
		}
	}
	public class CardPickerAI
	{
		public ICardPickerAI cardPickerAI;

		public PickerInfo pickerInfo;

		public CardPickerAI(ICardPickerAI cardPickerAI, PickerInfo pickerInfo)
		{
			this.cardPickerAI = cardPickerAI;
			this.pickerInfo = pickerInfo;
		}

		public CardPickerAI()
		{
			cardPickerAI = new WeightedCardsPicker();
			pickerInfo = new PickerInfo();
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.aalund13.rounds.roundswithbots", "Rounds With Bots", "3.2.1")]
	[BepInProcess("Rounds.exe")]
	public class RoundsWithBots : BaseUnityPlugin
	{
		private const string ModId = "com.aalund13.rounds.roundswithbots";

		private const string ModName = "Rounds With Bots";

		public const string Version = "3.2.1";

		public const string ModInitials = "RWB";

		public bool IsPicking = false;

		public AssetBundle Assets;

		internal static List<BaseUnityPlugin> Plugins { get; private set; }

		internal static RoundsWithBots Instance { get; private set; }

		internal static ManualLogSource ModLogger { get; private set; }

		private void Awake()
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			Instance = this;
			ModLogger = ((BaseUnityPlugin)this).Logger;
			Assets = AssetUtils.LoadAssetBundleFromResources("rwb_assets", typeof(RoundsWithBots).Assembly);
			Harmony val = new Harmony("com.aalund13.rounds.roundswithbots");
			val.PatchAll();
		}

		private void Start()
		{
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			Plugins = (List<BaseUnityPlugin>)typeof(Chainloader).GetField("_plugins", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null);
			RWBMenu.RegisterMenu("Rounds With Bots", ((BaseUnityPlugin)this).Config);
			Unbound.RegisterHandshake("com.aalund13.rounds.roundswithbots", (Action)OnHandShakeCompleted);
			Cards.instance.AddCardValidationFunction((Func<Player, CardInfo, bool>)((Player player, CardInfo card) => (!((Behaviour)((Component)player).GetComponent<PlayerAPI>()).enabled || !card.blacklistedCategories.Contains(CustomCardCategories.instance.CardCategory("NotForBots"))) ? true : false));
			CardExclusiveUtils.ExcludeCardsFromBots(CardManager.GetCardInfoWithName("Remote"));
			CardExclusiveUtils.ExcludeCardsFromBots(CardManager.GetCardInfoWithName("Teleport"));
			CardExclusiveUtils.ExcludeCardsFromBots(CardManager.GetCardInfoWithName("Shield Charge"));
			BotAIManager.Instance = new GameObject("RWB_BotAIManager").AddComponent<BotAIManager>();
			Object.DontDestroyOnLoad((Object)(object)((Component)BotAIManager.Instance).gameObject);
		}

		private void OnHandShakeCompleted()
		{
			if (PhotonNetwork.IsMasterClient)
			{
				NetworkingManager.RPC_Others(((object)this).GetType(), "RPCA_SyncSettings", new object[7]
				{
					RWBMenu.StalemateTimer.Value,
					RWBMenu.StalemateDamageCooldown.Value,
					RWBMenu.StalemateDamageDuration.Value,
					RWBMenu.CycleDelay.Value,
					RWBMenu.PreCycleDelay.Value,
					RWBMenu.GoToCardDelay.Value,
					RWBMenu.PickDelay.Value
				});
			}
		}

		[UnboundRPC]
		private static void RPCA_SyncSettings(float stalemateTimer, float stalemateDamageCooldown, float stalemateDamageDuration, float cycleDelay, float preCycleDelay, float goToCardDelay, float pickDelay)
		{
			RWBMenu.StalemateTimer.Value = stalemateTimer;
			RWBMenu.StalemateDamageCooldown.Value = stalemateDamageCooldown;
			RWBMenu.StalemateDamageDuration.Value = stalemateDamageDuration;
			RWBMenu.CycleDelay.Value = cycleDelay;
			RWBMenu.PreCycleDelay.Value = preCycleDelay;
			RWBMenu.GoToCardDelay.Value = goToCardDelay;
			RWBMenu.PickDelay.Value = pickDelay;
		}
	}
}
namespace RoundsWithBots.Utils
{
	public class CardExclusiveUtils
	{
		public static CardCategory NotBotCategory = CustomCardCategories.instance.CardCategory("NotForBots");

		public static void ExcludeCardsFromBots(CardInfo card)
		{
			card.blacklistedCategories = CollectionExtensions.AddToArray<CardCategory>(card.blacklistedCategories, NotBotCategory);
		}
	}
	public static class EaseUtils
	{
		public enum EaseType
		{
			easeInSine,
			easeOutSine,
			easeInOutSine,
			easeInQuad,
			easeOutQuad,
			easeInOutQuad
		}

		[CompilerGenerated]
		private sealed class <EaseCoroutine>d__2 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public float duration;

			public EaseType easeType;

			public Action<float> action;

			public Action onComplete;

			public float min;

			public float max;

			private float <time>5__1;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<time>5__1 = 0f;
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				if (<time>5__1 < duration)
				{
					action(Ease(<time>5__1, min, max, duration, easeType));
					<time>5__1 += Time.deltaTime;
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				action(Ease(duration, min, max, duration, easeType));
				onComplete?.Invoke();
				return false;
			}

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

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

		public static float Ease(float time, float start, float end, float duration, EaseType easeType)
		{
			return easeType switch
			{
				EaseType.easeInSine => 0f - Mathf.Cos(time / duration * ((float)Math.PI / 2f)) + 1f * (end - start) + start, 
				EaseType.easeOutSine => Mathf.Sin(time / duration * ((float)Math.PI / 2f)) * (end - start) + start, 
				EaseType.easeInOutSine => -0.5f * (Mathf.Cos((float)Math.PI * time / duration) - 1f) * (end - start) + start, 
				EaseType.easeInQuad => (end - start) * (time /= duration) * time + start, 
				EaseType.easeOutQuad => (0f - (end - start)) * (time /= duration) * (time - 2f) + start, 
				EaseType.easeInOutQuad => ((time /= duration / 2f) < 1f) ? ((end - start) / 2f * time * time + start) : ((0f - (end - start)) / 2f * ((time -= 1f) * (time - 2f) - 1f) + start), 
				_ => 0f, 
			};
		}

		[IteratorStateMachine(typeof(<EaseCoroutine>d__2))]
		public static IEnumerator EaseCoroutine(float duration, EaseType easeType, Action<float> action, Action onComplete = null, float min = 0f, float max = 1f)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <EaseCoroutine>d__2(0)
			{
				duration = duration,
				easeType = easeType,
				action = action,
				onComplete = onComplete,
				min = min,
				max = max
			};
		}
	}
	public static class LoggerUtils
	{
		public static void Log(string message)
		{
			if (RWBMenu.DebugMode.Value)
			{
				Debug.Log((object)message);
			}
		}

		public static void LogWarning(string message)
		{
			if (RWBMenu.DebugMode.Value)
			{
				Debug.LogWarning((object)message);
			}
		}

		public static void Error(string message)
		{
			if (RWBMenu.DebugMode.Value)
			{
				Debug.LogError((object)message);
			}
		}
	}
}
namespace RoundsWithBots.UI
{
	internal class BotMenuUIHandler : MonoBehaviour
	{
		[CompilerGenerated]
		private sealed class <HideThenDestroy>d__12 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public BotMenuUIHandler <>4__this;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					((Component)<>4__this).GetComponent<CanvasGroup>().interactable = false;
					<>2__current = <>4__this.ToggleMenu(toggle: false);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					Object.Destroy((Object)(object)((Component)<>4__this).gameObject);
					return false;
				}
			}

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

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

		[CompilerGenerated]
		private sealed class <ToggleMenu>d__13 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public bool toggle;

			public BotMenuUIHandler <>4__this;

			private float <min>5__1;

			private float <max>5__2;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					if (<>4__this.IsOpen == toggle)
					{
						return false;
					}
					<min>5__1 = (toggle ? 0f : 1f);
					<max>5__2 = (toggle ? 1f : 0f);
					<>2__current = EaseUtils.EaseCoroutine(0.2f, EaseUtils.EaseType.easeInQuad, delegate(float value)
					{
						((Component)<>4__this).GetComponent<CanvasGroup>().alpha = value;
					}, null, <min>5__1, <max>5__2);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					((Component)<>4__this).GetComponent<CanvasGroup>().blocksRaycasts = toggle;
					return false;
				}
			}

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

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

		public static GameObject Prefab;

		public static GameObject CurrentInstance;

		public GameObject MenuObject;

		public FaceSelectorUI faceSelectorUI;

		public TeamSelectorUI teamSelectorUI;

		private CharacterSelectionInstance characterSelectionInstance;

		private bool IsOpen => ((Component)this).GetComponent<CanvasGroup>().alpha == 1f;

		public void Update()
		{
			if (((Object)(object)characterSelectionInstance == (Object)null || (Object)(object)characterSelectionInstance.currentPlayer == (Object)null) && IsOpen)
			{
				Hide();
			}
		}

		public static BotMenuUIHandler Show(CharacterSelectionInstance characterSelectionInstance)
		{
			if ((Object)(object)CurrentInstance != (Object)null)
			{
				CurrentInstance.GetComponent<BotMenuUIHandler>().Hide();
			}
			CurrentInstance = CreateInstance(Prefab);
			BotMenuUIHandler component = CurrentInstance.GetComponent<BotMenuUIHandler>();
			component.characterSelectionInstance = characterSelectionInstance;
			component.faceSelectorUI.SetupForCharacterSelection(characterSelectionInstance);
			component.teamSelectorUI.SetupForCharacterSelection(characterSelectionInstance);
			((Component)component).GetComponent<CanvasGroup>().interactable = true;
			((MonoBehaviour)component).StartCoroutine(component.ToggleMenu(toggle: true));
			return component;
		}

		public void RemovePlayer()
		{
			PlayerManager.instance.RemovePlayer(characterSelectionInstance.currentPlayer);
		}

		public void Hide()
		{
			((MonoBehaviour)this).StartCoroutine(HideThenDestroy());
		}

		[IteratorStateMachine(typeof(<HideThenDestroy>d__12))]
		private IEnumerator HideThenDestroy()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <HideThenDestroy>d__12(0)
			{
				<>4__this = this
			};
		}

		[IteratorStateMachine(typeof(<ToggleMenu>d__13))]
		private IEnumerator ToggleMenu(bool toggle)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <ToggleMenu>d__13(0)
			{
				<>4__this = this,
				toggle = toggle
			};
		}

		private static GameObject CreateInstance(GameObject prefab)
		{
			GameObject val = Object.Instantiate<GameObject>(prefab);
			Object.DontDestroyOnLoad((Object)(object)val);
			GameObject gameObject = ((Component)val.transform.GetChild(0)).gameObject;
			gameObject.GetComponent<CanvasGroup>().interactable = false;
			gameObject.GetComponent<CanvasGroup>().blocksRaycasts = false;
			gameObject.GetComponent<CanvasGroup>().alpha = 0f;
			return gameObject;
		}

		static BotMenuUIHandler()
		{
			RoundsWithBots instance = RoundsWithBots.Instance;
			object prefab;
			if (instance == null)
			{
				prefab = null;
			}
			else
			{
				AssetBundle assets = instance.Assets;
				prefab = ((assets != null) ? assets.LoadAsset<GameObject>("BotMenu") : null);
			}
			Prefab = (GameObject)prefab;
		}
	}
	public class FaceSelectorUI : MonoBehaviour
	{
		internal CharacterSelectionInstance characterSelectionInstance;

		public TextMeshProUGUI faceText;

		public void SetupForCharacterSelection(CharacterSelectionInstance characterSelectionInstance)
		{
			this.characterSelectionInstance = characterSelectionInstance;
			UpdateText(characterSelectionInstance.currentlySelectedFace);
		}

		public void IncrementFaceIndex()
		{
			characterSelectionInstance.currentlySelectedFace = (characterSelectionInstance.currentlySelectedFace + 1 + 8) % 8;
			UpdateText(characterSelectionInstance.currentlySelectedFace);
		}

		public void DecrementFaceIndex()
		{
			characterSelectionInstance.currentlySelectedFace = (characterSelectionInstance.currentlySelectedFace - 1 + 8) % 8;
			UpdateText(characterSelectionInstance.currentlySelectedFace);
		}

		private void UpdateText(int selectedFace)
		{
			((TMP_Text)faceText).text = $"FACE: {selectedFace}";
		}
	}
	public class TeamSelectorUI : MonoBehaviour
	{
		internal CharacterSelectionInstance characterSelectionInstance;

		public TextMeshProUGUI teamText;

		public void SetupForCharacterSelection(CharacterSelectionInstance characterSelectionInstance)
		{
			this.characterSelectionInstance = characterSelectionInstance;
			UpdateText(PlayerExtensions.GetAdditionalData(characterSelectionInstance.currentPlayer).colorID);
		}

		public void IncrementTeamIndex()
		{
			int num = ChanageTeam(1);
			PlayerExtensions.AssignColorID(characterSelectionInstance.currentPlayer, num);
			characterSelectionInstance.currentPlayer.SetColors();
			CharacterSelectionInstancePatch.RequestColorChange[characterSelectionInstance] = true;
			UpdateText(num);
		}

		public void DecrementTeamIndex()
		{
			int num = ChanageTeam(-1);
			PlayerExtensions.AssignColorID(characterSelectionInstance.currentPlayer, num);
			characterSelectionInstance.currentPlayer.SetColors();
			CharacterSelectionInstancePatch.RequestColorChange[characterSelectionInstance] = true;
			UpdateText(num);
		}

		public int ChanageTeam(int colorIDDelta)
		{
			int num = (PlayerExtensions.GetAdditionalData(characterSelectionInstance.currentPlayer).colorID + colorIDDelta + RWFMod.MaxColorsHardLimit) % RWFMod.MaxColorsHardLimit;
			if (!GameModeManager.CurrentHandler.AllowTeams)
			{
				int num2 = PlayerExtensions.colorID(characterSelectionInstance.currentPlayer);
				while (PlayerManager.instance.players.Select((Player p) => PlayerExtensions.colorID(p)).Contains(num) && num != num2)
				{
					num = (num + colorIDDelta + RWFMod.MaxColorsHardLimit) % RWFMod.MaxColorsHardLimit;
				}
			}
			return num;
		}

		private void UpdateText(int selectedColor)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			PlayerSkin playerSkinColors = PlayerSkinBank.GetPlayerSkinColors(selectedColor);
			((TMP_Text)teamText).text = "TEAM: <color=#" + ColorUtility.ToHtmlStringRGB(playerSkinColors.color * 1.5f) + ">" + ExtraPlayerSkins.GetTeamColorName(selectedColor).ToUpper();
		}

		private static void SimulatePress(PlayerAction action)
		{
			((OneAxisInputControl)action).CommitWithValue(1f, (ulong)ExtensionMethods.GetFieldValue((object)action, "pendingTick"), 0f);
		}
	}
}
namespace RoundsWithBots.Patches
{
	[HarmonyPatch(typeof(CharacterSelectionInstance))]
	internal class CharacterSelectionInstancePatch
	{
		public static Dictionary<CharacterSelectionInstance, bool> RequestColorChange = new Dictionary<CharacterSelectionInstance, bool>();

		[HarmonyPatch("StartPicking")]
		[HarmonyBefore(new string[] { "io.olavim.rounds.rwf" })]
		[HarmonyPostfix]
		public static void StartPickingPostfix(CharacterSelectionInstance __instance, Player pickingPlayer)
		{
			if (((Behaviour)((Component)__instance.currentPlayer).GetComponent<PlayerAPI>()).enabled)
			{
				if (RWBMenu.RandomizationFace.Value)
				{
					__instance.currentlySelectedFace = Random.Range(0, 7);
				}
				else
				{
					__instance.currentlySelectedFace = RWBMenu.SelectedFace.Value;
				}
			}
			ExtensionMethods.ExecuteAfterFrames((MonoBehaviour)(object)__instance, 1, (Action)delegate
			{
				((Component)((Component)__instance).transform.GetChild(0).GetChild(1)).gameObject.SetActive(false);
				SetupButton(__instance);
			});
		}

		private static void SetupButton(CharacterSelectionInstance __instance)
		{
			//IL_0193: 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_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Expected O, but got Unknown
			//IL_00f5: Expected O, but got Unknown
			GameObject[] array = (from x in ((Component)((Component)__instance).transform.GetChild(0).GetChild(0)).GetComponentsInChildren<HoverEvent>(true)
				select ((Component)x).gameObject).ToArray();
			GameObject[] array2 = array;
			UnityAction val2 = default(UnityAction);
			foreach (GameObject val in array2)
			{
				if (((Behaviour)((Component)__instance.currentPlayer).GetComponent<PlayerAPI>()).enabled)
				{
					GameObject gameObject = ((Component)val.transform.Find("Tooltip")).gameObject;
					Button orAddComponent = ExtensionMethods.GetOrAddComponent<Button>(gameObject, false);
					Image componentInChildren = gameObject.GetComponentInChildren<Image>(true);
					TextMeshProUGUI componentInChildren2 = gameObject.GetComponentInChildren<TextMeshProUGUI>();
					ControllerImageToggler component = ((Component)componentInChildren).GetComponent<ControllerImageToggler>();
					((UnityEventBase)orAddComponent.onClick).RemoveAllListeners();
					ButtonClickedEvent onClick = orAddComponent.onClick;
					UnityAction obj = val2;
					if (obj == null)
					{
						UnityAction val3 = delegate
						{
							//IL_000c: 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_0016: Unknown result type (might be due to invalid IL or missing references)
							//IL_002b: Unknown result type (might be due to invalid IL or missing references)
							//IL_003f: Unknown result type (might be due to invalid IL or missing references)
							//IL_0044: 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_005d: Unknown result type (might be due to invalid IL or missing references)
							//IL_0062: Unknown result type (might be due to invalid IL or missing references)
							Debug.Log((object)"The bot have be clicked.");
							Vector2 val5 = Vector2.op_Implicit(Input.mousePosition);
							BotMenuUIHandler botMenuUIHandler = BotMenuUIHandler.Show(__instance);
							RectTransform component2 = ((Component)botMenuUIHandler).GetComponent<RectTransform>();
							Vector2 val6 = default(Vector2);
							RectTransformUtility.ScreenPointToLocalPointInRectangle(component2, val5, (Camera)null, ref val6);
							ref float y = ref val6.y;
							float num = y;
							Rect rect = component2.rect;
							y = num - ((Rect)(ref rect)).height / 2f;
							((Component)botMenuUIHandler).transform.position = ((Transform)component2).TransformPoint(Vector2.op_Implicit(val6));
						};
						UnityAction val4 = val3;
						val2 = val3;
						obj = val4;
					}
					((UnityEvent)onClick).AddListener(obj);
					((Selectable)orAddComponent).targetGraphic = (Graphic)(object)componentInChildren2;
					componentInChildren.overrideSprite = component.MKSprite;
					((Component)componentInChildren).transform.localEulerAngles = new Vector3(0f, 180f, 0f);
					((TMP_Text)componentInChildren2).text = "TO EDIT";
					((Selectable)orAddComponent).interactable = true;
				}
				else
				{
					GameObject gameObject2 = ((Component)val.transform.Find("Tooltip")).gameObject;
					Button orAddComponent2 = ExtensionMethods.GetOrAddComponent<Button>(gameObject2, false);
					Image componentInChildren3 = gameObject2.GetComponentInChildren<Image>(true);
					((Component)componentInChildren3).transform.localEulerAngles = new Vector3(0f, 0f, 0f);
					componentInChildren3.overrideSprite = null;
					((Selectable)orAddComponent2).interactable = false;
					((Selectable)orAddComponent2).targetGraphic = null;
				}
				val.GetComponent<SimulatedSelection>().Select();
			}
		}

		[HarmonyPatch("Update")]
		[HarmonyBefore(new string[] { "io.olavim.rounds.rwf" })]
		[HarmonyPrefix]
		public static bool UpdatePrefix(CharacterSelectionInstance __instance)
		{
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Expected O, but got Unknown
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)__instance.currentPlayer == (Object)null)
			{
				return false;
			}
			GameObject[] array = (from x in ((Component)((Component)__instance).transform.GetChild(0).GetChild(0)).GetComponentsInChildren<HoverEvent>(true)
				select ((Component)x).gameObject).ToArray();
			if (RequestColorChange.ContainsKey(__instance) && RequestColorChange[__instance])
			{
				GameObject[] array2 = array;
				foreach (GameObject val in array2)
				{
					((Component)val.transform.GetChild(2).GetChild(0)).GetComponent<SpriteRenderer>().color = __instance.currentPlayer.GetTeamColors().color;
					((TMP_Text)((Component)val.transform.GetChild(4).GetChild(2)).GetComponent<TextMeshProUGUI>()).text = (GameModeManager.CurrentHandler.AllowTeams ? "TEAM " : "") + ExtraPlayerSkins.GetTeamColorName(PlayerExtensions.colorID(__instance.currentPlayer)).ToUpper();
				}
				if (RequestColorChange.ContainsKey(__instance))
				{
					RequestColorChange[__instance] = false;
				}
				else
				{
					RequestColorChange.Add(__instance, value: false);
				}
			}
			if (((Behaviour)((Component)__instance.currentPlayer).GetComponent<PlayerAPI>()).enabled)
			{
				ExtensionMethods.SetFieldValue((object)__instance.currentPlayer.data.playerVel, "simulated", (object)false);
				if (__instance.currentPlayer.data.playerActions == null)
				{
					__instance.currentPlayer.data.playerActions = new PlayerActions();
					((PlayerActionSet)__instance.currentPlayer.data.playerActions).Device = InputDevice.Null;
				}
				if (Input.GetKeyDown((KeyCode)114))
				{
					AccessTools.Method(typeof(CharacterSelectionInstance), "ReadyUp", (Type[])null, (Type[])null).Invoke(__instance, null);
					return false;
				}
			}
			return true;
		}

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		public static void StartPostfix(CharacterSelectionInstance __instance)
		{
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Expected O, but got Unknown
			GameObject gameObject = ((Component)((Component)__instance).transform.GetChild(0).GetChild(0)).gameObject;
			for (int i = 0; i < gameObject.transform.childCount; i++)
			{
				Button button = ((Component)gameObject.transform.GetChild(i)).GetComponent<Button>();
				((UnityEventBase)button.onClick).RemoveAllListeners();
				((UnityEvent)button.onClick).AddListener((UnityAction)delegate
				{
					if (!((Object)(object)__instance.currentPlayer == (Object)null) && __instance.currentPlayer.data.GetAdditionalData().IsBot)
					{
						Debug.Log((object)"The bot have be clicked.");
						((Component)button).gameObject.GetComponent<ScaleShake>().AddForce();
					}
				});
			}
		}
	}
	[HarmonyPatch(typeof(Map))]
	internal class MapPatch
	{
		[CompilerGenerated]
		private sealed class <SetDamageBoxesColliders>d__1 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			private List<DamageBox> <damageBoxes>5__1;

			private List<DamageBox>.Enumerator <>s__2;

			private DamageBox <damageBox>5__3;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<damageBoxes>5__1 = null;
				<damageBox>5__3 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = null;
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<damageBoxes>5__1 = Object.FindObjectsOfType<DamageBox>().ToList();
					PlayerAIPhilipPatch.DamageBoxesColliders.Clear();
					<>s__2 = <damageBoxes>5__1.GetEnumerator();
					try
					{
						while (<>s__2.MoveNext())
						{
							<damageBox>5__3 = <>s__2.Current;
							PlayerAIPhilipPatch.DamageBoxesColliders.Add(((Component)<damageBox>5__3).GetComponent<Collider2D>());
							<damageBox>5__3 = null;
						}
					}
					finally
					{
						((IDisposable)<>s__2).Dispose();
					}
					return false;
				}
			}

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

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

		[HarmonyPatch("StartMatch")]
		public static void Postfix()
		{
			((MonoBehaviour)RoundsWithBots.Instance).StartCoroutine(SetDamageBoxesColliders());
		}

		[IteratorStateMachine(typeof(<SetDamageBoxesColliders>d__1))]
		public static IEnumerator SetDamageBoxesColliders()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <SetDamageBoxesColliders>d__1(0);
		}
	}
	[HarmonyPatch(typeof(PlayerAIPhilip))]
	internal class PlayerAIPhilipPatch
	{
		[CompilerGenerated]
		private sealed class <ApplyLayerMaskToRaycast>d__5 : IEnumerable<CodeInstruction>, IEnumerable, IEnumerator<CodeInstruction>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private CodeInstruction <>2__current;

			private int <>l__initialThreadId;

			private IEnumerable<CodeInstruction> instructions;

			public IEnumerable<CodeInstruction> <>3__instructions;

			private MethodInfo <raycastMethod>5__1;

			private int <layerToIgnore>5__2;

			private int <layerMask>5__3;

			private IEnumerator<CodeInstruction> <>s__4;

			private CodeInstruction <code>5__5;

			private MethodInfo <methodInfo>5__6;

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

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

			[DebuggerHidden]
			public <ApplyLayerMaskToRaycast>d__5(int <>1__state)
			{
				this.<>1__state = <>1__state;
				<>l__initialThreadId = Environment.CurrentManagedThreadId;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				int num = <>1__state;
				if (num == -3 || (uint)(num - 1) <= 2u)
				{
					try
					{
					}
					finally
					{
						<>m__Finally1();
					}
				}
				<raycastMethod>5__1 = null;
				<>s__4 = null;
				<code>5__5 = null;
				<methodInfo>5__6 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0178: Unknown result type (might be due to invalid IL or missing references)
				//IL_0182: Expected O, but got Unknown
				//IL_014c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0156: Expected O, but got Unknown
				try
				{
					switch (<>1__state)
					{
					default:
						return false;
					case 0:
						<>1__state = -1;
						<raycastMethod>5__1 = AccessTools.Method(typeof(Physics2D), "Raycast", new Type[4]
						{
							typeof(Vector2),
							typeof(Vector2),
							typeof(float),
							typeof(int)
						}, (Type[])null);
						<layerToIgnore>5__2 = LayerMask.NameToLayer("BackgroundObject");
						<layerMask>5__3 = ~(1 << <layerToIgnore>5__2);
						<>s__4 = instructions.GetEnumerator();
						<>1__state = -3;
						break;
					case 1:
						<>1__state = -3;
						<>2__current = new CodeInstruction(OpCodes.Call, (object)<raycastMethod>5__1);
						<>1__state = 2;
						return true;
					case 2:
						<>1__state = -3;
						goto IL_01b9;
					case 3:
						{
							<>1__state = -3;
							goto IL_01b9;
						}
						IL_01b9:
						<methodInfo>5__6 = null;
						<code>5__5 = null;
						break;
					}
					if (<>s__4.MoveNext())
					{
						<code>5__5 = <>s__4.Current;
						if (<code>5__5.opcode == OpCodes.Call)
						{
							object operand = <code>5__5.operand;
							<methodInfo>5__6 = operand as MethodInfo;
							if ((object)<methodInfo>5__6 != null && <methodInfo>5__6.Name == "Raycast")
							{
								<>2__current = new CodeInstruction(OpCodes.Ldc_I4, (object)<layerMask>5__3);
								<>1__state = 1;
								return true;
							}
						}
						<>2__current = <code>5__5;
						<>1__state = 3;
						return true;
					}
					<>m__Finally1();
					<>s__4 = null;
					return false;
				}
				catch
				{
					//try-fault
					((IDisposable)this).Dispose();
					throw;
				}
			}

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

			private void <>m__Finally1()
			{
				<>1__state = -1;
				if (<>s__4 != null)
				{
					<>s__4.Dispose();
				}
			}

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

			[DebuggerHidden]
			IEnumerator<CodeInstruction> IEnumerable<CodeInstruction>.GetEnumerator()
			{
				<ApplyLayerMaskToRaycast>d__5 <ApplyLayerMaskToRaycast>d__;
				if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
				{
					<>1__state = 0;
					<ApplyLayerMaskToRaycast>d__ = this;
				}
				else
				{
					<ApplyLayerMaskToRaycast>d__ = new <ApplyLayerMaskToRaycast>d__5(0);
				}
				<ApplyLayerMaskToRaycast>d__.instructions = <>3__instructions;
				return <ApplyLayerMaskToRaycast>d__;
			}

			[DebuggerHidden]
			IEnumerator IEnumerable.GetEnumerator()
			{
				return ((IEnumerable<CodeInstruction>)this).GetEnumerator();
			}
		}

		private const float maxDistance = 1f;

		public static List<Collider2D> DamageBoxesColliders = new List<Collider2D>();

		[HarmonyPostfix]
		[HarmonyPatch("Update")]
		public static void UpdatePostfix(PlayerAIPhilip __instance)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: 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_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			GeneralInput val = (GeneralInput)AccessTools.Field(typeof(PlayerAPI), "input").GetValue(((Component)__instance).GetComponentInParent<PlayerAPI>());
			OutOfBoundsHandler obj = Object.FindObjectOfType<OutOfBoundsHandler>();
			Vector3 val2 = (Vector3)AccessTools.Method(typeof(OutOfBoundsHandler), "GetPoint", (Type[])null, (Type[])null).Invoke(obj, new object[1] { ((Component)__instance).transform.position });
			float num = Mathf.Abs(((Component)__instance).transform.position.x - val2.x);
			float num2 = Mathf.Abs(((Component)__instance).transform.position.y - val2.y);
			if ((num <= 1f || num2 <= 1f) && (num >= 1f || num2 >= 1f))
			{
				val.shieldWasPressed = true;
			}
			foreach (Collider2D damageBoxesCollider in DamageBoxesColliders)
			{
				if (!((Object)(object)damageBoxesCollider == (Object)null))
				{
					Bounds bounds = damageBoxesCollider.bounds;
					Vector2 val3 = Vector2.op_Implicit(((Bounds)(ref bounds)).ClosestPoint(((Component)__instance).transform.position));
					float num3 = Vector2.Distance(val3, Vector2.op_Implicit(((Component)__instance).transform.position));
					if (num3 <= 1f)
					{
						val.shieldWasPressed = true;
						break;
					}
				}
			}
		}

		[HarmonyTranspiler]
		[HarmonyPatch("CanSee")]
		public static IEnumerable<CodeInstruction> CanSeeTranspiler(IEnumerable<CodeInstruction> instructions)
		{
			return ApplyLayerMaskToRaycast(instructions);
		}

		[HarmonyTranspiler]
		[HarmonyPatch("CheckGround")]
		public static IEnumerable<CodeInstruction> CheckGroundTranspiler(IEnumerable<CodeInstruction> instructions)
		{
			return ApplyLayerMaskToRaycast(instructions);
		}

		[IteratorStateMachine(typeof(<ApplyLayerMaskToRaycast>d__5))]
		private static IEnumerable<CodeInstruction> ApplyLayerMaskToRaycast(IEnumerable<CodeInstruction> instructions)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <ApplyLayerMaskToRaycast>d__5(-2)
			{
				<>3__instructions = instructions
			};
		}
	}
	[HarmonyPatch(typeof(PlayerAssigner))]
	internal class PlayerAssignerPatch
	{
		[CompilerGenerated]
		private sealed class <DelayedAIReplacement>d__1 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			private Player <player>5__1;

			private MonoBehaviour <playerAI>5__2;

			private PlayerAIZorro <playerAIZorro>5__3;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<player>5__1 = null;
				<playerAI>5__2 = null;
				<playerAIZorro>5__3 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = null;
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<player>5__1 = PlayerManager.instance.players.Last();
					if ((Object)(object)<player>5__1 == (Object)null)
					{
						Debug.LogError("Player could not be found.");
						return false;
					}
					<playerAI>5__2 = (MonoBehaviour)(((object)((Component)<player>5__1).GetComponentInChildren<PlayerAI>()) ?? ((object)((Component)<player>5__1).GetComponentInChildren<PlayerAIZorro>()));
					if ((Object)(object)<playerAI>5__2 != (Object)null)
					{
						ref PlayerAIZorro reference = ref <playerAIZorro>5__3;
						MonoBehaviour obj = <playerAI>5__2;
						reference = (PlayerAIZorro)(object)((obj is PlayerAIZorro) ? obj : null);
						if (<playerAIZorro>5__3 != null)
						{
							HealthHandler healthHandler = <player>5__1.data.healthHandler;
							healthHandler.delayedReviveAction = (Action)Delegate.Remove(healthHandler.delayedReviveAction, new Action(<playerAIZorro>5__3.Init));
						}
						((Component)<playerAI>5__2).gameObject.AddComponent<PlayerAIPhilip>();
						<player>5__1.data.GetAdditionalData().IsBot = true;
						Object.Destroy((Object)(object)<playerAI>5__2);
						<playerAIZorro>5__3 = null;
					}
					return false;
				}
			}

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

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

		[CompilerGenerated]
		private sealed class <EmptyEnumerator>d__2 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				if (<>1__state != 0)
				{
					return false;
				}
				<>1__state = -1;
				return false;
			}

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

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

		[HarmonyPatch("CreatePlayer")]
		public static bool Prefix(bool isAI, ref IEnumerator __result)
		{
			if (GameManager.instance.isPlaying && !AIMinionHandler.sandbox)
			{
				__result = EmptyEnumerator();
				return false;
			}
			if (isAI)
			{
				((MonoBehaviour)RoundsWithBots.Instance).StartCoroutine(DelayedAIReplacement());
			}
			return true;
		}

		[IteratorStateMachine(typeof(<DelayedAIReplacement>d__1))]
		private static IEnumerator DelayedAIReplacement()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <DelayedAIReplacement>d__1(0);
		}

		[IteratorStateMachine(typeof(<EmptyEnumerator>d__2))]
		private static IEnumerator EmptyEnumerator()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <EmptyEnumerator>d__2(0);
		}
	}
}
namespace RoundsWithBots.Patches.RWF
{
	[HarmonyPatch(typeof(KeybindHints))]
	internal class KeybindHintsPatch
	{
		[HarmonyPatch("CreateLocalHints")]
		public static void Postfix()
		{
			if (PlayerPrefs.GetInt(RWFMod.GetCustomPropertyKey("ShowKeybinds"), 1) != 0)
			{
				KeybindHints.AddHint("to ready up all bots", "[R]", (Vector2?)null);
			}
		}
	}
	[HarmonyPatch(typeof(PlayerSpotlight))]
	internal class RWFAddSpotToPlayerPatch
	{
		[HarmonyPatch("AddSpotToPlayer")]
		public static bool Prefix(Player player)
		{
			return !((Behaviour)((Component)player).GetComponent<PlayerAPI>()).enabled;
		}
	}
}
namespace RoundsWithBots.Menu
{
	internal static class RWBMenu
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static UnityAction <>9__4_0;

			public static UnityAction<float> <>9__4_1;

			public static UnityAction<float> <>9__4_2;

			public static UnityAction<float> <>9__4_3;

			public static UnityAction<float> <>9__4_4;

			public static UnityAction <>9__8_0;

			public static UnityAction<bool> <>9__8_1;

			public static UnityAction<float> <>9__8_2;

			public static UnityAction <>9__10_0;

			public static UnityAction<bool> <>9__11_0;

			public static UnityAction <>9__16_0;

			public static UnityAction<float> <>9__16_1;

			public static UnityAction<float> <>9__16_2;

			public static UnityAction<float> <>9__16_3;

			internal void <CreateCardsPickerMenu>b__4_0()
			{
			}

			internal void <CreateCardsPickerMenu>b__4_1(float value)
			{
				CycleDelay.Value = value;
			}

			internal void <CreateCardsPickerMenu>b__4_2(float value)
			{
				PreCycleDelay.Value = value;
			}

			internal void <CreateCardsPickerMenu>b__4_3(float value)
			{
				GoToCardDelay.Value = value;
			}

			internal void <CreateCardsPickerMenu>b__4_4(float value)
			{
				PickDelay.Value = value;
			}

			internal void <CreateDetailsMenu>b__8_0()
			{
			}

			internal void <CreateDetailsMenu>b__8_1(bool value)
			{
				RandomizationFace.Value = value;
				SelectedFaceObject.SetActive(!value);
			}

			internal void <CreateDetailsMenu>b__8_2(float value)
			{
				SelectedFace.Value = (int)value;
			}

			internal void <RegisterMenu>b__10_0()
			{
			}

			internal void <CreateRWBMenu>b__11_0(bool value)
			{
				DebugMode.Value = value;
			}

			internal void <CreateStalemateMenu>b__16_0()
			{
			}

			internal void <CreateStalemateMenu>b__16_1(float value)
			{
				StalemateTimer.Value = value;
			}

			internal void <CreateStalemateMenu>b__16_2(float value)
			{
				StalemateDamageCooldown.Value = value;
			}

			internal void <CreateStalemateMenu>b__16_3(float value)
			{
				StalemateDamageDuration.Value = value;
			}
		}

		public static ConfigEntry<float> CycleDelay;

		public static ConfigEntry<float> PreCycleDelay;

		public static ConfigEntry<float> GoToCardDelay;

		public static ConfigEntry<float> PickDelay;

		public static GameObject SelectedFaceObject;

		public static ConfigEntry<bool> RandomizationFace;

		public static ConfigEntry<int> SelectedFace;

		public static ConfigEntry<bool> DebugMode;

		public static ConfigEntry<float> StalemateTimer;

		public static ConfigEntry<float> StalemateDamageCooldown;

		public static ConfigEntry<float> StalemateDamageDuration;

		private static void CreateCardsPickerMenu(GameObject mainMenu)
		{
			//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_0025: Expected O, but got Unknown
			object obj = <>c.<>9__4_0;
			if (obj == null)
			{
				UnityAction val = delegate
				{
				};
				<>c.<>9__4_0 = val;
				obj = (object)val;
			}
			GameObject val2 = MenuHandler.CreateMenu("Cards Picker", (UnityAction)obj, mainMenu, 40, true, true, ((Component)mainMenu.transform.parent).gameObject, true, -1);
			TextMeshProUGUI val3 = default(TextMeshProUGUI);
			MenuHandler.CreateText("<b>Rounds With Bots | Cards Picker", val2, ref val3, 70, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			AddBlank(val2, 50);
			Slider val4 = default(Slider);
			MenuHandler.CreateSlider("Cycle Delay", val2, 30, 0f, 1f, CycleDelay.Value, (UnityAction<float>)delegate(float value)
			{
				CycleDelay.Value = value;
			}, ref val4, false, (Color?)null, (Direction)0, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			AddBlank(val2, 20);
			MenuHandler.CreateSlider("Pre-Cycle Delay", val2, 30, 0f, 5f, PreCycleDelay.Value, (UnityAction<float>)delegate(float value)
			{
				PreCycleDelay.Value = value;
			}, ref val4, false, (Color?)null, (Direction)0, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			AddBlank(val2, 20);
			MenuHandler.CreateSlider("Go To Card Delay", val2, 30, 0f, 1f, GoToCardDelay.Value, (UnityAction<float>)delegate(float value)
			{
				GoToCardDelay.Value = value;
			}, ref val4, false, (Color?)null, (Direction)0, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			AddBlank(val2, 20);
			MenuHandler.CreateSlider("Pick Delay", val2, 30, 0f, 5f, PickDelay.Value, (UnityAction<float>)delegate(float value)
			{
				PickDelay.Value = value;
			}, ref val4, false, (Color?)null, (Direction)0, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
		}

		private static void CreateDetailsMenu(GameObject mainMenu)
		{
			//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_0025: Expected O, but got Unknown
			object obj = <>c.<>9__8_0;
			if (obj == null)
			{
				UnityAction val = delegate
				{
				};
				<>c.<>9__8_0 = val;
				obj = (object)val;
			}
			GameObject val2 = MenuHandler.CreateMenu("Bot Details", (UnityAction)obj, mainMenu, 40, true, true, ((Component)mainMenu.transform.parent).gameObject, true, -1);
			TextMeshProUGUI val3 = default(TextMeshProUGUI);
			MenuHandler.CreateText("<b>Rounds With Bots | Bot Details", val2, ref val3, 70, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			AddBlank(val2, 50);
			MenuHandler.CreateToggle(RandomizationFace.Value, "Randomize Bot Faces", val2, (UnityAction<bool>)delegate(bool value)
			{
				RandomizationFace.Value = value;
				SelectedFaceObject.SetActive(!value);
			}, 30, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			AddBlank(val2, 20);
			Slider val4 = default(Slider);
			SelectedFaceObject = MenuHandler.CreateSlider("Selected Bot Face", val2, 30, 0f, 7f, (float)SelectedFace.Value, (UnityAction<float>)delegate(float value)
			{
				SelectedFace.Value = (int)value;
			}, ref val4, true, (Color?)null, (Direction)0, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			SelectedFaceObject.SetActive(!RandomizationFace.Value);
		}

		public static void RegisterMenu(string modName, ConfigFile config)
		{
			//IL_0016: 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: Expected O, but got Unknown
			object obj = <>c.<>9__10_0;
			if (obj == null)
			{
				UnityAction val = delegate
				{
				};
				<>c.<>9__10_0 = val;
				obj = (object)val;
			}
			Unbound.RegisterMenu(modName, (UnityAction)obj, (Action<GameObject>)CreateRWBMenu, (GameObject)null, false);
			DebugMode = config.Bind<bool>(modName, "DebugMode", false, "Enable or disable debug mode for additional logging and debugging features.");
			RandomizationFace = config.Bind<bool>(modName, "RandomizationFace", true, "Enable or disable randomization of bot faces.");
			SelectedFace = config.Bind<int>(modName, "SelectedFace", 0, "Select a specific bot face when Randomize Bot Faces is disabled.");
			StalemateTimer = config.Bind<float>(modName, "StalemateTimer", 10f, "The time in seconds before a stalemate is declared.");
			StalemateDamageCooldown = config.Bind<float>(modName, "StalemateDamageCooldown", 1f, "The time in seconds before a player can take damage again after a stalemate.");
			StalemateDamageDuration = config.Bind<float>(modName, "StalemateDamageDuration", 10f, "The time in seconds that a player takes damage after a stalemate.");
			CycleDelay = config.Bind<float>(modName, "CycleDelay", 0.3f, "The delay between cycling through cards.");
			PreCycleDelay = config.Bind<float>(modName, "PreCycleDelay", 1f, "The delay before cycling through cards.");
			GoToCardDelay = config.Bind<float>(modName, "GoToCardDelay", 0.2f, "The delay between going to a specific card.");
			PickDelay = config.Bind<float>(modName, "PickDelay", 0.5f, "The delay before picking a card.");
		}

		private static void CreateRWBMenu(GameObject mainMenu)
		{
			TextMeshProUGUI val = default(TextMeshProUGUI);
			MenuHandler.CreateText("<b>Rounds With Bots", mainMenu, ref val, 70, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			AddBlank(mainMenu, 50);
			CreateDetailsMenu(mainMenu);
			AddBlank(mainMenu, 20);
			CreateStalemateMenu(mainMenu);
			AddBlank(mainMenu, 20);
			CreateCardsPickerMenu(mainMenu);
			AddBlank(mainMenu, 20);
			MenuHandler.CreateToggle(DebugMode.Value, "<#c41010>Debug Mode", mainMenu, (UnityAction<bool>)delegate(bool value)
			{
				DebugMode.Value = value;
			}, 30, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
		}

		private static void AddBlank(GameObject menu, int size = 30)
		{
			TextMeshProUGUI val = default(TextMeshProUGUI);
			MenuHandler.CreateText(" ", menu, ref val, size, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
		}

		private static void CreateStalemateMenu(GameObject mainMenu)
		{
			//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_0025: Expected O, but got Unknown
			object obj = <>c.<>9__16_0;
			if (obj == null)
			{
				UnityAction val = delegate
				{
				};
				<>c.<>9__16_0 = val;
				obj = (object)val;
			}
			GameObject val2 = MenuHandler.CreateMenu("Stalemate Options", (UnityAction)obj, mainMenu, 40, true, true, ((Component)mainMenu.transform.parent).gameObject, true, -1);
			TextMeshProUGUI val3 = default(TextMeshProUGUI);
			MenuHandler.CreateText("<b>Rounds With Bots | Stalemate Options", val2, ref val3, 70, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			AddBlank(val2, 50);
			Slider val4 = default(Slider);
			MenuHandler.CreateSlider("Stalemate Timer", val2, 30, 0f, 60f, StalemateTimer.Value, (UnityAction<float>)delegate(float value)
			{
				StalemateTimer.Value = value;
			}, ref val4, false, (Color?)null, (Direction)0, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			AddBlank(val2, 20);
			MenuHandler.CreateSlider("Stalemate Damage Cooldown", val2, 30, 0f, 60f, StalemateDamageCooldown.Value, (UnityAction<float>)delegate(float value)
			{
				StalemateDamageCooldown.Value = value;
			}, ref val4, false, (Color?)null, (Direction)0, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			AddBlank(val2, 20);
			MenuHandler.CreateSlider("Stalemate Damage Duration", val2, 30, 0f, 60f, StalemateDamageDuration.Value, (UnityAction<float>)delegate(float value)
			{
				StalemateDamageDuration.Value = value;
			}, ref val4, false, (Color?)null, (Direction)0, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
		}
	}
}
namespace RoundsWithBots.Extensions
{
	[Serializable]
	public class CharacterDataAdditionalData
	{
		public bool IsBot { get; set; }

		public CharacterDataAdditionalData()
		{
			IsBot = false;
		}
	}
	public static class CharacterDataExtension
	{
		public static readonly ConditionalWeakTable<CharacterData, CharacterDataAdditionalData> data = new ConditionalWeakTable<CharacterData, CharacterDataAdditionalData>();

		public static CharacterDataAdditionalData GetAdditionalData(this CharacterData characterData)
		{
			return data.GetOrCreateValue(characterData);
		}

		public static void AddData(this CharacterData characterData, CharacterDataAdditionalData value)
		{
			try
			{
				data.Add(characterData, value);
			}
			catch (Exception)
			{
			}
		}
	}
}
namespace RoundsWithBots.CardPickerAIs
{
	public interface ICardPickerAI
	{
		List<CardInfo> PickCard(List<CardInfo> cards);
	}
	public class RarestCardPicker : ICardPickerAI
	{
		public List<CardInfo> PickCard(List<CardInfo> cards)
		{
			return (from card in cards
				group card by card.rarity into @group
				orderby @group.Key
				select @group).LastOrDefault()?.ToList();
		}
	}
}
namespace RoundsWithBots.CardPickerAIs.Weighted
{
	public interface IWeightedCardProcessor
	{
		float GetWeight(CardInfo card, Player player);
	}
	public class WeightedCardsPicker : ICardPickerAI
	{
		public List<IWeightedCardProcessor> CardProcessors { get; set; }

		public WeightedCardsPicker(List<IWeightedCardProcessor> cardProcessors)
		{
			CardProcessors = cardProcessors;
		}

		public WeightedCardsPicker()
			: this(GetDefaultWeightedCardProcessors())
		{
		}

		public List<CardInfo> PickCard(List<CardInfo> cards)
		{
			Player player = PlayerManager.instance.players.Find((Player p) => p.playerID == CardChoice.instance.pickrID);
			Dictionary<CardInfo, float> cardWeights = new Dictionary<CardInfo, float>();
			foreach (CardInfo card in cards)
			{
				float num = 1f;
				foreach (IWeightedCardProcessor cardProcessor in CardProcessors)
				{
					num *= cardProcessor.GetWeight(card, player);
					LoggerUtils.Log($"Card '{card.cardName}' processed by '{cardProcessor.GetType().Name}' with weight: {num}");
				}
				cardWeights[card] = num;
				LoggerUtils.Log($"Card '{card.cardName}' has weight: {num}");
			}
			List<CardInfo> list = new List<CardInfo>(cardWeights.Keys);
			list.Sort((CardInfo a, CardInfo b) => cardWeights[b].CompareTo(cardWeights[a]));
			if (list.Count > 0)
			{
				return new List<CardInfo> { list[0] };
			}
			return new List<CardInfo>();
		}

		public static List<IWeightedCardProcessor> GetDefaultWeightedCardProcessors()
		{
			List<IWeightedCardProcessor> list = new List<IWeightedCardProcessor>
			{
				new RarityWeightedCardProcessor(),
				new StatsWeightedCardProcessor(),
				new ThemedWeightedCardProcessor(1.5f, 0.5f),
				new CurseWeightedCardProcessor()
			};
			if (RoundsWithBots.Plugins.Any((BaseUnityPlugin plugin) => plugin.Info.Metadata.GUID == "root.classes.manager.reborn"))
			{
				list.Add(new WeighteClassesCardProcessor(2f));
			}
			return list;
		}
	}
}
namespace RoundsWithBots.CardPickerAIs.Weighted.WeightedCardProcessesor
{
	public class WeighteClassesCardProcessor : IWeightedCardProcessor
	{
		private readonly float multiplier;

		public WeighteClassesCardProcessor(float multiplier = 1f)
		{
			this.multiplier = multiplier;
		}

		public float GetWeight(CardInfo card, Player player)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: 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_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Invalid comparison between Unknown and I4
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Invalid comparison between Unknown and I4
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Invalid comparison between Unknown and I4
			ClassObject val = ClassesRegistry.Get(card);
			if (val == null)
			{
				return 1f;
			}
			CardType type = val.type;
			CardType val2 = type;
			if ((int)val2 != 1)
			{
				if ((int)val2 != 2)
				{
					if ((int)val2 == 16)
					{
						return 2f * multiplier;
					}
					return 1f;
				}
				return 1.5f * multiplier;
			}
			return 1.5f * multiplier;
		}
	}
	public class RarityWeightedCardProcessor : IWeightedCardProcessor
	{
		private readonly float multiplier;

		public RarityWeightedCardProcessor(float multiplier = 0.25f)
		{
			this.multiplier = multiplier;
		}

		public float GetWeight(CardInfo card, Player player)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return 1f / RarityUtils.GetRarityData(card.rarity).calculatedRarity * multiplier;
		}
	}
	public class StatsWeightedCardProcessor : IWeightedCardProcessor
	{
		private readonly float multiplier;

		public StatsWeightedCardProcessor(float multiplier = 1.25f)
		{
			this.multiplier = multiplier;
		}

		public float GetWeight(CardInfo card, Player player)
		{
			float num = 1f;
			CardInfoStat[] cardStats = card.cardStats;
			foreach (CardInfoStat val in cardStats)
			{
				num = ((!val.positive) ? (num * (1f / multiplier)) : (num * multiplier));
			}
			return num;
		}
	}
	public class ThemedWeightedCardProcessor : IWeightedCardProcessor
	{
		private readonly float multiplier;

		private readonly float minimumWeight;

		public ThemedWeightedCardProcessor(float multiplier = 1.5f, float minimumWeight = 0.1f)
		{
			this.multiplier = multiplier;
			this.minimumWeight = minimumWeight;
		}

		public float GetWeight(CardInfo card, Player player)
		{
			//IL_01a4: 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)
			Dictionary<CardThemeColorType, int> dictionary = (from c in player.data.currentCards
				group c by c.colorTheme).ToDictionary((IGrouping<CardThemeColorType, CardInfo> g) => g.Key, (IGrouping<CardThemeColorType, CardInfo> g) => g.Count());
			LoggerUtils.Log(string.Format("Player {0} themes: {1}", player.playerID, string.Join(", ", dictionary.Select((KeyValuePair<CardThemeColorType, int> kvp) => $"{kvp.Key}: {kvp.Value}"))));
			int highestThemeAmount = (dictionary.Values.Any() ? dictionary.Values.Max() : 0);
			if (highestThemeAmount == 0)
			{
				return 1f;
			}
			LoggerUtils.Log($"Highest theme amount for player {player.playerID}: {highestThemeAmount}");
			Dictionary<CardThemeColorType, float> dictionary2 = dictionary.ToDictionary((KeyValuePair<CardThemeColorType, int> kvp) => kvp.Key, (KeyValuePair<CardThemeColorType, int> kvp) => (float)kvp.Value / (float)highestThemeAmount);
			LoggerUtils.Log(string.Format("Player {0} theme weights: {1}", player.playerID, string.Join(", ", dictionary2.Select((KeyValuePair<CardThemeColorType, float> kvp) => $"{kvp.Key}: {kvp.Value}"))));
			if (dictionary2.TryGetValue(card.colorTheme, out var value))
			{
				LoggerUtils.Log($"Card '{card.cardName}' matches theme '{card.colorTheme}' with weight: {value}");
				return Mathf.Max(minimumWeight, (value + 1f) * multiplier);
			}
			return minimumWeight;
		}
	}
	public class CurseWeightedCardProcessor : IWeightedCardProcessor
	{
		private static readonly CardCategory curseCategory = CustomCardCategories.instance.CardCategory("Curse");

		private readonly float curseMultiplier;

		public CurseWeightedCardProcessor(float curseMultiplier = 0.01f)
		{
			this.curseMultiplier = curseMultiplier;
		}

		public float GetWeight(CardInfo card, Player player)
		{
			if (card.categories.Contains(curseCategory))
			{
				return curseMultiplier;
			}
			return 1f;
		}
	}
}
namespace RoundsWithBots.Mods.Interfaces
{
	public static class PickPhaseImprovementsInterrface
	{
		public static void RegisterHandFinalizationAction(Action<CardInfo[]> func)
		{
			PickManager.RegisterHandFinalizationAction(func);
		}
	}
}