Decompiled source of Pick N Cards Plus v0.3.0

PickNCardsPlus.dll

Decompiled 6 months 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 BepInEx;
using BepInEx.Configuration;
using DrawNCardsPlus;
using HarmonyLib;
using Photon.Pun;
using PickNCardsPlus;
using TMPro;
using UnboundLib;
using UnboundLib.GameModes;
using UnboundLib.Networking;
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(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("PickNCardsPlus")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("PickNCardsPlus")]
[assembly: AssemblyTitle("PickNCardsPlus")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace PickNCardsPlus
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("pykess.rounds.plugins.pickncardsplus", "Pick N Cards Plus", "0.0.1")]
	[BepInProcess("Rounds.exe")]
	public class PickNCardsPlus : BaseUnityPlugin
	{
		[Serializable]
		[HarmonyPatch(typeof(CardChoiceVisuals), "Show")]
		[HarmonyPriority(800)]
		private class CardChoiceVisualsPatchShow
		{
			private static bool Prefix(CardChoice __instance)
			{
				if (picks == 0)
				{
					return false;
				}
				return true;
			}
		}

		[Serializable]
		[HarmonyPatch(typeof(CardChoice), "DoPick")]
		[HarmonyPriority(800)]
		private class CardChoicePatchDoPick
		{
			private static bool Prefix(CardChoice __instance)
			{
				if (picks == 0)
				{
					return false;
				}
				return true;
			}

			private static void Postfix(CardChoice __instance, int picketIDToSet)
			{
				if (!lockPickQueue && !playerIDsToPick.Contains(picketIDToSet))
				{
					playerIDsToPick.Add(picketIDToSet);
				}
			}
		}

		[HarmonyPatch]
		private class CardChoicePatchReplaceCards
		{
			private static Type GetNestedReplaceCardsType()
			{
				Type[] nestedTypes = typeof(CardChoice).GetNestedTypes(BindingFlags.Instance | BindingFlags.NonPublic);
				Type result = null;
				Type[] array = nestedTypes;
				foreach (Type type in array)
				{
					if (type.Name.Contains("ReplaceCards"))
					{
						result = type;
						break;
					}
				}
				return result;
			}

			private static MethodBase TargetMethod()
			{
				return AccessTools.Method(GetNestedReplaceCardsType(), "MoveNext", (Type[])null, (Type[])null);
			}

			private static float GetNewDelay()
			{
				return delay;
			}

			private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
			{
				//IL_0101: Unknown result type (might be due to invalid IL or missing references)
				//IL_010b: Expected O, but got Unknown
				List<CodeInstruction> list = instructions.ToList();
				FieldInfo fieldInfo = ExtensionMethods.GetFieldInfo(typeof(PublicInt), "theInt");
				MethodInfo methodInfo = ExtensionMethods.GetMethodInfo(typeof(CardChoicePatchReplaceCards), "GetNewDelay");
				int num = -1;
				for (int i = 0; i < list.Count; i++)
				{
					if (CodeInstructionExtensions.StoresField(list[i], fieldInfo) && list[i + 1].opcode == OpCodes.Ldarg_0 && list[i + 2].opcode == OpCodes.Ldc_R4 && (float)list[i + 2].operand == 0.1f && list[i + 3].opcode == OpCodes.Newobj)
					{
						num = i;
						break;
					}
				}
				if (num == -1)
				{
					throw new Exception("[REPLACECARDS PATCH] INSTRUCTION NOT FOUND");
				}
				list[num + 2] = new CodeInstruction(OpCodes.Call, (object)methodInfo);
				return list.AsEnumerable();
			}
		}

		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static UnityAction <>9__16_0;

			public static Func<IGameModeHandler, IEnumerator> <>9__16_1;

			internal void <Start>b__16_0()
			{
			}

			internal IEnumerator <Start>b__16_1(IGameModeHandler gm)
			{
				return ResetPickQueue();
			}
		}

		private const string ModId = "pykess.rounds.plugins.pickncardsplus";

		private const string ModName = "Pick N Cards Plus";

		private const string CompatibilityModName = "PickNCardsPlus";

		private const int maxPicks = 5;

		internal static PickNCardsPlus instance;

		public static ConfigEntry<int> StartPicksConfig;

		public static ConfigEntry<int> PicksConfig;

		public static ConfigEntry<float> DelayConfig;

		internal static bool startPick;

		internal static int startPicks;

		internal static int picks;

		internal static float delay;

		internal static bool lockPickQueue = false;

		internal static List<int> playerIDsToPick = new List<int>();

		internal static bool extraPicksInPorgress = false;

		private void Awake()
		{
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			instance = this;
			StartPicksConfig = ((BaseUnityPlugin)this).Config.Bind<int>("PickNCardsPlus", "Start Picks", 1, "Total number of card picks per player at the start phase");
			PicksConfig = ((BaseUnityPlugin)this).Config.Bind<int>("PickNCardsPlus", "Picks", 1, "Total number of card picks per player per pick phase");
			global::DrawNCardsPlus.DrawNCardsPlus.StartNumDrawsConfig = ((BaseUnityPlugin)this).Config.Bind<int>("PickNCardsPlus", "Start Draws", 5, "Number of cards drawn from the deck to choose from at the start of the game");
			global::DrawNCardsPlus.DrawNCardsPlus.NumDrawsConfig = ((BaseUnityPlugin)this).Config.Bind<int>("PickNCardsPlus", "Draws", 5, "Number of cards drawn from the deck to choose from");
			DelayConfig = ((BaseUnityPlugin)this).Config.Bind<float>("PickNCardsPlus", "DelayBetweenDraws", 0.1f, "Delay (in seconds) between each card being drawn.");
			new Harmony("pykess.rounds.plugins.pickncardsplus").PatchAll();
		}

		private void Start()
		{
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Expected O, but got Unknown
			startPicks = StartPicksConfig.Value;
			picks = PicksConfig.Value;
			delay = DelayConfig.Value;
			Unbound.RegisterCredits("Pick N Cards", new string[2] { "Pykess (Code)", "Willis (Original picktwocards concept, icon)" }, new string[2] { "github", "Support Pykess" }, new string[2] { "https://github.com/pdcook/PickNCards", "https://ko-fi.com/pykess" });
			object obj = <>c.<>9__16_0;
			if (obj == null)
			{
				UnityAction val = delegate
				{
				};
				<>c.<>9__16_0 = val;
				obj = (object)val;
			}
			Unbound.RegisterMenu("Pick N Cards Plus", (UnityAction)obj, (Action<GameObject>)NewGUI, (GameObject)null, false);
			Unbound.RegisterHandshake("pykess.rounds.plugins.pickncardsplus", (Action)OnHandShakeCompleted);
			GameModeManager.AddHook("GameStart", (Func<IGameModeHandler, IEnumerator>)GameStart, 800);
			GameModeManager.AddHook("PickStart", (Func<IGameModeHandler, IEnumerator>)((IGameModeHandler gm) => ResetPickQueue()), 800);
			GameModeManager.AddHook("PickEnd", (Func<IGameModeHandler, IEnumerator>)ExtraPicks, 800);
			global::DrawNCardsPlus.DrawNCardsPlus.numDraws = global::DrawNCardsPlus.DrawNCardsPlus.NumDrawsConfig.Value;
			global::DrawNCardsPlus.DrawNCardsPlus.startNumDraws = global::DrawNCardsPlus.DrawNCardsPlus.StartNumDrawsConfig.Value;
		}

		internal static IEnumerator GameStart(IGameModeHandler gm)
		{
			if (startPicks > 0)
			{
				startPick = true;
			}
			yield break;
		}

		private void OnHandShakeCompleted()
		{
			if (PhotonNetwork.IsMasterClient)
			{
				NetworkingManager.RPC_Others(typeof(PickNCardsPlus), "SyncSettings", new object[4]
				{
					startPicks,
					picks,
					global::DrawNCardsPlus.DrawNCardsPlus.startNumDraws,
					global::DrawNCardsPlus.DrawNCardsPlus.numDraws
				});
			}
		}

		[UnboundRPC]
		private static void SyncSettings(int host_startPicks, int host_picks, int host_startDraws, int host_draws)
		{
			startPicks = host_startPicks;
			picks = host_picks;
			global::DrawNCardsPlus.DrawNCardsPlus.startNumDraws = host_startDraws;
			global::DrawNCardsPlus.DrawNCardsPlus.numDraws = host_draws;
		}

		private void NewGUI(GameObject menu)
		{
			TextMeshProUGUI val2 = default(TextMeshProUGUI);
			MenuHandler.CreateText("Pick N Cards Plus Options", menu, ref val2, 60, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			MenuHandler.CreateText(" ", menu, ref val2, 30, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			Slider val3 = default(Slider);
			MenuHandler.CreateSlider("Number of starter cards to pick", menu, 30, 0f, 5f, (float)StartPicksConfig.Value, (UnityAction<float>)StartPicksChanged, ref val3, true, (Color?)null, (Direction)0, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			MenuHandler.CreateText(" ", menu, ref val2, 30, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			MenuHandler.CreateSlider("Number of cards to pick", menu, 30, 0f, 5f, (float)PicksConfig.Value, (UnityAction<float>)PicksChanged, ref val3, true, (Color?)null, (Direction)0, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			MenuHandler.CreateText(" ", menu, ref val2, 30, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			MenuHandler.CreateText("Draw N Cards Options", menu, ref val2, 60, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			MenuHandler.CreateText(" ", menu, ref val2, 30, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			MenuHandler.CreateSlider("Number of cards to draw at start", menu, 30, 1f, 20f, (float)global::DrawNCardsPlus.DrawNCardsPlus.StartNumDrawsConfig.Value, (UnityAction<float>)StartDrawsChanged, ref val3, true, (Color?)null, (Direction)0, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			MenuHandler.CreateText(" ", menu, ref val2, 30, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			MenuHandler.CreateSlider("Number of cards to draw", menu, 30, 1f, 20f, (float)global::DrawNCardsPlus.DrawNCardsPlus.NumDrawsConfig.Value, (UnityAction<float>)DrawsChanged, ref val3, true, (Color?)null, (Direction)0, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			MenuHandler.CreateText(" ", menu, ref val2, 30, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			MenuHandler.CreateSlider("Time between each card draw", menu, 30, 0f, 0.5f, DelayConfig.Value, (UnityAction<float>)DelayChanged, ref val3, false, (Color?)null, (Direction)0, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			MenuHandler.CreateText(" ", menu, ref val2, 30, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			static void DelayChanged(float val)
			{
				DelayConfig.Value = Mathf.Clamp(val, 0f, 0.5f);
				delay = DelayConfig.Value;
			}
			void DrawsChanged(float val)
			{
				global::DrawNCardsPlus.DrawNCardsPlus.NumDrawsConfig.Value = Mathf.RoundToInt(Mathf.Clamp(val, 1f, 20f));
				global::DrawNCardsPlus.DrawNCardsPlus.numDraws = global::DrawNCardsPlus.DrawNCardsPlus.NumDrawsConfig.Value;
				OnHandShakeCompleted();
			}
			void PicksChanged(float val)
			{
				PicksConfig.Value = Mathf.RoundToInt(Mathf.Clamp(val, 0f, 5f));
				picks = PicksConfig.Value;
				OnHandShakeCompleted();
			}
			void StartDrawsChanged(float val)
			{
				global::DrawNCardsPlus.DrawNCardsPlus.StartNumDrawsConfig.Value = Mathf.RoundToInt(Mathf.Clamp(val, 1f, 20f));
				global::DrawNCardsPlus.DrawNCardsPlus.startNumDraws = global::DrawNCardsPlus.DrawNCardsPlus.StartNumDrawsConfig.Value;
				OnHandShakeCompleted();
			}
			void StartPicksChanged(float val)
			{
				StartPicksConfig.Value = Mathf.RoundToInt(Mathf.Clamp(val, 0f, 5f));
				startPicks = StartPicksConfig.Value;
				OnHandShakeCompleted();
			}
		}

		[UnboundRPC]
		public static void RPC_RequestSync(int requestingPlayer)
		{
			NetworkingManager.RPC(typeof(PickNCardsPlus), "RPC_SyncResponse", new object[2]
			{
				requestingPlayer,
				PhotonNetwork.LocalPlayer.ActorNumber
			});
		}

		[UnboundRPC]
		public static void RPC_SyncResponse(int requestingPlayer, int readyPlayer)
		{
			if (PhotonNetwork.LocalPlayer.ActorNumber == requestingPlayer)
			{
				MonoBehaviourExtensions.RemovePendingRequest((MonoBehaviour)(object)instance, readyPlayer, "RPC_RequestSync");
			}
		}

		private IEnumerator WaitForSyncUp()
		{
			if (!PhotonNetwork.OfflineMode)
			{
				yield return MonoBehaviourExtensions.SyncMethod((MonoBehaviour)(object)this, "RPC_RequestSync", (int[])null, new object[1] { PhotonNetwork.LocalPlayer.ActorNumber });
			}
		}

		internal static IEnumerator ResetPickQueue()
		{
			if (!extraPicksInPorgress)
			{
				playerIDsToPick = new List<int>();
				lockPickQueue = false;
			}
			yield break;
		}

		internal static IEnumerator ExtraPicks(IGameModeHandler gm)
		{
			if (extraPicksInPorgress || (picks <= 1 && !startPick) || (startPicks <= 1 && startPick) || playerIDsToPick.Count() < 1)
			{
				yield break;
			}
			lockPickQueue = true;
			extraPicksInPorgress = true;
			yield return instance.WaitForSyncUp();
			for (int _ = 0; _ < (startPick ? startPicks : picks) - 1; _++)
			{
				yield return instance.WaitForSyncUp();
				for (int i = 0; i < playerIDsToPick.Count(); i++)
				{
					yield return instance.WaitForSyncUp();
					int playerID = playerIDsToPick[i];
					yield return GameModeManager.TriggerHook("PlayerPickStart");
					CardChoiceVisuals.instance.Show(playerID, true);
					yield return CardChoice.instance.DoPick(1, playerID, (PickerType)1);
					yield return (object)new WaitForSecondsRealtime(0.1f);
					yield return GameModeManager.TriggerHook("PlayerPickEnd");
					yield return (object)new WaitForSecondsRealtime(0.1f);
				}
			}
			CardChoiceVisuals.instance.Hide();
			extraPicksInPorgress = false;
			startPick = false;
		}
	}
}
namespace DrawNCardsPlus
{
	public class DrawNCardsPlus
	{
		internal const int maxDraws = 20;

		public static ConfigEntry<int> StartNumDrawsConfig;

		public static ConfigEntry<int> NumDrawsConfig;

		internal static int startNumDraws;

		internal static int numDraws;

		private const float arc_A = 0.21020408f;

		private const float arc_B = 1.9591837f;

		private const float arc_C = -1.9591837f;

		private const float Harc_A = 1f;

		private const float Harc_B = 2f;

		private const float Harc_C = -1.7f;

		private const float xC = 0.5f;

		private const float yC = 0.5f;

		private const float absMaxX = 0.85f;

		private const float defMaxXWorld = 25f;

		internal const float z = -5f;

		private const float maxPhi = 15f;

		internal static float Arc(float x, float offset = 0f)
		{
			if (offset == 0f)
			{
				return -1.9591837f * x * x + 1.9591837f * x + 0.21020408f + offset;
			}
			if (offset < 0f)
			{
				return 0f - Mathf.Sqrt(1f + 4f * Mathf.Pow(x - 0.5f, 2f) / 1f) - -1.7f + offset;
			}
			return 0f - Mathf.Sqrt(1f + 4f * Mathf.Pow(x - 0.5f, 2f) / 2f) - -1.7f + offset;
		}

		internal static List<Vector3> GetPositions(int N, float offset = 0f)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			if (N == 0)
			{
				throw new Exception("Must have at least one card.");
			}
			if (N == 1)
			{
				return new List<Vector3>
				{
					new Vector3(0.5f, 0.5f, -5f)
				};
			}
			if (N == 3)
			{
				offset -= 0.025f;
			}
			else if (N > 10)
			{
				int num = Mathf.RoundToInt((float)(N / 2));
				int num2 = N - num;
				int n;
				int n2;
				if (num >= num2)
				{
					n = num;
					n2 = num2;
				}
				else
				{
					n = num2;
					n2 = num;
				}
				List<Vector3> positions = GetPositions(n, offset - 0.16f);
				List<Vector3> positions2 = GetPositions(n2, offset + 0.125f);
				return positions.Concat(positions2).ToList();
			}
			float num3 = 0.85f;
			num3 = ((N >= 4) ? Mathf.Clamp(num3 + 0.025f * (float)(N - 5), num3, 0.925f) : 0.75f);
			List<float> list = new List<float>();
			float num4 = 0.5f;
			if (N % 2 != 0)
			{
				num4 = 0.5f;
				list.Add(num4);
				N--;
				int num5 = N / 2;
				float num6 = (num3 - num4) / (float)num5;
				float num7 = num4;
				for (int i = 0; i < num5; i++)
				{
					num7 += num6;
					list.Add(num7);
					list.Add(1f - num7);
				}
			}
			else
			{
				num4 = 1f - num3;
				float num8 = (num3 - num4) / (float)(N - 1);
				float num9 = num4;
				for (int j = 0; j < N; j++)
				{
					list.Add(num9);
					num9 += num8;
				}
			}
			list.Sort();
			List<Vector3> list2 = new List<Vector3>();
			foreach (float item in list)
			{
				list2.Add(new Vector3(item, Arc(item, offset), -5f));
			}
			return list2;
		}

		internal static Vector3 GetScale(int N)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: 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_0078: 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_0108: 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_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			float num = 1.04f * 0.85f.xWorldPoint() / 25f;
			if (N == 5)
			{
				return new Vector3(1f, 1f, 1f) * num;
			}
			if (N < 5)
			{
				return new Vector3(1f, 1f, 1f) * num * (1f + 1f / (2f * (float)N));
			}
			if (N > 10)
			{
				return new Vector3(1f, 1f, 1f) * num * Mathf.Clamp(5f / (float)(N / 2 + 2), 0.6f, 1f);
			}
			return new Vector3(1f, 1f, 1f) * num * Mathf.Clamp(5f / (float)(N - 1), 0.6f, 1f);
		}

		internal static float ArcAngle(float x)
		{
			return -42.85714f * (x - 0.5f);
		}

		internal static List<Quaternion> GetRotations(int N)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			List<Vector3> positions = GetPositions(N);
			List<Quaternion> list = new List<Quaternion>();
			foreach (Vector3 item in positions)
			{
				list.Add(Quaternion.Euler(0f, 0f, ArcAngle(item.x)));
			}
			return list;
		}
	}
	[Serializable]
	[HarmonyPatch(typeof(CardChoice), "Spawn")]
	internal class CardChoicePatchSpawn
	{
		private static void Postfix(ref GameObject __result)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			__result.transform.localScale = DrawNCardsPlus.GetScale(global::PickNCardsPlus.PickNCardsPlus.startPick ? DrawNCardsPlus.startNumDraws : DrawNCardsPlus.numDraws);
			NetworkingManager.RPC_Others(typeof(CardChoicePatchSpawn), "RPCO_AddRemotelySpawnedCard", new object[1] { __result.GetComponent<PhotonView>().ViewID });
		}

		[UnboundRPC]
		private static void RPCO_AddRemotelySpawnedCard(int viewID)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			GameObject gameObject = ((Component)PhotonView.Find(viewID)).gameObject;
			gameObject.transform.localScale = DrawNCardsPlus.GetScale(global::PickNCardsPlus.PickNCardsPlus.startPick ? DrawNCardsPlus.startNumDraws : DrawNCardsPlus.numDraws);
		}
	}
	[Serializable]
	[HarmonyPatch(typeof(CardChoice), "StartPick")]
	internal class CardChoicePatchStartPick
	{
		private static GameObject _cardVis;

		private static GameObject cardVis
		{
			get
			{
				if ((Object)(object)_cardVis != (Object)null)
				{
					return _cardVis;
				}
				_cardVis = ((Component)((Transform[])ExtensionMethods.GetFieldValue((object)CardChoice.instance, "children"))[0]).gameObject;
				return _cardVis;
			}
			set
			{
			}
		}

		private static void Prefix(CardChoice __instance)
		{
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: 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_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			foreach (Transform item in ((Transform[])ExtensionMethods.GetFieldValue((object)CardChoice.instance, "children")).Skip(1))
			{
				Object.Destroy((Object)(object)((Component)item).gameObject);
			}
			List<Vector3> list = DrawNCardsPlus.GetPositions(global::PickNCardsPlus.PickNCardsPlus.startPick ? DrawNCardsPlus.startNumDraws : DrawNCardsPlus.numDraws).WorldPoint();
			List<Quaternion> rotations = DrawNCardsPlus.GetRotations(global::PickNCardsPlus.PickNCardsPlus.startPick ? DrawNCardsPlus.startNumDraws : DrawNCardsPlus.numDraws);
			Vector3 scale = DrawNCardsPlus.GetScale(global::PickNCardsPlus.PickNCardsPlus.startPick ? DrawNCardsPlus.startNumDraws : DrawNCardsPlus.numDraws);
			List<Transform> list2 = new List<Transform> { cardVis.transform };
			list2[0].position = list[0];
			list2[0].rotation = rotations[0];
			list2[0].localScale = scale;
			for (int i = 1; i < (global::PickNCardsPlus.PickNCardsPlus.startPick ? DrawNCardsPlus.startNumDraws : DrawNCardsPlus.numDraws); i++)
			{
				GameObject val = Object.Instantiate<GameObject>(cardVis, list[i], rotations[i], ((Component)__instance).transform);
				((Object)val).name = list2.Count.ToString();
				list2.Add(val.transform);
			}
			ExtensionMethods.SetFieldValue((object)__instance, "children", (object)list2.ToArray());
		}
	}
	[Serializable]
	[HarmonyPatch(typeof(CardChoiceVisuals), "Update")]
	internal class CardChoiceVisualsPatchUpdate
	{
		private static bool Prefix(CardChoiceVisuals __instance)
		{
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: 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_00d2: 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_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: 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)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0411: Unknown result type (might be due to invalid IL or missing references)
			//IL_0421: Unknown result type (might be due to invalid IL or missing references)
			//IL_042b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0436: Unknown result type (might be due to invalid IL or missing references)
			//IL_043b: Unknown result type (might be due to invalid IL or missing references)
			//IL_045c: Unknown result type (might be due to invalid IL or missing references)
			//IL_046c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0477: Unknown result type (might be due to invalid IL or missing references)
			//IL_047c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0487: Unknown result type (might be due to invalid IL or missing references)
			//IL_0491: Unknown result type (might be due to invalid IL or missing references)
			//IL_049b: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04db: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0516: Unknown result type (might be due to invalid IL or missing references)
			//IL_0578: Unknown result type (might be due to invalid IL or missing references)
			//IL_057d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0587: Unknown result type (might be due to invalid IL or missing references)
			//IL_058c: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: 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_0257: 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_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_0272: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0286: Unknown result type (might be due to invalid IL or missing references)
			//IL_028b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02db: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0301: Unknown result type (might be due to invalid IL or missing references)
			//IL_034f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0354: Unknown result type (might be due to invalid IL or missing references)
			//IL_035e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0363: Unknown result type (might be due to invalid IL or missing references)
			//IL_0384: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_05fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0606: Unknown result type (might be due to invalid IL or missing references)
			//IL_060b: Unknown result type (might be due to invalid IL or missing references)
			//IL_061d: 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_0637: Unknown result type (might be due to invalid IL or missing references)
			//IL_063c: Unknown result type (might be due to invalid IL or missing references)
			if (!(bool)ExtensionMethods.GetFieldValue((object)__instance, "isShowinig"))
			{
				return false;
			}
			if (Time.unscaledDeltaTime > 0.1f)
			{
				return false;
			}
			if (__instance.currentCardSelected >= __instance.cardParent.transform.childCount || __instance.currentCardSelected < 0)
			{
				return false;
			}
			if (__instance.rightHandTarget.position.x == float.NaN || __instance.rightHandTarget.position.y == float.NaN || __instance.rightHandTarget.position.z == float.NaN)
			{
				__instance.rightHandTarget.position = Vector3.zero;
				ExtensionMethods.SetFieldValue((object)__instance, "rightHandVel", (object)Vector3.zero);
			}
			if (__instance.leftHandTarget.position.x == float.NaN || __instance.leftHandTarget.position.y == float.NaN || __instance.leftHandTarget.position.z == float.NaN)
			{
				__instance.leftHandTarget.position = Vector3.zero;
				ExtensionMethods.SetFieldValue((object)__instance, "leftHandVel", (object)Vector3.zero);
			}
			GameObject gameObject = ((Component)__instance.cardParent.transform.GetChild(__instance.currentCardSelected)).gameObject;
			Vector3 position = gameObject.transform.GetChild(0).position;
			if (position.x < 0f)
			{
				ExtensionMethods.SetFieldValue((object)__instance, "leftHandVel", (object)((Vector3)ExtensionMethods.GetFieldValue((object)__instance, "leftHandVel") + (position - __instance.leftHandTarget.position) * __instance.spring * Time.unscaledDeltaTime));
				ExtensionMethods.SetFieldValue((object)__instance, "leftHandVel", (object)((Vector3)ExtensionMethods.GetFieldValue((object)__instance, "leftHandVel") - (Vector3)ExtensionMethods.GetFieldValue((object)__instance, "leftHandVel") * Time.unscaledDeltaTime * __instance.drag));
				ExtensionMethods.SetFieldValue((object)__instance, "rightHandVel", (object)((Vector3)ExtensionMethods.GetFieldValue((object)__instance, "rightHandVel") + ((Vector3)ExtensionMethods.GetFieldValue((object)__instance, "rightHandRestPos") - __instance.rightHandTarget.position) * __instance.spring * Time.unscaledDeltaTime * 0.5f));
				ExtensionMethods.SetFieldValue((object)__instance, "rightHandVel", (object)((Vector3)ExtensionMethods.GetFieldValue((object)__instance, "rightHandVel") - (Vector3)ExtensionMethods.GetFieldValue((object)__instance, "rightHandVel") * Time.unscaledDeltaTime * __instance.drag * 0.5f));
				ExtensionMethods.SetFieldValue((object)__instance, "rightHandVel", (object)((Vector3)ExtensionMethods.GetFieldValue((object)__instance, "rightHandVel") + __instance.sway * new Vector3(-0.5f + Mathf.PerlinNoise(Time.unscaledTime * __instance.swaySpeed, 0f), -0.5f + Mathf.PerlinNoise(Time.unscaledTime * __instance.swaySpeed + 100f, 0f), 0f) * Time.unscaledDeltaTime));
				((Component)__instance.shieldGem).transform.position = __instance.rightHandTarget.position;
				if (__instance.framesToSnap > 0)
				{
					__instance.leftHandTarget.position = position;
				}
			}
			else
			{
				ExtensionMethods.SetFieldValue((object)__instance, "rightHandVel", (object)((Vector3)ExtensionMethods.GetFieldValue((object)__instance, "rightHandVel") + (position - __instance.rightHandTarget.position) * __instance.spring * Time.unscaledDeltaTime));
				ExtensionMethods.SetFieldValue((object)__instance, "rightHandVel", (object)((Vector3)ExtensionMethods.GetFieldValue((object)__instance, "rightHandVel") - (Vector3)ExtensionMethods.GetFieldValue((object)__instance, "rightHandVel") * Time.unscaledDeltaTime * __instance.drag));
				ExtensionMethods.SetFieldValue((object)__instance, "leftHandVel", (object)((Vector3)ExtensionMethods.GetFieldValue((object)__instance, "leftHandVel") + ((Vector3)ExtensionMethods.GetFieldValue((object)__instance, "leftHandRestPos") - __instance.leftHandTarget.position) * __instance.spring * Time.unscaledDeltaTime * 0.5f));
				ExtensionMethods.SetFieldValue((object)__instance, "leftHandVel", (object)((Vector3)ExtensionMethods.GetFieldValue((object)__instance, "leftHandVel") - (Vector3)ExtensionMethods.GetFieldValue((object)__instance, "leftHandVel") * Time.unscaledDeltaTime * __instance.drag * 0.5f));
				ExtensionMethods.SetFieldValue((object)__instance, "leftHandVel", (object)((Vector3)ExtensionMethods.GetFieldValue((object)__instance, "leftHandVel") + __instance.sway * new Vector3(-0.5f + Mathf.PerlinNoise(Time.unscaledTime * __instance.swaySpeed, Time.unscaledTime * __instance.swaySpeed), -0.5f + Mathf.PerlinNoise(Time.unscaledTime * __instance.swaySpeed + 100f, Time.unscaledTime * __instance.swaySpeed + 100f), 0f) * Time.unscaledDeltaTime));
				((Component)__instance.shieldGem).transform.position = __instance.leftHandTarget.position;
				if (__instance.framesToSnap > 0)
				{
					__instance.rightHandTarget.position = position;
				}
			}
			__instance.framesToSnap--;
			Transform leftHandTarget = __instance.leftHandTarget;
			leftHandTarget.position += (Vector3)ExtensionMethods.GetFieldValue((object)__instance, "leftHandVel") * Time.unscaledDeltaTime;
			Transform rightHandTarget = __instance.rightHandTarget;
			rightHandTarget.position += (Vector3)ExtensionMethods.GetFieldValue((object)__instance, "rightHandVel") * Time.unscaledDeltaTime;
			return false;
		}
	}
	public static class WorldToScreenExtensions
	{
		public static Vector3 ScreenPoint(this Vector3 v3)
		{
			//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)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: 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)
			Vector3 result = ((Component)((Component)MainCam.instance).transform).GetComponent<Camera>().WorldToScreenPoint(v3);
			result.x /= Screen.width;
			result.y /= Screen.height;
			result.z = 0f;
			return result;
		}

		public static Vector3 WorldPoint(this Vector3 v3)
		{
			//IL_0032: 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_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: 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)
			v3.x *= Screen.width;
			v3.y *= Screen.height;
			Vector3 result = ((Component)((Component)MainCam.instance).transform).GetComponent<Camera>().ScreenToWorldPoint(v3);
			result.z = -5f;
			return result;
		}

		public static float xScreenPoint(this float x)
		{
			//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)
			return ScreenPoint(new Vector3(x, 0f, 0f)).x;
		}

		public static float xWorldPoint(this float x)
		{
			//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)
			return WorldPoint(new Vector3(x, 0f, 0f)).x;
		}

		public static float yScreenPoint(this float y)
		{
			//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)
			return ScreenPoint(new Vector3(0f, y, 0f)).y;
		}

		public static float yWorldPoint(this float y)
		{
			//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)
			return WorldPoint(new Vector3(0f, y, 0f)).y;
		}

		public static List<Vector3> ScreenPoint(this List<Vector3> v3)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: 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_001c: Unknown result type (might be due to invalid IL or missing references)
			List<Vector3> list = new List<Vector3>();
			foreach (Vector3 item in v3)
			{
				list.Add(item.ScreenPoint());
			}
			return list;
		}

		public static List<Vector3> WorldPoint(this List<Vector3> v3)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: 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_001c: Unknown result type (might be due to invalid IL or missing references)
			List<Vector3> list = new List<Vector3>();
			foreach (Vector3 item in v3)
			{
				list.Add(item.WorldPoint());
			}
			return list;
		}
	}
}