Decompiled source of InnateSkill v1.0.6

InnateSkill.dll

Decompiled a year 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 DrawNCards;
using HarmonyLib;
using InnateSkill;
using Microsoft.CodeAnalysis;
using Photon.Pun;
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("InnateSkill")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("InnateSkill")]
[assembly: AssemblyTitle("InnateSkill")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace InnateSkill
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("manyways.rounds.plugins.innateskill", "Innate Skill", "0.2.4")]
	[BepInProcess("Rounds.exe")]
	public class InnateSkill : BaseUnityPlugin
	{
		[Serializable]
		[HarmonyPatch(typeof(CardChoiceVisuals), "Show")]
		[HarmonyPriority(800)]
		private class CardChoiceVisualsPatchShow
		{
			private static bool Prefix(CardChoice __instance)
			{
				bool flag = false;
				return true;
			}
		}

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

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

		[Serializable]
		[HarmonyPatch(typeof(GM_ArmsRace), "StartGame")]
		private class GM_ArmsRacePatchStartGame
		{
			[HarmonyPostfix]
			private static void resetFirstRound()
			{
				firstRound = true;
			}
		}

		[Serializable]
		[HarmonyPatch(typeof(GM_ArmsRace), "GameOverRematch")]
		private class GM_ArmsRacePatchGameOverRematch
		{
			[HarmonyPostfix]
			private static void resetFirstRound()
			{
				firstRound = true;
			}
		}

		[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__13_0;

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

			internal void <Start>b__13_0()
			{
			}

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

		private const string ModId = "manyways.rounds.plugins.innateskill";

		private const string ModName = "Innate Skill";

		private const string CompatibilityModName = "InnateSkill";

		private const int picksOnFirstTurn = 1;

		internal static InnateSkill instance;

		public static ConfigEntry<bool> EnabledConfig;

		internal static bool modEnabled;

		internal static bool firstRound = true;

		internal static float delay = 0.01f;

		internal static bool lockPickQueue = false;

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

		internal static bool extraPicksInPorgress = false;

		private void Awake()
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			instance = this;
			EnabledConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("InnateSkill", "Enabled", true, "Allow an innate skill pick.");
			modEnabled = EnabledConfig.Value;
			global::DrawNCards.DrawNCards.NumDrawsConfig = ((BaseUnityPlugin)this).Config.Bind<int>("InnateSkill", "Draws", 7, "Number of cards drawn from the deck to choose from");
			new Harmony("manyways.rounds.plugins.innateskill").PatchAll();
		}

		private void Start()
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Expected O, but got Unknown
			Unbound.RegisterCredits("Innate Skill", new string[1] { "manyways (Code)" }, new string[1] { "github" }, new string[1] { "https://github.com/sk-manyways" });
			object obj = <>c.<>9__13_0;
			if (obj == null)
			{
				UnityAction val = delegate
				{
				};
				<>c.<>9__13_0 = val;
				obj = (object)val;
			}
			Unbound.RegisterMenu("Innate Skill", (UnityAction)obj, (Action<GameObject>)NewGUI, (GameObject)null, false);
			Unbound.RegisterHandshake("manyways.rounds.plugins.innateskill", (Action)OnHandShakeCompleted);
			GameModeManager.AddHook("PickStart", (Func<IGameModeHandler, IEnumerator>)((IGameModeHandler gm) => ResetPickQueue()), 800);
			GameModeManager.AddHook("PickEnd", (Func<IGameModeHandler, IEnumerator>)ExtraPicks, 800);
			global::DrawNCards.DrawNCards.defaultNumDraws = global::DrawNCards.DrawNCards.NumDrawsConfig.Value;
		}

		private void OnHandShakeCompleted()
		{
			if (PhotonNetwork.IsMasterClient)
			{
				NetworkingManager.RPC_Others(typeof(InnateSkill), "SyncSettings", new object[2]
				{
					modEnabled,
					global::DrawNCards.DrawNCards.defaultNumDraws
				});
			}
		}

		[UnboundRPC]
		private static void SyncSettings(bool host_enabled, int host_draws)
		{
			modEnabled = host_enabled;
			global::DrawNCards.DrawNCards.defaultNumDraws = host_draws;
		}

		private void NewGUI(GameObject menu)
		{
			TextMeshProUGUI val2 = default(TextMeshProUGUI);
			MenuHandler.CreateText("Innate Skill 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.CreateToggle(EnabledConfig.Value, "Innate Skill Pick Enabled", menu, (UnityAction<bool>)EnabledChanged, 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 cards to draw", menu, 30, 1f, 40f, (float)global::DrawNCards.DrawNCards.NumDrawsConfig.Value, (UnityAction<float>)DrawsChanged, ref val3, true, (Color?)null, (Direction)0, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			void DrawsChanged(float val)
			{
				global::DrawNCards.DrawNCards.NumDrawsConfig.Value = Mathf.RoundToInt(Mathf.Clamp(val, 1f, 40f));
				global::DrawNCards.DrawNCards.defaultNumDraws = global::DrawNCards.DrawNCards.NumDrawsConfig.Value;
				OnHandShakeCompleted();
			}
			void EnabledChanged(bool val)
			{
				EnabledConfig.Value = val;
				modEnabled = val;
				OnHandShakeCompleted();
			}
		}

		[UnboundRPC]
		public static void RPC_RequestSync(int requestingPlayer)
		{
			NetworkingManager.RPC(typeof(InnateSkill), "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");
			}
		}

		public static bool IsInnateRoundInEffect()
		{
			return modEnabled && firstRound;
		}

		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 bool IsFirstRound(IGameModeHandler gm)
		{
			firstRound = gm.GetPointWinners().Length == 0;
			return firstRound;
		}

		internal static IEnumerator ExtraPicks(IGameModeHandler gm)
		{
			int numPics = ((modEnabled && IsFirstRound(gm)) ? 1 : 1);
			firstRound = false;
			if (extraPicksInPorgress || numPics <= 1 || playerIDsToPick.Count() < 1)
			{
				yield break;
			}
			lockPickQueue = true;
			extraPicksInPorgress = true;
			yield return instance.WaitForSyncUp();
			for (int _ = 0; _ < numPics - 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;
		}
	}
}
namespace DrawNCards
{
	public class DrawNCards
	{
		internal const int maxDraws = 40;

		public static ConfigEntry<int> NumDrawsConfig;

		internal static int numPerRow = 10;

		internal static int ifEnabledNumDraws = 40;

		internal static int defaultNumDraws = 7;

		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 bool IsInnateSkillLayoutEnabled()
		{
			return global::InnateSkill.InnateSkill.IsInnateRoundInEffect() || defaultNumDraws == 40;
		}

		internal static List<Vector3> GetInnateSkillPositions(int N, float offset = 0f)
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			int num = ifEnabledNumDraws / numPerRow;
			float num2 = 0.11f;
			float num3 = 0.05f;
			float num4 = 0.25f;
			float num5 = 0.1f;
			List<Vector3> list = new List<Vector3>();
			for (int i = 0; i < num; i++)
			{
				for (int j = 0; j < numPerRow; j++)
				{
					list.Add(new Vector3(num3 + (float)j * num5, num2 + (float)i * num4, -5f));
				}
			}
			return list;
		}

		internal static List<Vector3> GetPositions(int N, float offset = 0f)
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			if (IsInnateSkillLayoutEnabled())
			{
				return GetInnateSkillPositions(N, offset);
			}
			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 > 20)
			{
				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 int GetNumDraws()
		{
			return global::InnateSkill.InnateSkill.IsInnateRoundInEffect() ? ifEnabledNumDraws : defaultNumDraws;
		}

		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 > 20)
			{
				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_0036: 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, 0f));
			}
			return list;
		}
	}
	[Serializable]
	[HarmonyPatch(typeof(CardVisuals), "Start")]
	internal class CardVisualsPatchStart
	{
		private static CardVisuals _cardVisualsInstance;

		private static void Prefix(CardVisuals __instance)
		{
			_cardVisualsInstance = __instance;
		}

		[HarmonyPostfix]
		private static void markCardAsShowing()
		{
			if (DrawNCards.IsInnateSkillLayoutEnabled())
			{
				_cardVisualsInstance.ChangeSelected(true);
			}
		}
	}
	[Serializable]
	[HarmonyPatch(typeof(CardVisuals), "ChangeSelected")]
	internal class CardVisualsPatchChangeSelected
	{
		private static CardVisuals _cardVisualsInstance;

		private static void Prefix(CardVisuals __instance)
		{
			_cardVisualsInstance = __instance;
		}

		[HarmonyPostfix]
		private static void increaseBrightness()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			if (DrawNCards.IsInnateSkillLayoutEnabled())
			{
				CanvasGroup val = (CanvasGroup)ExtensionMethods.GetFieldValue((object)_cardVisualsInstance, "group");
				val.alpha = 1f;
				Image[] array = (Image[])ExtensionMethods.GetFieldValue((object)_cardVisualsInstance, "images");
				for (int i = 0; i < array.Length; i++)
				{
					((Graphic)array[i]).color = _cardVisualsInstance.defaultColor;
				}
				((Graphic)_cardVisualsInstance.nameText).color = _cardVisualsInstance.defaultColor;
			}
		}
	}
	[Serializable]
	[HarmonyPatch(typeof(CardChoice), "DoPlayerSelect")]
	internal class CardChoicePatcDoPlayerSelect
	{
		private static CardChoice _cardChoiceInstance;

		private static int lastAction;

		private static void Prefix(CardChoice __instance)
		{
			_cardChoiceInstance = __instance;
		}

		[HarmonyPostfix]
		private static void jumpAheadForUpOrDownInput()
		{
			if (lastAction != 1 && DidMoveUp())
			{
				lastAction = 1;
				AddToCardSelected(DrawNCards.numPerRow);
			}
			else if (lastAction != 2 && DidMoveDown())
			{
				lastAction = 2;
				AddToCardSelected(-DrawNCards.numPerRow);
			}
			else
			{
				lastAction = 0;
			}
		}

		private static void AddToCardSelected(int value)
		{
			int num = (int)ExtensionMethods.GetFieldValue((object)_cardChoiceInstance, "currentlySelectedCard");
			List<GameObject> list = (List<GameObject>)ExtensionMethods.GetFieldValue((object)_cardChoiceInstance, "spawnedCards");
			int num2 = Mathf.Clamp(num + value, 0, list.Count - 1);
			ExtensionMethods.SetFieldValue((object)_cardChoiceInstance, "currentlySelectedCard", (object)num2);
		}

		private static bool DidMoveUp()
		{
			return Input.GetKeyDown("w") || (double)Input.GetAxis("Vertical") > 0.8;
		}

		private static bool DidMoveDown()
		{
			return Input.GetKeyDown("s") || (double)Input.GetAxis("Vertical") < -0.8;
		}
	}
	[Serializable]
	[HarmonyPatch(typeof(CardChoice), "Spawn")]
	internal class CardChoicePatchSpawn
	{
		private static void Postfix(ref GameObject __result)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			__result.transform.localScale = DrawNCards.GetScale(DrawNCards.GetNumDraws());
			NetworkingManager.RPC_Others(typeof(CardChoicePatchSpawn), "RPCO_AddRemotelySpawnedCard", new object[1] { __result.GetComponent<PhotonView>().ViewID });
		}

		[UnboundRPC]
		private static void RPCO_AddRemotelySpawnedCard(int viewID)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			GameObject gameObject = ((Component)PhotonView.Find(viewID)).gameObject;
			gameObject.transform.localScale = DrawNCards.GetScale(DrawNCards.GetNumDraws());
		}
	}
	[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_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			foreach (Transform item in ((Transform[])ExtensionMethods.GetFieldValue((object)CardChoice.instance, "children")).Skip(1))
			{
				Object.Destroy((Object)(object)((Component)item).gameObject);
			}
			List<Vector3> list = DrawNCards.GetPositions(DrawNCards.GetNumDraws()).WorldPoint();
			List<Quaternion> rotations = DrawNCards.GetRotations(DrawNCards.GetNumDraws());
			Vector3 scale = DrawNCards.GetScale(DrawNCards.GetNumDraws());
			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 < DrawNCards.GetNumDraws(); 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;
		}
	}
}