Decompiled source of ShopPrison v1.2.7

plugins/ShopPrison.dll

Decompiled 6 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using REPOLib.Modules;
using ShopPrison.Managers;
using ShopPrison.Utils;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("Autodesk.Fbx")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("FbxBuildTestAssets")]
[assembly: IgnoresAccessChecksTo("Klattersynth")]
[assembly: IgnoresAccessChecksTo("Photon3Unity3D")]
[assembly: IgnoresAccessChecksTo("PhotonChat")]
[assembly: IgnoresAccessChecksTo("PhotonRealtime")]
[assembly: IgnoresAccessChecksTo("PhotonUnityNetworking")]
[assembly: IgnoresAccessChecksTo("PhotonUnityNetworking.Utilities")]
[assembly: IgnoresAccessChecksTo("PhotonVoice.API")]
[assembly: IgnoresAccessChecksTo("PhotonVoice")]
[assembly: IgnoresAccessChecksTo("PhotonVoice.PUN")]
[assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime")]
[assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime.Public")]
[assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Attributes")]
[assembly: IgnoresAccessChecksTo("Sirenix.Serialization.Config")]
[assembly: IgnoresAccessChecksTo("Sirenix.Serialization")]
[assembly: IgnoresAccessChecksTo("Sirenix.Utilities")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Formats.Fbx.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Postprocessing.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Antlr3.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Core")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Flow")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.State")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: IgnoresAccessChecksTo("websocket-sharp")]
[assembly: AssemblyCompany("GlitchApotamus")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ShopPrison")]
[assembly: AssemblyTitle("glitchapotamus.shopprison")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace ShopPrison
{
	[BepInPlugin("GlitchApotamus-ShopPrison", "ShopPrison", "1.2.7")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class ShopPrison : BaseUnityPlugin
	{
		public static ShopPrison Instance { get; private set; }

		public static ManualLogSource Logger => Instance.BaseLogger;

		private ManualLogSource BaseLogger => ((BaseUnityPlugin)this).Logger;

		private Harmony? Harmony { get; set; }

		internal static ConfigManager BoundConfig { get; private set; }

		private static GameObject SpNetworker { get; set; }

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			BoundConfig = new ConfigManager(((BaseUnityPlugin)this).Config);
			((Component)this).gameObject.transform.parent = null;
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(Paths.PluginPath, "GlitchApotamus-ShopPrison/Assets/Resources/shopjail"));
			SpNetworker = val.LoadAsset<GameObject>("Networker");
			((Object)SpNetworker).name = "SPNetworker";
			SpNetworker.AddComponent<Networker>();
			NetworkPrefabs.RegisterNetworkPrefab(SpNetworker);
			Patch();
			Logger.LogInfo((object)"ShopPrison v1.2.7 has loaded!");
			Logger.LogInfo((object)("Config settings will only take affect on the host machine. " + (BoundConfig.DeveloperMode.Value ? "Developer Mode has been activated!" : "")));
			Logger.LogWarning((object)"If this is your first time loading ShopPrison, please restart your game now. Otherwise, you can safely discard this warning! Thank you for using ShopPrison!");
		}

		private void Patch()
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Expected O, but got Unknown
			//IL_001a: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony val = new Harmony("GlitchApotamus-ShopPrison");
				Harmony val2 = val;
				Harmony = val;
			}
			Harmony.PatchAll();
		}

		private void Unpatch()
		{
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}

		private void OnDestroy()
		{
			Unpatch();
			Object.Destroy((Object)(object)SpNetworker);
			Logger.LogInfo((object)"ShopPrison v1.2.7 has been unloaded!");
		}
	}
	internal static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "GlitchApotamus-ShopPrison";

		public const string PLUGIN_NAME = "ShopPrison";

		public const string PLUGIN_VERSION = "1.2.7";

		public const string PLUGIN_AUTHOR = "GlitchApotamus";
	}
}
namespace ShopPrison.Utils
{
	public abstract class UIConfig
	{
		public static readonly Vector2 ReferenceResolution = new Vector2(1920f, 1080f);

		public static readonly Color ContainerColor = new Color(0.95f, 0.95f, 0.95f, 1f);

		private const int TitleFontSize = 24;

		public const int PlayerNameFontSize = 14;

		private const float LayoutSpacing = 20f;

		public const float PlayerEntrySpacing = 10f;

		private const int ContainerPadding = 20;

		public const float AvatarSize = 40f;

		public static Vector2 ContainerSize => new Vector2(300f, CalculateContainerHeight());

		private static float CalculateContainerHeight()
		{
			int num = GameDirector.instance.PlayerList?.Count ?? 0;
			int num2 = (num + 1) / 2;
			float num3 = (float)num2 * 50f;
			return num3 + 40f + 24f + 60f + 30f;
		}

		public static float GetPlayerNameWidth(string playerName)
		{
			return Mathf.Max(100f, (float)(playerName.Length + 2) * 10f);
		}
	}
	internal static class UICreator
	{
		private static GameObject _canvas;

		private static GameObject _uiContainer;

		private static GameObject _leftColumn;

		private static GameObject _rightColumn;

		private static GameObject _contentContainer;

		private static GameObject _parentContainer;

		public static void CreateUI()
		{
			DestroyExistingUI();
			EnsureCanvasExists();
			if (!((Object)(object)_canvas == (Object)null))
			{
				CreateMainContainer();
				SetupContainerImage();
				SetupLayoutAndTransform();
			}
		}

		public static void DestroyExistingUI()
		{
			if (Object.op_Implicit((Object)(object)_uiContainer))
			{
				Object.Destroy((Object)(object)_uiContainer);
			}
		}

		private static void EnsureCanvasExists()
		{
			_canvas = GameObject.Find("ShopPrisonCanvas");
			if ((Object)(object)_canvas != (Object)null)
			{
				return;
			}
			try
			{
				CreateNewCanvas();
			}
			catch (Exception ex)
			{
				ShopPrison.Logger.LogError((object)("Failed to create canvas: " + ex.Message));
			}
		}

		private static void CreateNewCanvas()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Expected O, but got Unknown
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			_canvas = new GameObject("ShopPrisonCanvas");
			Canvas val = _canvas.AddComponent<Canvas>();
			val.renderMode = (RenderMode)0;
			val.sortingOrder = 10;
			CanvasScaler val2 = _canvas.AddComponent<CanvasScaler>();
			val2.uiScaleMode = (ScaleMode)1;
			val2.referenceResolution = UIConfig.ReferenceResolution;
			_canvas.AddComponent<GraphicRaycaster>();
		}

		private static void CreateMainContainer()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			_uiContainer = new GameObject("ShopPrisonUI", new Type[1] { typeof(RectTransform) });
			_uiContainer.transform.SetParent(_canvas.transform, false);
		}

		private static void CreateParentContainer()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			_parentContainer = new GameObject("ParentContainer", new Type[1] { typeof(RectTransform) });
			_parentContainer.transform.SetParent(_contentContainer.transform, false);
		}

		private static void SetupContainerImage()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			Image val = _uiContainer.AddComponent<Image>();
			val.sprite = Utils.LoadSprite("Sprite");
			((Graphic)val).color = UIConfig.ContainerColor;
			val.type = (Type)1;
			Outline val2 = _uiContainer.AddComponent<Outline>();
			((Shadow)val2).effectColor = Color.white;
			((Shadow)val2).effectDistance = new Vector2(2f, -2f);
		}

		private static void SetupLayoutAndTransform()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Expected O, but got Unknown
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Expected O, but got Unknown
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			RectTransform component = _uiContainer.GetComponent<RectTransform>();
			component.sizeDelta = new Vector2(600f, UIConfig.ContainerSize.y + 100f);
			component.anchorMin = new Vector2(1f, 0.5f);
			component.anchorMax = new Vector2(1f, 0.5f);
			component.anchoredPosition = new Vector2(-400f, -100f);
			component.pivot = new Vector2(0.5f, 0.5f);
			GameObject val = new GameObject("Content", new Type[1] { typeof(RectTransform) });
			val.transform.SetParent(_uiContainer.transform, false);
			HorizontalLayoutGroup val2 = val.AddComponent<HorizontalLayoutGroup>();
			((LayoutGroup)val2).childAlignment = (TextAnchor)4;
			_contentContainer = val;
			GameObject val3 = new GameObject("Title", new Type[1] { typeof(RectTransform) });
			val3.transform.SetParent(_uiContainer.transform, false);
			TextMeshProUGUI val4 = val3.AddComponent<TextMeshProUGUI>();
			((TMP_Text)val4).text = "Who is Getting Locked Up?";
			((TMP_Text)val4).fontSize = 36f;
			((TMP_Text)val4).alignment = (TextAlignmentOptions)514;
			((Graphic)val4).color = Color.white;
			((TMP_Text)val4).enableWordWrapping = false;
			RectTransform component2 = val3.GetComponent<RectTransform>();
			component2.sizeDelta = new Vector2(600f, 100f);
			component2.anchoredPosition = new Vector2(0f, UIConfig.ContainerSize.y / 3f + 100f);
			CreateColumns();
			CreatePlayerEntries();
			CreateSkipButton();
		}

		private static void CreatePlayerEntries()
		{
			if (GameDirector.instance?.PlayerList == null)
			{
				ShopPrison.Logger.LogError((object)"GameDirector or PlayerList is null");
				return;
			}
			int num = 0;
			foreach (PlayerAvatar player in GameDirector.instance.PlayerList)
			{
				GameObject parent = ((num % 2 == 0) ? _leftColumn : _rightColumn);
				CreatePlayerEntry(player, parent);
				num++;
			}
		}

		private static void CreateColumns()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Expected O, but got Unknown
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Expected O, but got Unknown
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Expected O, but got Unknown
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Expected O, but got Unknown
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Expected O, but got Unknown
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)_parentContainer))
			{
				CreateParentContainer();
			}
			_contentContainer = new GameObject("ContentContainer", new Type[1] { typeof(RectTransform) });
			_contentContainer.transform.SetParent(_parentContainer.transform, false);
			HorizontalLayoutGroup val = _contentContainer.AddComponent<HorizontalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)val).spacing = 10f;
			((LayoutGroup)val).childAlignment = (TextAnchor)0;
			((LayoutGroup)val).padding = new RectOffset(100, 100, 40, 40);
			((HorizontalOrVerticalLayoutGroup)val).childForceExpandHeight = false;
			((HorizontalOrVerticalLayoutGroup)val).childForceExpandWidth = false;
			RectTransform component = _contentContainer.GetComponent<RectTransform>();
			component.sizeDelta = new Vector2(600f, 400f);
			ContentSizeFitter val2 = _contentContainer.AddComponent<ContentSizeFitter>();
			val2.horizontalFit = (FitMode)2;
			val2.verticalFit = (FitMode)2;
			_leftColumn = new GameObject("LeftColumn", new Type[1] { typeof(RectTransform) });
			_leftColumn.transform.SetParent(_contentContainer.transform, false);
			VerticalLayoutGroup val3 = _leftColumn.AddComponent<VerticalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)val3).spacing = 10f;
			((LayoutGroup)val3).childAlignment = (TextAnchor)1;
			((HorizontalOrVerticalLayoutGroup)val3).childForceExpandHeight = false;
			((HorizontalOrVerticalLayoutGroup)val3).childForceExpandWidth = false;
			((LayoutGroup)val3).padding = new RectOffset(10, 10, 10, 10);
			ContentSizeFitter val4 = _leftColumn.AddComponent<ContentSizeFitter>();
			val4.horizontalFit = (FitMode)2;
			val4.verticalFit = (FitMode)2;
			RectTransform component2 = _leftColumn.GetComponent<RectTransform>();
			component2.sizeDelta = new Vector2(280f, 400f);
			_rightColumn = new GameObject("RightColumn", new Type[1] { typeof(RectTransform) });
			_rightColumn.transform.SetParent(_contentContainer.transform, false);
			VerticalLayoutGroup val5 = _rightColumn.AddComponent<VerticalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)val5).spacing = 10f;
			((LayoutGroup)val5).childAlignment = (TextAnchor)1;
			((HorizontalOrVerticalLayoutGroup)val5).childForceExpandHeight = false;
			((HorizontalOrVerticalLayoutGroup)val5).childForceExpandWidth = false;
			((LayoutGroup)val5).padding = new RectOffset(10, 10, 10, 10);
			ContentSizeFitter val6 = _rightColumn.AddComponent<ContentSizeFitter>();
			val6.horizontalFit = (FitMode)2;
			val6.verticalFit = (FitMode)2;
			RectTransform component3 = _rightColumn.GetComponent<RectTransform>();
			component3.sizeDelta = new Vector2(280f, 400f);
		}

		private static void CreatePlayerEntry(PlayerAvatar player, GameObject parent)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			GameObject playerEntry = CreatePlayerEntryBase(player.playerName, parent);
			CreatePlayerAvatar(playerEntry, player.playerAvatarVisuals.color);
			CreatePlayerName(playerEntry, player.playerName);
		}

		private static GameObject CreatePlayerEntryBase(string playerName, GameObject parent)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Expected O, but got Unknown
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("PlayerEntry_" + playerName, new Type[1] { typeof(RectTransform) });
			val.transform.SetParent(parent.transform, false);
			Button button = val.AddComponent<Button>();
			val.AddComponent<Utils.CursorOnHover>();
			HorizontalLayoutGroup val2 = val.AddComponent<HorizontalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)val2).spacing = 10f;
			((LayoutGroup)val2).padding = new RectOffset(30, 5, 5, 5);
			((LayoutGroup)val2).childAlignment = (TextAnchor)3;
			((HorizontalOrVerticalLayoutGroup)val2).childForceExpandHeight = false;
			((HorizontalOrVerticalLayoutGroup)val2).childForceExpandWidth = false;
			RectTransform component = val.GetComponent<RectTransform>();
			component.sizeDelta = new Vector2(260f, 50f);
			Image val3 = val.AddComponent<Image>();
			val3.sprite = Utils.LoadSprite("Sprite");
			val3.type = (Type)1;
			((Graphic)val3).color = Color.green;
			Outline val4 = val.AddComponent<Outline>();
			((Shadow)val4).effectColor = Color.green;
			((Shadow)val4).effectDistance = new Vector2(2f, -2f);
			SetupVoteButton(button, playerName);
			LayoutElement val5 = val.AddComponent<LayoutElement>();
			val5.minHeight = 50f;
			val5.preferredHeight = 50f;
			val5.flexibleHeight = 0f;
			return val;
		}

		private static void CreatePlayerAvatar(GameObject playerEntry, Color color)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			//IL_0042: 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)
			GameObject val = new GameObject("Avatar", new Type[1] { typeof(RectTransform) });
			val.transform.SetParent(playerEntry.transform, false);
			RectTransform component = val.GetComponent<RectTransform>();
			component.sizeDelta = new Vector2(40f, 40f);
			Image val2 = val.AddComponent<Image>();
			Sprite sprite = Utils.LoadSprite("Avatar");
			val2.sprite = sprite;
			((Graphic)val2).color = color;
			LayoutElement val3 = val.AddComponent<LayoutElement>();
			val3.preferredWidth = 40f;
			val3.preferredHeight = 40f;
			val3.minWidth = 40f;
			val3.minHeight = 40f;
		}

		private static void CreatePlayerName(GameObject playerEntry, string playerName)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("PlayerName", new Type[1] { typeof(RectTransform) });
			val.transform.SetParent(playerEntry.transform, false);
			Text val2 = val.AddComponent<Text>();
			val2.text = playerName + "  ";
			val2.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
			val2.fontSize = 14;
			val2.alignment = (TextAnchor)4;
			((Graphic)val2).color = Color.white;
			LayoutElement val3 = val.AddComponent<LayoutElement>();
			val3.minWidth = UIConfig.GetPlayerNameWidth(playerName);
			val3.preferredWidth = UIConfig.GetPlayerNameWidth(playerName);
			val3.flexibleWidth = 0f;
			val2.horizontalOverflow = (HorizontalWrapMode)1;
		}

		private static void CreateSkipButton()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Expected O, but got Unknown
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("SkipButton", new Type[1] { typeof(RectTransform) });
			val.transform.SetParent(_uiContainer.transform, false);
			Button button = val.AddComponent<Button>();
			val.AddComponent<Utils.CursorOnHover>();
			Image val2 = val.AddComponent<Image>();
			val2.sprite = Utils.LoadSprite("Sprite");
			val2.type = (Type)1;
			Outline val3 = val.AddComponent<Outline>();
			((Shadow)val3).effectColor = Color.green;
			((Shadow)val3).effectDistance = new Vector2(2f, -2f);
			GameObject val4 = new GameObject("Text", new Type[1] { typeof(RectTransform) });
			val4.transform.SetParent(val.transform, false);
			Text val5 = val4.AddComponent<Text>();
			val5.text = "Skip Vote";
			val5.fontSize = 24;
			val5.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
			val5.alignment = (TextAnchor)4;
			((Graphic)val5).color = Color.white;
			val5.horizontalOverflow = (HorizontalWrapMode)1;
			RectTransform component = val.GetComponent<RectTransform>();
			component.sizeDelta = new Vector2(300f, 40f);
			component.anchorMin = new Vector2(0.5f, 0f);
			component.anchorMax = new Vector2(0.5f, 0f);
			component.pivot = new Vector2(0.5f, 0f);
			component.anchoredPosition = new Vector2(0f, (0f - UIConfig.ContainerSize.y) / 150f);
			SetupVoteButton(button, "SKIP");
		}

		private static void SetupVoteButton(Button button, string targetPlayerName)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			string targetPlayerName2 = targetPlayerName;
			Button button2 = button;
			((UnityEvent)button2.onClick).AddListener((UnityAction)delegate
			{
				if (PhotonNetwork.IsConnected)
				{
					Player localPlayer = PhotonNetwork.LocalPlayer;
					if (localPlayer.nickName == targetPlayerName2 && !ShopPrison.BoundConfig.DeveloperMode.Value)
					{
						ShopPrison.Logger.LogInfo((object)"You can't vote for yourself!");
					}
					else
					{
						ShopPrison.Logger.LogInfo((object)("Sending vote for " + targetPlayerName2));
						PhotonView photonView = Networker.Instance.photonView;
						if (photonView != null)
						{
							photonView.RPC("SendVote", (RpcTarget)2, new object[1] { targetPlayerName2 });
						}
						((Selectable)button2).interactable = false;
					}
				}
			});
		}
	}
	public static class Utils
	{
		public class CursorOnHover : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler
		{
			private Button? _button;

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

			private void OnEnable()
			{
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				Sprite val = LoadSprite("Cursor_Default");
				Cursor.SetCursor(val.texture, Vector2.zero, (CursorMode)0);
			}

			public void OnPointerEnter(PointerEventData eventData)
			{
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				if (_button != null && ((Selectable)_button).interactable)
				{
					Sprite val = LoadSprite("Cursor_Hover");
					Cursor.SetCursor(val.texture, Vector2.zero, (CursorMode)0);
				}
			}

			public void OnPointerExit(PointerEventData eventData)
			{
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				Sprite val = LoadSprite("Cursor_Default");
				Cursor.SetCursor(val.texture, Vector2.zero, (CursorMode)0);
			}
		}

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

			private object <>2__current;

			public bool disableAiming;

			private float <duration>5__2;

			private float <timer>5__3;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0047: Unknown result type (might be due to invalid IL or missing references)
				//IL_0051: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<duration>5__2 = GetJailDuration();
					<timer>5__3 = 0f;
					break;
				case 1:
					<>1__state = -1;
					<timer>5__3 += 0.05f;
					break;
				}
				if (float.IsInfinity(<duration>5__2) || <timer>5__3 < <duration>5__2)
				{
					SemiFunc.InputDisableMovement();
					if (disableAiming)
					{
						SemiFunc.InputDisableAiming();
					}
					<>2__current = (object)new WaitForSeconds(0.05f);
					<>1__state = 1;
					return true;
				}
				((Behaviour)PlayerController.instance).enabled = true;
				if (disableAiming)
				{
					((Behaviour)PlayerController.instance.cameraAim).enabled = true;
				}
				return false;
			}

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

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

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

			private object <>2__current;

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

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

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

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

			private bool MoveNext()
			{
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(GetJailDuration());
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					JailMessageUI.DestroyJailMessage();
					return false;
				}
			}

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

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

		private static Coroutine? _jailCoroutine;

		public static void CreateUI()
		{
			if (GameDirector.instance.PlayerList.Count >= 2)
			{
				UICreator.CreateUI();
				Cursor.visible = true;
				Cursor.lockState = (CursorLockMode)0;
			}
		}

		public static void DestroyUI()
		{
			UICreator.DestroyExistingUI();
			Cursor.visible = false;
			Cursor.lockState = (CursorLockMode)1;
		}

		private static Sprite LoadSpriteFromFile(string filePath)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			if (!File.Exists(filePath))
			{
				ShopPrison.Logger.LogError((object)("Sprite file not found: " + filePath));
				return null;
			}
			byte[] array = File.ReadAllBytes(filePath);
			Texture2D val = new Texture2D(2, 2);
			if (ImageConversion.LoadImage(val, array))
			{
				return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f));
			}
			ShopPrison.Logger.LogError((object)"Failed to load image data into texture.");
			return null;
		}

		public static Sprite LoadSprite(string spriteName)
		{
			string filePath = Path.Combine(Paths.PluginPath, "GlitchApotamus-ShopPrison/Assets/Sprites/VotingUI_" + spriteName + ".png");
			return LoadSpriteFromFile(filePath);
		}

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

		private static float GetJailDuration()
		{
			if (!(ShopPrison.BoundConfig.JailTime.Value <= 0f))
			{
				return ShopPrison.BoundConfig.JailTime.Value;
			}
			return float.PositiveInfinity;
		}

		public static void FreezePlayer(bool disable)
		{
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			if (PlayerController.instance != null)
			{
				Rigidbody rb = PlayerController.instance.rb;
				if (_jailCoroutine != null)
				{
					((MonoBehaviour)PlayerController.instance).StopCoroutine(_jailCoroutine);
					_jailCoroutine = null;
				}
				if (disable)
				{
					_jailCoroutine = ((MonoBehaviour)PlayerController.instance).StartCoroutine(DisableInputsOverTime(disableAiming: true));
				}
				else
				{
					PlayerController.instance.InputDisable(GetJailDuration());
					_jailCoroutine = ((MonoBehaviour)PlayerController.instance).StartCoroutine(DisableInputsOverTime(disableAiming: false));
					((MonoBehaviour)PlayerController.instance).StartCoroutine(HideJailMessageNextFrame());
				}
				if (rb != null)
				{
					rb.isKinematic = false;
					rb.velocity = Vector3.zero;
					rb.angularVelocity = Vector3.zero;
					rb.isKinematic = true;
				}
				((Behaviour)PlayerController.instance).enabled = false;
				((Behaviour)PlayerController.instance.cameraAim).enabled = !disable;
			}
		}

		[IteratorStateMachine(typeof(<DisableInputsOverTime>d__9))]
		private static IEnumerator DisableInputsOverTime(bool disableAiming)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <DisableInputsOverTime>d__9(0)
			{
				disableAiming = disableAiming
			};
		}
	}
	public class JailMessageUI : MonoBehaviour
	{
		[CompilerGenerated]
		private sealed class <HideAfterDelay>d__7 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public float delay;

			public JailMessageUI <>4__this;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0025: Unknown result type (might be due to invalid IL or missing references)
				//IL_002f: Expected O, but got Unknown
				int num = <>1__state;
				JailMessageUI jailMessageUI = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(delay);
					<>1__state = 1;
					return true;
				case 1:
				{
					<>1__state = -1;
					GameObject? canvasObject = jailMessageUI._canvasObject;
					if (canvasObject != null)
					{
						canvasObject.SetActive(false);
					}
					return false;
				}
				}
			}

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

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

		public static JailMessageUI? Instance;

		private Canvas? _canvas;

		private GameObject? _canvasObject;

		private TextMeshProUGUI? _text;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
				InitializeUI();
			}
			else
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}

		private void InitializeUI()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			_canvasObject = new GameObject("JailMessageCanvas");
			_canvas = _canvasObject.AddComponent<Canvas>();
			_canvas.renderMode = (RenderMode)0;
			_canvas.sortingOrder = 999;
			_canvasObject.AddComponent<CanvasScaler>().uiScaleMode = (ScaleMode)1;
			_canvasObject.AddComponent<GraphicRaycaster>();
			Object.DontDestroyOnLoad((Object)(object)_canvasObject);
			GameObject val = new GameObject("JailMessageText");
			val.transform.SetParent(_canvasObject.transform, false);
			_text = val.AddComponent<TextMeshProUGUI>();
			((TMP_Text)_text).fontSize = 48f;
			((TMP_Text)_text).alignment = (TextAlignmentOptions)514;
			((TMP_Text)_text).enableWordWrapping = false;
			RectTransform component = ((Component)_text).GetComponent<RectTransform>();
			component.sizeDelta = new Vector2(800f, 200f);
			component.anchorMin = new Vector2(0.5f, 0.5f);
			component.anchorMax = new Vector2(0.5f, 0.5f);
			component.pivot = new Vector2(0.5f, 0.5f);
			component.anchoredPosition = Vector2.zero;
			_canvasObject.SetActive(false);
		}

		public void Show(string message, Color color)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_canvasObject == (Object)null) && !((Object)(object)_text == (Object)null))
			{
				((TMP_Text)_text).text = message;
				((Graphic)_text).color = color;
				_canvasObject.SetActive(true);
				((MonoBehaviour)this).StopAllCoroutines();
			}
		}

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

		public static void DestroyJailMessage()
		{
			if (Instance?._canvasObject != null)
			{
				Object.Destroy((Object)(object)Instance._canvasObject);
			}
		}
	}
}
namespace ShopPrison.Patches
{
	[HarmonyPatch(typeof(GameplayManager))]
	internal class GameplayManagerPatch
	{
		[CompilerGenerated]
		private sealed class <WaitForPlayers>d__1 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0047: Unknown result type (might be due to invalid IL or missing references)
				//IL_004c: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				if (GameDirector.instance.PlayerList.Count < 2)
				{
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				PhotonNetwork.InstantiateRoomObject("SpNetworker", Vector3.zero, Quaternion.identity, (byte)0, (object[])null);
				ShopPrison.Logger.LogInfo((object)"Networker instantiated on Master Client.");
				return false;
			}

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

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

		[HarmonyPostfix]
		[HarmonyPatch("Start")]
		private static void StartPatch()
		{
			if (SemiFunc.IsMultiplayer() && !((Object)(object)Networker.Instance != (Object)null) && PhotonNetwork.IsMasterClient && SemiFunc.RunIsShop())
			{
				((MonoBehaviour)ShopPrison.Instance).StartCoroutine(WaitForPlayers());
			}
		}

		[IteratorStateMachine(typeof(<WaitForPlayers>d__1))]
		private static IEnumerator WaitForPlayers()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <WaitForPlayers>d__1(0);
		}
	}
	[HarmonyPatch(typeof(LoadingUI))]
	internal static class LoadingUIPatch
	{
		[CompilerGenerated]
		private sealed class <ResumeLoadingAfterDelay>d__2 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public LoadingUI loadingUI;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0032: Unknown result type (might be due to invalid IL or missing references)
				//IL_003c: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(ShopPrison.BoundConfig.VoteTime?.Value ?? 10f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					_suppressPatch = true;
					global::ShopPrison.Utils.Utils.DestroyUI();
					((Behaviour)loadingUI).enabled = true;
					loadingUI.LevelAnimationStart();
					_suppressPatch = false;
					return false;
				}
			}

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

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

		private static bool _suppressPatch;

		[HarmonyPrefix]
		[HarmonyPatch("LevelAnimationStart")]
		private static void Start_Prefix(LoadingUI __instance)
		{
			if (!_suppressPatch && !((Object)(object)Networker.Instance == (Object)null) && SemiFunc.RunIsShop())
			{
				((Behaviour)__instance).enabled = false;
				global::ShopPrison.Utils.Utils.CreateUI();
				((MonoBehaviour)__instance).StartCoroutine(ResumeLoadingAfterDelay(__instance));
			}
		}

		[IteratorStateMachine(typeof(<ResumeLoadingAfterDelay>d__2))]
		private static IEnumerator ResumeLoadingAfterDelay(LoadingUI loadingUI)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <ResumeLoadingAfterDelay>d__2(0)
			{
				loadingUI = loadingUI
			};
		}
	}
	[HarmonyPatch(typeof(SemiFunc))]
	internal static class SemiFuncPatch
	{
		[CompilerGenerated]
		private sealed class <WaitForLevelAnimationCompletion>d__1 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

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

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

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

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

			private bool MoveNext()
			{
				string text;
				PhotonView photonView;
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					goto IL_003b;
				case 1:
					<>1__state = -1;
					goto IL_003b;
				case 2:
					{
						<>1__state = -1;
						return false;
					}
					IL_003b:
					if (!LoadingUI.instance.levelAnimationCompleted)
					{
						<>2__current = null;
						<>1__state = 1;
						return true;
					}
					text = VoteManager.GetTopVoted()?.TargetPlayer;
					if (string.IsNullOrEmpty(text) || text == "SKIP")
					{
						return false;
					}
					if (PlayerController.instance.playerName != text)
					{
						return false;
					}
					if (ShopPrison.BoundConfig.BypassHost.Value && SemiFunc.IsMasterClient())
					{
						return false;
					}
					photonView = Networker.Instance.photonView;
					if (photonView != null)
					{
						photonView.RPC("ReceiveVote", (RpcTarget)2, new object[1] { PlayerController.instance.playerName });
					}
					<>2__current = null;
					<>1__state = 2;
					return true;
				}
			}

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

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

		[HarmonyPostfix]
		[HarmonyPatch("OnLevelGenDone")]
		private static void OnLevelGenDone_Postfix()
		{
			if (SemiFunc.RunIsShop())
			{
				((MonoBehaviour)ShopPrison.Instance).StartCoroutine(WaitForLevelAnimationCompletion());
				GameObject val = GameObject.Find("ShopPrisonCanvas");
				if (Object.op_Implicit((Object)(object)val))
				{
					Object.Destroy((Object)(object)val);
				}
			}
			else if (SemiFunc.RunIsLobby())
			{
				string text = VoteManager.GetTopVoted()?.TargetPlayer;
				if ((text != null && !(text == "SKIP")) || 1 == 0)
				{
					PlayerAvatar val2 = SemiFunc.PlayerGetFromName(text);
					if (ShopPrison.BoundConfig.TeleportToChair.Value || ShopPrison.BoundConfig.TeleportToSideRoom.Value)
					{
						val2.Revive(true);
						val2.playerHealth.Heal(val2.playerHealth.maxHealth, true);
					}
					VoteManager.ResetVotes(GameDirector.instance.PlayerList.Count);
					JailMessageUI.DestroyJailMessage();
				}
			}
			else
			{
				VoteManager.ResetVotes(GameDirector.instance.PlayerList.Count);
				JailMessageUI.DestroyJailMessage();
			}
		}

		[IteratorStateMachine(typeof(<WaitForLevelAnimationCompletion>d__1))]
		private static IEnumerator WaitForLevelAnimationCompletion()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <WaitForLevelAnimationCompletion>d__1(0);
		}
	}
}
namespace ShopPrison.Managers
{
	public class ConfigManager
	{
		public readonly ConfigEntry<bool> BypassHost;

		public readonly ConfigEntry<float> JailTime;

		public readonly ConfigEntry<float> VoteTime;

		public readonly ConfigEntry<bool> FullDisable;

		public readonly ConfigEntry<bool> TeleportToChair;

		public readonly ConfigEntry<bool> TeleportToSideRoom;

		public readonly ConfigEntry<bool> DeveloperMode;

		public ConfigManager(ConfigFile cfg)
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Expected O, but got Unknown
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Expected O, but got Unknown
			cfg.SaveOnConfigSet = false;
			BypassHost = cfg.Bind<bool>("General", "BypassHost", false, "The host can't be voted to jail");
			JailTime = cfg.Bind<float>("General", "JailTime", 120f, new ConfigDescription("Time to imprison a player in the shop", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 640f), Array.Empty<object>()));
			VoteTime = cfg.Bind<float>("General", "VoteTime", 10f, new ConfigDescription("Time to vote for a player to jail", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 640f), Array.Empty<object>()));
			FullDisable = cfg.Bind<bool>("General", "FullDisable", false, "Completely disable the player controller. The player will not be able to move, aim, or interact with the game. This is useful for preventing players from doing anything while in jail.");
			TeleportToChair = cfg.Bind<bool>("General", "TeleportToChair", false, "Teleport the player to the chair when jailed, then frozen. If false, the player will be frozen in place instead. Do not use if TeleportToSideRoom is set to true");
			TeleportToSideRoom = cfg.Bind<bool>("General", "TeleportToSideRoom", false, "Teleport the player to the side room when jailed, then frozen. If false, the player will be frozen in place instead. Do not use if TeleportToChair is set to true");
			DeveloperMode = cfg.Bind<bool>("General", "DeveloperMode", false, "Enable developer mode. This will allow you to vote for yourself during the voting session. This setting is meant only for TESTING!");
			if (TeleportToChair.Value && TeleportToSideRoom.Value)
			{
				TeleportToSideRoom.Value = false;
				ShopPrison.Logger.LogWarning((object)"Both teleport options were enabled; disabling 'TeleportToSideRoom'. Reload UI to see changes.");
			}
			TeleportToChair.SettingChanged += delegate
			{
				if (TeleportToChair.Value && TeleportToSideRoom.Value)
				{
					TeleportToSideRoom.Value = false;
					ShopPrison.Logger.LogInfo((object)"Disabled 'TeleportToSideRoom' because 'TeleportToChair' was enabled. Reload UI to see changes.");
				}
			};
			TeleportToSideRoom.SettingChanged += delegate
			{
				if (TeleportToSideRoom.Value && TeleportToChair.Value)
				{
					TeleportToChair.Value = false;
					ShopPrison.Logger.LogInfo((object)"Disabled 'TeleportToChair' because 'TeleportToSideRoom' was enabled. Reload UI to see changes.");
				}
			};
			ClearOrphanedEntries(cfg);
			cfg.Save();
			cfg.SaveOnConfigSet = true;
		}

		private static void ClearOrphanedEntries(ConfigFile cfg)
		{
			PropertyInfo propertyInfo = AccessTools.Property(typeof(ConfigFile), "OrphanedEntries");
			Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)propertyInfo.GetValue(cfg);
			dictionary.Clear();
		}
	}
	internal class JailPlayer : MonoBehaviour
	{
		private static GameObject? FindByNamePartial(string partialName)
		{
			string partialName2 = partialName;
			GameObject[] source = Object.FindObjectsOfType<GameObject>();
			return ((IEnumerable<GameObject>)source).LastOrDefault((Func<GameObject, bool>)((GameObject go) => ((Object)go).name.Replace(" ", "").ToLower().Contains(partialName2.Replace(" ", "").ToLower())));
		}

		[PunRPC]
		public static void TeleportToSideRoom(int photonID)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = GameObject.Find("Shop Door");
			if (Object.op_Implicit((Object)(object)val))
			{
				Transform parent = val.transform.parent;
				LevelPoint val2 = ((parent != null) ? ((Component)parent).GetComponentInChildren<LevelPoint>() : null);
				if (val2 != null)
				{
					Networker.Instance.RequestTeleport(photonID, ((Component)val2).transform.position, ((Component)val2).transform.rotation);
				}
				Networker.Instance.MakeDoorGlass();
			}
		}

		[PunRPC]
		public static void TeleportToChair(int photonID)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = FindByNamePartial("shop chair") ?? GameObject.Find("Shop chair");
			if (Object.op_Implicit((Object)(object)val))
			{
				Networker.Instance.RequestTeleport(photonID, val.transform.position, val.transform.rotation);
				Object.Destroy((Object)(object)val);
			}
		}

		[PunRPC]
		public static void UnjailPlayerByID(int photonID)
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = FindByNamePartial("spawn point") ?? GameObject.Find("Spawn Point");
			ShopPrison.Logger.LogDebug((object)("Found spawn point: " + ((val != null) ? ((Object)val).name : null)));
			if (!((Object)(object)val == (Object)null))
			{
				Networker.Instance.RequestTeleport(photonID, val.transform.position, val.transform.rotation);
			}
		}
	}
	public class Networker : MonoBehaviourPun
	{
		[CompilerGenerated]
		private sealed class <ReenableAfterDelay>d__26 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public PhotonTransformView transformView;

			public PlayerController controller;

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

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

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

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

			private bool MoveNext()
			{
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(0.1f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					if (transformView != null)
					{
						((Behaviour)transformView).enabled = true;
					}
					if (controller != null)
					{
						((Behaviour)controller).enabled = true;
					}
					return false;
				}
			}

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

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

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

			private object <>2__current;

			public Networker <>4__this;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0034: Unknown result type (might be due to invalid IL or missing references)
				//IL_003e: Expected O, but got Unknown
				int num = <>1__state;
				Networker networker = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(ShopPrison.BoundConfig.VoteTime.Value + 5f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					if (networker._pendingVotes.Count >= PhotonNetwork.CurrentRoom.PlayerCount)
					{
						return false;
					}
					networker.ProcessVotes();
					ShopPrison.Logger.LogInfo((object)"Vote timeout reached. Processing partial votes.");
					return false;
				}
			}

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

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

		public PhotonView? photonView;

		private static readonly int Mode = Shader.PropertyToID("_Mode");

		private static readonly int SrcBlend = Shader.PropertyToID("_SrcBlend");

		private static readonly int DstBlend = Shader.PropertyToID("_DstBlend");

		private static readonly int ZWrite = Shader.PropertyToID("_ZWrite");

		private readonly Dictionary<string, string> _pendingVotes = new Dictionary<string, string>();

		private bool _voteTimerStarted;

		private bool _alreadyProcessedVotes;

		public static Networker Instance { get; private set; } = null;


		public bool VoteHandled { get; set; }

		private void Awake()
		{
			if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
				return;
			}
			Instance = this;
			Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
			photonView = ((Component)this).GetComponent<PhotonView>();
		}

		public void RequestTeleport(int targetViewID, Vector3 position, Quaternion rotation)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			PhotonView val = PhotonView.Find(targetViewID);
			if (val != null && photonView != null)
			{
				photonView.RPC("PerformTeleport", val.Owner, new object[3] { targetViewID, position, rotation });
			}
		}

		public void MakeDoorGlass()
		{
			GameObject val = GameObject.Find("Shop Door");
			Rigidbody componentInChildren = val.GetComponentInChildren<Rigidbody>();
			componentInChildren.isKinematic = true;
			PhotonView? obj = photonView;
			if (obj != null)
			{
				obj.RPC("MakeGlassRPC", (RpcTarget)0, new object[3]
				{
					val.GetComponentInChildren<PhotonView>().ViewID,
					true,
					false
				});
			}
			Renderer[] componentsInChildren = val.GetComponentsInChildren<Renderer>();
			foreach (Renderer val2 in componentsInChildren)
			{
				MakeGlass(val2.material);
			}
		}

		[PunRPC]
		public void ReceiveVote(string playerName)
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			if (!VoteHandled && !(PlayerController.instance.playerName != playerName))
			{
				VoteHandled = true;
				ShopPrison.Logger.LogInfo((object)("Received vote RPC: jailing player " + playerName));
				if ((Object)(object)JailMessageUI.Instance == (Object)null)
				{
					new GameObject("JailMessageManager").AddComponent<JailMessageUI>();
				}
				bool flag = false;
				if (ShopPrison.BoundConfig.TeleportToChair.Value)
				{
					JailPlayer.TeleportToChair(PlayerAvatar.instance.photonView.ViewID);
					global::ShopPrison.Utils.Utils.FreezePlayer(ShopPrison.BoundConfig.FullDisable.Value);
					flag = true;
				}
				else if (ShopPrison.BoundConfig.TeleportToSideRoom.Value)
				{
					JailPlayer.TeleportToSideRoom(PlayerAvatar.instance.photonView.ViewID);
					flag = true;
				}
				else
				{
					global::ShopPrison.Utils.Utils.FreezePlayer(ShopPrison.BoundConfig.FullDisable.Value);
					flag = true;
				}
				if (flag)
				{
					JailMessageUI.Instance?.Show("You were voted to Jail!", Color.red);
				}
				VoteManager.ResetVotes(GameDirector.instance.PlayerList.Count);
				VoteHandled = false;
			}
		}

		[PunRPC]
		public void SendVote(string targetPlayerName, PhotonMessageInfo info)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			if (PhotonNetwork.IsMasterClient)
			{
				string nickName = info.Sender.nickName;
				ShopPrison.Logger.LogInfo((object)((targetPlayerName == "SKIP") ? (info.Sender.NickName + " skipped voting") : (info.Sender.NickName + " voted for " + targetPlayerName)));
				_pendingVotes[nickName] = targetPlayerName;
				ShopPrison.Logger.LogInfo((object)$"Received {_pendingVotes.Count}/{PhotonNetwork.CurrentRoom.PlayerCount} votes");
				if (!_voteTimerStarted)
				{
					_voteTimerStarted = true;
					((MonoBehaviour)this).StartCoroutine(VoteTimeoutRoutine());
				}
				if (_pendingVotes.Count >= PhotonNetwork.CurrentRoom.PlayerCount)
				{
					ProcessVotes();
				}
			}
		}

		public void AllVotesReceived()
		{
			(string, int)? topVoted = VoteManager.GetTopVoted();
			if (!topVoted.HasValue || string.IsNullOrEmpty(topVoted?.Item1) || topVoted?.Item1 == "SKIP")
			{
				ShopPrison.Logger.LogInfo((object)"Voting skipped, tied or no valid target.");
				return;
			}
			ShopPrison.Logger.LogInfo((object)("Top voted player is " + topVoted?.Item1 + ", sending RPC to jail them."));
			PhotonView? obj = photonView;
			if (obj != null)
			{
				obj.RPC("ReceiveVote", (RpcTarget)0, new object[1] { topVoted?.Item1 });
			}
			_pendingVotes.Clear();
		}

		private void ProcessVotes()
		{
			if (_alreadyProcessedVotes)
			{
				ShopPrison.Logger.LogInfo((object)"Votes already processed.");
				return;
			}
			foreach (KeyValuePair<string, string> pendingVote in _pendingVotes)
			{
				VoteManager.AddVote(pendingVote.Key, pendingVote.Value);
			}
			ShopPrison.Logger.LogInfo((object)"Votes processed.");
			AllVotesReceived();
			_pendingVotes.Clear();
			_voteTimerStarted = false;
			_alreadyProcessedVotes = true;
		}

		[PunRPC]
		private void PerformTeleport(int targetViewID, Vector3 position, Quaternion rotation)
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			PlayerAvatar val = SemiFunc.PlayerAvatarGetFromPhotonID(targetViewID);
			if (!((Object)(object)val == (Object)null))
			{
				PlayerController instance = PlayerController.instance;
				if ((Object)(object)instance != (Object)null)
				{
					((Behaviour)instance).enabled = false;
				}
				PhotonTransformView component = ((Component)val).GetComponent<PhotonTransformView>();
				if ((Object)(object)component != (Object)null)
				{
					((Behaviour)component).enabled = false;
				}
				val.Spawn(position, rotation);
				((MonoBehaviour)this).StartCoroutine(ReenableAfterDelay(instance, component));
			}
		}

		[PunRPC]
		public void MakeGlassRPC(int viewID, bool isKinematic, bool isGlass)
		{
			PhotonView val = PhotonView.Find(viewID);
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			GameObject gameObject = ((Component)val).gameObject;
			if ((Object)(object)gameObject == (Object)null)
			{
				return;
			}
			Rigidbody componentInChildren = gameObject.GetComponentInChildren<Rigidbody>();
			if ((Object)(object)componentInChildren != (Object)null)
			{
				componentInChildren.isKinematic = isKinematic;
			}
			Renderer[] componentsInChildren = gameObject.GetComponentsInChildren<Renderer>();
			Renderer[] array = componentsInChildren;
			foreach (Renderer val2 in array)
			{
				if (isGlass)
				{
					MakeGlass(val2.material);
				}
			}
		}

		private static void MakeGlass(Material mat, float alpha = 0.3f)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			Color color = mat.color;
			Shader val = Shader.Find("Standard");
			if (val != null)
			{
				mat.shader = val;
				mat.SetFloat(Mode, 3f);
				mat.SetInt(SrcBlend, 5);
				mat.SetInt(DstBlend, 10);
				mat.SetInt(ZWrite, 0);
				mat.DisableKeyword("_ALPHATEST_ON");
				mat.EnableKeyword("_ALPHABLEND_ON");
				mat.DisableKeyword("_ALPHAPREMULTIPLY_ON");
				mat.renderQueue = 3000;
				Color color2 = color;
				color2.a = alpha;
				mat.color = color2;
			}
		}

		[IteratorStateMachine(typeof(<ReenableAfterDelay>d__26))]
		private static IEnumerator ReenableAfterDelay(PlayerController? controller, PhotonTransformView? transformView)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <ReenableAfterDelay>d__26(0)
			{
				controller = controller,
				transformView = transformView
			};
		}

		[IteratorStateMachine(typeof(<VoteTimeoutRoutine>d__27))]
		private IEnumerator VoteTimeoutRoutine()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <VoteTimeoutRoutine>d__27(0)
			{
				<>4__this = this
			};
		}
	}
	public static class VoteManager
	{
		private static readonly Dictionary<string, string> Votes = new Dictionary<string, string>();

		private static int _expectedVoteCount = 0;

		public static void ResetVotes(int playerCount)
		{
			Votes.Clear();
			_expectedVoteCount = playerCount;
		}

		public static bool AddVote(string voterPlayerName, string targetPlayerName)
		{
			Votes[voterPlayerName] = targetPlayerName;
			return Votes.Count >= _expectedVoteCount;
		}

		public static (string TargetPlayer, int Count)? GetTopVoted()
		{
			if (Votes.Count == 0)
			{
				return null;
			}
			List<(string, int)> list = (from kv in Votes
				group kv by kv.Value into @group
				select (@group.Key, @group.Count()) into g
				orderby g.Count descending
				select g).ToList();
			if (list.Count < 2 || list[0].Item2 > list[1].Item2)
			{
				return list[0];
			}
			return null;
		}
	}
}