Decompiled source of FishyCards v1.2.0

SlipSkid.FishyCards.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.Mono;
using CameraUtils;
using Game;
using Game.Levels;
using Game.Settings;
using HarmonyLib;
using Menus.UI;
using Menus.UI.InputRebind;
using Obstacles;
using Obstacles.ObstacleAffixes;
using Obstacles.ObstacleGameModifiers;
using Player;
using SlipSkid.CardKit;
using TMPro;
using UI;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Utilities;
using UnityEngine.Localization;
using UnityEngine.Localization.Settings;
using UnityEngine.Localization.Tables;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("SlipSkid.FishyCards")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+70443946d9a466de93d71710a8884f99307e19a4")]
[assembly: AssemblyProduct("SlipSkid.FishyCards")]
[assembly: AssemblyTitle("SlipSkid.FishyCards")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace SlipSkid.FishyCards;

internal static class Coconut
{
	private struct Launch
	{
		public int Id;

		public int Thrower;

		public int Target;

		public Vector3 Origin;

		public Vector3 Direction;

		public float Speed;

		public void Write(FastBufferWriter w)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: 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_003c: 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_006c: Unknown result type (might be due to invalid IL or missing references)
			((FastBufferWriter)(ref w)).WriteValueSafe<int>(ref Id, default(ForPrimitives));
			((FastBufferWriter)(ref w)).WriteValueSafe<int>(ref Thrower, default(ForPrimitives));
			((FastBufferWriter)(ref w)).WriteValueSafe<int>(ref Target, default(ForPrimitives));
			((FastBufferWriter)(ref w)).WriteValueSafe(ref Origin);
			((FastBufferWriter)(ref w)).WriteValueSafe(ref Direction);
			((FastBufferWriter)(ref w)).WriteValueSafe<float>(ref Speed, default(ForPrimitives));
		}

		public static Launch Read(FastBufferReader r)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: 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_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			Launch result = default(Launch);
			((FastBufferReader)(ref r)).ReadValueSafe<int>(ref result.Id, default(ForPrimitives));
			((FastBufferReader)(ref r)).ReadValueSafe<int>(ref result.Thrower, default(ForPrimitives));
			((FastBufferReader)(ref r)).ReadValueSafe<int>(ref result.Target, default(ForPrimitives));
			((FastBufferReader)(ref r)).ReadValueSafe(ref result.Origin);
			((FastBufferReader)(ref r)).ReadValueSafe(ref result.Direction);
			((FastBufferReader)(ref r)).ReadValueSafe<float>(ref result.Speed, default(ForPrimitives));
			return result;
		}
	}

	private struct Hit
	{
		public int Id;

		public int Victim;

		public Vector3 At;

		public void Write(FastBufferWriter w)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			((FastBufferWriter)(ref w)).WriteValueSafe<int>(ref Id, default(ForPrimitives));
			((FastBufferWriter)(ref w)).WriteValueSafe<int>(ref Victim, default(ForPrimitives));
			((FastBufferWriter)(ref w)).WriteValueSafe(ref At);
		}

		public static Hit Read(FastBufferReader r)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: 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_0030: Unknown result type (might be due to invalid IL or missing references)
			Hit result = default(Hit);
			((FastBufferReader)(ref r)).ReadValueSafe<int>(ref result.Id, default(ForPrimitives));
			((FastBufferReader)(ref r)).ReadValueSafe<int>(ref result.Victim, default(ForPrimitives));
			((FastBufferReader)(ref r)).ReadValueSafe(ref result.At);
			return result;
		}
	}

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

		public static HandleNamedMessageDelegate <>9__31_0;

		public static HandleNamedMessageDelegate <>9__31_1;

		public static HandleNamedMessageDelegate <>9__31_2;

		public static HandleNamedMessageDelegate <>9__31_3;

		internal void <Register>b__31_0(ulong sender, FastBufferReader reader)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			ServerThrow(Launch.Read(reader));
		}

		internal void <Register>b__31_1(ulong sender, FastBufferReader reader)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			OnLaunch(Launch.Read(reader));
		}

		internal void <Register>b__31_2(ulong sender, FastBufferReader reader)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			ServerHit(Hit.Read(reader));
		}

		internal void <Register>b__31_3(ulong sender, FastBufferReader reader)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			OnPop(Hit.Read(reader));
		}
	}

	internal const string ActionName = "ThrowCoconut";

	internal static readonly Guid ActionId = new Guid("5d3c9e71-0b4a-4f62-9e18-7a2c4b6d8e01");

	internal const string DefaultKey = "<Keyboard>/q";

	internal const string DefaultPad = "<Gamepad>/dpad/up";

	private const string ThrowMessage = "slipskid.coconut.throw";

	private const string LaunchMessage = "slipskid.coconut.launch";

	private const string HitMessage = "slipskid.coconut.hit";

	private const string PopMessage = "slipskid.coconut.pop";

	internal static readonly Dictionary<int, int> Held = new Dictionary<int, int>();

	internal static readonly Dictionary<int, CoconutProjectile> Flying = new Dictionary<int, CoconutProjectile>();

	private static readonly Dictionary<int, Obstacle> Credit = new Dictionary<int, Obstacle>();

	internal static readonly HashSet<Obstacle> Kept = new HashSet<Obstacle>();

	internal static bool Releasing;

	private static readonly HashSet<int> Requested = new HashSet<int>();

	private static CustomMessagingManager _registered;

	private static int _nextId = 1;

	internal static void Grant(PlayerData owner, Obstacle card)
	{
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Expected O, but got Unknown
		if (!((Object)(object)owner == (Object)null))
		{
			int value = owner.playerIndex.Value;
			Held.TryGetValue(value, out var value2);
			Held[value] = value2 + 1;
			if ((Object)(object)card != (Object)null)
			{
				Credit[value] = card;
				Kept.Add(card);
			}
			ManualLogSource log = FishyCardsPlugin.Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(31, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(owner.DisplayNameRaw);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" holds a coconut for this race.");
			}
			log.LogInfo(val);
		}
	}

	internal static Obstacle CreditOf(int thrower)
	{
		if (!Credit.TryGetValue(thrower, out var value) || !((Object)(object)value != (Object)null))
		{
			return null;
		}
		return value;
	}

	internal static void NewRound()
	{
		NetworkManager singleton = NetworkManager.Singleton;
		if ((Object)(object)singleton != (Object)null && singleton.IsServer)
		{
			Releasing = true;
			try
			{
				foreach (Obstacle item in Kept)
				{
					if ((Object)(object)item != (Object)null)
					{
						ObstacleManager.Delete(item);
					}
				}
			}
			finally
			{
				Releasing = false;
			}
		}
		Kept.Clear();
		Credit.Clear();
	}

	internal static void Hide(Obstacle o)
	{
		Renderer[] componentsInChildren = ((Component)o).GetComponentsInChildren<Renderer>(true);
		for (int i = 0; i < componentsInChildren.Length; i++)
		{
			componentsInChildren[i].enabled = false;
		}
		Collider[] componentsInChildren2 = ((Component)o).GetComponentsInChildren<Collider>(true);
		for (int i = 0; i < componentsInChildren2.Length; i++)
		{
			componentsInChildren2[i].enabled = false;
		}
		Light[] componentsInChildren3 = ((Component)o).GetComponentsInChildren<Light>(true);
		for (int i = 0; i < componentsInChildren3.Length; i++)
		{
			((Behaviour)componentsInChildren3[i]).enabled = false;
		}
	}

	internal static string LocalKey()
	{
		if (GameManager.Players != null)
		{
			foreach (PlayerData player in GameManager.Players)
			{
				if ((Object)(object)player != (Object)null && ((NetworkBehaviour)player).IsOwner)
				{
					return KeyOf(player);
				}
			}
		}
		return "Q";
	}

	internal static int HeldBy(PlayerData p)
	{
		if (!((Object)(object)p != (Object)null) || !Held.TryGetValue(p.playerIndex.Value, out var value))
		{
			return 0;
		}
		return value;
	}

	internal static void EndOfRace()
	{
		Held.Clear();
		Requested.Clear();
		foreach (CoconutProjectile value in Flying.Values)
		{
			if ((Object)(object)value != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)value).gameObject);
			}
		}
		Flying.Clear();
	}

	internal static void EnsureAction(InputActionAsset asset)
	{
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: 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_00e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f7: 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_010a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0113: Unknown result type (might be due to invalid IL or missing references)
		InputActionMap val = (((Object)(object)asset != (Object)null) ? asset.FindActionMap("Player", false) : null);
		if (val == null || val.FindAction("ThrowCoconut", false) != null)
		{
			return;
		}
		List<InputActionMap> list = new List<InputActionMap>();
		Enumerator<InputActionMap> enumerator = asset.actionMaps.GetEnumerator();
		try
		{
			while (enumerator.MoveNext())
			{
				InputActionMap current = enumerator.Current;
				if (current.enabled)
				{
					list.Add(current);
				}
			}
		}
		finally
		{
			((IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
		}
		foreach (InputActionMap item in list)
		{
			item.Disable();
		}
		try
		{
			InputAction obj = InputActionSetupExtensions.AddAction(val, "ThrowCoconut", (InputActionType)1, (string)null, (string)null, (string)null, (string)null, (string)null);
			Traverse.Create((object)obj).Field("m_Id").SetValue((object)ActionId.ToString());
			BindingSyntax val2 = InputActionSetupExtensions.AddBinding(obj, "<Keyboard>/q", (string)null, (string)null, (string)null);
			((BindingSyntax)(ref val2)).WithGroup("Keyboard&Mouse");
			val2 = InputActionSetupExtensions.AddBinding(obj, "<Gamepad>/dpad/up", (string)null, (string)null, (string)null);
			((BindingSyntax)(ref val2)).WithGroup("Gamepad");
		}
		finally
		{
			foreach (InputActionMap item2 in list)
			{
				item2.Enable();
			}
		}
	}

	internal static InputAction ActionOf(PlayerData p)
	{
		InputActionAsset val = (((Object)(object)p != (Object)null && (Object)(object)p.inputs != (Object)null) ? p.inputs.actions : null);
		if ((Object)(object)val == (Object)null)
		{
			return null;
		}
		if (val.FindAction("ThrowCoconut", false) == null)
		{
			EnsureAction(val);
		}
		return val.FindAction("ThrowCoconut", false);
	}

	internal static string KeyOf(PlayerData p)
	{
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		InputAction val = ActionOf(p);
		if (val == null)
		{
			return "Q";
		}
		try
		{
			string text = ((p.device is Gamepad) ? "Gamepad" : "Keyboard&Mouse");
			string bindingDisplayString = InputActionRebindingExtensions.GetBindingDisplayString(val, InputBinding.MaskByGroup(text), (DisplayStringOptions)0);
			return string.IsNullOrEmpty(bindingDisplayString) ? InputActionRebindingExtensions.GetBindingDisplayString(val, (DisplayStringOptions)0, (string)null) : bindingDisplayString;
		}
		catch
		{
			return "Q";
		}
	}

	internal static void Tick()
	{
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Invalid comparison between Unknown and I4
		Register();
		GameManager instance = GameManager.instance;
		if ((Object)(object)instance == (Object)null || (Object)(object)instance.networkVariables == (Object)null || GameManager.Players == null || (int)instance.networkVariables.state.Value != 5)
		{
			return;
		}
		foreach (PlayerData player in GameManager.Players)
		{
			if (!((Object)(object)player == (Object)null) && ((NetworkBehaviour)player).IsOwner && HeldBy(player) > 0 && !Requested.Contains(player.playerIndex.Value) && !player.isDead.Value && !player.finishedRace.Value && !((Object)(object)player.controller == (Object)null))
			{
				InputAction val = ActionOf(player);
				if (val != null && val.WasPressedThisFrame())
				{
					Throw(player);
				}
			}
		}
	}

	internal static PlayerData PickTarget(PlayerData thrower, Vector3 from, Vector3 forward)
	{
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: 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_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		PlayerData result = null;
		float num = 250f;
		foreach (PlayerData player in GameManager.Players)
		{
			if (!((Object)(object)player == (Object)null) && !((Object)(object)player == (Object)(object)thrower) && !((Object)(object)player.controller == (Object)null) && !player.isDead.Value && !player.finishedRace.Value)
			{
				Vector3 val = player.controller.sphereRigidbody.position - from;
				if (!(((Vector3)(ref val)).magnitude >= num) && !(Vector3.Angle(forward, val) > 75f))
				{
					result = player;
					num = ((Vector3)(ref val)).magnitude;
				}
			}
		}
		return result;
	}

	internal static void Throw(PlayerData p)
	{
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//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_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_0091: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00da: Unknown result type (might be due to invalid IL or missing references)
		//IL_0142: Unknown result type (might be due to invalid IL or missing references)
		//IL_0143: Unknown result type (might be due to invalid IL or missing references)
		//IL_014c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0151: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager singleton = NetworkManager.Singleton;
		if (!((Object)(object)singleton == (Object)null) && singleton.IsListening)
		{
			Transform val = (((Object)(object)p.controller.car != (Object)null) ? p.controller.car : ((Component)p.controller).transform);
			Vector3 val2 = Vector3.ProjectOnPlane(val.forward, Vector3.up);
			Vector3 val3;
			if (!(((Vector3)(ref val2)).sqrMagnitude > 0.01f))
			{
				val2 = p.controller.sphereRigidbody.velocity;
				val3 = ((Vector3)(ref val2)).normalized;
			}
			else
			{
				val3 = val.forward;
			}
			Vector3 val4 = val3;
			Vector3 val5 = p.controller.sphereRigidbody.position + val4 * 3.5f + Vector3.up * 0.6f;
			PlayerData val6 = PickTarget(p, val5, val4);
			val2 = p.controller.sphereRigidbody.velocity;
			float speed = Mathf.Max(44f, ((Vector3)(ref val2)).magnitude + 6f);
			Requested.Add(p.playerIndex.Value);
			Launch launch = new Launch
			{
				Thrower = p.playerIndex.Value,
				Target = (((Object)(object)val6 != (Object)null) ? val6.playerIndex.Value : (-1)),
				Origin = val5,
				Direction = ((Vector3)(ref val4)).normalized,
				Speed = speed
			};
			if (singleton.IsServer)
			{
				ServerThrow(launch);
			}
			else
			{
				Send(singleton, "slipskid.coconut.throw", 0uL, ((Launch)launch).Write);
			}
		}
	}

	private static void Register()
	{
		//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)
		//IL_0068: Expected O, but got Unknown
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Expected O, but got Unknown
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00be: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c4: Expected O, but got Unknown
		//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f2: Expected O, but got Unknown
		NetworkManager singleton = NetworkManager.Singleton;
		if ((Object)(object)singleton == (Object)null || !singleton.IsListening || singleton.CustomMessagingManager == null)
		{
			_registered = null;
		}
		else
		{
			if (singleton.CustomMessagingManager == _registered)
			{
				return;
			}
			_registered = singleton.CustomMessagingManager;
			CustomMessagingManager registered = _registered;
			object obj = <>c.<>9__31_0;
			if (obj == null)
			{
				HandleNamedMessageDelegate val = delegate(ulong sender, FastBufferReader reader)
				{
					//IL_0000: Unknown result type (might be due to invalid IL or missing references)
					ServerThrow(Launch.Read(reader));
				};
				<>c.<>9__31_0 = val;
				obj = (object)val;
			}
			registered.RegisterNamedMessageHandler("slipskid.coconut.throw", (HandleNamedMessageDelegate)obj);
			CustomMessagingManager registered2 = _registered;
			object obj2 = <>c.<>9__31_1;
			if (obj2 == null)
			{
				HandleNamedMessageDelegate val2 = delegate(ulong sender, FastBufferReader reader)
				{
					//IL_0000: Unknown result type (might be due to invalid IL or missing references)
					OnLaunch(Launch.Read(reader));
				};
				<>c.<>9__31_1 = val2;
				obj2 = (object)val2;
			}
			registered2.RegisterNamedMessageHandler("slipskid.coconut.launch", (HandleNamedMessageDelegate)obj2);
			CustomMessagingManager registered3 = _registered;
			object obj3 = <>c.<>9__31_2;
			if (obj3 == null)
			{
				HandleNamedMessageDelegate val3 = delegate(ulong sender, FastBufferReader reader)
				{
					//IL_0000: Unknown result type (might be due to invalid IL or missing references)
					ServerHit(Hit.Read(reader));
				};
				<>c.<>9__31_2 = val3;
				obj3 = (object)val3;
			}
			registered3.RegisterNamedMessageHandler("slipskid.coconut.hit", (HandleNamedMessageDelegate)obj3);
			CustomMessagingManager registered4 = _registered;
			object obj4 = <>c.<>9__31_3;
			if (obj4 == null)
			{
				HandleNamedMessageDelegate val4 = delegate(ulong sender, FastBufferReader reader)
				{
					//IL_0000: Unknown result type (might be due to invalid IL or missing references)
					OnPop(Hit.Read(reader));
				};
				<>c.<>9__31_3 = val4;
				obj4 = (object)val4;
			}
			registered4.RegisterNamedMessageHandler("slipskid.coconut.pop", (HandleNamedMessageDelegate)obj4);
		}
	}

	private static void ServerThrow(Launch request)
	{
		NetworkManager singleton = NetworkManager.Singleton;
		if (!((Object)(object)singleton == (Object)null) && singleton.IsServer && Held.TryGetValue(request.Thrower, out var value) && value > 0)
		{
			request.Id = _nextId++;
			ToEveryone(singleton, "slipskid.coconut.launch", ((Launch)request).Write);
			OnLaunch(request);
		}
	}

	private static void OnLaunch(Launch l)
	{
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: 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_009a: Expected O, but got Unknown
		if (Held.TryGetValue(l.Thrower, out var value))
		{
			Held[l.Thrower] = Mathf.Max(0, value - 1);
		}
		Requested.Remove(l.Thrower);
		if (!Flying.ContainsKey(l.Id))
		{
			Flying[l.Id] = CoconutProjectile.Launch(l.Id, l.Thrower, l.Target, l.Origin, l.Direction, l.Speed);
			ManualLogSource log = FishyCardsPlugin.Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(31, 3, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Coconut ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(l.Id);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" thrown by player ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(l.Thrower);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" at ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>((l.Target >= 0) ? ("player " + l.Target) : "nobody (straight on)");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(".");
			}
			log.LogInfo(val);
		}
	}

	internal static void ReportHit(int id, PlayerData victim, Vector3 at)
	{
		//IL_002a: 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)
		NetworkManager singleton = NetworkManager.Singleton;
		Hit hit = new Hit
		{
			Id = id,
			Victim = victim.playerIndex.Value,
			At = at
		};
		if ((Object)(object)singleton != (Object)null && singleton.IsListening && !singleton.IsServer)
		{
			Send(singleton, "slipskid.coconut.hit", 0uL, ((Hit)hit).Write);
		}
		else
		{
			ServerHit(hit);
		}
	}

	private static void ServerHit(Hit hit)
	{
		NetworkManager singleton = NetworkManager.Singleton;
		if ((Object)(object)singleton != (Object)null && singleton.IsListening && singleton.IsServer)
		{
			ToEveryone(singleton, "slipskid.coconut.pop", ((Hit)hit).Write);
		}
		OnPop(hit);
	}

	private static void OnPop(Hit hit)
	{
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		if (Flying.TryGetValue(hit.Id, out var value) && (Object)(object)value != (Object)null)
		{
			value.Pop(hit.At, hit.Victim);
		}
		Flying.Remove(hit.Id);
	}

	private unsafe static void Send(NetworkManager nm, string message, ulong client, Action<FastBufferWriter> write)
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: 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)
		FastBufferWriter val = default(FastBufferWriter);
		((FastBufferWriter)(ref val))..ctor(64, (Allocator)2, -1);
		FastBufferWriter val2 = val;
		try
		{
			write(val);
			nm.CustomMessagingManager.SendNamedMessage(message, client, val, (NetworkDelivery)2);
		}
		finally
		{
			((IDisposable)(*(FastBufferWriter*)(&val2))/*cast due to .constrained prefix*/).Dispose();
		}
	}

	private static void ToEveryone(NetworkManager nm, string message, Action<FastBufferWriter> write)
	{
		foreach (ulong connectedClientsId in nm.ConnectedClientsIds)
		{
			if (connectedClientsId != 0L)
			{
				Send(nm, message, connectedClientsId, write);
			}
		}
	}
}
internal sealed class CoconutDriver : MonoBehaviour
{
	private GameState _last;

	private CoconutHud _hud;

	private void Update()
	{
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Expected O, but got Unknown
		//IL_0030: 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_0033: 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_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Invalid comparison between Unknown and I4
		//IL_0061: 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)
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Invalid comparison between Unknown and I4
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Invalid comparison between Unknown and I4
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			GameManager instance = GameManager.instance;
			GameState val = (GameState)(((Object)(object)instance != (Object)null && (Object)(object)instance.networkVariables != (Object)null) ? ((int)instance.networkVariables.state.Value) : 0);
			if (val != _last && ((int)val == 6 || (int)val == 10 || (int)val == 0))
			{
				Coconut.EndOfRace();
			}
			if (val != _last && ((int)val == 7 || (int)val == 0))
			{
				Coconut.NewRound();
			}
			_last = val;
			Coconut.Tick();
			if ((Object)(object)_hud == (Object)null)
			{
				_hud = CoconutHud.Create();
			}
			_hud.Refresh(val);
		}
		catch (Exception ex)
		{
			ManualLogSource log = FishyCardsPlugin.Log;
			bool flag = default(bool);
			BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(9, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Coconut: ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
			}
			log.LogWarning(val2);
		}
	}
}
internal sealed class CoconutHud : MonoBehaviour
{
	private RectTransform _box;

	private TextMeshProUGUI _hint;

	private TextMeshProUGUI _warning;

	private CanvasGroup _boxGroup;

	private float _pulse;

	internal static CoconutHud Create()
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0013: Expected O, but got Unknown
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject("FishyCards coconut HUD")
		{
			hideFlags = (HideFlags)61
		};
		Object.DontDestroyOnLoad((Object)(object)val);
		Canvas obj = val.AddComponent<Canvas>();
		obj.renderMode = (RenderMode)0;
		obj.sortingOrder = 500;
		CanvasScaler obj2 = val.AddComponent<CanvasScaler>();
		obj2.uiScaleMode = (ScaleMode)1;
		obj2.referenceResolution = new Vector2(1920f, 1080f);
		obj2.matchWidthOrHeight = 0.5f;
		CoconutHud coconutHud = val.AddComponent<CoconutHud>();
		coconutHud.Build(val.transform);
		return coconutHud;
	}

	private void Build(Transform root)
	{
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00af: Unknown result type (might be due to invalid IL or missing references)
		//IL_00be: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0106: Unknown result type (might be due to invalid IL or missing references)
		//IL_0115: 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_0143: Unknown result type (might be due to invalid IL or missing references)
		//IL_018f: Unknown result type (might be due to invalid IL or missing references)
		//IL_019e: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ad: 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)
		TMP_FontAsset font = GameFont();
		_box = Rect(root, "Box", new Vector2(0.5f, 0f), new Vector2(0f, 150f), new Vector2(1000f, 120f));
		_boxGroup = ((Component)_box).gameObject.AddComponent<CanvasGroup>();
		((Component)_box).gameObject.AddComponent<RawImage>().texture = (Texture)(object)RoundedBox(new Color32((byte)18, (byte)12, (byte)30, (byte)215), new Color32(byte.MaxValue, (byte)196, (byte)92, byte.MaxValue));
		((Component)Rect((Transform)(object)_box, "Coconut", new Vector2(0f, 0.5f), new Vector2(78f, 0f), new Vector2(124f, 124f))).gameObject.AddComponent<RawImage>().texture = (Texture)(object)LoadPng("CoconutIcon.png");
		_hint = Text(Rect((Transform)(object)_box, "Hint", new Vector2(0.5f, 0.5f), new Vector2(70f, 0f), new Vector2(820f, 104f)), font, 48f, new Color(1f, 0.96f, 0.88f));
		((TMP_Text)_hint).enableAutoSizing = true;
		((TMP_Text)_hint).fontSizeMin = 26f;
		((TMP_Text)_hint).fontSizeMax = 48f;
		_warning = Text(Rect(root, "Warning", new Vector2(0.5f, 1f), new Vector2(0f, -170f), new Vector2(1400f, 120f)), font, 76f, new Color(1f, 0.25f, 0.2f));
		((TMP_Text)_warning).fontStyle = (FontStyles)1;
		((Component)_box).gameObject.SetActive(false);
		((Component)_warning).gameObject.SetActive(false);
	}

	internal void Refresh(GameState state)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0002: Invalid comparison between Unknown and I4
		//IL_0004: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Invalid comparison between Unknown and I4
		//IL_01db: Unknown result type (might be due to invalid IL or missing references)
		bool num = (int)state == 5 || (int)state == 4;
		List<PlayerData> list = new List<PlayerData>();
		bool flag = false;
		if (num && GameManager.Players != null)
		{
			foreach (PlayerData player in GameManager.Players)
			{
				if ((Object)(object)player == (Object)null || !((NetworkBehaviour)player).IsOwner || player.isDead.Value || player.finishedRace.Value)
				{
					continue;
				}
				if (Coconut.HeldBy(player) > 0)
				{
					list.Add(player);
				}
				foreach (CoconutProjectile value in Coconut.Flying.Values)
				{
					if ((Object)(object)value != (Object)null && value.Target == player.playerIndex.Value)
					{
						flag = true;
					}
				}
			}
		}
		((Component)_box).gameObject.SetActive(list.Count > 0);
		if (list.Count > 0)
		{
			List<string> list2 = new List<string>();
			foreach (PlayerData item in list)
			{
				string text = Loc.CoconutHud("<color=#FFC85C><b>[" + Coconut.KeyOf(item) + "]</b></color>");
				list2.Add((list.Count > 1) ? (item.DisplayNameRaw + ": " + text) : text);
			}
			((TMP_Text)_hint).text = string.Join("\n", list2);
			_pulse += Time.unscaledDeltaTime;
			float num2 = 1f + 0.035f * Mathf.Sin(_pulse * 5f);
			((Transform)_box).localScale = new Vector3(num2, num2, 1f);
			_boxGroup.alpha = Mathf.Clamp01(_boxGroup.alpha + Time.unscaledDeltaTime * 4f);
		}
		else if ((Object)(object)_boxGroup != (Object)null)
		{
			_boxGroup.alpha = 0f;
		}
		((Component)_warning).gameObject.SetActive(flag);
		if (flag)
		{
			((TMP_Text)_warning).text = Loc.CoconutIncoming;
			((TMP_Text)_warning).alpha = 0.55f + 0.45f * Mathf.Abs(Mathf.Sin(Time.unscaledTime * 9f));
		}
	}

	private static RectTransform Rect(Transform parent, string name, Vector2 anchor, Vector2 position, Vector2 size)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: 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_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)
		//IL_0022: 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_003e: 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)
		GameObject val = new GameObject(name);
		val.transform.SetParent(parent, false);
		RectTransform obj = val.AddComponent<RectTransform>();
		Vector2 anchorMin = (obj.anchorMax = anchor);
		obj.anchorMin = anchorMin;
		obj.pivot = new Vector2(0.5f, 0.5f);
		obj.anchoredPosition = position;
		obj.sizeDelta = size;
		return obj;
	}

	private static TextMeshProUGUI Text(RectTransform r, TMP_FontAsset font, float size, Color colour)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		TextMeshProUGUI val = ((Component)r).gameObject.AddComponent<TextMeshProUGUI>();
		if ((Object)(object)font != (Object)null)
		{
			((TMP_Text)val).font = font;
		}
		((TMP_Text)val).fontSize = size;
		((Graphic)val).color = colour;
		((TMP_Text)val).alignment = (TextAlignmentOptions)514;
		((TMP_Text)val).richText = true;
		((TMP_Text)val).enableWordWrapping = true;
		((TMP_Text)val).outlineWidth = 0.12f;
		((TMP_Text)val).outlineColor = new Color32((byte)0, (byte)0, (byte)0, (byte)220);
		return val;
	}

	private static TMP_FontAsset GameFont()
	{
		TMP_FontAsset val = null;
		TMP_FontAsset[] array = Resources.FindObjectsOfTypeAll<TMP_FontAsset>();
		foreach (TMP_FontAsset val2 in array)
		{
			if (!((Object)(object)val2 == (Object)null))
			{
				if (((Object)val2).name.IndexOf("Signika", StringComparison.OrdinalIgnoreCase) >= 0)
				{
					return val2;
				}
				if ((Object)(object)val == (Object)null || ((Object)val2).name.IndexOf("Comfortaa", StringComparison.OrdinalIgnoreCase) >= 0)
				{
					val = val2;
				}
			}
		}
		return val ?? TMP_Settings.defaultFontAsset;
	}

	private static Texture2D LoadPng(string name)
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Expected O, but got Unknown
		byte[] array = CardKitApi.EmbeddedPng(name);
		Texture2D val = new Texture2D(2, 2, (TextureFormat)4, true);
		if (array != null)
		{
			ImageConversion.LoadImage(val, array);
		}
		return val;
	}

	private static Texture2D RoundedBox(Color32 fill, Color32 border)
	{
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Expected O, but got Unknown
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_010a: Unknown result type (might be due to invalid IL or missing references)
		//IL_010c: 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_00e9: Unknown result type (might be due to invalid IL or missing references)
		Texture2D val = new Texture2D(256, 64, (TextureFormat)4, false)
		{
			wrapMode = (TextureWrapMode)1
		};
		Color32[] array = (Color32[])(object)new Color32[16384];
		for (int i = 0; i < 64; i++)
		{
			for (int j = 0; j < 256; j++)
			{
				float num = Mathf.Max((float)Mathf.Max(18 - j, j - 237), 0f);
				float num2 = Mathf.Max((float)Mathf.Max(18 - i, i - 45), 0f);
				float num3 = Mathf.Sqrt(num * num + num2 * num2);
				float num4 = Mathf.Min(Mathf.Min(j, 255 - j), Mathf.Min(i, 63 - i));
				Color32 val2 = (Color32)((num3 > 18f) ? new Color32((byte)0, (byte)0, (byte)0, (byte)0) : ((num3 > 15f || (num == 0f && num2 == 0f && num4 < 3f)) ? border : fill));
				if (num3 > 17f && num3 <= 18f)
				{
					val2.a = (byte)((float)(int)val2.a * (18f - num3));
				}
				array[i * 256 + j] = val2;
			}
		}
		val.SetPixels32(array);
		val.Apply();
		return val;
	}
}
[HarmonyPatch(typeof(GameSettings), "InitInputBindings")]
internal static class CoconutActionPatch
{
	private static void Prefix()
	{
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Expected O, but got Unknown
		try
		{
			GameManager instance = GameManager.instance;
			if (!((Object)(object)instance == (Object)null))
			{
				Coconut.EnsureAction(instance.defaultInputActions);
				PlayerInput val = (((Object)(object)instance.inputsPrefab != (Object)null) ? instance.inputsPrefab.GetComponent<PlayerInput>() : null);
				if ((Object)(object)val != (Object)null)
				{
					Coconut.EnsureAction(val.actions);
				}
			}
		}
		catch (Exception ex)
		{
			ManualLogSource log = FishyCardsPlugin.Log;
			bool flag = default(bool);
			BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(41, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Coconut: could not add the throw action: ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
			}
			log.LogError(val2);
		}
	}
}
[HarmonyPatch(typeof(LocalizedString), "GetLocalizedString", new Type[] { })]
internal static class CoconutActionNamePatch
{
	internal static readonly string Key = "input_action_name_player_" + "ThrowCoconut".ToLowerInvariant();

	private static bool Prefix(LocalizedString __instance, ref string __result)
	{
		//IL_0004: Unknown result type (might be due to invalid IL or missing references)
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		if (__instance != null)
		{
			TableEntryReference tableEntryReference = ((LocalizedReference)__instance).TableEntryReference;
			if (!(((TableEntryReference)(ref tableEntryReference)).Key != Key))
			{
				__result = Loc.CoconutAction;
				return false;
			}
		}
		return true;
	}
}
[HarmonyPatch(typeof(ObstacleManager), "Delete", new Type[] { typeof(Obstacle) })]
internal static class CoconutKeepPatch
{
	private static bool Prefix(Obstacle obstacle)
	{
		if (!Coconut.Releasing && !((Object)(object)obstacle == (Object)null))
		{
			return !Coconut.Kept.Contains(obstacle);
		}
		return true;
	}
}
[HarmonyPatch(typeof(InputRebindElement), "Init")]
internal static class CoconutRebindRowPatch
{
	private static void Postfix(InputRebindElement __instance, InputAction action)
	{
		if (action != null && action.name == "ThrowCoconut" && (Object)(object)__instance.inputRebindActionName != (Object)null)
		{
			__instance.inputRebindActionName.text = Loc.CoconutAction;
		}
	}
}
internal sealed class CoconutProjectile : MonoBehaviour
{
	internal const float Speed = 44f;

	internal const float TurnRate = 70f;

	internal const float Lifetime = 7f;

	internal const float HitDistance = 2.2f;

	internal const float Radius = 0.75f;

	private const float Hover = 0.9f;

	private const float ThrowerGrace = 0.8f;

	internal const float RadToDeg = 57.29578f;

	internal const float DegToRad = 0.01745329f;

	private int _id;

	private int _thrower;

	private int _target;

	private Vector3 _direction;

	private float _speed;

	private float _age;

	private float _fall;

	private float _dust;

	private float _closest = float.MaxValue;

	private bool _homing = true;

	private bool _done;

	private Transform _body;

	internal int Target
	{
		get
		{
			if (!_homing)
			{
				return -1;
			}
			return _target;
		}
	}

	internal static CoconutProjectile Launch(int id, int thrower, int target, Vector3 origin, Vector3 direction, float speed)
	{
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Expected O, but got Unknown
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: 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_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: 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)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject($"Coconut {id}");
		val.transform.position = origin;
		CoconutProjectile coconutProjectile = val.AddComponent<CoconutProjectile>();
		coconutProjectile._id = id;
		coconutProjectile._thrower = thrower;
		coconutProjectile._target = target;
		Vector3 val2 = Vector3.ProjectOnPlane(direction, Vector3.up);
		Vector3 direction2;
		if (!(((Vector3)(ref val2)).sqrMagnitude > 0.01f))
		{
			direction2 = Vector3.forward;
		}
		else
		{
			val2 = Vector3.ProjectOnPlane(direction, Vector3.up);
			direction2 = ((Vector3)(ref val2)).normalized;
		}
		coconutProjectile._direction = direction2;
		coconutProjectile._speed = speed;
		coconutProjectile._body = CoconutLook.Make(val.transform, 0.75f);
		return coconutProjectile;
	}

	private static Vector3 TurnTowards(Vector3 from, Vector3 to, float maxDegrees)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		float num = Mathf.Atan2(Vector3.Cross(from, to).y, Vector3.Dot(from, to)) * 57.29578f;
		return Quaternion.Euler(0f, Mathf.Clamp(num, 0f - maxDegrees, maxDegrees), 0f) * from;
	}

	internal static PlayerData Player(int index)
	{
		if (index < 0 || GameManager.Players == null)
		{
			return null;
		}
		foreach (PlayerData player in GameManager.Players)
		{
			if ((Object)(object)player != (Object)null && player.playerIndex.Value == index)
			{
				return player;
			}
		}
		return null;
	}

	private void Update()
	{
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0167: Unknown result type (might be due to invalid IL or missing references)
		//IL_016d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0178: Unknown result type (might be due to invalid IL or missing references)
		//IL_017e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0183: 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_0189: Unknown result type (might be due to invalid IL or missing references)
		//IL_018a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0194: Unknown result type (might be due to invalid IL or missing references)
		//IL_0199: Unknown result type (might be due to invalid IL or missing references)
		//IL_019e: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01be: Unknown result type (might be due to invalid IL or missing references)
		//IL_021e: Unknown result type (might be due to invalid IL or missing references)
		//IL_022b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0230: Unknown result type (might be due to invalid IL or missing references)
		//IL_0235: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0269: Unknown result type (might be due to invalid IL or missing references)
		//IL_027b: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_0106: 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_039f: Unknown result type (might be due to invalid IL or missing references)
		//IL_011d: 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_0130: Unknown result type (might be due to invalid IL or missing references)
		//IL_0135: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_0331: Unknown result type (might be due to invalid IL or missing references)
		//IL_0337: Unknown result type (might be due to invalid IL or missing references)
		//IL_033c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0341: Unknown result type (might be due to invalid IL or missing references)
		//IL_0345: Unknown result type (might be due to invalid IL or missing references)
		//IL_034a: 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_0359: Unknown result type (might be due to invalid IL or missing references)
		//IL_035f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0369: Unknown result type (might be due to invalid IL or missing references)
		//IL_036e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0373: Unknown result type (might be due to invalid IL or missing references)
		//IL_0386: Unknown result type (might be due to invalid IL or missing references)
		//IL_0390: Unknown result type (might be due to invalid IL or missing references)
		//IL_0395: Unknown result type (might be due to invalid IL or missing references)
		if (_done)
		{
			return;
		}
		float deltaTime = Time.deltaTime;
		_age += deltaTime;
		if (_age > 7f)
		{
			Pop(((Component)this).transform.position, -1);
			return;
		}
		PlayerData val = Player(_target);
		if (_homing && (Object)(object)val != (Object)null && (Object)(object)val.controller != (Object)null && !val.isDead.Value)
		{
			Rigidbody sphereRigidbody = val.controller.sphereRigidbody;
			Vector3 val2 = sphereRigidbody.position + sphereRigidbody.velocity * 0.2f - ((Component)this).transform.position;
			float magnitude = ((Vector3)(ref val2)).magnitude;
			_closest = Mathf.Min(_closest, magnitude);
			if (_closest < 8f && magnitude > _closest + 3f)
			{
				_homing = false;
			}
			else
			{
				Vector3 val3 = Vector3.ProjectOnPlane(val2, Vector3.up);
				if (((Vector3)(ref val3)).sqrMagnitude > 0.001f)
				{
					_direction = TurnTowards(_direction, ((Vector3)(ref val3)).normalized, 70f * deltaTime);
				}
			}
		}
		else if (_homing && (Object)(object)val != (Object)null && val.isDead.Value)
		{
			_homing = false;
		}
		Vector3 val4 = ((Component)this).transform.position + _direction * _speed * deltaTime;
		RaycastHit val5 = default(RaycastHit);
		bool num = Physics.Raycast(val4 + Vector3.up * 4f, Vector3.down, ref val5, 9f, 1, (QueryTriggerInteraction)1);
		if (num)
		{
			val4.y = Mathf.Lerp(val4.y, ((RaycastHit)(ref val5)).point.y + 0.9f, Mathf.Clamp01(deltaTime * 20f));
			_fall = 0f;
		}
		else
		{
			_fall += 30f * deltaTime;
			val4.y -= _fall * deltaTime;
		}
		((Component)this).transform.position = val4;
		((Component)this).transform.rotation = Quaternion.LookRotation(_direction, Vector3.up);
		if ((Object)(object)_body != (Object)null)
		{
			float num2 = Mathf.Sin(_age * 18f);
			_body.localPosition = Vector3.up * (0.18f * Mathf.Abs(num2));
			_body.localRotation = Quaternion.Euler(-8f + 6f * num2, 0f, 9f * Mathf.Sin(_age * 11f));
			float num3 = 1f - 0.08f * (1f - Mathf.Abs(num2));
			_body.localScale = new Vector3(1f / Mathf.Sqrt(num3), num3, 1f / Mathf.Sqrt(num3));
		}
		_dust += deltaTime;
		if (num && _dust > 0.08f)
		{
			_dust = 0f;
			Vector3 val6 = Vector3.Cross(Vector3.up, _direction);
			CoconutLook.Dust(((RaycastHit)(ref val5)).point + Vector3.up * 0.08f - _direction * 0.75f + val6 * Mathf.Sin(_age * 37f) * 0.6f);
		}
		if (val4.y < -200f)
		{
			Pop(val4, -1);
		}
		CheckLocalCars();
	}

	private void CheckLocalCars()
	{
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00da: Expected O, but got Unknown
		//IL_012a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0131: Unknown result type (might be due to invalid IL or missing references)
		if (GameManager.Players == null)
		{
			return;
		}
		bool flag = default(bool);
		foreach (PlayerData player in GameManager.Players)
		{
			if ((Object)(object)player == (Object)null || !((NetworkBehaviour)player).IsOwner || (Object)(object)player.controller == (Object)null || player.isDead.Value || player.finishedRace.Value || (player.playerIndex.Value == _thrower && _age < 0.8f))
			{
				continue;
			}
			Vector3 val = player.controller.sphereRigidbody.position - ((Component)this).transform.position;
			if (!(((Vector3)(ref val)).magnitude > 2.2f))
			{
				Vector3 position = ((Component)this).transform.position;
				ManualLogSource log = FishyCardsPlugin.Log;
				BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(14, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Coconut ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(_id);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" hit ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(player.DisplayNameRaw);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(".");
				}
				log.LogInfo(val2);
				Coconut.ReportHit(_id, player, position);
				Pop(position, player.playerIndex.Value);
				player.Die(Coconut.CreditOf(_thrower), false);
				break;
			}
		}
	}

	internal void Pop(Vector3 at, int victim)
	{
		//IL_0021: 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)
		if (!_done)
		{
			_done = true;
			Coconut.Flying.Remove(_id);
			CoconutLook.Split(at, _direction, 0.75f);
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}
	}
}
internal static class CoconutLook
{
	private sealed class Fade : MonoBehaviour
	{
		private float _life;

		private float _age;

		private float _grow;

		private float _gravity;

		private Vector3 _velocity;

		private Vector3 _spin;

		private Vector3 _scale;

		internal void Init(float life, Vector3 velocity, float grow, Vector3 spin = default(Vector3), float gravity = 0f)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: 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_002c: 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)
			_life = life;
			_velocity = velocity;
			_grow = grow;
			_spin = spin;
			_gravity = gravity;
			_scale = ((Component)this).transform.localScale;
		}

		private void Update()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: 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_00cf: Unknown result type (might be due to invalid IL or missing references)
			_age += Time.deltaTime;
			if (_age >= _life)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
				return;
			}
			_velocity += Vector3.down * _gravity * Time.deltaTime;
			Transform transform = ((Component)this).transform;
			transform.position += _velocity * Time.deltaTime;
			((Component)this).transform.Rotate(_spin * Time.deltaTime, (Space)1);
			float num = _age / _life;
			((Component)this).transform.localScale = _scale * (1f + _grow * num) * (1f - num * num);
		}
	}

	private const float Pi = (float)Math.PI;

	private static Mesh _husk;

	private static Mesh _ball;

	private static Mesh _half;

	private static Material _huskMat;

	private static Material _darkMat;

	private static Material _whiteMat;

	private static Material _fleshMat;

	private static Material _dustMat;

	internal static Transform Make(Transform parent, float radius)
	{
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cc: 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_00d7: 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_00e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_010f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0114: Unknown result type (might be due to invalid IL or missing references)
		//IL_0132: Unknown result type (might be due to invalid IL or missing references)
		//IL_0138: Unknown result type (might be due to invalid IL or missing references)
		//IL_013d: Unknown result type (might be due to invalid IL or missing references)
		//IL_014e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0154: Unknown result type (might be due to invalid IL or missing references)
		//IL_0186: Unknown result type (might be due to invalid IL or missing references)
		//IL_018c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0191: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
		Ensure();
		Transform transform = new GameObject("Body").transform;
		transform.SetParent(parent, false);
		Part(transform, _husk, _huskMat, Vector3.zero, Quaternion.identity, Vector3.one * radius);
		float[] array = new float[2] { -1f, 1f };
		foreach (float num in array)
		{
			Vector3 val = new Vector3(0.3f * num, 0.2f, 0.97f) * radius;
			Part(transform, _ball, _darkMat, val, Quaternion.identity, Vector3.one * 0.16f * radius);
			Part(transform, _ball, _whiteMat, val + new Vector3(0.05f, 0.05f, 0.11f) * radius, Quaternion.identity, Vector3.one * 0.05f * radius);
			Quaternion rot = Quaternion.Euler(0f, -18f * num, 28f * num);
			Part(transform, _ball, _darkMat, new Vector3(0.3f * num, 0.45f, 0.86f) * radius, rot, new Vector3(0.24f, 0.06f, 0.08f) * radius);
		}
		Part(transform, _ball, _darkMat, new Vector3(0f, -0.3f, 1f) * radius, Quaternion.identity, new Vector3(0.12f, 0.07f, 0.07f) * radius);
		return transform;
	}

	internal static void Dust(Vector3 at)
	{
		//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_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: 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: Unknown result type (might be due to invalid IL or missing references)
		Ensure();
		((Component)Part(null, _ball, _dustMat, at, Quaternion.identity, new Vector3(0.22f, 0.12f, 0.22f))).gameObject.AddComponent<Fade>().Init(0.3f, Vector3.up * 0.6f, 1.4f);
	}

	internal static void Split(Vector3 at, Vector3 forward, float radius)
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: 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_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: 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_0065: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: 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_00c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_014e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0153: Unknown result type (might be due to invalid IL or missing references)
		//IL_0158: Unknown result type (might be due to invalid IL or missing references)
		//IL_015d: Unknown result type (might be due to invalid IL or missing references)
		//IL_016a: Unknown result type (might be due to invalid IL or missing references)
		//IL_016b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0170: 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_01a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
		Ensure();
		Vector3 spin = Vector3.Cross(Vector3.up, forward);
		Vector3 normalized = ((Vector3)(ref spin)).normalized;
		for (int i = -1; i <= 1; i += 2)
		{
			Transform transform = new GameObject("Coconut half").transform;
			transform.position = at;
			transform.rotation = Quaternion.LookRotation(forward, normalized * (float)i);
			Part(transform, _half, _huskMat, Vector3.zero, Quaternion.identity, Vector3.one * radius);
			Part(transform, _half, _fleshMat, Vector3.up * 0.02f * radius, Quaternion.identity, new Vector3(0.9f, 0.05f, 0.9f) * radius);
			((Component)transform).gameObject.AddComponent<Fade>().Init(1.4f, normalized * (float)i * 7f + Vector3.up * 8f, 0f, new Vector3(200f, 0f, 360f * (float)i), 25f);
		}
		Random random = new Random();
		for (int j = 0; j < 12; j++)
		{
			Vector3 val = Quaternion.Euler((float)random.NextDouble() * 140f - 70f, (float)random.NextDouble() * 360f, 0f) * Vector3.up;
			Fade fade = ((Component)Part(null, _ball, _fleshMat, at, Quaternion.identity, Vector3.one * (0.12f + 0.1f * (float)random.NextDouble()))).gameObject.AddComponent<Fade>();
			Vector3 velocity = val * (6f + 6f * (float)random.NextDouble());
			spin = default(Vector3);
			fade.Init(0.9f, velocity, 0f, spin, 30f);
		}
	}

	private static Transform Part(Transform parent, Mesh mesh, Material material, Vector3 local, Quaternion rot, Vector3 scale)
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_003d: 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)
		GameObject val = new GameObject("Part");
		val.transform.SetParent(parent, false);
		val.transform.localPosition = local;
		val.transform.localRotation = rot;
		val.transform.localScale = scale;
		val.AddComponent<MeshFilter>().sharedMesh = mesh;
		((Renderer)val.AddComponent<MeshRenderer>()).sharedMaterial = material;
		return val.transform;
	}

	private static void Ensure()
	{
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)_husk != (Object)null))
		{
			_husk = Sphere(40, 24, husk: true);
			_ball = Sphere(14, 10, husk: false);
			_half = Hemisphere(28, 10);
			Material source = ToonBase();
			_huskMat = Toon(source, Color.white, HuskTexture());
			_darkMat = Toon(source, new Color(0.05f, 0.03f, 0.02f), null);
			_whiteMat = Toon(source, Color.white, null);
			_fleshMat = Toon(source, new Color(0.97f, 0.95f, 0.9f), null);
			_dustMat = Toon(source, new Color(0.85f, 0.75f, 0.6f), null);
		}
	}

	private static Material ToonBase()
	{
		//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00da: Expected O, but got Unknown
		Material[] array = Resources.FindObjectsOfTypeAll<Material>();
		foreach (Material val in array)
		{
			if ((Object)(object)val != (Object)null && ((Object)val).name == "ToonWood" && (Object)(object)val.shader != (Object)null)
			{
				return val;
			}
		}
		if ((Object)(object)ObstacleManager.instance != (Object)null)
		{
			ObstacleDescription[] allowedObstacleDescriptions = ObstacleManager.instance.allowedObstacleDescriptions;
			foreach (ObstacleDescription val2 in allowedObstacleDescriptions)
			{
				if (!((Object)(object)val2 == (Object)null) && !(((Object)val2).name != "Pea") && !((Object)(object)val2.prefab == (Object)null))
				{
					MeshRenderer componentInChildren = ((Component)val2.prefab).GetComponentInChildren<MeshRenderer>(true);
					if ((Object)(object)componentInChildren != (Object)null)
					{
						return ((Renderer)componentInChildren).sharedMaterial;
					}
				}
			}
		}
		FishyCardsPlugin.Log.LogWarning((object)"Coconut: no toon material found.");
		return new Material(Shader.Find("Universal Render Pipeline/Lit"));
	}

	private static Material Toon(Material source, Color c, Texture2D texture)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Expected O, but got Unknown
		//IL_001a: 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_0039: 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_0063: Unknown result type (might be due to invalid IL or missing references)
		Material val = new Material(source);
		if (val.HasProperty("_Color"))
		{
			val.SetColor("_Color", c);
		}
		if (val.HasProperty("_RampTint"))
		{
			val.SetColor("_RampTint", c * 0.55f);
		}
		if (val.HasProperty("_BaseColor"))
		{
			val.SetColor("_BaseColor", val.HasProperty("_RampTint") ? Color.white : c);
		}
		if ((Object)(object)texture != (Object)null && val.HasProperty("_MainTex"))
		{
			val.SetTexture("_MainTex", (Texture)(object)texture);
		}
		return val;
	}

	private static Texture2D HuskTexture()
	{
		//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_0019: Expected O, but got Unknown
		//IL_0134: Unknown result type (might be due to invalid IL or missing references)
		//IL_0135: Unknown result type (might be due to invalid IL or missing references)
		//IL_0138: Unknown result type (might be due to invalid IL or missing references)
		//IL_013d: Unknown result type (might be due to invalid IL or missing references)
		//IL_013f: Unknown result type (might be due to invalid IL or missing references)
		//IL_014f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0154: Unknown result type (might be due to invalid IL or missing references)
		//IL_0169: Unknown result type (might be due to invalid IL or missing references)
		//IL_016e: Unknown result type (might be due to invalid IL or missing references)
		//IL_017c: Unknown result type (might be due to invalid IL or missing references)
		//IL_017e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0183: Unknown result type (might be due to invalid IL or missing references)
		Texture2D val = new Texture2D(256, 128, (TextureFormat)4, true)
		{
			wrapMode = (TextureWrapMode)0
		};
		Color32[] array = (Color32[])(object)new Color32[32768];
		Color val2 = default(Color);
		((Color)(ref val2))..ctor(0.16f, 0.08f, 0.035f);
		Color val3 = default(Color);
		((Color)(ref val3))..ctor(0.52f, 0.31f, 0.14f);
		Color val4 = default(Color);
		((Color)(ref val4))..ctor(0.24f, 0.13f, 0.06f);
		for (int i = 0; i < 128; i++)
		{
			float num = (float)i / 127f;
			for (int j = 0; j < 256; j++)
			{
				float num2 = (float)j / 256f * (float)Math.PI * 2f;
				float num3 = 0.5f + 0.5f * Mathf.Sin(num2 * 34f + 2.2f * Mathf.Sin(num * 9f) + 1.3f * Mathf.Sin(num2 * 3f));
				float num4 = 0.5f + 0.5f * Mathf.Sin(num2 * 87f + num * 30f);
				float num5 = Mathf.Clamp01(0.2f + 0.6f * num3 * num4 + 0.15f * Mathf.Sin(num2 * 13f + num * 12f));
				Color val5 = Color.Lerp(val2, val3, num5);
				val5 = Color.Lerp(val4 * (0.85f + 0.3f * num3), val5, Mathf.Clamp01((num - 0.12f) * 5f));
				array[i * 256 + j] = Color32.op_Implicit(val5);
			}
		}
		val.SetPixels32(array);
		val.Apply();
		return val;
	}

	private static Mesh Sphere(int lon, int lat, bool husk)
	{
		//IL_0076: 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_01ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d7: Expected O, but got Unknown
		//IL_011c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0128: 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_00d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0114: Unknown result type (might be due to invalid IL or missing references)
		//IL_0119: Unknown result type (might be due to invalid IL or missing references)
		List<Vector3> list = new List<Vector3>();
		List<Vector2> list2 = new List<Vector2>();
		List<int> list3 = new List<int>();
		Vector3 val = default(Vector3);
		for (int i = 0; i <= lat; i++)
		{
			float num = (float)i / (float)lat;
			float num2 = num * (float)Math.PI;
			for (int j = 0; j <= lon; j++)
			{
				float num3 = (float)j / (float)lon;
				float num4 = num3 * (float)Math.PI * 2f;
				((Vector3)(ref val))..ctor(Mathf.Sin(num2) * Mathf.Cos(num4), Mathf.Sin(num2) * Mathf.Sin(num4), Mathf.Cos(num2));
				Vector3 item = val;
				if (husk)
				{
					float num5 = 0.025f * (0.5f + 0.5f * Mathf.Sin(num4 * 34f + 2.2f * Mathf.Sin(num * 9f))) + 0.012f * Mathf.Sin(num4 * 87f + num * 30f);
					item = new Vector3(val.x, val.y * 0.94f, val.z * 1.12f) * (1f - num5 * Mathf.Clamp01((num - 0.12f) * 5f));
				}
				list.Add(item);
				list2.Add(new Vector2(num3, num));
			}
		}
		for (int k = 0; k < lat; k++)
		{
			for (int l = 0; l < lon; l++)
			{
				int num6 = k * (lon + 1) + l;
				int num7 = num6 + lon + 1;
				list3.AddRange(new int[6]
				{
					num6,
					num6 + 1,
					num7,
					num6 + 1,
					num7 + 1,
					num7
				});
			}
		}
		Mesh val2 = new Mesh();
		val2.SetVertices(list);
		val2.SetUVs(0, list2);
		val2.SetTriangles(list3, 0);
		val2.RecalculateNormals();
		val2.RecalculateBounds();
		return val2;
	}

	private static Mesh Hemisphere(int lon, int lat)
	{
		//IL_007f: Unknown result type (might be due to invalid IL or missing references)
		//IL_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_011d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0122: 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_0131: Unknown result type (might be due to invalid IL or missing references)
		//IL_0139: Unknown result type (might be due to invalid IL or missing references)
		//IL_013f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0146: Expected O, but got Unknown
		List<Vector3> list = new List<Vector3>();
		List<Vector2> list2 = new List<Vector2>();
		List<int> list3 = new List<int>();
		for (int i = 0; i <= lat; i++)
		{
			float num = (float)i / (float)lat;
			float num2 = num * (float)Math.PI * 0.5f;
			for (int j = 0; j <= lon; j++)
			{
				float num3 = (float)j / (float)lon;
				float num4 = num3 * (float)Math.PI * 2f;
				list.Add(new Vector3(Mathf.Sin(num2) * Mathf.Cos(num4), Mathf.Cos(num2) * 0.94f, Mathf.Sin(num2) * Mathf.Sin(num4) * 1.12f));
				list2.Add(new Vector2(num3, 0.3f + num * 0.7f));
			}
		}
		for (int k = 0; k < lat; k++)
		{
			for (int l = 0; l < lon; l++)
			{
				int num5 = k * (lon + 1) + l;
				int num6 = num5 + lon + 1;
				list3.AddRange(new int[6]
				{
					num5,
					num6,
					num5 + 1,
					num5 + 1,
					num6,
					num6 + 1
				});
			}
		}
		Mesh val = new Mesh();
		val.SetVertices(list);
		val.SetUVs(0, list2);
		val.SetTriangles(list3, 0);
		val.RecalculateNormals();
		val.RecalculateBounds();
		return val;
	}
}
internal static class FakeCheckpointCounter
{
	private static int RealCount
	{
		get
		{
			if (!((Object)(object)LevelManager.instance != (Object)null) || !((Object)(object)LevelManager.instance.levelDefinition != (Object)null))
			{
				return 0;
			}
			return LevelManager.instance.levelDefinition.checkpoints.Count;
		}
	}

	private static List<FakeCheckpointMark> Ordered()
	{
		return (from m in FakeCheckpointMark.All
			where (Object)(object)m != (Object)null && (Object)(object)m.Obstacle != (Object)null && (Object)(object)((NetworkBehaviour)m.Obstacle).NetworkObject != (Object)null
			orderby ((NetworkBehaviour)m.Obstacle).NetworkObjectId
			select m).ToList();
	}

	internal static void AddSlots(PlayerData player)
	{
		if (!((Object)(object)player == (Object)null) && ((NetworkBehaviour)player).IsOwner && player.passedCheckPoints != null)
		{
			int count = Ordered().Count;
			for (int i = 0; i < count; i++)
			{
				player.passedCheckPoints.Add(0uL);
			}
		}
	}

	internal static void MarkPassed(FakeCheckpointMark mark, PlayerData player)
	{
		if (!((Object)(object)player == (Object)null) && ((NetworkBehaviour)player).IsOwner && player.passedCheckPoints != null)
		{
			int num = RealCount + Ordered().IndexOf(mark);
			if (num >= RealCount && num < player.passedCheckPoints.Count)
			{
				player.passedCheckPoints[num] = (ulong)DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
			}
		}
	}

	internal static bool PassedRealOnes(PlayerData player, out bool result)
	{
		result = true;
		NetworkList<ulong> passedCheckPoints = player.passedCheckPoints;
		int realCount = RealCount;
		if (passedCheckPoints == null || passedCheckPoints.Count <= realCount)
		{
			return false;
		}
		for (int i = 0; i < realCount; i++)
		{
			if (passedCheckPoints[i] == 0L)
			{
				result = false;
			}
		}
		return true;
	}
}
[HarmonyPatch(typeof(PlayerData), "ClearCheckpoints")]
internal static class FakeCheckpointSlotsPatch
{
	private static void Postfix(PlayerData __instance)
	{
		FakeCheckpointCounter.AddSlots(__instance);
	}
}
[HarmonyPatch(typeof(PlayerData), "PassedAllCheckPoints")]
internal static class FakeCheckpointFinishPatch
{
	private static bool Prefix(PlayerData __instance, ref bool __result)
	{
		return !FakeCheckpointCounter.PassedRealOnes(__instance, out __result);
	}
}
internal sealed class FakeCheckpointHud : MonoBehaviour
{
	internal static bool LocalPicked;

	private bool _showBanner;

	private bool _showTags;

	private GUIStyle _title;

	private GUIStyle _text;

	private GUIStyle _tag;

	private void Update()
	{
		//IL_0030: 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_0033: Invalid comparison between Unknown and I4
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Invalid comparison between Unknown and I4
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Invalid comparison between Unknown and I4
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Invalid comparison between Unknown and I4
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Invalid comparison between Unknown and I4
		GameManager instance = GameManager.instance;
		GameState val = (GameState)(((Object)(object)instance != (Object)null && (Object)(object)instance.networkVariables != (Object)null) ? ((int)instance.networkVariables.state.Value) : 0);
		if ((int)val != 7 && (int)val != 8)
		{
			LocalPicked = false;
		}
		_showTags = (int)val == 8 && OwnsAFake();
		_showBanner = ((int)val == 7 && LocalPicked) || ((int)val == 8 && (LocalPicked || HoldsAFake()));
	}

	private static bool HoldsAFake()
	{
		if (GameManager.Players == null)
		{
			return false;
		}
		foreach (PlayerData player in GameManager.Players)
		{
			if ((Object)(object)player != (Object)null && ((NetworkBehaviour)player).IsOwner && (Object)(object)player.currentObstacle != (Object)null && (Object)(object)((Component)player.currentObstacle).GetComponent<FakeCheckpointMark>() != (Object)null)
			{
				return true;
			}
		}
		return false;
	}

	private static bool OwnsAFake()
	{
		foreach (FakeCheckpointMark item in FakeCheckpointMark.All)
		{
			if ((Object)(object)item != (Object)null && (Object)(object)item.Obstacle != (Object)null && ((NetworkBehaviour)item.Obstacle).IsOwner)
			{
				return true;
			}
		}
		return false;
	}

	private void OnGUI()
	{
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0174: Unknown result type (might be due to invalid IL or missing references)
		//IL_0179: Unknown result type (might be due to invalid IL or missing references)
		//IL_0183: 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_018d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0192: Unknown result type (might be due to invalid IL or missing references)
		//IL_0194: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a2: 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_01cd: Unknown result type (might be due to invalid IL or missing references)
		if (!_showBanner && !_showTags)
		{
			return;
		}
		EnsureStyles();
		if (_showBanner)
		{
			float num = Mathf.Min(900f, (float)Screen.width - 40f);
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(((float)Screen.width - num) / 2f, (float)Screen.height * 0.06f, num, 110f);
			GUI.backgroundColor = Color.black;
			GUI.Box(val, "");
			GUI.Box(val, "");
			GUI.backgroundColor = Color.white;
			Shadowed(new Rect(((Rect)(ref val)).x, ((Rect)(ref val)).y + 8f, ((Rect)(ref val)).width, 54f), Loc.BannerTitle, _title);
			Shadowed(new Rect(((Rect)(ref val)).x + 10f, ((Rect)(ref val)).y + 60f, ((Rect)(ref val)).width - 20f, 44f), Loc.BannerText, _text);
		}
		if (!_showTags)
		{
			return;
		}
		foreach (FakeCheckpointMark item in FakeCheckpointMark.All)
		{
			if ((Object)(object)item == (Object)null || (Object)(object)item.Obstacle == (Object)null || !((NetworkBehaviour)item.Obstacle).IsOwner)
			{
				continue;
			}
			Camera val2 = CameraFor(item.Obstacle.playerInfos);
			if (!((Object)(object)val2 == (Object)null))
			{
				Vector3 val3 = val2.WorldToScreenPoint(((Component)item).transform.position + Vector3.up * 5f);
				if (!(val3.z <= 0f))
				{
					Shadowed(new Rect(val3.x - 120f, (float)Screen.height - val3.y - 25f, 240f, 50f), Loc.Tag, _tag);
				}
			}
		}
	}

	private static Camera CameraFor(PlayerData player)
	{
		Camera val = (((Object)(object)player != (Object)null) ? CameraManager.GetCamerasFromIndex(player.LocalIndex).Item1 : null);
		if (!((Object)(object)val != (Object)null))
		{
			return Camera.main;
		}
		return val;
	}

	private static void Shadowed(Rect r, string text, GUIStyle style)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		Color textColor = style.normal.textColor;
		style.normal.textColor = new Color(0f, 0f, 0f, 0.9f);
		GUI.Label(new Rect(((Rect)(ref r)).x + 2f, ((Rect)(ref r)).y + 2f, ((Rect)(ref r)).width, ((Rect)(ref r)).height), text, style);
		style.normal.textColor = textColor;
		GUI.Label(r, text, style);
	}

	private void EnsureStyles()
	{
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		if (_title == null)
		{
			_title = Style(44, new Color(1f, 0.25f, 0.2f));
			_text = Style(20, Color.white);
			_text.fontStyle = (FontStyle)0;
			_text.wordWrap = true;
			_tag = Style(36, new Color(1f, 0.25f, 0.2f));
		}
	}

	private static GUIStyle Style(int size, Color color)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0013: 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_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Expected O, but got Unknown
		GUIStyle val = new GUIStyle
		{
			fontSize = size,
			fontStyle = (FontStyle)1,
			alignment = (TextAnchor)4
		};
		val.normal.textColor = color;
		return val;
	}
}
internal sealed class FakeCheckpointMark : MonoBehaviour
{
	internal static readonly List<FakeCheckpointMark> All = new List<FakeCheckpointMark>();

	internal Obstacle Obstacle { get; private set; }

	private void Awake()
	{
		Obstacle = ((Component)this).GetComponent<Obstacle>();
	}

	private void OnEnable()
	{
		All.Add(this);
	}

	private void OnDisable()
	{
		All.Remove(this);
	}

	internal void OnDriveThrough(CheckPoint gate, Collider other)
	{
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Invalid comparison between Unknown and I4
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Invalid comparison between Unknown and I4
		//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: Expected O, but got Unknown
		if ((Object)(object)Obstacle == (Object)null || (int)Obstacle.state != 3)
		{
			return;
		}
		GameManager instance = GameManager.instance;
		if ((Object)(object)instance == (Object)null || (Object)(object)instance.networkVariables == (Object)null || (int)instance.networkVariables.state.Value != 5)
		{
			return;
		}
		PlayerNetworking componentInParent = ((Component)other).GetComponentInParent<PlayerNetworking>();
		PlayerData val = (((Object)(object)componentInParent != (Object)null) ? componentInParent.playerInfos : null);
		if (!((Object)(object)componentInParent == (Object)null) && ((NetworkBehaviour)componentInParent).IsOwner && !((Object)(object)val == (Object)null) && !gate.HasPassedCheckPoint(val))
		{
			gate.Pass(val);
			FakeCheckpointCounter.MarkPassed(this, val);
			if ((Object)(object)val.controller != (Object)null && (Object)(object)val.controller.effects != (Object)null)
			{
				val.controller.effects.PassCheckPoint();
			}
			instance.PlacePlayerAtSpawn(val, false);
			ManualLogSource log = FishyCardsPlugin.Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(37, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Fake Checkpoint: ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(val.DisplayNameRaw);
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" sent back to spawn.");
			}
			log.LogInfo(val2);
		}
	}

	internal static void Unregister(Obstacle obstacle)
	{
		ObstacleCheckpoint val = (ObstacleCheckpoint)(object)((obstacle is ObstacleCheckpoint) ? obstacle : null);
		if (val != null && !((Object)(object)val.checkPoint == (Object)null))
		{
			LevelDefinition val2 = (((Object)(object)LevelManager.instance != (Object)null) ? LevelManager.instance.levelDefinition : null);
			if (!((Object)(object)val2 == (Object)null) && val2.checkpoints.Contains(val.checkPoint))
			{
				val2.UnRegisterCheckPoint(val.checkPoint);
				FishyCardsPlugin.Log.LogInfo((object)"Fake Checkpoint spawned already placed: removed from the level's checkpoints.");
			}
		}
	}

	internal static void ResetAll()
	{
		foreach (FakeCheckpointMark item in All)
		{
			object obj;
			if ((Object)(object)item != (Object)null)
			{
				Obstacle obstacle = item.Obstacle;
				ObstacleCheckpoint val = (ObstacleCheckpoint)(object)((obstacle is ObstacleCheckpoint) ? obstacle : null);
				if (val != null)
				{
					obj = val.checkPoint;
					goto IL_0036;
				}
			}
			obj = null;
			goto IL_0036;
			IL_0036:
			CheckPoint val2 = (CheckPoint)obj;
			if ((Object)(object)val2 != (Object)null)
			{
				val2.Reset();
			}
		}
	}
}
[HarmonyPatch(typeof(ObstacleCheckpoint), "RegisterCheckpointDelayed")]
internal static class SkipCheckpointRegisterPatch
{
	private static bool Prefix(ObstacleCheckpoint __instance, ref IEnumerator __result)
	{
		if ((Object)(object)((Component)__instance).GetComponent<FakeCheckpointMark>() == (Object)null)
		{
			return true;
		}
		__result = Nothing();
		FishyCardsPlugin.Log.LogInfo((object)"Fake Checkpoint placed: not registered as a checkpoint.");
		return false;
	}

	private static IEnumerator Nothing()
	{
		yield break;
	}
}
[HarmonyPatch(typeof(CheckPoint), "OnTriggerEnter")]
internal static class TrapTriggerPatch
{
	private static bool Prefix(CheckPoint __instance, Collider other)
	{
		FakeCheckpointMark componentInParent = ((Component)__instance).GetComponentInParent<FakeCheckpointMark>();
		if ((Object)(object)componentInParent == (Object)null)
		{
			return true;
		}
		componentInParent.OnDriveThrough(__instance, other);
		return false;
	}
}
[HarmonyPatch(typeof(LevelDefinition), "ResetCheckPoints")]
internal static class ResetFakesPatch
{
	private static void Postfix()
	{
		FakeCheckpointMark.ResetAll();
	}
}
[HarmonyPatch(typeof(ObstacleSelectionElement), "Init")]
internal static class DraftDisguisePatch
{
	[HarmonyAfter(new string[] { "slipskid.cardkit" })]
	[HarmonyPriority(0)]
	private static void Postfix(ObstacleSelectionElement __instance, ObstacleDescription obstacleDescription)
	{
		if (FishyCardsPlugin.IsTrapThief(obstacleDescription))
		{
			if ((Object)(object)__instance.nameLabel != (Object)null)
			{
				__instance.nameLabel.text = Loc.TrapThiefName;
			}
			if ((Object)(object)__instance.descriptionLabel != (Object)null)
			{
				__instance.descriptionLabel.text = Loc.TrapThiefText;
			}
		}
		else if (FishyCardsPlugin.IsCoconut(obstacleDescription))
		{
			if ((Object)(object)__instance.nameLabel != (Object)null)
			{
				__instance.nameLabel.text = Loc.CoconutName;
			}
			if ((Object)(object)__instance.descriptionLabel != (Object)null)
			{
				__instance.descriptionLabel.text = Loc.CoconutText(Coconut.LocalKey());
			}
		}
		else
		{
			if (!FishyCardsPlugin.IsFakeCheckpoint(obstacleDescription))
			{
				return;
			}
			ObstacleDescription val = FishyCardsPlugin.Carrier();
			if (!((Object)(object)val == (Object)null))
			{
				if ((Object)(object)__instance.nameLabel != (Object)null)
				{
					__instance.nameLabel.text = TextProcessor.Process(val.displayName);
				}
				if ((Object)(object)__instance.descriptionLabel != (Object)null)
				{
					__instance.descriptionLabel.text = TextProcessor.Process(val.description);
				}
			}
		}
	}
}
[HarmonyPatch(typeof(ObstacleSelectionElement), "SetSelected")]
internal static class PickRevealPatch
{
	private static void Postfix(ObstacleSelectionElement __instance, PlayerData playerData)
	{
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0072: Expected O, but got Unknown
		if ((Object)(object)playerData == (Object)null || !((NetworkBehaviour)playerData).IsOwner || !FishyCardsPlugin.IsFakeCheckpoint(__instance.Description))
		{
			return;
		}
		if ((Object)(object)__instance.nameLabel != (Object)null)
		{
			__instance.nameLabel.text = Loc.CardName;
		}
		if ((Object)(object)__instance.descriptionLabel != (Object)null)
		{
			__instance.descriptionLabel.text = Loc.CardText;
		}
		if (!FakeCheckpointHud.LocalPicked)
		{
			ManualLogSource log = FishyCardsPlugin.Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(28, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(playerData.DisplayNameRaw);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" picked the Fake Checkpoint.");
			}
			log.LogInfo(val);
		}
		FakeCheckpointHud.LocalPicked = true;
	}
}
[HarmonyPatch(typeof(ObstacleManager), "GetRandomObstaclesDescriptions")]
internal static class ForceInDraftPatch
{
	private static void Postfix(bool modifierOnly, ref ((int, ObstacleDescription)[], (int, ObstacleAffixDescription)[]) __result)
	{
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Expected O, but got Unknown
		if (FishyCardsPlugin.ForceInDraft == null || !FishyCardsPlugin.ForceInDraft.Value || modifierOnly)
		{
			return;
		}
		Card fakeCheckpoint = FishyCardsPlugin.FakeCheckpoint;
		ObstacleDescription val = ((fakeCheckpoint != null) ? fakeCheckpoint.Asset : null);
		if ((Object)(object)val == (Object)null || (Object)(object)ObstacleManager.instance == (Object)null)
		{
			return;
		}
		int num = Array.IndexOf(ObstacleManager.instance.allowedObstacleDescriptions, val);
		(int, ObstacleDescription)[] item = __result.Item1;
		if (num >= 0 && item != null && item.Length != 0)
		{
			item[0] = (num, val);
			ManualLogSource log = FishyCardsPlugin.Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(53, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Fake Checkpoint forced into draft slot 1 (catalog #");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(num);
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(").");
			}
			log.LogInfo(val2);
		}
	}
}
[BepInPlugin("slipskid.fishycards", "Slip & Skid - Fishy Cards", "1.2.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public sealed class FishyCardsPlugin : BaseUnityPlugin
{
	public const string Guid = "slipskid.fishycards";

	public const string FakeCheckpointGuid = "a7c3e901-4b2d-4f8a-9c1e-0d5f6a7b8c9d";

	public const string TrapThiefGuid = "c4e1f2a8-6b3d-4e9a-8f17-2d5c9b0a1e36";

	public const string CoconutGuid = "e2a7d4c9-3f1b-4b8e-a6c5-9d0e7f2b4a18";

	internal const string CarrierName = "CheckpointGate";

	internal static ManualLogSource Log;

	internal static Card FakeCheckpoint;

	internal static Card TrapThiefCard;

	internal static Card CoconutCard;

	internal static ConfigEntry<bool> ForceInDraft;

	private void Awake()
	{
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: 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_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: 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_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f5: Expected O, but got Unknown
		//IL_009b: Expected O, but got Unknown
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cd: 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_00d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0125: Expected O, but got Unknown
		//IL_012f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0134: Unknown result type (might be due to invalid IL or missing references)
		//IL_013f: Unknown result type (might be due to invalid IL or missing references)
		//IL_014a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0155: Unknown result type (might be due to invalid IL or missing references)
		//IL_0157: Unknown result type (might be due to invalid IL or missing references)
		//IL_01