Decompiled source of BigPuzzleSDK v0.1.2

BigPuzzleSDK.dll

Decompiled 18 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Cryptography;
using System.Security.Permissions;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using BigPuzzleSDK;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.Attributes;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Il2CppSystem.Reflection;
using LobbyNetworking;
using Microsoft.CodeAnalysis;
using Mirror;
using Mirror.Authenticators;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("BigPuzzleSDK")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Editor mod for hot reloading puzzles")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BigPuzzleSDK")]
[assembly: AssemblyTitle("BigPuzzleSDK")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
public class PuzzleButton : PuzzleButtonBase
{
	private const string TemplatePath = "LandmarksNonChallenge/SpawnCourtyardandHubPlatform/Positioner/TeachingArea/Positioner/ObjectsTeaching/Switch/PushButton/BasicPushButton";

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

	private PuzzleEvent onPressed;

	private PuzzleEvent onReleased;

	private readonly List<PeckSwitch> switches = new List<PeckSwitch>();

	private readonly List<TrackedPeckState> states = new List<TrackedPeckState>();

	private PeckSwitch mainSwitch;

	private List<ushort> ticketIds = new List<ushort>();

	private int targetId;

	private bool wasHeld;

	internal static PuzzleButton pressing;

	internal bool IsHeld => wasHeld;

	public PuzzleButton(IntPtr ptr)
		: base(ptr)
	{
	}

	internal void SetupInteraction(int index)
	{
		//IL_0090: 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_00b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b7: 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_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Expected O, but got Unknown
		//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0108: Unknown result type (might be due to invalid IL or missing references)
		//IL_011f: Unknown result type (might be due to invalid IL or missing references)
		//IL_012d: Unknown result type (might be due to invalid IL or missing references)
		ManualLogSource log = Plugin.log;
		GameObject val = Templates.Find("LandmarksNonChallenge/SpawnCourtyardandHubPlatform/Positioner/TeachingArea/Positioner/ObjectsTeaching/Switch/PushButton/BasicPushButton");
		if ((Object)(object)val == (Object)null)
		{
			ManualLogSource val2 = log;
			bool flag = default(bool);
			BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(68, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[PuzzleButton] Vanilla button not found at '");
				((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>("LandmarksNonChallenge/SpawnCourtyardandHubPlatform/Positioner/TeachingArea/Positioner/ObjectsTeaching/Switch/PushButton/BasicPushButton");
				((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("' (is that area loaded?)");
			}
			val2.LogWarning(val3);
			return;
		}
		GameObject val4 = Templates.Clone(val, ((Component)this).transform);
		((Object)val4).name = "VanillaButton";
		val4.SetActive(true);
		val4.transform.localPosition = Vector3.zero;
		val4.transform.localRotation = Quaternion.identity;
		Vector3 lossyScale = ((Component)this).transform.lossyScale;
		val4.transform.localScale = new Vector3(Mathf.Approximately(lossyScale.x, 0f) ? 1f : (1f / lossyScale.x), Mathf.Approximately(lossyScale.y, 0f) ? 1f : (1f / lossyScale.y), Mathf.Approximately(lossyScale.z, 0f) ? 1f : (1f / lossyScale.z));
		Renderer component = ((Component)this).GetComponent<Renderer>();
		if ((Object)(object)component != (Object)null)
		{
			component.enabled = false;
		}
		Collider component2 = ((Component)this).GetComponent<Collider>();
		if ((Object)(object)component2 != (Object)null)
		{
			component2.enabled = false;
		}
		foreach (Component item in (Il2CppArrayBase<Component>)(object)val4.GetComponentsInChildren(Il2CppType.Of<PeckSwitch>(), true))
		{
			PeckSwitch val5 = ((Il2CppObjectBase)item).TryCast<PeckSwitch>();
			if (!((Object)(object)val5 == (Object)null))
			{
				switches.Add(val5);
				if ((Object)(object)mainSwitch == (Object)null && (Object)(object)((Component)val5).GetComponent<CastableTarget>() != (Object)null)
				{
					mainSwitch = val5;
				}
			}
		}
		foreach (Component item2 in (Il2CppArrayBase<Component>)(object)val4.GetComponentsInChildren(Il2CppType.Of<TrackedPeckState>(), true))
		{
			TrackedPeckState val6 = ((Il2CppObjectBase)item2).TryCast<TrackedPeckState>();
			if ((Object)(object)val6 != (Object)null)
			{
				states.Add(val6);
			}
		}
		ticketIds = Tickets.Allocate(switches.Count + states.Count, null, "C:\\Users\\Marcus\\Documents\\GitHub\\big-puzzle-sdk\\Mod\\PuzzleButton.cs");
		AssignTickets(register: false);
		if (!((Object)(object)mainSwitch != (Object)null))
		{
			return;
		}
		try
		{
			if ((Object)(object)mainSwitch.trackedStateSystem != (Object)null)
			{
				StateMirrors.HoldStates.Add(((Il2CppObjectBase)mainSwitch.trackedStateSystem).Pointer);
			}
		}
		catch (Exception)
		{
		}
		targetId = ((Object)((Component)mainSwitch).GetComponent<CastableTarget>()).GetInstanceID();
		byTarget[targetId] = this;
	}

	private void Start()
	{
		AssignTickets(register: true);
	}

	private void AssignTickets(bool register)
	{
		//IL_0066: 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)
		int num = 0;
		foreach (PeckSwitch @switch in switches)
		{
			if (register)
			{
				Register(((Il2CppObjectBase)@switch).Cast<ITicketed>(), @switch.ticket, ticketIds[num]);
			}
			@switch.useTicket = true;
			@switch.ticket = ticketIds[num];
			@switch.shellReference = new ShellReference(ticketIds[num]);
			num++;
		}
		foreach (TrackedPeckState state in states)
		{
			if (register)
			{
				Register(((Il2CppObjectBase)state).Cast<ITicketed>(), state.ticket, ticketIds[num]);
			}
			state.ticket = ticketIds[num];
			state.shellReference = new ShellReference(ticketIds[num]);
			num++;
		}
	}

	private static void Register(ITicketed item, ushort current, ushort wanted)
	{
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Expected O, but got Unknown
		TicketOffice instance = TicketOffice.instance;
		if ((Object)(object)instance == (Object)null)
		{
			return;
		}
		try
		{
			Dictionary<ushort, ITicketed> tickets = instance.tickets;
			if (current != wanted && tickets.ContainsKey(current) && ((Il2CppObjectBase)tickets[current]).Pointer == ((Il2CppObjectBase)item).Pointer)
			{
				tickets.Remove(current);
			}
			tickets[wanted] = item;
		}
		catch (Exception ex)
		{
			ManualLogSource log = Plugin.log;
			bool flag = default(bool);
			BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(45, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[PuzzleButton] ticket registration failed: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.GetType().Name);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
			}
			log.LogWarning(val);
		}
	}

	private void Update()
	{
		if ((Object)(object)mainSwitch == (Object)null)
		{
			return;
		}
		bool flag = (Object)(object)mainSwitch.playerHoldingThis != (Object)null;
		if (flag == wasHeld)
		{
			return;
		}
		wasHeld = flag;
		if (flag)
		{
			if (onPressed != null)
			{
				pressing = this;
				try
				{
					onPressed.Invoke();
				}
				finally
				{
					pressing = null;
				}
			}
			if (pressedHook != null)
			{
				pressedHook();
			}
		}
		else if (onReleased != null)
		{
			onReleased.Invoke();
		}
	}

	private void OnDestroy()
	{
		byTarget.Remove(targetId);
	}
}
namespace BigPuzzleSDK
{
	internal static class GameRefs
	{
		internal static class Box
		{
			public const string ExactPath = "LandmarksPlayerCountAny/CoordinatesHolding/PositionerStart/GourdBox/OpenableBox";

			public const string TemplateName = "OpenableBox";

			public const string PreferredPath = "GourdBox";

			public static readonly string[] DisabledChildren = new string[3] { "BoxOpenSwitch", "BoxGourdHome", "ButtonPanel" };
		}

		internal static class Button
		{
			public const string TemplatePath = "LandmarksNonChallenge/SpawnCourtyardandHubPlatform/Positioner/TeachingArea/Positioner/ObjectsTeaching/Switch/PushButton/BasicPushButton";
		}

		internal static class Confetti
		{
			public const string ExactPath = "LandmarksPlayerCountAny/TellerWindow/Positioner/RewardConfetti";

			public const string TemplateName = "RewardConfetti";

			public const string PreferredPath = "TellerWindow/Positioner/RewardConfetti";
		}

		internal static class Display
		{
			public const string ExactPath = "LandmarksPlayerCount4/Contents/RingRoomChallenge/Positioner/RingRoomChamber/PlayerCountToggledContents/PegtileStuff/MasterSequenceSplitFlap1Slot";

			public const string ExactPath3 = "LandmarksPlayerCount3/Contents/RingRoomChallenge 3 Player/Positioner/RingRoomChamber (3)/PlayerCountToggledContents/PegtileStuff/MasterSequenceSplitFlap1Slot";

			public const string ExactPath2 = "LandmarksPlayerCount2/Contents/RingRoomChallenge 2 Player/Positioner/RingRoomChamber/PlayerCountToggledContents/PegtileStuff/MasterSequenceSplitFlap1Slot";

			public const string TemplateName = "MasterSequenceSplitFlap1Slot";

			public const string ExactPathTwo = "LandmarksPlayerCount4/Contents/SilentGauntlet 4Player/Positioner/Level0/GauntletChamber00PegBoard/4Player/Peg0/MasterSequenceSplitFlap2Slot";

			public const string ExactPathThree = "LandmarksPlayerCount4/Contents/SilentGauntlet 4Player/Positioner/Level0/GauntletChamber00PegBoard/3Player/Peg0/MasterSequenceSplitFlap3Slot";

			public const string ExactPathFive = "LandmarksPlayerCountAny/TellerWindow/Positioner/MasterSequenceSplitFlap5Slot";
		}

		internal static class Door
		{
			public const string ExactPath = "LandmarksPlayerCountAny/TellerWindow/Positioner/BasicDoor";

			public const string LogicName = "BasicDoorPeckLogic";

			public const string PreferredPath = "TellerWindow/Positioner/BasicDoor";

			public static readonly string[] LeafColliders = new string[2] { "leftCollider", "rightCollider" };
		}

		internal static class Glass
		{
			public const string WireMaterialName = "SoundproofWire";
		}

		internal static class GourdPlinth
		{
			public const string ExactPath = "LandmarksNonChallenge/OverflowMonument/Positioner/GourdPlinth X13/Monuments/pivot/GourdPlinth X1";

			public const string TemplatePrefix = "GourdPlinth X";

			public const string PinName = "GourdPin";

			public const string ButtonedStateName = "flapIsButtonedSystem";

			public const string OpenStateName = "flapIsOpenSystem";

			public static readonly string[] RemovedComponents = new string[1] { "PeckEffectGourdMap" };
		}

		internal static class GourdVice
		{
			public const string ExactPath = "LandmarksPlayerCountAny/TellerWindow/Positioner/GourdVice";

			public const string VictorySwitchName = "GourdViceVictorySwitch";

			public const string PreferredPath = "TellerWindow";

			public const string PinnedSwitchName = "GourdViceOnGourdPinned";

			public const string LaunchSwitchName = "GourdViceLaunchSwitch";

			public static readonly string[] RemovedComponents = new string[2] { "PeckEffectGourdMap", "PeckEffectSavableHome" };
		}

		internal static class Item
		{
			public const string BellName = "cowbell_large_bell";

			public const string SwitchName = "CowbellSwitchSystem";

			public static readonly string[] RemovedParts = new string[1] { "CowbellAudio" };

			public static readonly string[] HiddenModels = new string[3] { "cowbell_large_clapper", "cowbell_medium_bell", "cowbell_small_bell" };

			public static readonly string[] SoundSets = new string[26]
			{
				"sfx_prop_peg", "sfx_prop_cowbell_large", "sfx_prop_buoy", "sfx_prop_footy", "sfx_prop_cannonball", "sfx_prop_torch", "sfx_prop_foldingChair", "sfx_prop_walkieTalkie", "sfx_prop_binocular", "sfx_prop_kettle",
				"sfx_prop_nightvisionGoggles", "sfx_prop_laserPointer", "sfx_prop_clock", "sfx_prop_pomodoro", "sfx_prop_sign", "sfx_prop_flaregun", "sfx_prop_blindfold", "sfx_prop_megaphone", "sfx_prop_salonBrush", "sfx_prop_laptop",
				"sfx_prop_foldingMap", "sfx_prop_coordinatesTracker", "sfx_prop_gourdholder", "sfx_prop_gourd_cradle", "sfx_prop_key", "sfx_prop_permo_sign"
			};
		}

		internal static class Light
		{
			public const string LensColorProperty = "_TintMask0";

			public static string TemplateName(PuzzleLightType kind)
			{
				return kind switch
				{
					PuzzleLightType.Pendant => "Light_PendantLamp", 
					PuzzleLightType.Spotlight_Black => "Light_Spotlight", 
					PuzzleLightType.Spotlight_Red => "Light_DownLight", 
					PuzzleLightType.Tube => "Light_Tube", 
					PuzzleLightType.Circle => "TrainLightFlood", 
					PuzzleLightType.Ring => "Light_Fluoro_Ring", 
					PuzzleLightType.Conductor => "ConductorLight", 
					_ => "Light_Table_Red", 
				};
			}

			public static string ExactPath(PuzzleLightType kind)
			{
				return kind switch
				{
					PuzzleLightType.TableRed => "LandmarksNonChallenge/SpawnCourtyardandHubPlatform/Positioner/TeachingArea/Positioner/ObjectsTeaching/Switch/PushButton/Light_Table_Red", 
					PuzzleLightType.Pendant => "LandmarksNonChallenge/SpawnCourtyardandHubPlatform/Positioner/TeachingArea/Positioner/ObjectsTeaching/Switch/LightSwitch/Light_PendantLamp", 
					PuzzleLightType.Spotlight_Black => "LandmarksNonChallenge/SpawnCourtyardandHubPlatform/Positioner/TeachingArea/Positioner/ObjectsTeaching/Light_Spotlight (6)", 
					PuzzleLightType.Conductor => "LandmarksPlayerCount4/Contents/ConductorConcert/Positioner/Room_Upper/BasicConductorPanel7/ConductorLight0", 
					_ => null, 
				};
			}

			public static string[] ExtraPaths(PuzzleLightType kind)
			{
				if (kind == PuzzleLightType.Conductor)
				{
					return new string[2] { "LandmarksPlayerCount3/Contents/PointersParadise/Positioner/BasicConductorPanel6/ConductorLight", "LandmarksPlayerCount2/Contents/ConductorConcert 2 Player/Positioner/Room_Upper/BasicConductorPanel7/ConductorLight1" };
				}
				return new string[0];
			}

			public static string PreferredPath(PuzzleLightType kind)
			{
				return kind switch
				{
					PuzzleLightType.Pendant => "ObjectsTeaching/Switch/LightSwitch/Light_PendantLamp", 
					PuzzleLightType.Spotlight_Black => "ObjectsTeaching/Light_Spotlight (6)", 
					PuzzleLightType.Spotlight_Red => "Hub Lighting/GameObject (1)/Light_DownLight (3)", 
					PuzzleLightType.Tube => "Lookout_RedCone/lighting and door/Roof/Light_Tube", 
					PuzzleLightType.Circle => "CarriageContentsFront/TrainLightFlood", 
					PuzzleLightType.Ring => "DoofChamber/Positioner/Lights/RingLight/Light_Fluoro_Ring", 
					PuzzleLightType.Conductor => "BasicConductorPanel7/ConductorLight0", 
					_ => "ObjectsTeaching/Switch/PushButton/Light_Table_Red", 
				};
			}
		}

		internal static class LiveSignal
		{
			public const string ExactPath = "LandmarksPlayerCountAny/TellerWindow/Positioner/LiveSignal";

			public const string LogicName = "LiveSignalPeckLogic";

			public const string PreferredPath = "TellerWindow/Positioner/LiveSignal";
		}

		internal static class PegBoard
		{
			public const string ExactPath = "LandmarksPlayerCountAny/TellerWindow/Positioner/PegBoard5Slot";

			public const string TemplateName = "PegBoard5Slot";

			public const string PreferredPath = "TellerWindow/Positioner/PegBoard5Slot";
		}

		internal static class PegTile
		{
			public const string ExactPath = "LandmarksPlayerCountAny/BlindfoldFishTrap/Positioner/Rack/PegTileRack_SetA/Pegtiles/PegTileProp1";

			public const string TemplateName = "PegTileProp1";

			public const string PreferredPath = "PegTileRack_SetA/Pegtiles/PegTileProp1";
		}

		internal static class Pillow
		{
			public const string ExactPath = "LandmarksPlayerCount4/Contents/TallButtonChallenge/Positioner/GourdValet/gourdValetPillowModel";

			public const string TemplateName = "gourdValetPillowModel";

			public const string PreferredPath = "GourdValet/gourdValetPillowModel";
		}

		internal static class PokeButton
		{
			public const string ExactPath = "LandmarksPlayerCount4/Contents/TallButtonChallenge/Positioner/PlayerCountAdjustment/BasicPokeButton";

			public const string ExactPath3 = "LandmarksPlayerCount3/Contents/TallButtonChallenge 3Player/Positioner/PlayerCountAdjustment/BasicPokeButton";

			public const string ExactPath2 = "LandmarksPlayerCount2/Contents/TallButtonChallenge 2Player/Positioner/PlayerCountAdjustment/BasicPokeButton";

			public const string TemplatePrefix = "BasicPokeButton";

			public const string LogicName = "PokeButtonPeckLogic";

			public const string PreferredPath = "TallButtonChallenge/Positioner/PlayerCountAdjustment/";
		}

		internal static class ProgressBar
		{
			public const string ExactPath = "LandmarksPlayerCount4/Contents/CenturionSong/CenturionConents/Positioner - signal room/CenturionRoom/BasicProgressBar";

			public const string ExactPath3 = "LandmarksPlayerCount3/Contents/CenturionSong 3Player/CenturionConents/Positioner - input room/CenturionRoom/BasicProgressBar";

			public const string ExactPath2 = "LandmarksPlayerCount2/Contents/CenturionSong 2Player/CenturionConents/Positioner - signal room/CenturionRoom/BasicProgressBar -outside";

			public const string SpiralPath = "LandmarksPlayerCountAny/MemoryBombs/Positioner/BasicProgressBar_spiral";

			public const string PreferredPath = "CenturionSong";
		}

		internal static class Seat
		{
			public static readonly string[] Paths = new string[2] { "LandmarksNonChallenge/CreditsTheatre/Positioner/Chair_Midcentury", "LandmarksPlayerCount4/Contents/CabinFeverLong/Positioner/CabinFeverHouse/Chair_Midcentury" };
		}

		internal static class SimPressSwitch
		{
			public const string ExactPath = "LandmarksPlayerCount4/Contents/SmallSimPressChallenge/Positioner/SimPressSwitch";

			public const string ExactPath3 = "LandmarksPlayerCount3/Contents/MediumSimPressChallenge 3Player/Positioner/MediumSimPressStation - 0/SimPressSwitch";

			public const string ExactPath2 = "LandmarksPlayerCount2/Contents/MediumSimPressChallenge 2Player/Positioner/MediumSimPressStation - 1/SimPressSwitch";

			public const string PreferredPath = "SmallSimPressChallenge/Positioner/SimPressSwitch";
		}

		internal static class StartSwitch
		{
			public const string ExactPath = "LandmarksPlayerCountAny/TellerWindow/Positioner/BasicKnob - primary";

			public const string PreferredPath = "TellerWindow/Positioner/BasicKnob - primary";
		}

		internal static class Switch
		{
			public const string ExactPath = "LandmarksNonChallenge/SpawnCourtyardandHubPlatform/Positioner/TeachingArea/Positioner/ObjectsTeaching/Switch/LightSwitch/BasicLightSwitch";

			public const string TemplateName = "BasicLightSwitch";

			public const string PreferredPath = "ObjectsTeaching/Switch/LightSwitch/BasicLightSwitch";
		}

		internal static class SyncPrototype
		{
			public const string ButtonPath = "LandmarksNonChallenge/SpawnCourtyardandHubPlatform/Positioner/TeachingArea/Positioner/ObjectsTeaching/Switch/PushButton/BasicPushButton";
		}

		internal static class Telescope
		{
			public const string ExactPath = "LandmarksPlayerCountAny/InvisibleInkChallenge/Positioner/FixedTelescope";

			public const string NormalPath = "LandmarksPlayerCountAny/OpticalTelegraph/Positioner/CentralArea/FixedTelescope";

			public const string PreferredPath = "InvisibleInkChallenge";
		}

		internal static class Timer
		{
			public const string ExactPath = "LandmarksPlayerCount4/Contents/CabinFever/Positioner/CabinFeverHouse/TimerObject";

			public const string ExactPath3 = "LandmarksPlayerCount3/Contents/CabinFeverLong 3Player/Positioner/CabinFeverHouse/TimerObject";

			public const string ExactPath2 = "LandmarksPlayerCount2/Contents/CabinFever 2Player/Positioner/CabinFeverHouse/TimerObject";

			public const string PreferredPath = "CabinFever";
		}

		internal static class Validator
		{
			public const string ExactPath = "LandmarksPlayerCountAny/TellerWindow/Positioner/PegTileValidatorWithScreenAndButton/BasicStandaloneValidatorScreen";

			public const string ScreenName = "BasicStandaloneValidatorScreen";

			public const string PreferredPath = "TellerWindow/Positioner/PegTileValidatorWithScreenAndButton/BasicStandaloneValidatorScreen";
		}

		internal static class Copies
		{
			public static readonly Dictionary<string, string[]> TemplatePaths = new Dictionary<string, string[]>
			{
				["PuzzleVanillaItem Blindfold"] = new string[2] { "LandmarksPlayerCountAny/BlindfoldCatwalk/Positioner/BlindfoldProp", "LandmarksPlayerCountAny/BlindfoldFishTrap/Positioner/BlindfoldProp" },
				["PuzzleVanillaItem FoldingChair"] = new string[2] { "LandmarksPlayerCount4/Contents/ConductorConcert/Positioner/Room_Outside/foldingChair", "LandmarksNonChallenge/SpeakerStage/Positioner/foldingChair" },
				["PuzzleVanillaItem Torch"] = new string[3] { "TunnelSystem/TunnelOutlet - Red/TorchParent/TorchProp", "LandmarksNonChallenge/Lookouts/Lookout_RedCone/TorchProp", "TunnelSystem/TunnelOutlet - Green/TorchParent/TorchProp" },
				["PuzzleVanillaItem FmRadio"] = new string[3] { "LandmarksNonChallenge/MusicGarden/Sports Valley - Greensteps/BroadcastStation/FmRadioProp", "LandmarksNonChallenge/MusicGarden/SouthPeakArea - Abbey/BroadcastStation/FmRadioProp", "LandmarksPlayerCountAny/MusicalHoliday/PositionerMusicGarden/BroadcastStation/FmRadioProp" },
				["PuzzleVanillaItem WalkieTalkie"] = new string[3] { "LandmarksNonChallenge/WalkieTalkieHolders/WalkieTalkieHolder - OceanTreasure2 (Blue)/WalkyTalkyHolder/WalkieTalkieHolder_base/WalkieTalkieProp", "LandmarksNonChallenge/WalkieTalkieHolders/WalkieTalkieHolder - Red Cone Hill (Yellow)/WalkyTalkyHolder/WalkieTalkieHolder_base/WalkieTalkieProp", "LandmarksNonChallenge/WalkieTalkieHolders/WalkieTalkieHolder - Red Cone Valley (Blue) (1)/WalkyTalkyHolder/WalkieTalkieHolder_base/WalkieTalkieProp" },
				["PuzzleVanillaItem Binoculars"] = new string[3] { "LandmarksNonChallenge/Lookouts/Lookout_RedCone/RoofStuff/BinocularsProp", "LandmarksNonChallenge/PeakMarker/Positioner/BinocularsProp", "LandmarksNonChallenge/Lookouts/Lookout_BlueTube/RoofStuff/BinocularsProp" },
				["PuzzleVanillaItem XrayGoggles"] = new string[3] { "LandmarksNonChallenge/Lookouts/Lookout_BlueTube/XrayGogglesProp", "LandmarksNonChallenge/Lookouts/Lookout_YellowZigzag/XrayGogglesProp", "LandmarksNonChallenge/Lookouts/Lookout_GreenHourglass/XrayGogglesProp" },
				["PuzzleVanillaItem Clock"] = new string[3] { "TrainSystem/TrainStop - South Valley Beach/WallHook/WallHookHome/ClockProp", "TrainSystem/TrainStop - Green Diffuser/WallHook/WallHookHome/ClockProp", "TrainSystem/TrainStop - Sports Valley/WallHook/WallHookHome/ClockProp" },
				["PuzzleVanillaItem Laser"] = new string[3] { "LandmarksNonChallenge/Lookouts/Lookout_RedCone/RoofStuff/LaserProp", "LandmarksNonChallenge/MapRoom/Positioner/MapRoom_entrance/PropBench/LaserProp", "LandmarksNonChallenge/Lookouts/Lookout_GreenHourglass/RoofStuff/LaserProp" },
				["PuzzleVanillaItem Megaphone"] = new string[3] { "LandmarksNonChallenge/MegaphoneHolders/PositionerPyramid/MegaphoneHolder_pyramid/MegaphoneProp", "LandmarksNonChallenge/MegaphoneHolders/PositionerRamp/MegaphoneHolder_ramp/MegaphoneProp", "LandmarksNonChallenge/MegaphoneHolders/PositionerSpiral/MegaphoneHolder_spiral/MegaphoneProp" },
				["PuzzleVanillaItem Kettle"] = new string[2] { "LandmarksPlayerCountAny/ScoutBombs/Positioner/Tokens/pivot/KettleProp", "LandmarksPlayerCount4/Contents/SilentGauntlet 4Player/Positioner/Level4/GauntletChamberVolleyBall/KettleProp" },
				["PuzzleVanillaItem CannonBall"] = new string[1] { "LandmarksPlayerCountAny/CannonBallCarry/PositionerBase/BaseHome/cannonballProp" },
				["PuzzleVanillaItem PermoSign"] = new string[2] { "LandmarksPlayerCountAny/CoordinatesSimPress/Positioner/WallhookWithPermoSign/WallHook/WallHookHome/PermoSignProp", "LandmarksPlayerCountAny/CoordinatesHolding/PositionerStart/WallhookWithPermoSign/WallHook/WallHookHome/PermoSignProp" },
				["PuzzleVanillaItem SpareSign"] = new string[1] { "LandmarksPlayerCountAny/CoordinatesSimPress/Positioner/SpareSignProp" },
				["PuzzleVanillaItem GourdHolder"] = new string[1] { "LandmarksNonChallenge/CartonPlaza/Positioner/GourdCartonProp" },
				["PuzzleVanillaItem Belt"] = new string[3] { "LandmarksNonChallenge/PackPavillions/UndergroundBackpackPavilion/PackPavilion Holster/PackHanger/PackHanger home/HolsterProp", "LandmarksNonChallenge/PackPavillions/HighlandsBackpackPavillion/PackPavilion Holster/HolsterProp", "LandmarksNonChallenge/PackPavillions/OverlookBackpackPavilion/PackPavilion Holster/PackHanger/PackHanger home/HolsterProp" },
				["PuzzleVanillaItem Backpack"] = new string[3] { "LandmarksNonChallenge/PackPavillions/CrevasseBackpackPavilion/BackpackPavilion/PackHanger/PackHanger home/BackpackProp", "LandmarksNonChallenge/PackPavillions/ForestBackpackPavilion/BackpackPavilion/PackHanger/PackHanger home/BackpackProp", "LandmarksNonChallenge/PackPavillions/MonkeyCreekBackpackPavillion/BackpackPavilion/PackHanger/PackHanger home/BackpackProp" },
				["PuzzleVanillaItem Gps"] = new string[1] { "LandmarksPlayerCountAny/CoordinatesSimPress/Positioner/CoordinateTrackerProp" },
				["PuzzleVanillaItem FoldingMap"] = new string[1] { "LandmarksNonChallenge/MapRoom/Positioner/MapRoom_entrance/PropBench/FoldingMapProp" },
				["PuzzleVanillaItem Compass"] = new string[1] { "LandmarksNonChallenge/MapRoom/Positioner/MapRoom_entrance/PropBench/CompassProp" },
				["PuzzleVanillaItem FlareGun"] = new string[3] { "LandmarksNonChallenge/DiffuserBuilding/Positioner/FlareGunProp", "LandmarksNonChallenge/Diffuser_Peak/Positioner/FlareGunPropGreen", "LandmarksNonChallenge/Diffuser_Spawn/Position/FlareGunPropYellow" },
				["PuzzleVanillaItem Cowbell"] = new string[1] { "LandmarksNonChallenge/SpawnCourtyardandHubPlatform/Positioner/TeachingArea/Positioner/ObjectsTeaching/PickUp/bellshelf/CowBellLargeProp" },
				["PuzzleVanillaItem Paintbrush"] = new string[2] { "LandmarksNonChallenge/Salon_Secret/Positioner/SalonBuilding/SalonBrushProp (1)", "LandmarksNonChallenge/Salon/Positioner/SalonBuilding/SalonBrushProp (1)" },
				["PuzzleVanillaItem CowbellMedium"] = new string[1] { "LandmarksNonChallenge/SpawnCourtyardandHubPlatform/Positioner/TeachingArea/Positioner/ObjectsTeaching/PickUp/bellshelf/CowBellMediumProp" },
				["PuzzleVanillaItem CowbellSmall"] = new string[1] { "LandmarksNonChallenge/SpawnCourtyardandHubPlatform/Positioner/TeachingArea/Positioner/ObjectsTeaching/PickUp/bellshelf/CowBellSmallProp" },
				["PuzzleVanillaItem Football"] = new string[1] { "LandmarksNonChallenge/SpawnCourtyardandHubPlatform/Positioner/TeachingArea/Positioner/FootyProp" },
				["PuzzleCountInput"] = new string[1] { "LandmarksPlayerCountAny/PerspectiveCounting/Positioner/InputPlatform/countingpivot/CountingMachine" },
				["PuzzleCountValidator"] = new string[1] { "LandmarksPlayerCountAny/PerspectiveCounting/Positioner/InputPlatform/validatorpivot/CountingValidatorDisplay" },
				["PuzzleIntercom"] = new string[1] { "LandmarksPlayerCount4/Contents/RingRoomChallenge/Positioner/RingRoomChamber/PlayerCountToggledContents/FixedRadio(sending)" },
				["PuzzleIntercomSpeaker"] = new string[1] { "LandmarksPlayerCountAny/SingerAndSelecter/Positioner/Intercoms/Intercom(listening) (2)" },
				["PuzzleSoundPeg"] = new string[1] { "LandmarksPlayerCountAny/SingerAndSelecter/Positioner/SelecterBuilding/PegTileSetSpeaker/PegTileProp Speaker" },
				["PuzzleSoundPegAnswer"] = new string[1] { "LandmarksPlayerCountAny/SingerAndSelecter/Positioner/SelecterBuilding/MasterSequenceSpeaker5/MasterSequenceSpeaker" },
				["PuzzleNoItemsGate"] = new string[1] { "LandmarksPlayerCountAny/PoetAndPreist/Positioner/PoetBuilding/BasicTurnstile OneWay - Priest" },
				["PuzzleNoItemsGate TwoWay"] = new string[1] { "LandmarksPlayerCountAny/PoetAndPreist/Positioner/PoetBuilding/BasicTurnstile (1)" },
				["PuzzleNoItemsGate BlindMask"] = new string[1] { "LandmarksPlayerCountAny/BlindfoldCatwalk/Positioner/BlindfoldTurnstile" },
				["PuzzleTimerSpawner"] = new string[3] { "LandmarksPlayerCount4/Contents/Obby/Positioner/ObbyBuilding/5/PomodoroDispenser", "LandmarksPlayerCount3/Contents/Obby 3Player/Positioner/ObbyBuilding/5/PomodoroDispenser", "LandmarksPlayerCount2/Contents/Obby 2Player/Positioner/ObbyBuilding/5/PomodoroDispenser" },
				["PuzzleTimerGoal"] = new string[3] { "LandmarksPlayerCount4/Contents/Obby/Positioner/ObbyBuilding/5/BasicReceptical", "LandmarksPlayerCount3/Contents/Obby 3Player/Positioner/ObbyBuilding/5/BasicReceptical/PlacementCastable/pomodoro_holder", "LandmarksPlayerCount2/Contents/Obby 2Player/Positioner/ObbyBuilding/5/BasicReceptical/PlacementCastable/pomodoro_holder" },
				["PuzzleFireworkLauncher"] = new string[1] { "LandmarksPlayerCountAny/FlareRun/Positioner Rocket/FixedFlare" },
				["PuzzleItem"] = new string[1] { "LandmarksNonChallenge/SpawnCourtyardandHubPlatform/Positioner/TeachingArea/Positioner/ObjectsTeaching/PickUp/bellshelf/CowBellLargeProp" },
				["PuzzleCirclePeg"] = new string[1] { "LandmarksPlayerCountAny/EggHunt/Positioner/Eggs/PegTileHook_Round_red/PegSlot/PegSlotHome/PegTileRoundProp" },
				["PuzzleCirclePegBoard"] = new string[1] { "LandmarksPlayerCountAny/EggHunt/Positioner/Building/PegBoard_EggHunt" },
				["PuzzleBuoyLight"] = new string[3] { "LandmarksNonChallenge/LooseBuoyPedestals/buoypedestal_Full_Orange", "LandmarksNonChallenge/LooseBuoyPedestals/Anywhere/buoypedestal_Full_Orange", "LandmarksNonChallenge/LooseBuoyPedestals/Intro/buoypedestalFull" },
				["PuzzleBuoyLight Red"] = new string[3] { "LandmarksPlayerCountAny/CannonBallCarry/buoypedestal_Full_Red", "LandmarksNonChallenge/LooseBuoyPedestals/buoypedestal_Full_Red", "LandmarksNonChallenge/LooseBuoyPedestals/Anywhere/buoypedestal_Full_Red" },
				["PuzzleButtonNHold"] = new string[5] { "LandmarksPlayerCount4/Contents/BlackTower/Positioner/NHoldFullSet/NHoldSet4/Pivot/ButtonNHoldFour", "LandmarksPlayerCount3/Contents/BlackTower PlayerCount3/Positioner/NHoldFullSet/NHoldSet4/Pivot/ButtonNHoldFour", "LandmarksPlayerCount3/Contents/BlackTower PlayerCount3/Positioner/NHoldFullSet/NHoldSet2/Pivot/ButtonNHoldTwo", "LandmarksPlayerCount2/Contents/BlackTower PlayerCount2/Positioner/NHoldFullSet/NHoldSet4/Pivot/ButtonNHoldFour", "LandmarksPlayerCount2/Contents/BlackTower PlayerCount2/Positioner/NHoldFullSet/NHoldSet2/Pivot/ButtonNHoldTwo" }
			};
		}

		internal static class Lobby
		{
			public const string ManagerType = "EOSPrivateLobbyManager";

			public const string UpdateAttribute = "UpdateAttribute";

			public const string ConvertToLobbyInfo = "ConvertToLobbyInfo";

			public const string DetailsExtensionsType = "LobbyDetailsExtensions";

			public const string TryGetStringAttribute = "TryGetStringAttribute";
		}

		internal static class PasswordPopup
		{
			public const string CancelButtonName = "CancelButton";
		}

		internal static class Hooks
		{
			public const string OnSetHeld = "OnSetHeld";

			public const string SetLobbyVisionActive = "SetLobbyVisionActive";

			public const string ApplyVolume = "ApplyVolume";

			public const string ApplyVolumeSfx = "ApplyVolumeSfx";

			public const string DoPeck = "DoPeck";

			public const string IsSafeToPlace = "IsSafeToPlace";

			public const string MatchesConditions = "MatchesConditions";

			public const string ServerSetPinned = "ServerSetPinned";

			public const string PredictivelyPlaceInHome = "PredictivelyPlaceInHome";

			public const string WriteCurrentSaveData = "WriteCurrentSaveData";

			public const string DeleteSave = "Delete";

			public const string MusicPlay = "Play";
		}
	}
	internal static class HeldJoinFix
	{
		private class Pending
		{
			public PlayerNetworking player;

			public float since;

			public float readyAt;

			public float nextTry;

			public int tries;
		}

		private static bool reportedSkip;

		private static bool reportedNudge;

		private static int nudges;

		private static readonly Dictionary<IntPtr, Pending> pending = new Dictionary<IntPtr, Pending>();

		private static bool applying;

		internal static void InstallHook(Harmony harmony)
		{
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			try
			{
				MethodInfo methodInfo = AccessTools.Method(typeof(PlayerNetworking), "OnSetHeld", (Type[])null, (Type[])null);
				if (methodInfo == null)
				{
					throw new MissingMethodException("PlayerNetworking.OnSetHeld not found");
				}
				harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(HeldJoinFix).GetMethod("HeldPrefix", BindingFlags.Static | BindingFlags.NonPublic)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
			catch (Exception ex)
			{
				ManualLogSource log = Plugin.log;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(113, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[HeldJoinFix] could not hook PlayerNetworking.OnSetHeld (");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.GetType().Name);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("); joining while a player holds a puzzle item may fail");
				}
				log.LogWarning(val);
			}
		}

		private static bool HeldPrefix(PlayerNetworking __instance, ref PlayerHeldInformation oldValue, PlayerHeldInformation newValue)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Invalid comparison between Unknown and I4
			try
			{
				if (applying)
				{
					return true;
				}
				IntPtr pointer = ((Il2CppObjectBase)__instance).Pointer;
				if ((int)newValue.heldType == 0)
				{
					pending.Remove(pointer);
					if (Unresolved(oldValue))
					{
						oldValue = null;
					}
					return true;
				}
				if (Unresolved(newValue))
				{
					if (!pending.ContainsKey(pointer))
					{
						pending[pointer] = new Pending
						{
							player = __instance,
							since = Time.unscaledTime
						};
					}
					if (!reportedSkip)
					{
						reportedSkip = true;
						Plugin.log.LogInfo((object)"[HeldJoinFix] a player is holding an item this PC doesn't have yet; skipped the game's held-item handler (it is shown once the item has arrived).");
					}
					return false;
				}
				if (pending.ContainsKey(pointer))
				{
					return false;
				}
				if (Unresolved(oldValue))
				{
					oldValue = null;
				}
				return true;
			}
			catch (Exception)
			{
				return true;
			}
		}

		internal static void Tick()
		{
			//IL_026b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0272: Expected O, but got Unknown
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Invalid comparison between Unknown and I4
			if (pending.Count == 0)
			{
				return;
			}
			float unscaledTime = Time.unscaledTime;
			List<IntPtr> list = null;
			bool flag2 = default(bool);
			foreach (KeyValuePair<IntPtr, Pending> item in pending)
			{
				Pending value = item.Value;
				if (list == null)
				{
					list = new List<IntPtr>();
				}
				bool flag = false;
				try
				{
					flag = (Object)(object)value.player == (Object)null;
				}
				catch (Exception)
				{
					flag = true;
				}
				if (flag)
				{
					list.Add(item.Key);
				}
				else if (unscaledTime - value.since > 90f)
				{
					Plugin.log.LogWarning((object)"[HeldJoinFix] gave up showing a held item after 90 s.");
					list.Add(item.Key);
				}
				else
				{
					if (unscaledTime < value.nextTry)
					{
						continue;
					}
					value.nextTry = unscaledTime + 0.25f;
					PlayerHeldInformation networkplayerHeldInformation;
					try
					{
						networkplayerHeldInformation = value.player.NetworkplayerHeldInformation;
					}
					catch (Exception)
					{
						list.Add(item.Key);
						continue;
					}
					if ((int)networkplayerHeldInformation.heldType == 0)
					{
						list.Add(item.Key);
						continue;
					}
					if (Unresolved(networkplayerHeldInformation))
					{
						value.readyAt = 0f;
						continue;
					}
					if (value.readyAt == 0f)
					{
						value.readyAt = unscaledTime + 1f;
					}
					if (unscaledTime < value.readyAt)
					{
						continue;
					}
					try
					{
						applying = true;
						value.player.OnSetHeld((PlayerHeldInformation)null, networkplayerHeldInformation);
						Plugin.log.LogInfo((object)("[HeldJoinFix] showed a held item that arrived after joining" + ((value.tries > 0) ? $" (after {value.tries} failed tries)" : "") + "."));
						list.Add(item.Key);
					}
					catch (Exception ex3)
					{
						value.tries++;
						value.nextTry = unscaledTime + 1.5f;
						Exception ex4 = ex3.InnerException ?? ex3;
						if (value.tries == 1)
						{
							ManualLogSource log = Plugin.log;
							BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(58, 2, ref flag2);
							if (flag2)
							{
								((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[HeldJoinFix] showing the held item failed, will retry: ");
								((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex4.GetType().Name);
								((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": ");
								((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex4.Message);
							}
							log.LogWarning(val);
							string stackTrace = ex4.StackTrace;
							if (!string.IsNullOrEmpty(stackTrace))
							{
								Plugin.log.LogWarning((object)("[HeldJoinFix] stack: " + ((stackTrace.Length > 900) ? stackTrace.Substring(0, 900) : stackTrace)));
							}
						}
						if (TryDirect(value.player, networkplayerHeldInformation))
						{
							list.Add(item.Key);
						}
						else if (value.tries >= 8)
						{
							Plugin.log.LogWarning((object)"[HeldJoinFix] gave up showing a held item after 8 tries; it appears once the player puts it down and picks it up.");
							list.Add(item.Key);
						}
					}
					finally
					{
						applying = false;
					}
				}
			}
			if (list == null)
			{
				return;
			}
			foreach (IntPtr item2 in list)
			{
				pending.Remove(item2);
			}
		}

		private static bool TryDirect(PlayerNetworking player, PlayerHeldInformation held)
		{
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Expected O, but got Unknown
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			bool flag = default(bool);
			try
			{
				Prop prop = held.GetProp();
				PlayerCharacter playerCharacter = player.playerCharacter;
				if ((Object)(object)prop == (Object)null || (Object)(object)playerCharacter == (Object)null)
				{
					ManualLogSource log = Plugin.log;
					BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(61, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[HeldJoinFix] direct attach not possible (prop ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)(object)prop == (Object)null) ? "null" : "ok");
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", character ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)(object)playerCharacter == (Object)null) ? "null" : "ok");
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(").");
					}
					log.LogWarning(val);
					return false;
				}
				prop.SetHeld(playerCharacter);
				Plugin.log.LogInfo((object)"[HeldJoinFix] attached the held item to the player directly.");
				return true;
			}
			catch (Exception ex)
			{
				Exception ex2 = ex.InnerException ?? ex;
				ManualLogSource log2 = Plugin.log;
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(38, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[HeldJoinFix] direct attach failed: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex2.GetType().Name);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex2.Message);
				}
				log2.LogWarning(val);
				return false;
			}
		}

		private static bool Unresolved(PlayerHeldInformation held)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Invalid comparison between Unknown and I4
			try
			{
				if ((int)held.heldType == 0)
				{
					return false;
				}
				return (Object)(object)held.identity == (Object)null || (Object)(object)held.GetProp() == (Object)null;
			}
			catch (Exception)
			{
				return true;
			}
		}

		internal static void NudgeHolders()
		{
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Expected O, but got Unknown
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkServer.active)
			{
				return;
			}
			try
			{
				foreach (Object item in (Il2CppArrayBase<Object>)(object)Resources.FindObjectsOfTypeAll(Il2CppType.Of<PlayerNetworking>()))
				{
					PlayerNetworking val = ((item != (Object)null) ? ((Il2CppObjectBase)item).TryCast<PlayerNetworking>() : null);
					if ((Object)(object)val == (Object)null)
					{
						continue;
					}
					PlayerHeldInformation networkplayerHeldInformation = val.NetworkplayerHeldInformation;
					if ((int)networkplayerHeldInformation.heldType != 0 && !((Object)(object)networkplayerHeldInformation.identity == (Object)null) && (networkplayerHeldInformation.identity.sceneId & 0xFF00000000000000uL) == 12754194144713244672uL)
					{
						MarkChanged(val);
						if (nudges++ < 5)
						{
							Plugin.log.LogInfo((object)"[HeldJoinFix] host: sent a player's held puzzle item again for a joining player.");
						}
					}
				}
			}
			catch (Exception ex)
			{
				if (!reportedNudge)
				{
					reportedNudge = true;
					ManualLogSource log = Plugin.log;
					bool flag = default(bool);
					BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(53, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[HeldJoinFix] could not check who is holding what: ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.GetType().Name);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
					}
					log.LogWarning(val2);
				}
			}
		}

		private static void MarkChanged(PlayerNetworking player)
		{
			((NetworkBehaviour)player).SetDirty();
		}
	}
	internal static class HostNotice
	{
		private class Notice
		{
			public GameObject box;

			public CanvasGroup group;

			public RectTransform rect;

			public float height;

			public float shownAt;
		}

		private const float ShowSeconds = 20f;

		private const float FadeInSeconds = 0.25f;

		private const float FadeOutSeconds = 1f;

		private const float Width = 820f;

		private const float Top = 48f;

		private const float Spacing = 10f;

		private const string LineColor = "#FF5A5A";

		private static readonly List<Notice> shown = new List<Notice>();

		private static GameObject root;

		private static TMP_FontAsset font;

		private static bool broken;

		internal static void Show(string title, params string[] lines)
		{
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Expected O, but got Unknown
			if (broken || !Build())
			{
				return;
			}
			try
			{
				string text = "<noparse>" + title + "</noparse>";
				if (lines != null)
				{
					foreach (string text2 in lines)
					{
						text = text + "\n<color=#FF5A5A><noparse>" + text2 + "</noparse></color>";
					}
				}
				shown.Add(MakeBox(text));
				Layout();
			}
			catch (Exception ex)
			{
				ManualLogSource log = Plugin.log;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(68, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[SDK] could not show an on-screen message (");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.GetType().Name);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("); see the log instead.");
				}
				log.LogWarning(val);
			}
		}

		internal static void Tick()
		{
			if (shown.Count == 0)
			{
				return;
			}
			bool flag = false;
			for (int num = shown.Count - 1; num >= 0; num--)
			{
				Notice notice = shown[num];
				float num2 = Time.unscaledTime - notice.shownAt;
				if ((Object)(object)notice.box == (Object)null || num2 >= 20f)
				{
					if ((Object)(object)notice.box != (Object)null)
					{
						Object.Destroy((Object)(object)notice.box);
					}
					shown.RemoveAt(num);
					flag = true;
				}
				else
				{
					float num3 = Mathf.Clamp01(num2 / 0.25f);
					float num4 = Mathf.Clamp01((20f - num2) / 1f);
					notice.group.alpha = Mathf.Min(num3, num4);
				}
			}
			if (flag)
			{
				Layout();
			}
		}

		private static void Layout()
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			float num = -48f;
			foreach (Notice item in shown)
			{
				if (!((Object)(object)item.rect == (Object)null))
				{
					item.rect.anchoredPosition = new Vector2(0f, num);
					num -= item.height + 10f;
				}
			}
		}

		private static Notice MakeBox(string content)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: 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_00ca: Expected O, but got Unknown
			//IL_00f2: 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_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: 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)
			GameObject val = new GameObject("Message");
			val.transform.SetParent(root.transform, false);
			Image val2 = val.AddComponent<Image>();
			((Graphic)val2).color = new Color(0.07f, 0.07f, 0.09f, 0.88f);
			((Graphic)val2).raycastTarget = false;
			CanvasGroup val3 = val.AddComponent<CanvasGroup>();
			val3.interactable = false;
			val3.blocksRaycasts = false;
			val3.alpha = 0f;
			RectTransform component = val.GetComponent<RectTransform>();
			component.anchorMin = new Vector2(0.5f, 1f);
			component.anchorMax = new Vector2(0.5f, 1f);
			component.pivot = new Vector2(0.5f, 1f);
			GameObject val4 = new GameObject("Text");
			val4.transform.SetParent(val.transform, false);
			TextMeshProUGUI val5 = val4.AddComponent<TextMeshProUGUI>();
			RectTransform component2 = val4.GetComponent<RectTransform>();
			component2.anchorMin = Vector2.zero;
			component2.anchorMax = Vector2.one;
			component2.offsetMin = new Vector2(24f, 18f);
			component2.offsetMax = new Vector2(-24f, -18f);
			if ((Object)(object)font != (Object)null)
			{
				((TMP_Text)val5).font = font;
			}
			((TMP_Text)val5).fontSize = 32f;
			((Graphic)val5).color = Color.white;
			((TMP_Text)val5).alignment = (TextAlignmentOptions)514;
			((Graphic)val5).raycastTarget = false;
			((TMP_Text)val5).text = content;
			float num = ((TMP_Text)val5).GetPreferredValues(content, 772f, 0f).y + 36f;
			component.sizeDelta = new Vector2(820f, num);
			return new Notice
			{
				box = val,
				group = val3,
				rect = component,
				height = num,
				shownAt = Time.unscaledTime
			};
		}

		private static bool Build()
		{
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Expected O, but got Unknown
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)root != (Object)null)
			{
				return true;
			}
			try
			{
				root = new GameObject("BigPuzzleSDK Notice");
				Object.DontDestroyOnLoad((Object)(object)root);
				Canvas val = root.AddComponent<Canvas>();
				val.renderMode = (RenderMode)0;
				val.sortingOrder = 32000;
				CanvasScaler val2 = root.AddComponent<CanvasScaler>();
				val2.uiScaleMode = (ScaleMode)1;
				val2.referenceResolution = new Vector2(1920f, 1080f);
				val2.matchWidthOrHeight = 0.5f;
				font = GameFont();
				return true;
			}
			catch (Exception ex)
			{
				broken = true;
				ManualLogSource log = Plugin.log;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(68, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[SDK] could not show an on-screen message (");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex.GetType().Name);
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(": ");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex.Message);
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("); see the log instead.");
				}
				log.LogWarning(val3);
				if ((Object)(object)root != (Object)null)
				{
					Object.Destroy((Object)(object)root);
				}
				root = null;
				return false;
			}
		}

		internal static TMP_FontAsset GameFont()
		{
			//IL_0041: 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)
			try
			{
				foreach (Object item in (Il2CppArrayBase<Object>)(object)Resources.FindObjectsOfTypeAll(Il2CppType.Of<TextMeshProUGUI>()))
				{
					TextMeshProUGUI val = ((Il2CppObjectBase)item).TryCast<TextMeshProUGUI>();
					if (!((Object)(object)val == (Object)null) && !((Object)(object)((TMP_Text)val).font == (Object)null))
					{
						Scene scene = ((Component)val).gameObject.scene;
						if (((Scene)(ref scene)).IsValid())
						{
							return ((TMP_Text)val).font;
						}
					}
				}
			}
			catch (Exception)
			{
			}
			try
			{
				return TMP_Settings.defaultFontAsset;
			}
			catch (Exception)
			{
				return null;
			}
		}
	}
	internal static class JoinPopup
	{
		private const string Title = "PuzzleSDK versions don't match host:";

		private const string LineColor = "#FF5A5A";

		private static string[] pending;

		private static PasswordMenu cachedMenu;

		private static PasswordMenu menu;

		private static TMP_InputField lockedField;

		private static bool fieldWasInteractable;

		private static GameObject root;

		private static bool open;

		private static float nextCheck;

		private static float pendingSince;

		private static bool reportedWaiting;

		internal static void Set(string[] lines)
		{
			if (lines == null || lines.Length == 0)
			{
				pending = null;
				return;
			}
			pending = lines;
			pendingSince = Time.unscaledTime;
			reportedWaiting = false;
			Plugin.log.LogInfo((object)("[JoinPopup] the password screen will show: " + string.Join(" | ", lines)));
		}

		internal static void Clear()
		{
			pending = null;
		}

		internal static void Tick()
		{
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Expected O, but got Unknown
			if (open)
			{
				bool flag;
				try
				{
					flag = (Object)(object)menu == (Object)null || (Object)(object)root == (Object)null || !((Component)menu).gameObject.activeInHierarchy;
				}
				catch (Exception)
				{
					flag = true;
				}
				if (flag)
				{
					Close();
				}
			}
			else
			{
				if (pending == null || Time.unscaledTime < nextCheck)
				{
					return;
				}
				nextCheck = Time.unscaledTime + 0.2f;
				PasswordMenu val = ActiveMenu();
				if ((Object)(object)val != (Object)null)
				{
					Open(val);
				}
				else
				{
					if (reportedWaiting || !(Time.unscaledTime - pendingSince > 6f))
					{
						return;
					}
					reportedWaiting = true;
					bool flag2 = default(bool);
					string text;
					try
					{
						object obj2;
						if (!((Object)(object)cachedMenu == (Object)null))
						{
							string[] obj = new string[5] { "PasswordMenu found but not shown (activeSelf=", null, null, null, null };
							flag2 = ((Component)cachedMenu).gameObject.activeSelf;
							obj[1] = flag2.ToString();
							obj[2] = ", activeInHierarchy=";
							flag2 = ((Component)cachedMenu).gameObject.activeInHierarchy;
							obj[3] = flag2.ToString();
							obj[4] = ")";
							obj2 = string.Concat(obj);
						}
						else
						{
							obj2 = "no PasswordMenu object found";
						}
						text = (string)obj2;
					}
					catch (Exception)
					{
						text = "PasswordMenu state unreadable";
					}
					ManualLogSource log = Plugin.log;
					BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(129, 1, ref flag2);
					if (flag2)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[JoinPopup] 6 s later the password screen still isn't up: ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(text);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(". A lobby without a password may skip that screen, so nothing is shown.");
					}
					log.LogInfo(val2);
				}
			}
		}

		private static PasswordMenu ActiveMenu()
		{
			//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)
			try
			{
				if ((Object)(object)cachedMenu == (Object)null)
				{
					foreach (Object item in (Il2CppArrayBase<Object>)(object)Resources.FindObjectsOfTypeAll(Il2CppType.Of<PasswordMenu>()))
					{
						PasswordMenu val = ((item != (Object)null) ? ((Il2CppObjectBase)item).TryCast<PasswordMenu>() : null);
						if (!((Object)(object)val == (Object)null))
						{
							Scene scene = ((Component)val).gameObject.scene;
							if (((Scene)(ref scene)).IsValid())
							{
								cachedMenu = val;
								break;
							}
						}
					}
				}
				return ((Object)(object)cachedMenu != (Object)null && ((Component)cachedMenu).gameObject.activeInHierarchy) ? cachedMenu : null;
			}
			catch (Exception)
			{
				cachedMenu = null;
				return null;
			}
		}

		private static void Open(PasswordMenu screen)
		{
			//IL_0581: Unknown result type (might be due to invalid IL or missing references)
			//IL_0588: Expected O, but got Unknown
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected O, but got Unknown
			//IL_0523: Unknown result type (might be due to invalid IL or missing references)
			//IL_052a: Expected O, but got Unknown
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: 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_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Expected O, but got Unknown
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_029b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a2: Expected O, but got Unknown
			//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f6: Expected O, but got Unknown
			//IL_033f: Unknown result type (might be due to invalid IL or missing references)
			//IL_037e: 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_03b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_040c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0419: Unknown result type (might be due to invalid IL or missing references)
			//IL_0431: Unknown result type (might be due to invalid IL or missing references)
			//IL_044c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0469: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_0496: Unknown result type (might be due to invalid IL or missing references)
			//IL_0498: Unknown result type (might be due to invalid IL or missing references)
			//IL_0486: Unknown result type (might be due to invalid IL or missing references)
			//IL_0488: Unknown result type (might be due to invalid IL or missing references)
			string[] array = pending;
			bool flag = default(bool);
			try
			{
				menu = screen;
				Transform val = FindChild(((Component)screen).transform, "CancelButton");
				CanvasScaler val2 = null;
				try
				{
					val2 = ((Component)screen).GetComponentInParent<CanvasScaler>();
				}
				catch (Exception)
				{
				}
				root = new GameObject("BigPuzzleSDK Join Popup");
				Object.DontDestroyOnLoad((Object)(object)root);
				Canvas val3 = root.AddComponent<Canvas>();
				val3.renderMode = (RenderMode)0;
				val3.sortingOrder = 32001;
				CanvasScaler val4 = root.AddComponent<CanvasScaler>();
				if ((Object)(object)val2 != (Object)null)
				{
					val4.uiScaleMode = val2.uiScaleMode;
					val4.referenceResolution = val2.referenceResolution;
					val4.screenMatchMode = val2.screenMatchMode;
					val4.matchWidthOrHeight = val2.matchWidthOrHeight;
					val4.scaleFactor = val2.scaleFactor;
					val4.referencePixelsPerUnit = val2.referencePixelsPerUnit;
				}
				else
				{
					val4.uiScaleMode = (ScaleMode)1;
					val4.referenceResolution = new Vector2(1920f, 1080f);
					val4.matchWidthOrHeight = 0.5f;
				}
				root.AddComponent<GraphicRaycaster>();
				GameObject val5 = new GameObject("Dim");
				val5.transform.SetParent(root.transform, false);
				Image val6 = val5.AddComponent<Image>();
				((Graphic)val6).color = new Color(0f, 0f, 0f, 0f);
				((Graphic)val6).raycastTarget = true;
				Stretch(val5.GetComponent<RectTransform>());
				Rect rect = ((Component)screen).GetComponent<RectTransform>().rect;
				float num = ((Rect)(ref rect)).width;
				if (num < 200f)
				{
					num = 1920f;
				}
				Vector2 val7 = default(Vector2);
				((Vector2)(ref val7))..ctor(420f, 110f);
				float num2 = 36f;
				if ((Object)(object)val != (Object)null)
				{
					rect = ((Component)val).GetComponent<RectTransform>().rect;
					Vector2 size = ((Rect)(ref rect)).size;
					if (size.x > 10f && size.y > 10f)
					{
						val7 = size;
					}
					TextMeshProUGUI componentInChildren = ((Component)val).GetComponentInChildren<TextMeshProUGUI>(true);
					if ((Object)(object)componentInChildren != (Object)null && ((TMP_Text)componentInChildren).fontSize > 8f)
					{
						num2 = ((TMP_Text)componentInChildren).fontSize;
					}
				}
				string text = "<b><nobr><noparse>PuzzleSDK versions don't match host:</noparse></nobr></b>";
				string[] array2 = array;
				foreach (string text2 in array2)
				{
					text = text + "\n<color=#FF5A5A><noparse>" + text2 + "</noparse></color>";
				}
				float num3 = num * 0.65f;
				float num4 = num2 * 0.8f;
				float num5 = num2 * 1.8f;
				GameObject val8 = new GameObject("Message");
				val8.transform.SetParent(root.transform, false);
				Image val9 = val8.AddComponent<Image>();
				((Graphic)val9).color = Color.white;
				((Graphic)val9).raycastTarget = false;
				RectTransform component = val8.GetComponent<RectTransform>();
				Center(component);
				GameObject val10 = new GameObject("Text");
				val10.transform.SetParent(val8.transform, false);
				TextMeshProUGUI val11 = val10.AddComponent<TextMeshProUGUI>();
				TMP_FontAsset val12 = HostNotice.GameFont();
				if ((Object)(object)val12 != (Object)null)
				{
					((TMP_Text)val11).font = val12;
				}
				((TMP_Text)val11).fontSize = num2;
				((Graphic)val11).color = Color.black;
				((TMP_Text)val11).alignment = (TextAlignmentOptions)258;
				((Graphic)val11).raycastTarget = false;
				((TMP_Text)val11).text = text;
				float y = ((TMP_Text)val11).GetPreferredValues(text, num3 - 2f * num4, 0f).y;
				RectTransform component2 = val10.GetComponent<RectTransform>();
				component2.anchorMin = new Vector2(0f, 1f);
				component2.anchorMax = new Vector2(1f, 1f);
				component2.pivot = new Vector2(0.5f, 1f);
				component2.sizeDelta = new Vector2(-2f * num4, y);
				component2.anchoredPosition = new Vector2(0f, 0f - num4);
				float num6 = num4 + y + num5 + val7.y + num4;
				float num7 = val7.y * 0.8f;
				component.sizeDelta = new Vector2(num3, num6 + num7);
				component.anchoredPosition = new Vector2(0f, (0f - num7) / 2f);
				Vector2 position = default(Vector2);
				((Vector2)(ref position))..ctor(0f, 0f - (num6 / 2f - num4 - val7.y / 2f));
				GameObject selectedGameObject = (((Object)(object)val != (Object)null) ? MakeCopy(val, val7, position) : MakeFallback(val7, position, num2, val12));
				try
				{
					lockedField = screen.passwordField;
					if ((Object)(object)lockedField != (Object)null)
					{
						fieldWasInteractable = ((Selectable)lockedField).interactable;
						((Selectable)lockedField).interactable = false;
					}
				}
				catch (Exception)
				{
					lockedField = null;
				}
				try
				{
					if ((Object)(object)EventSystem.current != (Object)null)
					{
						EventSystem.current.SetSelectedGameObject(selectedGameObject);
					}
				}
				catch (Exception)
				{
				}
				open = true;
				ManualLogSource log = Plugin.log;
				BepInExInfoLogInterpolatedStringHandler val13 = new BepInExInfoLogInterpolatedStringHandler(46, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val13).AppendLiteral("[JoinPopup] shown over the password screen (");
					((BepInExLogInterpolatedStringHandler)val13).AppendFormatted<string>(((Object)(object)val != (Object)null) ? "copy of the game's Cancel button" : "the game's Cancel button wasn't found, plain button used");
					((BepInExLogInterpolatedStringHandler)val13).AppendLiteral(").");
				}
				log.LogInfo(val13);
			}
			catch (Exception ex4)
			{
				ManualLogSource log2 = Plugin.log;
				BepInExWarningLogInterpolatedStringHandler val14 = new BepInExWarningLogInterpolatedStringHandler(81, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val14).AppendLiteral("[JoinPopup] could not show the message (");
					((BepInExLogInterpolatedStringHandler)val14).AppendFormatted<string>(ex4.GetType().Name);
					((BepInExLogInterpolatedStringHandler)val14).AppendLiteral(": ");
					((BepInExLogInterpolatedStringHandler)val14).AppendFormatted<string>(ex4.Message);
					((BepInExLogInterpolatedStringHandler)val14).AppendLiteral("); the problems are in the log instead.");
				}
				log2.LogWarning(val14);
				pending = null;
				Close();
			}
		}

		private static GameObject MakeCopy(Transform original, Vector2 size, Vector2 position)
		{
			//IL_005b: 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)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = ((Il2CppObjectBase)Object.Instantiate((Object)(object)((Component)original).gameObject, root.transform)).Cast<GameObject>();
			((Object)val).name = ((Object)((Component)original).gameObject).name + " (SDK)";
			val.SetActive(true);
			RectTransform component = val.GetComponent<RectTransform>();
			Vector2 val2 = default(Vector2);
			((Vector2)(ref val2))..ctor(0.5f, 0.5f);
			component.pivot = val2;
			Vector2 anchorMin = (component.anchorMax = val2);
			component.anchorMin = anchorMin;
			component.sizeDelta = size;
			component.anchoredPosition = position;
			Button component2 = val.GetComponent<Button>();
			if ((Object)(object)component2 != (Object)null)
			{
				int persistentEventCount = ((UnityEventBase)component2.onClick).GetPersistentEventCount();
				for (int i = 0; i < persistentEventCount; i++)
				{
					((UnityEventBase)component2.onClick).SetPersistentListenerState(i, (UnityEventCallState)0);
				}
				((UnityEventBase)component2.onClick).RemoveAllListeners();
				((UnityEvent)component2.onClick).AddListener(UnityAction.op_Implicit((Action)OnBack));
				Navigation navigation = ((Selectable)component2).navigation;
				navigation.mode = (Mode)0;
				((Selectable)component2).navigation = navigation;
			}
			return val;
		}

		private static GameObject MakeFallback(Vector2 size, Vector2 position, float fontSize, TMP_FontAsset font)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_003f: 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_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Expected O, but got Unknown
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Back (SDK)");
			val.transform.SetParent(root.transform, false);
			Image val2 = val.AddComponent<Image>();
			((Graphic)val2).color = new Color(0.2f, 0.2f, 0.25f, 1f);
			Button val3 = val.AddComponent<Button>();
			((Selectable)val3).targetGraphic = (Graphic)(object)val2;
			((UnityEvent)val3.onClick).AddListener(UnityAction.op_Implicit((Action)OnBack));
			RectTransform component = val.GetComponent<RectTransform>();
			Center(component);
			component.sizeDelta = size;
			component.anchoredPosition = position;
			GameObject val4 = new GameObject("Text");
			val4.transform.SetParent(val.transform, false);
			TextMeshProUGUI val5 = val4.AddComponent<TextMeshProUGUI>();
			if ((Object)(object)font != (Object)null)
			{
				((TMP_Text)val5).font = font;
			}
			((TMP_Text)val5).fontSize = fontSize;
			((Graphic)val5).color = Color.white;
			((TMP_Text)val5).alignment = (TextAlignmentOptions)514;
			((Graphic)val5).raycastTarget = false;
			((TMP_Text)val5).text = "Back";
			Stretch(val4.GetComponent<RectTransform>());
			return val;
		}

		private static void OnBack()
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			PasswordMenu val = menu;
			pending = null;
			try
			{
				if ((Object)(object)val != (Object)null)
				{
					val.Cancel();
				}
			}
			catch (Exception ex)
			{
				Exception ex2 = ex.InnerException ?? ex;
				ManualLogSource log = Plugin.log;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(53, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[JoinPopup] the password screen's Cancel() failed: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex2.GetType().Name);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex2.Message);
				}
				log.LogWarning(val2);
			}
			Close();
		}

		private static void Close()
		{
			try
			{
				if ((Object)(object)lockedField != (Object)null)
				{
					((Selectable)lockedField).interactable = fieldWasInteractable;
				}
			}
			catch (Exception)
			{
			}
			lockedField = null;
			try
			{
				if ((Object)(object)root != (Object)null)
				{
					Object.Destroy((Object)(object)root);
				}
			}
			catch (Exception)
			{
			}
			root = null;
			menu = null;
			open = false;
		}

		private static Transform FindChild(Transform parent, string name)
		{
			Transform val = parent.Find(name);
			if ((Object)(object)val != (Object)null)
			{
				return val;
			}
			for (int i = 0; i < parent.childCount; i++)
			{
				Transform val2 = FindChild(parent.GetChild(i), name);
				if ((Object)(object)val2 != (Object)null)
				{
					return val2;
				}
			}
			return null;
		}

		private static void Center(RectTransform rect)
		{
			//IL_0015: 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_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor(0.5f, 0.5f);
			rect.pivot = val;
			Vector2 anchorMin = (rect.anchorMax = val);
			rect.anchorMin = anchorMin;
		}

		private static void Stretch(RectTransform rect)
		{
			//IL_0002: 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_001a: 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)
			rect.anchorMin = Vector2.zero;
			rect.anchorMax = Vector2.one;
			rect.offsetMin = Vector2.zero;
			rect.offsetMax = Vector2.zero;
		}
	}
	internal static class LobbyData
	{
		private class Entry
		{
			public string key;

			public string full;

			public string name;
		}

		private const string Protocol = "BWSDK1";

		private const string KeyMain = "bpsdk";

		private const string KeyList = "bpsdk_";

		private const string KeyNames = "bpsdk_n";

		private const int NameChars = 24;

		private const int NameChunkChars = 900;

		private const int IdChars = 6;

		private const int VersionChars = 3;

		private const int EntryChars = 9;

		private const int EntriesPerChunk = 100;

		private const int MaxChunks = 8;

		private static MethodInfo updateAttribute;

		private static MethodInfo tryGetString;

		private static bool reportedPublishFail;

		private static bool reportedReadFail;

		private static int publishLogs;

		private static int readLogs;

		private static bool adding;

		private static readonly HashSet<long> alreadyAdded = new HashSet<long>();

		internal static void Install(Harmony harmony)
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Expected O, but got Unknown
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Expected O, but got Unknown
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Expected O, but got Unknown
			//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cc: Expected O, but got Unknown
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Expected O, but got Unknown
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Expected O, but got Unknown
			Type type = null;
			Type type2 = null;
			bool flag = default(bool);
			try
			{
				type = typeof(EOSPrivateLobbyManager);
				type2 = typeof(LobbyDetailsExtensions);
				updateAttribute = AccessTools.Method(type, "UpdateAttribute", (Type[])null, (Type[])null);
				if (type2 != null)
				{
					tryGetString = AccessTools.Method(type2, "TryGetStringAttribute", (Type[])null, (Type[])null);
				}
			}
			catch (Exception ex)
			{
				ManualLogSource log = Plugin.log;
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(93, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[LobbyData] could not find the game's lobby code (");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.GetType().Name);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("); the lobby won't carry the puzzle list.");
				}
				log.LogWarning(val);
				return;
			}
			bool flag2 = false;
			bool flag3 = false;
			try
			{
				if (updateAttribute != null)
				{
					harmony.Patch((MethodBase)updateAttribute, (HarmonyMethod)null, new HarmonyMethod(typeof(LobbyData).GetMethod("UpdateAttributePostfix", BindingFlags.Static | BindingFlags.NonPublic)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
					flag2 = true;
				}
			}
			catch (Exception ex2)
			{
				ManualLogSource log2 = Plugin.log;
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(73, 4, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[LobbyData] could not hook ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("EOSPrivateLobbyManager");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(".");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("UpdateAttribute");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" (");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex2.GetType().Name);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex2.Message);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("); the lobby won't carry the puzzle list.");
				}
				log2.LogWarning(val);
			}
			try
			{
				MethodInfo methodInfo = AccessTools.Method(type, "ConvertToLobbyInfo", (Type[])null, (Type[])null);
				if (methodInfo != null && tryGetString != null)
				{
					harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(LobbyData).GetMethod("ConvertPostfix", BindingFlags.Static | BindingFlags.NonPublic)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
					flag3 = true;
				}
			}
			catch (Exception ex3)
			{
				ManualLogSource log3 = Plugin.log;
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(76, 4, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[LobbyData] could not hook ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("EOSPrivateLobbyManager");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(".");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("ConvertToLobbyInfo");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" (");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex3.GetType().Name);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex3.Message);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("); this PC can't read a lobby's puzzle list.");
				}
				log3.LogWarning(val);
			}
			ManualLogSource log4 = Plugin.log;
			BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(50, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[LobbyData] hooks: writing the list ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(flag2 ? "ready" : "NOT available");
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", reading it ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(flag3 ? "ready" : "NOT available");
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(".");
			}
			log4.LogInfo(val2);
		}

		private static string Hex(byte[] bytes)
		{
			return Convert.ToHexString(bytes).ToLowerInvariant();
		}

		private static void Add(List<Entry> list, HashSet<string> seen, PuzzlePack pack)
		{
			if (pack != null && !string.IsNullOrEmpty(pack.id) && !string.IsNullOrEmpty(pack.hash) && pack.hash.Length >= 3)
			{
				string text = pack.id + ":" + pack.hash;
				if (seen.Add(text))
				{
					string text2 = Hex(SHA256.HashData(Encoding.UTF8.GetBytes(pack.id))).Substring(0, 6);
					list.Add(new Entry
					{
						key = text2 + pack.hash.Substring(0, 3).ToLowerInvariant(),
						full = text,
						name = (string.IsNullOrEmpty(pack.name) ? pack.id : pack.name)
					});
				}
			}
		}

		private static List<Entry> Local(bool host)
		{
			List<Entry> list = new List<Entry>();
			HashSet<string> seen = new HashSet<string>();
			foreach (PuzzlePack pack in PuzzleLibrary.packs)
			{
				Add(list, seen, pack);
			}
			if (!host)
			{
				Add(list, seen, PuzzleLibrary.builtInTower);
			}
			list.Sort((Entry a, Entry b) => string.CompareOrdinal(a.full, b.full));
			return list;
		}

		private static string OverallHash(List<Entry> entries)
		{
			StringBuilder stringBuilder = new StringBuilder();
			foreach (Entry entry in entries)
			{
				stringBuilder.Append(entry.full).Append('\n');
			}
			return Hex(SHA256.HashData(Encoding.UTF8.GetBytes(stringBuilder.ToString()))).Substring(0, 8);
		}

		private static void UpdateAttributePostfix(object __instance, object update)
		{
			if (!adding)
			{
				AddTo(__instance, update, "the game adding an attribute");
			}
		}

		private static void AddTo(object manager, object modification, string via)
		{
			//IL_03e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ef: Expected O, but got Unknown
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Expected O, but got Unknown
			//IL_0333: Unknown result type (might be due to invalid IL or missing references)
			//IL_033a: Expected O, but got Unknown
			bool flag = default(bool);
			try
			{
				if (manager == null || modification == null || updateAttribute == null)
				{
					return;
				}
				long num = PointerOf(modification);
				if (num != 0L && !alreadyAdded.Add(num))
				{
					return;
				}
				if (alreadyAdded.Count > 64)
				{
					alreadyAdded.Clear();
				}
				adding = true;
				List<Entry> list = Local(host: true);
				int count = list.Count;
				if (count > 800)
				{
					ManualLogSource log = Plugin.log;
					BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(90, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[LobbyData] ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(count);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" puzzles are installed but the lobby list only holds ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(800);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("; the rest aren't listed.");
					}
					log.LogWarning(val);
					list = list.GetRange(0, 800);
					count = list.Count;
				}
				string text = OverallHash(list);
				Set(manager, modification, "bpsdk", "BWSDK1|0.1.2|" + text + "|" + count);
				int num2 = 0;
				int num3 = 0;
				while (num3 < count)
				{
					StringBuilder stringBuilder = new StringBuilder();
					for (int i = num3; i < Math.Min(count, num3 + 100); i++)
					{
						stringBuilder.Append(list[i].key);
					}
					Set(manager, modification, "bpsdk_" + num2, stringBuilder.ToString());
					num3 += 100;
					num2++;
				}
				StringBuilder stringBuilder2 = new StringBuilder();
				int num4 = 0;
				foreach (Entry item in list)
				{
					string text2 = item.name.Replace('|', ' ').Replace('\n', ' ').Replace('\r', ' ')
						.Trim();
					if (text2.Length > 24)
					{
						text2 = text2.Substring(0, 24).TrimEnd();
					}
					string text3 = item.key.Substring(0, 6) + text2 + "|";
					if (stringBuilder2.Length + text3.Length > 900 && stringBuilder2.Length > 0)
					{
						if (num4 >= 8)
						{
							stringBuilder2.Clear();
							break;
						}
						Set(manager, modification, "bpsdk_n" + num4++, stringBuilder2.ToString());
						stringBuilder2.Clear();
					}
					stringBuilder2.Append(text3);
				}
				if (stringBuilder2.Length > 0 && num4 < 8)
				{
					Set(manager, modification, "bpsdk_n" + num4++, stringBuilder2.ToString());
				}
				if (publishLogs++ < 10)
				{
					ManualLogSource log2 = Plugin.log;
					BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(105, 4, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[LobbyData] added the SDK's attributes to the lobby (via ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(via);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("): ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(count);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" puzzle(s) in ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(num2);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" list attribute(s), list hash ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(text);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(".");
					}
					log2.LogInfo(val2);
				}
			}
			catch (Exception ex)
			{
				if (!reportedPublishFail)
				{
					reportedPublishFail = true;
					Exception ex2 = ex.InnerException ?? ex;
					ManualLogSource log3 = Plugin.log;
					BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(63, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[LobbyData] could not add the SDK's attributes to the lobby: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex2.GetType().Name);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex2.Message);
					}
					log3.LogWarning(val);
				}
			}
			finally
			{
				adding = false;
			}
		}

		private static long PointerOf(object wrapper)
		{
			Il2CppObjectBase val = (Il2CppObjectBase)((wrapper is Il2CppObjectBase) ? wrapper : null);
			return (val != null) ? val.Pointer.ToInt64() : 0;
		}

		private static void Set(object manager, object modification, string key, string value)
		{
			updateAttribute.Invoke(manager, new object[3] { modification, key, value });
		}

		private static void ConvertPostfix(object[] __args)
		{
			//IL_0807: Unknown result type (might be due to invalid IL or missing references)
			//IL_080e: Expected O, but got Unknown
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Expected O, but got Unknown
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Expected O, but got Unknown
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Expected O, but got Unknown
			//IL_0278: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Expected O, but got Unknown
			//IL_038b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0392: Expected O, but got Unknown
			//IL_0527: Unknown result type (might be due to invalid IL or missing references)
			//IL_052e: Expected O, but got Unknown
			bool flag = default(bool);
			try
			{
				if (__args == null || __args.Length < 1 || __args[0] == null || tryGetString == null)
				{
					return;
				}
				object details = __args[0];
				bool active = NetworkServer.active;
				string text = (active ? "host, read back from the lobby" : "read before joining");
				string text2 = Get(details, "bpsdk");
				if (!active)
				{
					SdkJoinGate.JoiningSdkLobby = text2 != null;
					if (text2 != null)
					{
						SdkJoinGate.InstallClient();
					}
				}
				if (text2 == null)
				{
					JoinPopup.Clear();
					if (readLogs++ < 20)
					{
						ManualLogSource log = Plugin.log;
						BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(104, 1, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[LobbyData] (");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text);
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") this lobby has no SDK data: the host doesn't have the SDK, or it didn't publish its list.");
						}
						log.LogInfo(val);
					}
					return;
				}
				string[] array = text2.Split('|');
				if (array.Length < 4 || !int.TryParse(array[3], out var result))
				{
					JoinPopup.Clear();
					ManualLogSource log2 = Plugin.log;
					BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(77, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[LobbyData] (");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(text);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(") the lobby's SDK data isn't in a format this PC understands: '");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(text2);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("'");
					}
					log2.LogWarning(val2);
					return;
				}
				bool flag2 = readLogs++ < 20;
				if (flag2)
				{
					ManualLogSource log3 = Plugin.log;
					BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(75, 5, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[LobbyData] (");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") SDK data found in the lobby: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(array[0]);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", SDK ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(array[1]);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(result);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" puzzle(s), list hash ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(array[2]);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(".");
					}
					log3.LogInfo(val);
				}
				bool flag3 = array[0] != "BWSDK1" || array[1] != "0.1.2";
				if (flag3 && flag2)
				{
					ManualLogSource log4 = Plugin.log;
					BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(52, 4, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[LobbyData] the host's SDK (");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(array[0]);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(array[1]);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(") is not this PC's (");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("BWSDK1");
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("0.1.2");
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(").");
					}
					log4.LogWarning(val2);
				}
				StringBuilder stringBuilder = new StringBuilder();
				for (int i = 0; i * 100 < result && i < 8; i++)
				{
					string text3 = Get(details, "bpsdk_" + i);
					if (text3 == null)
					{
						break;
					}
					stringBuilder.Append(text3);
				}
				string text4 = stringBuilder.ToString();
				int num = text4.Length / 9;
				if (num != result)
				{
					ManualLogSource log5 = Plugin.log;
					BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(72, 3, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[LobbyData] the lobby says ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(result);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" puzzle(s) but its list holds ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(num);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" (");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(text4.Length);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" characters).");
					}
					log5.LogWarning(val2);
				}
				List<Entry> list = Local(active);
				HashSet<string> hashSet = new HashSet<string>();
				Dictionary<string, Entry> dictionary = new Dictionary<string, Entry>();
				foreach (Entry item in list)
				{
					hashSet.Add(item.key);
					dictionary[item.key.Substring(0, 6)] = item;
				}
				int num2 = 0;
				int num3 = 0;
				List<string> list2 = new List<string>();
				List<string> list3 = new List<string>();
				for (int j = 0; j < num; j++)
				{
					string text5 = text4.Substring(j * 9, 9);
					if (!hashSet.Contains(text5))
					{
						if (dictionary.TryGetValue(text5.Substring(0, 6), out var value))
						{
							num3++;
							list2.Add(value.name);
						}
						else
						{
							num2++;
							list3.Add(text5.Substring(0, 6));
						}
					}
				}
				if (flag2)
				{
					if (num2 == 0 && num3 == 0)
					{
						ManualLogSource log6 = Plugin.log;
						BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(74, 2, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[LobbyData] this PC has every puzzle the host lists (");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num);
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral("); it has ");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(list.Count);
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" installed.");
						}
						log6.LogInfo(val);
					}
					else
					{
						Plugin.log.LogInfo((object)($"[LobbyData] this PC is missing {num2} of the host's puzzle(s) and has {num3} out of date" + ((num3 > 0) ? (" (" + string.Join(", ", list2) + ")") : "") + "."));
					}
				}
				List<string> list4 = new List<string>();
				if (flag3)
				{
					list4.Add($"The host has SDK {array[1]}, you have {"0.1.2"}.");
				}
				if (num2 > 0)
				{
					List<string> list5 = ((num2 > 0 && !active) ? MissingNames(details, list3) : null);
					if (list5 != null && list5.Count > 0)
					{
						string text6 = string.Join("\n", list5.GetRange(0, Math.Min(8, list5.Count)));
						if (list5.Count > 8)
						{
							text6 += $"\nand {list5.Count - 8} more";
						}
						list4.Add("Missing puzzle(s):\n" + text6);
					}
					else
					{
						list4.Add($"Missing {num2} puzzle(s) the host has.");
					}
				}
				if (num3 > 0)
				{
					list4.Add("Out of date:\n" + string.Join("\n", list2));
				}
				if (active || list4.Count == 0)
				{
					JoinPopup.Clear();
				}
				else
				{
					JoinPopup.Set(list4.ToArray());
				}
			}
			catch (Exception ex)
			{
				if (!reportedReadFail)
				{
					reportedReadFail = true;
					Exception ex2 = ex.InnerException ?? ex;
					ManualLogSource log7 = Plugin.log;
					BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(51, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[LobbyData] could not read the lobby's SDK data: ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex2.GetType().Name);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex2.Message);
					}
					log7.LogWarning(val2);
				}
			}
		}

		private static List<string> MissingNames(object details, List<string> ids)
		{
			try
			{
				Dictionary<string, string> dictionary = new Dictionary<string, string>();
				for (int i = 0; i < 8; i++)
				{
					string text = Get(details, "bpsdk_n" + i);
					if (text == null)
					{
						break;
					}
					string[] array = text.Split('|');
					foreach (string text2 in array)
					{
						if (text2.Length > 6)
						{
							dictionary[text2.Substring(0, 6)] = text2.Substring(6);
						}
					}
				}
				if (dictionary.Count == 0)
				{
					return null;
				}
				List<string> list = new List<string>();
				foreach (string id in ids)
				{
					list.Add(dictionary.TryGetValue(id, out var value) ? value : "an unnamed puzzle");
				}
				return list;
			}
			catch (Exception)
			{
				return null;
			}
		}

		private static string Get(object details, string key)
		{
			return tryGetString.Invoke(null, new object[2] { details, key }) as string;
		}
	}
	internal static class LobbyVision
	{
		private static bool hooked;

		private static int checkedFrame = -1;

		private static bool on;

		private static bool volumeFailed;

		internal static bool On
		{
			get
			{
				int frameCount = Time.frameCount;
				if (frameCount != checkedFrame)
				{
					checkedFrame = frameCount;
					on = hooked || FilterShowing();
				}
				return on;
			}
		}

		private static bool FilterShowing()
		{
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Expected O, but got Unknown
			if (volumeFailed)
			{
				return false;
			}
			try
			{
				PostProcessingManager instance = PostProcessingManager.instance;
				if (instance == null)
				{
					return false;
				}
				Volume lobbyVisionPPVolume = instance.lobbyVisionPPVolume;
				return (Object)(object)lobbyVisionPPVolume != (Object)null && ((Behaviour)lobbyVisionPPVolume).enabled && ((Component)lobbyVisionPPVolume).gameObject.activeInHierarchy && lobbyVisionPPVolume.weight > 0.5f;
			}
			catch (Exception ex)
			{
				volumeFailed = true;
				ManualLogSource log = Plugin.log;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(54, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[LobbyVision] could not read the telescope filter (");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.GetType().Name);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")");
				}
				log.LogWarning(val);
				return false;
			}
		}

		internal static void InstallHook(Harmony harmony)
		{
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Expected O, but got Unknown
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			try
			{
				MethodInfo methodInfo = AccessTools.Method(typeof(LobbyVisionToggler), "SetLobbyVisionActive", (Type[])null, (Type[])null);
				if (methodInfo == null)
				{
					throw new MissingMethodException("LobbyVisionToggler.SetLobbyVisionActive not found");
				}
				harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(LobbyVision).GetMethod("Postfix", BindingFlags.Static | BindingFlags.NonPublic)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
			catch (Exception ex)
			{
				ManualLogSource log = Plugin.log;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(92, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[LobbyVision] could not hook the telescope filter announcement (");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.GetType().Name);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("); using the filter itself");
				}
				log.LogWarning(val);
			}
		}

		private static void Postfix(bool __0)
		{
			hooked = __0;
		}
	}
	[BepInPlugin("markviews.BigPuzzleSDK", "Big Puzzle SDK", "0.1.2")]
	public class Plugin : BasePlugin
	{
		internal const string Version = "0.1.2";

		internal static ManualLogSource log;

		private static readonly HashSet<Type> registered = new HashSet<Type>();

		internal static string DevFolder => Path.Combine(Pa