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 MonoMod.RuntimeDetour;
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.Serialization;
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+1788fc0c15e1b7b276fb6bb3e4f79d91c6f6dd8a")]
[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
{
internal sealed class Hooks
{
[CompilerGenerated]
private sealed class <OpenDoorAfterVoting>d__6 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public TruckDoor truckDoor;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <OpenDoorAfterVoting>d__6(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: 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);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
global::ShopPrison.Utils.Utils.DestroyUI();
((Behaviour)truckDoor).enabled = true;
((Behaviour)PlayerController.instance).enabled = true;
((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 <WaitAndCreateUIAndStartVoting>d__5 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public TruckDoor truckDoor;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <WaitAndCreateUIAndStartVoting>d__5(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
ShopPrison.Logger.LogDebug((object)"Waiting for 5 seconds before creating UI.");
<>2__current = (object)new WaitForSeconds(5f);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
((Behaviour)PlayerController.instance).enabled = false;
((Behaviour)PlayerController.instance.cameraAim).enabled = false;
ShopPrison.Logger.LogDebug((object)"Creating UI.");
global::ShopPrison.Utils.Utils.CreateUI();
<>2__current = OpenDoorAfterVoting(truckDoor);
<>1__state = 2;
return true;
case 2:
<>1__state = -1;
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();
}
}
internal static void GameplayManager_StartHook(Action<GameplayManager> orig, GameplayManager __instance)
{
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
orig(__instance);
if (SemiFunc.IsMultiplayer() && !((Object)(object)Networker.Instance != (Object)null) && PhotonNetwork.IsMasterClient && SemiFunc.RunIsShop())
{
PhotonNetwork.InstantiateRoomObject("SpNetworker", Vector3.zero, Quaternion.identity, (byte)0, (object[])null);
ShopPrison.Logger.LogDebug((object)"Networker instantiated on Master Client.");
}
}
internal static void GameplayManager_UpdateHook(Action<GameplayManager> orig, GameplayManager __instance)
{
if (SemiFunc.RunIsShop())
{
orig(__instance);
return;
}
Networker.Instance?.ResetJailState();
orig(__instance);
}
internal static void PlayerAvatar_FixedUpdateHook(Action<PlayerAvatar> orig, PlayerAvatar self)
{
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
orig(self);
if (!SemiFunc.IsMultiplayer() || !SemiFunc.RunIsShop() || (Object)(object)Networker.Instance == (Object)null || !Networker.IsJailed)
{
return;
}
string currentTopVotedPlayer = Networker.CurrentTopVotedPlayer;
if (string.IsNullOrEmpty(currentTopVotedPlayer) || !PlayerAvatar.instance.isLocal)
{
return;
}
string text = PlayerAvatar.instance.playerName.Trim().ToLowerInvariant();
string text2 = currentTopVotedPlayer.Trim().ToLowerInvariant();
if (text != text2)
{
return;
}
GameObject val = GameObject.Find("Shop Door");
if (!Object.op_Implicit((Object)(object)val))
{
return;
}
Transform parent = val.transform.parent;
LevelPoint val2 = ((parent != null) ? ((Component)parent).GetComponentInChildren<LevelPoint>() : null);
if (val2 == null)
{
return;
}
Transform transform = ((Component)val2).transform;
if (!((Object)(object)transform == (Object)null))
{
float num = Vector3.Distance(((Component)PlayerAvatar.instance).transform.position, transform.position);
if (!(num <= 5f))
{
self.spawned = false;
PlayerAvatar.instance.Spawn(transform.position, transform.rotation);
}
}
}
internal static void PlayerAvatar_SpawnHook(Action<PlayerAvatar> orig, PlayerAvatar self)
{
if (self.spawned)
{
self.spawned = false;
}
orig(self);
}
internal static void TruckDoor_StartHook(Action<TruckDoor> orig, TruckDoor truckDoor)
{
orig(truckDoor);
if (SemiFunc.IsMultiplayer() && SemiFunc.RunIsShop() && !((Object)(object)Networker.Instance == (Object)null))
{
Networker.Instance.alreadyProcessedVotes = false;
((Behaviour)truckDoor).enabled = false;
if (GameDirector.instance.PlayerList.Count < 2)
{
((Behaviour)truckDoor).enabled = true;
return;
}
((MonoBehaviour)truckDoor).StartCoroutine(WaitAndCreateUIAndStartVoting(truckDoor));
ShopPrison.Logger.LogDebug((object)((!((Behaviour)truckDoor).enabled) ? "TruckDoor disabled for Voting." : "TruckDoor enabled."));
}
}
[IteratorStateMachine(typeof(<WaitAndCreateUIAndStartVoting>d__5))]
private static IEnumerator WaitAndCreateUIAndStartVoting(TruckDoor truckDoor)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <WaitAndCreateUIAndStartVoting>d__5(0)
{
truckDoor = truckDoor
};
}
[IteratorStateMachine(typeof(<OpenDoorAfterVoting>d__6))]
private static IEnumerator OpenDoorAfterVoting(TruckDoor truckDoor)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <OpenDoorAfterVoting>d__6(0)
{
truckDoor = truckDoor
};
}
}
[BepInPlugin("GlitchApotamus-ShopPrison", "ShopPrison", "1.4.2")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class ShopPrison : BaseUnityPlugin
{
public static ShopPrison Instance { get; 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; }
public 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.4.2 has loaded!");
}
private void Update()
{
}
private void Patch()
{
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_0158: Unknown result type (might be due to invalid IL or missing references)
Logger.LogDebug((object)"Patching TruckDoor.Start method.");
new Hook((MethodBase)AccessTools.Method(typeof(TruckDoor), "Start", (Type[])null, (Type[])null), (Delegate)new Action<Action<TruckDoor>, TruckDoor>(Hooks.TruckDoor_StartHook));
Logger.LogDebug((object)"Patching GameplayManager.Start method.");
new Hook((MethodBase)AccessTools.Method(typeof(GameplayManager), "Start", (Type[])null, (Type[])null), (Delegate)new Action<Action<GameplayManager>, GameplayManager>(Hooks.GameplayManager_StartHook));
Logger.LogDebug((object)"Patching GameplayManager.Update method.");
new Hook((MethodBase)AccessTools.Method(typeof(GameplayManager), "Update", (Type[])null, (Type[])null), (Delegate)new Action<Action<GameplayManager>, GameplayManager>(Hooks.GameplayManager_UpdateHook));
Logger.LogDebug((object)"Patching PlayerAvatar.FixedUpdate method.");
new Hook((MethodBase)AccessTools.Method(typeof(PlayerAvatar), "FixedUpdate", (Type[])null, (Type[])null), (Delegate)new Action<Action<PlayerAvatar>, PlayerAvatar>(Hooks.PlayerAvatar_FixedUpdateHook));
Logger.LogDebug((object)"Patching PlayerAvatar.Spawn method.");
new Hook((MethodBase)AccessTools.Method(typeof(PlayerAvatar), "Awake", (Type[])null, (Type[])null), (Delegate)new Action<Action<PlayerAvatar>, PlayerAvatar>(Hooks.PlayerAvatar_SpawnHook));
}
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.4.2 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.4.2";
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()
{
return Mathf.Max(100f, 140f);
}
}
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()
{
EnsureCanvasExists();
CreateMainContainer();
SetupContainerImage();
SetupLayoutAndTransform();
}
public static void DestroyExistingUI()
{
if (Object.op_Implicit((Object)(object)_uiContainer))
{
Object.Destroy((Object)(object)_uiContainer);
}
}
public static bool IsUIActive()
{
return Object.op_Implicit((Object)(object)_uiContainer);
}
private static void EnsureCanvasExists()
{
_canvas = GameObject.Find("ShopPrisonCanvas");
if (_canvas != 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(15, 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, 55f);
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_005e: 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)3;
((Graphic)val2).color = Color.white;
LayoutElement val3 = val.AddComponent<LayoutElement>();
val3.minWidth = UIConfig.GetPlayerNameWidth();
val3.preferredWidth = UIConfig.GetPlayerNameWidth();
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
{
//IL_00bb: 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)
if (PhotonNetwork.IsConnected)
{
Player localPlayer = PhotonNetwork.LocalPlayer;
if (localPlayer.nickName == targetPlayerName2)
{
ShopPrison.Logger.LogDebug((object)"You can't vote for yourself!");
}
else
{
ShopPrison.Logger.LogDebug((object)("Sending vote for " + targetPlayerName2));
PhotonView photonView = Networker.Instance.photonView;
if (photonView != null)
{
photonView.RPC("SendVote", (RpcTarget)2, new object[1] { targetPlayerName2 });
}
if (targetPlayerName2 == "SKIP")
{
Text componentInChildren = ((Component)button2).GetComponentInChildren<Text>();
if (componentInChildren != null)
{
componentInChildren.text = "✖\ufe0f Skip Vote";
componentInChildren.fontSize = 28;
((Graphic)componentInChildren).color = new Color(1f, 0.65f, 0.035f);
}
}
else
{
Button[] componentsInChildren = _contentContainer.GetComponentsInChildren<Button>(true);
Button[] array = componentsInChildren;
foreach (Button val in array)
{
if (((Object)val).name.Equals("PlayerEntry_" + targetPlayerName2))
{
Text componentInChildren2 = ((Component)val).GetComponentInChildren<Text>();
if (componentInChildren2 != null)
{
componentInChildren2.text = "✖\ufe0f " + componentInChildren2.text;
componentInChildren2.fontSize = 22;
((Graphic)componentInChildren2).color = new Color(1f, 0.65f, 0.035f);
break;
}
}
}
}
Button[] componentsInChildren2 = _uiContainer.GetComponentsInChildren<Button>();
Button[] array2 = componentsInChildren2;
foreach (Button val2 in array2)
{
if (((Object)val2).name.Equals(targetPlayerName2))
{
break;
}
((Selectable)val2).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;
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_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(delay);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
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();
}
}
public static JailMessageUI? Instance;
private static Canvas? _canvas;
private static GameObject? _canvasObject;
private static TextMeshProUGUI? _text;
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
InitializeUI();
}
else
{
Object.Destroy((Object)(object)((Component)this).gameObject);
}
}
private static void InitializeUI()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Expected O, but got Unknown
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Expected O, but got Unknown
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
//IL_0107: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: 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_002b: 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);
if (ShopPrison.BoundConfig.HideJailMessage.Value)
{
((MonoBehaviour)this).StartCoroutine(HideAfterDelay(ShopPrison.BoundConfig.HideJailMessageTime.Value));
}
}
}
[IteratorStateMachine(typeof(<HideAfterDelay>d__7))]
private static IEnumerator HideAfterDelay(float delay)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <HideAfterDelay>d__7(0)
{
delay = delay
};
}
public static void DestroyJailMessage()
{
if (_canvasObject != null)
{
_canvasObject.SetActive(false);
Object.Destroy((Object)(object)_canvasObject);
_canvasObject = null;
_canvas = null;
_text = null;
Instance = null;
}
}
}
}
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> HideJailMessage;
public readonly ConfigEntry<float> HideJailMessageTime;
public readonly ConfigEntry<bool> FullDisable;
public readonly ConfigEntry<bool> TeleportToChair;
public readonly ConfigEntry<bool> TeleportToSideRoom;
public ConfigManager(ConfigFile cfg)
{
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Expected O, but got Unknown
//IL_0052: Expected O, but got Unknown
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Expected O, but got Unknown
//IL_0095: Expected O, but got Unknown
//IL_00ab: 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_00d8: Expected O, but got Unknown
//IL_00d8: Expected O, but got Unknown
//IL_00ee: 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_0109: Expected O, but got Unknown
//IL_0109: Expected O, but got Unknown
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_0142: Unknown result type (might be due to invalid IL or missing references)
//IL_014c: Expected O, but got Unknown
//IL_014c: Expected O, but got Unknown
//IL_0162: Unknown result type (might be due to invalid IL or missing references)
//IL_0173: Unknown result type (might be due to invalid IL or missing references)
//IL_017d: Expected O, but got Unknown
//IL_017d: Expected O, but got Unknown
//IL_0193: Unknown result type (might be due to invalid IL or missing references)
//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
//IL_01ae: Expected O, but got Unknown
//IL_01ae: Expected O, but got Unknown
//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
//IL_01df: Expected O, but got Unknown
//IL_01df: Expected O, but got Unknown
ConfigFile cfg2 = cfg;
base..ctor();
ConfigManager configManager = this;
cfg2.SaveOnConfigSet = false;
BypassHost = cfg2.Bind<bool>(new ConfigDefinition("General", "BypassHost"), false, new ConfigDescription("The host can't be voted to jail", (AcceptableValueBase)null, Array.Empty<object>()));
JailTime = cfg2.Bind<float>(new ConfigDefinition("General", "JailTime"), 120f, new ConfigDescription("Time to imprison a player in the shop", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 640f), Array.Empty<object>()));
VoteTime = cfg2.Bind<float>(new ConfigDefinition("General", "VoteTime"), 10f, new ConfigDescription("Time to vote for a player to jail", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 640f), Array.Empty<object>()));
HideJailMessage = cfg2.Bind<bool>(new ConfigDefinition("General", "HideJailMessage"), false, new ConfigDescription("Hide the jail message when a player is jailed after some time.", (AcceptableValueBase)null, Array.Empty<object>()));
HideJailMessageTime = cfg2.Bind<float>(new ConfigDefinition("General", "HideJailMessageTime"), 5f, new ConfigDescription("Time to hide the jail message when a player is jailed.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(3f, 120f), Array.Empty<object>()));
FullDisable = cfg2.Bind<bool>(new ConfigDefinition("General", "FullDisable"), false, new ConfigDescription("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.", (AcceptableValueBase)null, Array.Empty<object>()));
TeleportToChair = cfg2.Bind<bool>(new ConfigDefinition("General", "TeleportToChair"), false, new ConfigDescription("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", (AcceptableValueBase)null, Array.Empty<object>()));
TeleportToSideRoom = cfg2.Bind<bool>(new ConfigDefinition("General", "TeleportToSideRoom"), false, new ConfigDescription("Teleport the player to the side room when jailed, then frozen. If false, the player will be frozen in place instead. THIS SETTING IS A DIRECT INCOMPATIBILITY WITH ANY MODS THAT USE THE SIDE ROOM, EX: CASINO MODS", (AcceptableValueBase)null, Array.Empty<object>()));
cfg2.SettingChanged += delegate
{
if (SemiFunc.IsMultiplayer() || PhotonNetwork.IsMasterClient)
{
cfg2.Save();
cfg2.Reload();
ShopPrison.Logger.LogInfo((object)"Config reloaded.");
}
};
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 (configManager.TeleportToChair.Value && configManager.TeleportToSideRoom.Value)
{
configManager.TeleportToSideRoom.Value = false;
ShopPrison.Logger.LogDebug((object)"Disabled 'TeleportToSideRoom' because 'TeleportToChair' was enabled. Reload UI to see changes.");
}
};
TeleportToSideRoom.SettingChanged += delegate
{
if (configManager.TeleportToSideRoom.Value && configManager.TeleportToChair.Value)
{
configManager.TeleportToChair.Value = false;
ShopPrison.Logger.LogDebug((object)"Disabled 'TeleportToChair' because 'TeleportToSideRoom' was enabled. Reload UI to see changes.");
}
};
ClearOrphanedEntries(cfg2);
cfg2.Save();
cfg2.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();
}
public object[] GetConfigValues()
{
return new object[8] { BypassHost.Value, JailTime.Value, VoteTime.Value, HideJailMessage.Value, HideJailMessageTime.Value, FullDisable.Value, TeleportToChair.Value, TeleportToSideRoom.Value };
}
}
public class Networker : MonoBehaviourPun
{
[CompilerGenerated]
private sealed class <Check2>d__42 : 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 <Check2>d__42(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
int num = <>1__state;
Networker networker = <>4__this;
switch (num)
{
default:
return false;
case 0:
<>1__state = -1;
break;
case 1:
<>1__state = -1;
break;
}
if (UICreator.IsUIActive())
{
<>2__current = null;
<>1__state = 1;
return true;
}
(string, int) topVoted = VoteManager.GetTopVoted();
ShopPrison.Logger.LogDebug((object)("Top voted player is " + topVoted.Item1 + ", sending RPC to jail them."));
PhotonView? photonView = networker.photonView;
if (photonView != null)
{
photonView.RPC("BroadcastTopVotedPlayer", (RpcTarget)1, new object[1] { topVoted.Item1 });
}
PhotonView? photonView2 = networker.photonView;
if (photonView2 != null)
{
photonView2.RPC("ReceiveVote", (RpcTarget)0, new object[1] { topVoted.Item1 });
}
PhotonView? photonView3 = networker.photonView;
if (photonView3 != null)
{
photonView3.RPC("SetShopDoorColliders", (RpcTarget)0, new object[1] { topVoted.Item1 });
}
networker._pendingVotes.Clear();
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 <Check>d__41 : 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 <Check>d__41(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
int num = <>1__state;
Networker networker = <>4__this;
if (num != 0)
{
return false;
}
<>1__state = -1;
networker.VoteTimerStarted = UICreator.IsUIActive();
if (networker._previousTimerState && !networker.VoteTimerStarted && networker._pendingVotes.Count > 0 && !networker.alreadyProcessedVotes)
{
networker.ProcessVotes();
}
networker._previousTimerState = networker.VoteTimerStarted;
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 <ReenableAfterDelay>d__40 : 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__40(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();
}
}
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>();
[FormerlySerializedAs("_alreadyProcessedVotes")]
public bool alreadyProcessedVotes;
private GameObject? _jailMessage;
private bool _previousTimerState;
public static Networker Instance { get; private set; } = null;
public bool VoteTimerStarted { get; set; }
private bool wasJailed { get; set; }
public static bool IsJailed => Instance.wasJailed;
public static string? CurrentTopVotedPlayer { 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>();
}
private void Update()
{
if (SemiFunc.RunIsShop() && PhotonNetwork.InRoom && (Object)(object)photonView != (Object)null)
{
((MonoBehaviour)this).StartCoroutine(Check());
if (!PhotonNetwork.IsMasterClient)
{
SendConfigToMasterClient();
}
}
else
{
JailMessageUI.DestroyJailMessage();
}
}
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,
true
});
}
Renderer[] componentsInChildren = val.GetComponentsInChildren<Renderer>();
foreach (Renderer val2 in componentsInChildren)
{
MakeGlass(val2.material);
}
}
[PunRPC]
public void SetShopDoorColliders(string jailedPlayerName)
{
GameObject val = GameObject.Find("Shop Door");
if (!((Object)(object)val == (Object)null))
{
bool flag = PlayerController.instance.playerName != jailedPlayerName;
Collider[] componentsInChildren = val.GetComponentsInChildren<Collider>();
foreach (Collider val2 in componentsInChildren)
{
val2.enabled = !flag;
}
}
}
[PunRPC]
public void ReceiveVote(string playerName)
{
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Expected O, but got Unknown
//IL_0143: Unknown result type (might be due to invalid IL or missing references)
//IL_0180: Unknown result type (might be due to invalid IL or missing references)
//IL_018b: Unknown result type (might be due to invalid IL or missing references)
if (PlayerController.instance.playerName != playerName || (ShopPrison.BoundConfig.BypassHost.Value && PhotonNetwork.IsMasterClient))
{
return;
}
ShopPrison.Logger.LogDebug((object)("Received vote RPC: jailing player " + playerName));
if ((Object)(object)JailMessageUI.Instance == (Object)null)
{
_jailMessage = new GameObject("JailMessageManager");
_jailMessage.AddComponent<JailMessageUI>();
}
if (ShopPrison.BoundConfig.TeleportToChair.Value)
{
ShopPrison.Logger.LogDebug((object)"Teleporting to chair.");
TeleportToChair(PlayerAvatar.instance.photonView.ViewID);
global::ShopPrison.Utils.Utils.FreezePlayer(ShopPrison.BoundConfig.FullDisable.Value);
wasJailed = true;
}
else if (ShopPrison.BoundConfig.TeleportToSideRoom.Value)
{
ShopPrison.Logger.LogDebug((object)"Teleporting to side room.");
TeleportToSideRoom(PlayerAvatar.instance.photonView.ViewID);
wasJailed = true;
}
else
{
ShopPrison.Logger.LogDebug((object)"Freezing player in place.");
global::ShopPrison.Utils.Utils.FreezePlayer(ShopPrison.BoundConfig.FullDisable.Value);
wasJailed = true;
}
if (wasJailed && SemiFunc.RunIsShop())
{
JailMessageUI.Instance?.Show("You were voted to Jail!", Color.red);
PlayerAvatar val = SemiFunc.PlayerAvatarGetFromPhotonID(PlayerAvatar.instance.photonView.ViewID);
Rigidbody val2 = ((val != null) ? ((Component)val).GetComponent<Rigidbody>() : null);
if ((Object)(object)val2 != (Object)null)
{
val2.isKinematic = false;
val2.velocity = Vector3.zero;
val2.angularVelocity = Vector3.zero;
val2.collisionDetectionMode = (CollisionDetectionMode)2;
}
}
}
[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.LogDebug((object)((targetPlayerName == "SKIP") ? (info.Sender.NickName + " skipped voting") : (info.Sender.NickName + " voted for " + targetPlayerName)));
_pendingVotes[nickName] = targetPlayerName;
ShopPrison.Logger.LogDebug((object)$"Received {_pendingVotes.Count}/{PhotonNetwork.CurrentRoom.PlayerCount} votes");
if (_pendingVotes.Count >= PhotonNetwork.CurrentRoom.PlayerCount)
{
ProcessVotes();
}
}
}
public void AllVotesReceived()
{
if (_pendingVotes.Count != 0)
{
((MonoBehaviour)this).StartCoroutine(Check2());
}
}
private int CountVotes(string target)
{
string target2 = target;
return _pendingVotes.Count<KeyValuePair<string, string>>((KeyValuePair<string, string> vote) => vote.Value == target2);
}
private void ProcessVotes()
{
if (alreadyProcessedVotes)
{
return;
}
int num = CountVotes("SKIP");
int num2 = (from v in _pendingVotes
where v.Value != "SKIP"
group v by v.Value into g
select g.Count()).DefaultIfEmpty(0).Max();
if (num > num2)
{
ShopPrison.Logger.LogDebug((object)"SKIP received most votes - no player will be jailed");
_pendingVotes.Clear();
alreadyProcessedVotes = true;
return;
}
foreach (KeyValuePair<string, string> item in _pendingVotes.Where<KeyValuePair<string, string>>((KeyValuePair<string, string> vote) => vote.Value != "SKIP"))
{
VoteManager.AddVote(item.Key, item.Value);
}
AllVotesReceived();
alreadyProcessedVotes = true;
}
[PunRPC]
private void PerformTeleport(int targetViewID, Vector3 position, Quaternion rotation)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
if (position == Vector3.zero || Mathf.Abs(rotation.x) + Mathf.Abs(rotation.y) + Mathf.Abs(rotation.z) + Mathf.Abs(rotation.w) < 0.9f)
{
return;
}
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;
}
((Component)val).transform.position = position;
((Component)val).transform.rotation = rotation;
Rigidbody component2 = ((Component)val).GetComponent<Rigidbody>();
if ((Object)(object)component2 != (Object)null)
{
component2.isKinematic = false;
}
Physics.SyncTransforms();
((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__40))]
private static IEnumerator ReenableAfterDelay(PlayerController? controller, PhotonTransformView? transformView)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <ReenableAfterDelay>d__40(0)
{
controller = controller,
transformView = transformView
};
}
[IteratorStateMachine(typeof(<Check>d__41))]
private IEnumerator Check()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <Check>d__41(0)
{
<>4__this = this
};
}
[IteratorStateMachine(typeof(<Check2>d__42))]
private IEnumerator Check2()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <Check2>d__42(0)
{
<>4__this = this
};
}
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())));
}
private void TeleportToSideRoom(int photonID)
{
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: 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)
{
RequestTeleport(photonID, ((Component)val2).transform.position, ((Component)val2).transform.rotation);
}
MakeDoorGlass();
}
}
private void TeleportToChair(int photonID)
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
GameObject val = FindByNamePartial("shop chair") ?? GameObject.Find("Shop chair");
if (Object.op_Implicit((Object)(object)val))
{
RequestTeleport(photonID, val.transform.position, val.transform.rotation);
}
}
[PunRPC]
public void ReceiveConfigFromClient(bool bypassHost, float jailTime, float voteTime, bool hideJailMessage, float hideJailMessageTime, bool fullDisable, bool teleportToChair, bool teleportToSideRoom)
{
if (!PhotonNetwork.IsMasterClient)
{
return;
}
var anon = new
{
BypassHost = bypassHost,
JailTime = jailTime,
VoteTime = voteTime,
HideJailMessage = hideJailMessage,
HideJailMessageTime = hideJailMessageTime,
FullDisable = fullDisable,
TeleportToChair = teleportToChair,
TeleportToSideRoom = teleportToSideRoom
};
var obj = new
{
BypassHost = ShopPrison.BoundConfig.BypassHost.Value,
JailTime = ShopPrison.BoundConfig.JailTime.Value,
VoteTime = ShopPrison.BoundConfig.VoteTime.Value,
HideJailMessage = ShopPrison.BoundConfig.HideJailMessage.Value,
HideJailMessageTime = ShopPrison.BoundConfig.HideJailMessageTime.Value,
FullDisable = ShopPrison.BoundConfig.FullDisable.Value,
TeleportToChair = ShopPrison.BoundConfig.TeleportToChair.Value,
TeleportToSideRoom = ShopPrison.BoundConfig.TeleportToSideRoom.Value
};
if (!anon.Equals(obj))
{
PhotonView? obj2 = photonView;
if (obj2 != null)
{
obj2.RPC("SyncConfigWithHost", (RpcTarget)1, ShopPrison.BoundConfig.GetConfigValues());
}
}
}
public void SendConfigToMasterClient()
{
if (!PhotonNetwork.IsMasterClient && !((Object)(object)Instance == (Object)null) && !((Object)(object)Instance.photonView == (Object)null) && PhotonNetwork.InRoom)
{
object[] configValues = ShopPrison.BoundConfig.GetConfigValues();
PhotonView? obj = photonView;
if (obj != null)
{
obj.RPC("ReceiveConfigFromClient", (RpcTarget)2, configValues);
}
}
}
[PunRPC]
public void SyncConfigWithHost(bool bypassHost, float jailTime, float voteTime, bool hideJailMessage, float hideJailMessageTime, bool fullDisable, bool teleportToChair, bool teleportToSideRoom)
{
ShopPrison.BoundConfig.BypassHost.Value = bypassHost;
ShopPrison.BoundConfig.JailTime.Value = jailTime;
ShopPrison.BoundConfig.VoteTime.Value = voteTime;
ShopPrison.BoundConfig.HideJailMessage.Value = hideJailMessage;
ShopPrison.BoundConfig.HideJailMessageTime.Value = hideJailMessageTime;
ShopPrison.BoundConfig.FullDisable.Value = fullDisable;
ShopPrison.BoundConfig.TeleportToChair.Value = teleportToChair;
ShopPrison.BoundConfig.TeleportToSideRoom.Value = teleportToSideRoom;
}
[PunRPC]
public void BroadcastTopVotedPlayer(string playerName)
{
if (playerName != null)
{
PhotonView? obj = photonView;
if (obj != null)
{
obj.RPC("ReceiveTopVotedPlayer", (RpcTarget)0, new object[1] { playerName });
}
}
else
{
Debug.Log((object)"[ShopPrison] No top voted player found to broadcast.");
}
}
[PunRPC]
public void ReceiveTopVotedPlayer(string playerName)
{
Debug.Log((object)("[ShopPrison] Received top voted player: " + playerName));
CurrentTopVotedPlayer = playerName;
}
internal void ResetJailState()
{
if (CurrentTopVotedPlayer != null)
{
ShopPrison.Logger.LogDebug((object)"Resetting jail state.");
wasJailed = false;
CurrentTopVotedPlayer = null;
_pendingVotes.Clear();
alreadyProcessedVotes = false;
VoteManager.ResetVotes(PhotonNetwork.CurrentRoom.PlayerCount);
if ((Object)(object)_jailMessage != (Object)null)
{
Object.Destroy((Object)(object)_jailMessage);
_jailMessage = null;
}
JailMessageUI.DestroyJailMessage();
}
}
}
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, 0);
}
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, 0);
}
}
}