Decompiled source of REPO Map Party v1.0.0

MapRandomizer.dll

Decompiled 4 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using ExitGames.Client.Photon;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("Omniscye")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MapRandomizer")]
[assembly: AssemblyTitle("MapRandomizer")]
[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 Empress.VoteNextMap
{
	public class VoteOption
	{
		public string Label;

		public List<string> LevelNames;
	}
	[BepInPlugin("Empress.VoteNextMap", "Vote Next Map", "1.5.2")]
	public class VoteNextMapPlugin : BaseUnityPlugin
	{
		public const string PluginGuid = "Empress.VoteNextMap";

		public const string PluginName = "Vote Next Map";

		public const string PluginVersion = "1.5.2";

		internal static VoteNextMapPlugin Instance;

		internal static Harmony Harmony;

		private const string AsciiBanner = "\r\n/*  ██████╗ ███╗   ███╗███╗   ██╗██╗                           */\r\n/* ██╔═══██╗████╗ ████║████╗  ██║██║                           */\r\n/* ██║   ██║██╔████╔██║██╔██╗ ██║██║                           */\r\n/* ██║   ██║██║╚██╔╝██║██║╚██╗██║██║                           */\r\n/* ╚██████╔╝██║ ╚═╝ ██║██║ ╚████║██║                           */\r\n/*  ╚═════╝ ╚═╝     ╚═╝╚═╝  ╚═══╝╚═╝                           */\r\n/*                                                             */\r\n/* ███████╗███╗   ███╗██████╗ ██████╗ ███████╗███████╗███████╗ */\r\n/* ██╔════╝████╗ ████║██╔══██╗██╔══██╗██╔════╝██╔════╝██╔════╝ */\r\n/* █████╗  ██╔████╔██║██████╔╝██████╔╝█████╗  ███████╗███████╗ */\r\n/* ██╔══╝  ██║╚██╔╝██║██╔═══╝ ██╔══██╗██╔══╝  ╚════██║╚════██║ */\r\n/* ███████╗██║ ╚═╝ ██║██║     ██║  ██║███████╗███████║███████║ */\r\n/* ╚══════╝╚═╝     ╚═╝╚═╝     ╚═╝  ╚═╝╚══════╝╚══════╝╚══════╝ */\r\n";

		internal static ConfigEntry<string> Mode;

		internal static ConfigEntry<int> VoteDurationSeconds;

		internal static ConfigEntry<string> TiebreakRule;

		internal static ConfigEntry<bool> AllowAbstain;

		internal static ConfigEntry<bool> FailsafeAdvanceIfError;

		internal static ConfigEntry<int> MinPlayersToStartVote;

		internal static ConfigEntry<bool> AutoPopulateWhenEmpty;

		internal static ConfigEntry<float> RandomizerDuration;

		internal static ConfigEntry<float> RandomizerCyclesPerSec;

		internal static ConfigEntry<float> RandomizerEaseOut;

		internal static ConfigEntry<float> TickPitch;

		internal static ConfigEntry<bool> IncludeShopInRandomizer;

		internal static ConfigEntry<int> RandomizerRunLevelMin;

		internal static ConfigEntry<int> RandomizerRunLevelMax;

		internal static readonly List<VoteOption> Options = new List<VoteOption>();

		private void Awake()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			Instance = this;
			Harmony = new Harmony("Empress.VoteNextMap");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"\r\n/*  ██████╗ ███╗   ███╗███╗   ██╗██╗                           */\r\n/* ██╔═══██╗████╗ ████║████╗  ██║██║                           */\r\n/* ██║   ██║██╔████╔██║██╔██╗ ██║██║                           */\r\n/* ██║   ██║██║╚██╔╝██║██║╚██╗██║██║                           */\r\n/* ╚██████╔╝██║ ╚═╝ ██║██║ ╚████║██║                           */\r\n/*  ╚═════╝ ╚═╝     ╚═╝╚═╝  ╚═══╝╚═╝                           */\r\n/*                                                             */\r\n/* ███████╗███╗   ███╗██████╗ ██████╗ ███████╗███████╗███████╗ */\r\n/* ██╔════╝████╗ ████║██╔══██╗██╔══██╗██╔════╝██╔════╝██╔════╝ */\r\n/* █████╗  ██╔████╔██║██████╔╝██████╔╝█████╗  ███████╗███████╗ */\r\n/* ██╔══╝  ██║╚██╔╝██║██╔═══╝ ██╔══██╗██╔══╝  ╚════██║╚════██║ */\r\n/* ███████╗██║ ╚═╝ ██║██║     ██║  ██║███████╗███████║███████║ */\r\n/* ╚══════╝╚═╝     ╚═╝╚═╝     ╚═╝  ╚═╝╚══════╝╚══════╝╚══════╝ */\r\n");
			Mode = ((BaseUnityPlugin)this).Config.Bind<string>("General", "Mode", "Random", "Random | Vote");
			VoteDurationSeconds = ((BaseUnityPlugin)this).Config.Bind<int>("Vote", "VoteDurationSeconds", 15, "How long the vote stays open.");
			TiebreakRule = ((BaseUnityPlugin)this).Config.Bind<string>("Vote", "TiebreakRule", "Host", "Tiebreak rule: Host | Random");
			AllowAbstain = ((BaseUnityPlugin)this).Config.Bind<bool>("Vote", "AllowAbstain", false, "If true, players can abstain.");
			FailsafeAdvanceIfError = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "FailsafeAdvanceIfError", true, "If feature cannot run, fall back to vanilla.");
			MinPlayersToStartVote = ((BaseUnityPlugin)this).Config.Bind<int>("General", "MinPlayersToStartVote", 1, "Minimum players required to open.");
			AutoPopulateWhenEmpty = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "AutoPopulateWhenEmpty", true, "If true and no options are configured, build one option per playable Level from RunManager.levels.");
			RandomizerDuration = ((BaseUnityPlugin)this).Config.Bind<float>("Randomizer", "Duration", 3.5f, "Total spin duration seconds.");
			RandomizerCyclesPerSec = ((BaseUnityPlugin)this).Config.Bind<float>("Randomizer", "CyclesPerSecond", 8f, "Approx cycles/sec at peak speed.");
			RandomizerEaseOut = ((BaseUnityPlugin)this).Config.Bind<float>("Randomizer", "EaseOutPortion", 0.33f, "Portion of time spent slowing down (0..1).");
			TickPitch = ((BaseUnityPlugin)this).Config.Bind<float>("Randomizer", "TickPitch", 1f, "Pitch multiplier for tick sound.");
			IncludeShopInRandomizer = ((BaseUnityPlugin)this).Config.Bind<bool>("Randomizer", "IncludeShopInRandomizer", true, "Add Shop as an option if available.");
			RandomizerRunLevelMin = ((BaseUnityPlugin)this).Config.Bind<int>("Randomizer", "RunLevelMin", 1, "Minimum run level (inclusive).");
			RandomizerRunLevelMax = ((BaseUnityPlugin)this).Config.Bind<int>("Randomizer", "RunLevelMax", 20, "Maximum run level (inclusive).");
			LoadOptionBlock("Option1");
			LoadOptionBlock("Option2");
			LoadOptionBlock("Option3");
			LoadOptionBlock("Option4");
			LoadOptionBlock("Option5");
			Harmony.PatchAll(Assembly.GetExecutingAssembly());
			((BaseUnityPlugin)this).Logger.LogInfo((object)string.Format("{0} {1} loaded with {2} options (Mode={3}, AutoPopulate={4}).", "Vote Next Map", "1.5.2", Options.Count, Mode.Value, AutoPopulateWhenEmpty.Value));
		}

		private void LoadOptionBlock(string section)
		{
			if (((BaseUnityPlugin)this).Config.Bind<bool>(section, "Enabled", false, "Enable this option.").Value)
			{
				string text = ((BaseUnityPlugin)this).Config.Bind<string>(section, "Label", section, "Label shown in the UI.").Value?.Trim();
				string text2 = ((BaseUnityPlugin)this).Config.Bind<string>(section, "Levels", string.Empty, "Comma-separated Level names as in RunManager.levels list").Value ?? string.Empty;
				List<string> list = (from s in text2.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries)
					select s.Trim() into s
					where !string.IsNullOrEmpty(s)
					select s).Distinct<string>(StringComparer.Ordinal).ToList();
				if (!string.IsNullOrEmpty(text) && list.Count != 0)
				{
					Options.Add(new VoteOption
					{
						Label = text,
						LevelNames = list
					});
				}
			}
		}

		internal static bool EnsureOptions(out string error)
		{
			error = null;
			if (Options.Count == 0)
			{
				ConfigEntry<bool> autoPopulateWhenEmpty = AutoPopulateWhenEmpty;
				if (autoPopulateWhenEmpty == null || autoPopulateWhenEmpty.Value)
				{
					TryAutoPopulateOptions();
				}
			}
			if (Options.Count == 0)
			{
				error = "No options configured.";
				return false;
			}
			if (PhotonNetwork.InRoom && PhotonNetwork.PlayerList.Length < MinPlayersToStartVote.Value)
			{
				error = "Not enough players.";
				return false;
			}
			return true;
		}

		internal static void ForceVanillaAdvance(string reason)
		{
			((BaseUnityPlugin)Instance).Logger.LogWarning((object)("[VoteNextMap] Fallback to vanilla ChangeLevel: " + reason));
			try
			{
				RunManager.instance.ChangeLevel(true, false, (ChangeLevelType)0);
			}
			catch (Exception arg)
			{
				((BaseUnityPlugin)Instance).Logger.LogError((object)$"Vanilla fallback failed: {arg}");
			}
		}

		private static void TryAutoPopulateOptions()
		{
			try
			{
				RunManager instance = RunManager.instance;
				if (!Object.op_Implicit((Object)(object)instance) || instance.levels == null)
				{
					return;
				}
				Options.Clear();
				foreach (Level level in instance.levels)
				{
					if (Object.op_Implicit((Object)(object)level))
					{
						string text = ((Object)level).name ?? string.Empty;
						if (!IsUtilityLevelName(text))
						{
							Options.Add(new VoteOption
							{
								Label = CleanLabel(text),
								LevelNames = new List<string> { text }
							});
						}
					}
				}
				ConfigEntry<bool> includeShopInRandomizer = IncludeShopInRandomizer;
				if ((includeShopInRandomizer == null || includeShopInRandomizer.Value) && Object.op_Implicit((Object)(object)instance.levelShop))
				{
					Options.Add(new VoteOption
					{
						Label = "Shop",
						LevelNames = new List<string> { ((Object)instance.levelShop).name }
					});
				}
				((BaseUnityPlugin)Instance).Logger.LogInfo((object)$"[AutoPopulate] Built {Options.Count} options from RunManager.levels (IncludeShop={IncludeShopInRandomizer.Value}).");
			}
			catch (Exception arg)
			{
				((BaseUnityPlugin)Instance).Logger.LogWarning((object)$"[AutoPopulate] Failed: {arg}");
			}
		}

		private static bool IsUtilityLevelName(string name)
		{
			string name2 = name;
			if (string.IsNullOrEmpty(name2))
			{
				return true;
			}
			string[] source = new string[5] { "Lobby", "Menu", "MainMenu", "Recording", "Splash" };
			return source.Any((string b) => name2.IndexOf(b, StringComparison.OrdinalIgnoreCase) >= 0);
		}

		private static string CleanLabel(string levelName)
		{
			return levelName.Replace("Level - ", string.Empty).Trim();
		}
	}
	[HarmonyPatch(typeof(TruckScreenText), "GotoNextLevel")]
	public static class Patch_TruckScreen_GotoNextLevel
	{
		private static bool Prefix()
		{
			if (!VoteNextMapPlugin.EnsureOptions(out string error))
			{
				if (VoteNextMapPlugin.FailsafeAdvanceIfError.Value)
				{
					VoteNextMapPlugin.ForceVanillaAdvance(error ?? "unknown");
				}
				return false;
			}
			VoteManager voteManager = VoteManager.Ensure();
			if (!Object.op_Implicit((Object)(object)voteManager))
			{
				if (VoteNextMapPlugin.FailsafeAdvanceIfError.Value)
				{
					VoteNextMapPlugin.ForceVanillaAdvance("No VoteManager");
				}
				return false;
			}
			if (!PhotonNetwork.IsMasterClient)
			{
				return false;
			}
			if (string.Equals(VoteNextMapPlugin.Mode.Value, "Random", StringComparison.OrdinalIgnoreCase))
			{
				voteManager.StartRandomizer(VoteNextMapPlugin.Options, VoteNextMapPlugin.RandomizerDuration.Value, VoteNextMapPlugin.RandomizerCyclesPerSec.Value, VoteNextMapPlugin.RandomizerEaseOut.Value, VoteNextMapPlugin.TickPitch.Value, VoteNextMapPlugin.RandomizerRunLevelMin.Value, VoteNextMapPlugin.RandomizerRunLevelMax.Value);
			}
			else
			{
				voteManager.StartNetworkedVote(VoteNextMapPlugin.Options, VoteNextMapPlugin.VoteDurationSeconds.Value, VoteNextMapPlugin.AllowAbstain.Value, VoteNextMapPlugin.TiebreakRule.Value);
			}
			return false;
		}
	}
	public class VoteManager : MonoBehaviourPun, IOnEventCallback
	{
		[CompilerGenerated]
		private sealed class <HostCountdownVote>d__49 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public VoteManager <>4__this;

			private (int winnerIndex, string winnerLabel) <result>5__1;

			private object[] <content>5__2;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<result>5__1 = default((int, string));
				<content>5__2 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00da: Unknown result type (might be due to invalid IL or missing references)
				//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00eb: Expected O, but got Unknown
				//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f4: 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)
				//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
				//IL_0105: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				if (<>4__this._timeLeft > 0f && <>4__this.IsVoteActive)
				{
					<>4__this._timeLeft -= Time.deltaTime;
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				if (!<>4__this.IsVoteActive)
				{
					return false;
				}
				<result>5__1 = <>4__this.ComputeWinner();
				<content>5__2 = new object[2] { <result>5__1.winnerIndex, <result>5__1.winnerLabel };
				PhotonNetwork.RaiseEvent((byte)43, (object)<content>5__2, new RaiseEventOptions
				{
					Receivers = (ReceiverGroup)1
				}, SendOptions.SendReliable);
				PhotonNetwork.RaiseEvent((byte)41, (object)null, new RaiseEventOptions
				{
					CachingOption = (EventCaching)6
				}, SendOptions.SendReliable);
				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 <LandAndClose>d__60 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public VoteManager <>4__this;

			private string <label>5__1;

			private object[] <content>5__2;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<label>5__1 = null;
				<content>5__2 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Expected O, but got Unknown
				//IL_0096: Unknown result type (might be due to invalid IL or missing references)
				//IL_009b: Unknown result type (might be due to invalid IL or missing references)
				//IL_009d: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ac: Expected O, but got Unknown
				//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c6: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(0.85f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<label>5__1 = <>4__this._currentOptions[<>4__this._randWinnerIndex].Label;
					<content>5__2 = new object[2] { <>4__this._randWinnerIndex, <label>5__1 };
					PhotonNetwork.RaiseEvent((byte)45, (object)<content>5__2, new RaiseEventOptions
					{
						Receivers = (ReceiverGroup)1
					}, SendOptions.SendReliable);
					PhotonNetwork.RaiseEvent((byte)44, (object)null, new RaiseEventOptions
					{
						CachingOption = (EventCaching)6
					}, SendOptions.SendReliable);
					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 VoteManager Instance;

		private readonly Dictionary<int, int> _votesByActor = new Dictionary<int, int>();

		private readonly Dictionary<int, int> _tally = new Dictionary<int, int>();

		private List<VoteOption> _currentOptions = new List<VoteOption>();

		private bool _allowAbstain;

		private string _tiebreakRule = "Host";

		private float _timeLeft;

		private int _localChoice = int.MinValue;

		private Random _rng;

		private float _randDuration;

		private float _randCyclesPerSec;

		private float _randEaseOut;

		private int _randWinnerIndex;

		private double _randStartTime;

		private int _lastTickIndex = -1;

		private float _tickPitch = 1f;

		private int _randRunLevel = 1;

		private bool _randLanding;

		private bool _randSentClose;

		private bool _finalBeepPlayed;

		private const float FLASH_DURATION = 0.85f;

		private AudioSource _audio;

		private AudioClip _tickClip;

		private AudioClip _finalClip;

		private bool _cursorForced;

		private CursorLockMode _priorLock;

		private bool _priorVisible;

		private const byte EV_OPEN_VOTE = 41;

		private const byte EV_VOTE = 42;

		private const byte EV_CLOSE_VOTE = 43;

		private const byte EV_OPEN_RAND = 44;

		private const byte EV_CLOSE_RAND = 45;

		public bool IsVoteActive { get; private set; }

		public bool IsRandomizing { get; private set; }

		public static VoteManager Ensure()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			if (Object.op_Implicit((Object)(object)Instance))
			{
				return Instance;
			}
			GameObject val = new GameObject("Empress_VoteManager");
			Object.DontDestroyOnLoad((Object)(object)val);
			Instance = val.AddComponent<VoteManager>();
			return Instance;
		}

		private void OnEnable()
		{
			PhotonNetwork.AddCallbackTarget((object)this);
			EnsureAudio();
		}

		private void OnDisable()
		{
			PhotonNetwork.RemoveCallbackTarget((object)this);
		}

		private void EnsureAudio()
		{
			if (!Object.op_Implicit((Object)(object)_audio))
			{
				_audio = ((Component)this).gameObject.AddComponent<AudioSource>();
				_audio.playOnAwake = false;
				_audio.spatialBlend = 0f;
				_audio.volume = 0.4f;
				_tickClip = MakeBeepClip(0.05f, 350f);
				_finalClip = MakeBeepClip(0.12f, 550f);
			}
		}

		public void StartRandomizer(List<VoteOption> options, float duration, float cyclesPerSec, float easeOut, float tickPitch, int runLevelMin, int runLevelMax)
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Expected O, but got Unknown
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			if (IsRandomizing || IsVoteActive)
			{
				return;
			}
			if (!PhotonNetwork.InRoom)
			{
				Debug.LogWarning((object)"[VoteNextMap] Not in room; cannot start randomizer.");
				return;
			}
			PhotonNetwork.RaiseEvent((byte)44, (object)null, new RaiseEventOptions
			{
				CachingOption = (EventCaching)6
			}, SendOptions.SendReliable);
			int minValue = Math.Min(runLevelMin, runLevelMax);
			int num = Math.Max(runLevelMin, runLevelMax);
			if (num < 1)
			{
				minValue = 1;
				num = 1;
			}
			int num2 = PhotonNetwork.ServerTimestamp ^ Environment.TickCount ^ ((PhotonNetwork.LocalPlayer != null) ? PhotonNetwork.LocalPlayer.ActorNumber : 0) ^ Guid.NewGuid().GetHashCode();
			Random random = new Random(num2);
			int num3 = ((options.Count > 0) ? random.Next(0, options.Count) : 0);
			int num4 = random.Next(minValue, num + 1);
			string[] array = options.Select((VoteOption o) => o.Label).ToArray();
			string[] array2 = options.Select((VoteOption o) => string.Join("|", o.LevelNames ?? new List<string>())).ToArray();
			object[] array3 = new object[9] { array, array2, duration, cyclesPerSec, easeOut, num2, num3, tickPitch, num4 };
			RaiseEventOptions val = new RaiseEventOptions
			{
				Receivers = (ReceiverGroup)1,
				CachingOption = (EventCaching)4
			};
			PhotonNetwork.RaiseEvent((byte)44, (object)array3, val, SendOptions.SendReliable);
		}

		public void StartNetworkedVote(List<VoteOption> options, int durationSeconds, bool allowAbstain, string tiebreakRule)
		{
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Expected O, but got Unknown
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			if (IsVoteActive || IsRandomizing)
			{
				return;
			}
			if (!PhotonNetwork.InRoom)
			{
				Debug.LogWarning((object)"[VoteNextMap] Not in room; cannot start vote.");
				return;
			}
			string[] array = options.Select((VoteOption o) => o.Label).ToArray();
			string[] array2 = options.Select((VoteOption o) => string.Join("|", o.LevelNames ?? new List<string>())).ToArray();
			object[] array3 = new object[5]
			{
				array,
				array2,
				durationSeconds,
				allowAbstain,
				tiebreakRule ?? "Host"
			};
			RaiseEventOptions val = new RaiseEventOptions
			{
				Receivers = (ReceiverGroup)1,
				CachingOption = (EventCaching)4
			};
			PhotonNetwork.RaiseEvent((byte)41, (object)array3, val, SendOptions.SendReliable);
		}

		public void OnEvent(EventData photonEvent)
		{
			try
			{
				switch (photonEvent.Code)
				{
				case 41:
				{
					object[] array5 = (object[])photonEvent.CustomData;
					string[] optionLabels2 = (string[])array5[0];
					string[] levelGroups2 = (string[])array5[1];
					int durationSeconds = Convert.ToInt32(array5[2]);
					bool allowAbstain = (bool)array5[3];
					string tiebreakRule = (string)array5[4];
					OpenLocalVote(optionLabels2, levelGroups2, durationSeconds, allowAbstain, tiebreakRule);
					break;
				}
				case 42:
					if (PhotonNetwork.IsMasterClient)
					{
						object[] array4 = (object[])photonEvent.CustomData;
						int key = (int)array4[0];
						int value = (int)array4[1];
						if (IsVoteActive)
						{
							_votesByActor[key] = value;
							RecountTally();
						}
					}
					break;
				case 43:
				{
					object[] array3 = (object[])photonEvent.CustomData;
					int winnerIndex3 = (int)array3[0];
					string winnerLabel2 = (string)array3[1];
					CloseLocalVote(winnerIndex3, winnerLabel2);
					break;
				}
				case 44:
				{
					object[] array2 = (object[])photonEvent.CustomData;
					string[] optionLabels = (string[])array2[0];
					string[] levelGroups = (string[])array2[1];
					float duration = Convert.ToSingle(array2[2]);
					float cyclesPerSec = Convert.ToSingle(array2[3]);
					float easeOut = Convert.ToSingle(array2[4]);
					int seed = (int)array2[5];
					int winnerIndex2 = (int)array2[6];
					float tickPitch = Convert.ToSingle(array2[7]);
					int runLevel = (int)array2[8];
					OpenLocalRandom(optionLabels, levelGroups, duration, cyclesPerSec, easeOut, seed, winnerIndex2, tickPitch, runLevel);
					break;
				}
				case 45:
				{
					object[] array = (object[])photonEvent.CustomData;
					int winnerIndex = (int)array[0];
					string winnerLabel = (string)array[1];
					CloseLocalRandom(winnerIndex, winnerLabel);
					break;
				}
				}
			}
			catch (Exception arg)
			{
				Debug.LogError((object)$"[VoteNextMap] OnEvent error: {arg}");
			}
		}

		private void OpenLocalVote(string[] optionLabels, string[] levelGroups, int durationSeconds, bool allowAbstain, string tiebreakRule)
		{
			if (IsVoteActive || IsRandomizing)
			{
				return;
			}
			IsVoteActive = true;
			_allowAbstain = allowAbstain;
			_tiebreakRule = tiebreakRule ?? "Host";
			_timeLeft = Mathf.Max(5, durationSeconds);
			_currentOptions = new List<VoteOption>();
			_tally.Clear();
			for (int i = 0; i < optionLabels.Length; i++)
			{
				List<string> levelNames = ((i < levelGroups.Length && !string.IsNullOrEmpty(levelGroups[i])) ? (from s in levelGroups[i].Split('|')
					select s.Trim() into s
					where s.Length > 0
					select s).ToList() : new List<string>());
				_currentOptions.Add(new VoteOption
				{
					Label = optionLabels[i],
					LevelNames = levelNames
				});
				_tally[i] = 0;
			}
			_localChoice = int.MinValue;
			ForceCursor(on: true);
			if (PhotonNetwork.IsMasterClient)
			{
				((MonoBehaviour)this).StartCoroutine(HostCountdownVote());
			}
		}

		private void CloseLocalVote(int winnerIndex, string winnerLabel)
		{
			if (IsVoteActive)
			{
				IsVoteActive = false;
				ForceCursor(on: false);
				if (PhotonNetwork.IsMasterClient)
				{
					TryForceLevelFromWinner(winnerIndex, winnerLabel, null);
				}
			}
		}

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

		private (int winnerIndex, string winnerLabel) ComputeWinner()
		{
			RecountTally();
			int num = -1;
			List<int> list = new List<int>();
			foreach (KeyValuePair<int, int> item in _tally)
			{
				if (item.Value > num)
				{
					list.Clear();
					list.Add(item.Key);
					num = item.Value;
				}
				else if (item.Value == num)
				{
					list.Add(item.Key);
				}
			}
			if (list.Count == 1)
			{
				return (list[0], _currentOptions[list[0]].Label);
			}
			if (string.Equals(_tiebreakRule, "Host", StringComparison.OrdinalIgnoreCase))
			{
				int actorNumber = PhotonNetwork.MasterClient.ActorNumber;
				if (_votesByActor.TryGetValue(actorNumber, out var value) && list.Contains(value))
				{
					return (value, _currentOptions[value].Label);
				}
				int num2 = list[0];
				return (num2, _currentOptions[num2].Label);
			}
			int num3 = list[Random.Range(0, list.Count)];
			return (num3, _currentOptions[num3].Label);
		}

		private void RecountTally()
		{
			_tally.Clear();
			for (int i = 0; i < _currentOptions.Count; i++)
			{
				_tally[i] = 0;
			}
			foreach (int value in _votesByActor.Values)
			{
				if (value >= 0 && value < _currentOptions.Count)
				{
					_tally[value]++;
				}
			}
		}

		private void OpenLocalRandom(string[] optionLabels, string[] levelGroups, float duration, float cyclesPerSec, float easeOut, int seed, int winnerIndex, float tickPitch, int runLevel)
		{
			if (IsRandomizing || IsVoteActive)
			{
				return;
			}
			IsRandomizing = true;
			_currentOptions = new List<VoteOption>();
			for (int i = 0; i < optionLabels.Length; i++)
			{
				List<string> levelNames = ((i < levelGroups.Length && !string.IsNullOrEmpty(levelGroups[i])) ? (from s in levelGroups[i].Split('|')
					select s.Trim() into s
					where s.Length > 0
					select s).ToList() : new List<string>());
				_currentOptions.Add(new VoteOption
				{
					Label = optionLabels[i],
					LevelNames = levelNames
				});
			}
			_rng = new Random(seed);
			_randDuration = Mathf.Max(1.5f, duration);
			_randCyclesPerSec = Mathf.Max(1f, cyclesPerSec);
			_randEaseOut = Mathf.Clamp01(easeOut);
			_randWinnerIndex = Mathf.Clamp(winnerIndex, 0, Mathf.Max(0, _currentOptions.Count - 1));
			_randRunLevel = Mathf.Max(1, runLevel);
			_randStartTime = Time.timeAsDouble;
			_lastTickIndex = -1;
			_tickPitch = Mathf.Clamp(tickPitch, 0.25f, 3f);
			_randLanding = false;
			_randSentClose = false;
			_finalBeepPlayed = false;
			EnsureAudio();
		}

		private void CloseLocalRandom(int winnerIndex, string winnerLabel)
		{
			if (IsRandomizing)
			{
				IsRandomizing = false;
				if (PhotonNetwork.IsMasterClient)
				{
					TryForceLevelFromWinner(winnerIndex, winnerLabel, _randRunLevel);
				}
			}
		}

		private static void FillRect(Rect r, Color c)
		{
			//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_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			Color color = GUI.color;
			GUI.color = c;
			GUI.DrawTexture(r, (Texture)(object)Texture2D.whiteTexture);
			GUI.color = color;
		}

		private static Rect Inset(Rect r, float px)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			return new Rect(((Rect)(ref r)).x + px, ((Rect)(ref r)).y + px, ((Rect)(ref r)).width - px * 2f, ((Rect)(ref r)).height - px * 2f);
		}

		private void OnGUI()
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: 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_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: 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_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Expected O, but got Unknown
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0297: Unknown result type (might be due to invalid IL or missing references)
			if (IsVoteActive || IsRandomizing)
			{
				GUI.depth = -1000;
				Rect r = default(Rect);
				((Rect)(ref r))..ctor(0f, 0f, (float)Screen.width, (float)Screen.height);
				FillRect(r, new Color(0f, 0f, 0f, 0.6f));
				float num = Mathf.Min(820f, (float)Screen.width - 120f);
				float num2 = Mathf.Min(580f, (float)Screen.height - 140f);
				Rect val = default(Rect);
				((Rect)(ref val))..ctor(((float)Screen.width - num) / 2f, ((float)Screen.height - num2) / 2f, num, num2);
				FillRect(new Rect(((Rect)(ref val)).x + 8f, ((Rect)(ref val)).y + 10f, ((Rect)(ref val)).width, ((Rect)(ref val)).height), new Color(0f, 0f, 0f, 0.35f));
				FillRect(val, new Color(0.06f, 0.07f, 0.1f, 0.95f));
				FillRect(new Rect(((Rect)(ref val)).x, ((Rect)(ref val)).y, ((Rect)(ref val)).width, 2f), new Color(1f, 1f, 1f, 0.05f));
				FillRect(new Rect(((Rect)(ref val)).x, ((Rect)(ref val)).yMax - 2f, ((Rect)(ref val)).width, 2f), new Color(0f, 0f, 0f, 0.35f));
				Rect val2 = default(Rect);
				((Rect)(ref val2))..ctor(((Rect)(ref val)).x, ((Rect)(ref val)).y, ((Rect)(ref val)).width, 38f);
				FillRect(val2, new Color(0.1f, 0.12f, 0.2f, 1f));
				FillRect(new Rect(((Rect)(ref val2)).x, ((Rect)(ref val2)).y, ((Rect)(ref val2)).width, 18f), new Color(0.14f, 0.16f, 0.28f, 0.85f));
				GUIStyle val3 = new GUIStyle(GUI.skin.label)
				{
					alignment = (TextAnchor)4,
					fontStyle = (FontStyle)1,
					fontSize = 16
				};
				GUI.Label(val2, IsRandomizing ? "RANDOM SELECT" : "VOTE: Choose the next map type", val3);
				if (IsVoteActive)
				{
					DrawVoteUI(val);
				}
				else if (IsRandomizing)
				{
					DrawRandomizerUI(val);
				}
			}
		}

		private void DrawVoteUI(Rect panel)
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Expected O, but got Unknown
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_032b: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02da: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e4: Expected O, but got Unknown
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Expected O, but got Unknown
			//IL_0385: Unknown result type (might be due to invalid IL or missing references)
			//IL_038a: Unknown result type (might be due to invalid IL or missing references)
			//IL_038c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0391: Unknown result type (might be due to invalid IL or missing references)
			//IL_039b: Expected O, but got Unknown
			//IL_039f: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b5: Expected O, but got Unknown
			string text = TimeSpan.FromSeconds(Mathf.Max(0f, _timeLeft)).ToString("mm\\:ss");
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(((Rect)(ref panel)).x, ((Rect)(ref panel)).y + 40f, ((Rect)(ref panel)).width, 22f);
			GUIStyle val2 = new GUIStyle(GUI.skin.label)
			{
				alignment = (TextAnchor)4,
				fontStyle = (FontStyle)1
			};
			GUI.Label(val, "Time left: " + text, val2);
			float num = ((Rect)(ref panel)).x + 18f;
			float num2 = ((Rect)(ref panel)).y + 68f;
			float num3 = ((Rect)(ref panel)).width - 36f;
			Rect val3 = default(Rect);
			((Rect)(ref val3))..ctor(num, num2, num3, ((Rect)(ref panel)).height - 122f);
			int num4 = 2;
			int num5 = _currentOptions.Count + (_allowAbstain ? 1 : 0);
			float num6 = (((Rect)(ref val3)).width - (float)(num4 - 1) * 10f) / (float)num4;
			float num7 = 48f;
			int num8 = 0;
			Rect val4 = default(Rect);
			for (int i = 0; i < _currentOptions.Count; i++)
			{
				int num9 = num8 / num4;
				int num10 = num8 % num4;
				((Rect)(ref val4))..ctor(((Rect)(ref val3)).x + (float)num10 * (num6 + 10f), ((Rect)(ref val3)).y + (float)num9 * (num7 + 8f), num6, num7);
				int value;
				int num11 = (_tally.TryGetValue(i, out value) ? value : 0);
				string label = _currentOptions[i].Label;
				string text2 = ((_localChoice == i) ? $"> {label} — {num11}" : $"{label} — {num11}");
				if (GUI.Button(val4, text2))
				{
					_localChoice = i;
					object[] array = new object[2]
					{
						PhotonNetwork.LocalPlayer.ActorNumber,
						i
					};
					PhotonNetwork.RaiseEvent((byte)42, (object)array, new RaiseEventOptions
					{
						Receivers = (ReceiverGroup)2
					}, SendOptions.SendReliable);
				}
				num8++;
			}
			if (_allowAbstain)
			{
				int num12 = num8 / num4;
				int num13 = num8 % num4;
				Rect val5 = default(Rect);
				((Rect)(ref val5))..ctor(((Rect)(ref val3)).x + (float)num13 * (num6 + 10f), ((Rect)(ref val3)).y + (float)num12 * (num7 + 8f), num6, num7);
				if (GUI.Button(val5, (_localChoice == -1) ? "> Abstain" : "Abstain"))
				{
					_localChoice = -1;
					object[] array2 = new object[2]
					{
						PhotonNetwork.LocalPlayer.ActorNumber,
						-1
					};
					PhotonNetwork.RaiseEvent((byte)42, (object)array2, new RaiseEventOptions
					{
						Receivers = (ReceiverGroup)2
					}, SendOptions.SendReliable);
				}
			}
			Rect val6 = default(Rect);
			((Rect)(ref val6))..ctor(((Rect)(ref panel)).x + (((Rect)(ref panel)).width - 200f) / 2f, ((Rect)(ref panel)).yMax - 44f, 200f, 30f);
			GUI.enabled = PhotonNetwork.IsMasterClient;
			if (GUI.Button(val6, PhotonNetwork.IsMasterClient ? "Host: Close Now" : "Waiting for Host…") && PhotonNetwork.IsMasterClient)
			{
				(int, string) tuple = ComputeWinner();
				object[] array3 = new object[2] { tuple.Item1, tuple.Item2 };
				PhotonNetwork.RaiseEvent((byte)43, (object)array3, new RaiseEventOptions
				{
					Receivers = (ReceiverGroup)1
				}, SendOptions.SendReliable);
				PhotonNetwork.RaiseEvent((byte)41, (object)null, new RaiseEventOptions
				{
					CachingOption = (EventCaching)6
				}, SendOptions.SendReliable);
			}
			GUI.enabled = true;
		}

		private void DrawRandomizerUI(Rect panel)
		{
			//IL_0868: Unknown result type (might be due to invalid IL or missing references)
			//IL_086d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0875: Unknown result type (might be due to invalid IL or missing references)
			//IL_087e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0888: Expected O, but got Unknown
			//IL_0888: Unknown result type (might be due to invalid IL or missing references)
			//IL_0450: Unknown result type (might be due to invalid IL or missing references)
			//IL_0469: Unknown result type (might be due to invalid IL or missing references)
			//IL_0474: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_048e: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_051d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0536: Unknown result type (might be due to invalid IL or missing references)
			//IL_0541: Unknown result type (might be due to invalid IL or missing references)
			//IL_0548: Unknown result type (might be due to invalid IL or missing references)
			//IL_054d: Unknown result type (might be due to invalid IL or missing references)
			//IL_054f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0584: Unknown result type (might be due to invalid IL or missing references)
			//IL_0569: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_05cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_05fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0609: Expected O, but got Unknown
			//IL_0629: Unknown result type (might be due to invalid IL or missing references)
			//IL_0689: Unknown result type (might be due to invalid IL or missing references)
			//IL_069f: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_06dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0708: Unknown result type (might be due to invalid IL or missing references)
			//IL_0721: Unknown result type (might be due to invalid IL or missing references)
			//IL_0736: Unknown result type (might be due to invalid IL or missing references)
			//IL_073b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0743: Unknown result type (might be due to invalid IL or missing references)
			//IL_074c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0756: Expected O, but got Unknown
			//IL_0756: Unknown result type (might be due to invalid IL or missing references)
			//IL_07c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_07cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_07dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_07df: Unknown result type (might be due to invalid IL or missing references)
			//IL_07e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0807: Unknown result type (might be due to invalid IL or missing references)
			float num = ((Rect)(ref panel)).x + 18f;
			float num2 = ((Rect)(ref panel)).y + 56f;
			float num3 = ((Rect)(ref panel)).width - 36f;
			float num4 = ((Rect)(ref panel)).height - 110f;
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(num, num2, num3, num4);
			int num5 = Mathf.Clamp((_currentOptions.Count >= 8) ? 3 : 2, 1, 4);
			float num6 = (((Rect)(ref val)).width - (float)(num5 - 1) * 14f) / (float)num5;
			float num7 = 76f;
			double num8 = Math.Max(0.0, Time.timeAsDouble - _randStartTime);
			double num9 = _randDuration;
			double num10 = num9 * (1.0 - (double)_randEaseOut);
			double value;
			if (num8 <= num10)
			{
				double num11 = num8 / Math.Max(0.0001, num10);
				double num12 = (double)_randCyclesPerSec * (0.5 + 0.5 * num11);
				value = num12 * num8 * (double)_currentOptions.Count;
			}
			else
			{
				double val2 = (num8 - num10) / Math.Max(0.0001, num9 - num10);
				val2 = Math.Min(1.0, val2);
				double num13 = (double)((float)_currentOptions.Count * _randCyclesPerSec) * num10;
				double num14 = num13 + (double)(2 * _currentOptions.Count) + (double)((_randWinnerIndex - (int)(num13 % (double)_currentOptions.Count) + _currentOptions.Count) % _currentOptions.Count);
				double num15 = 1.0 - Math.Pow(1.0 - val2, 3.0);
				value = num13 + (num14 - num13) * num15;
			}
			int num16 = ((_currentOptions.Count > 0) ? ((int)Math.Abs(value) % _currentOptions.Count) : 0);
			if (num8 < num9 && num16 != _lastTickIndex)
			{
				_lastTickIndex = num16;
				if (Object.op_Implicit((Object)(object)_audio) && Object.op_Implicit((Object)(object)_tickClip))
				{
					_audio.pitch = _tickPitch * Random.Range(0.95f, 1.05f);
					_audio.PlayOneShot(_tickClip);
				}
			}
			if (num8 >= num9 && !_randLanding)
			{
				_randLanding = true;
				_lastTickIndex = _randWinnerIndex;
				if (!_finalBeepPlayed && Object.op_Implicit((Object)(object)_audio) && Object.op_Implicit((Object)(object)_finalClip))
				{
					_finalBeepPlayed = true;
					_audio.pitch = 1f;
					_audio.PlayOneShot(_finalClip);
				}
				if (PhotonNetwork.IsMasterClient && !_randSentClose)
				{
					_randSentClose = true;
					((MonoBehaviour)this).StartCoroutine(LandAndClose());
				}
			}
			Rect r = default(Rect);
			Rect val4 = default(Rect);
			Color c = default(Color);
			for (int i = 0; i < _currentOptions.Count; i++)
			{
				int num17 = i / num5;
				int num18 = i % num5;
				((Rect)(ref r))..ctor(((Rect)(ref val)).x + (float)num18 * (num6 + 14f), ((Rect)(ref val)).y + (float)num17 * (num7 + 12f), num6, num7);
				bool flag = i == _randWinnerIndex;
				bool flag2 = i == num16 || (_randLanding && flag);
				if (_randLanding && flag)
				{
					float num19 = 1f + 0.04f * Mathf.Sin(Time.time * 12f);
					float num20 = ((Rect)(ref r)).width * (num19 - 1f) / 2f;
					float num21 = ((Rect)(ref r)).height * (num19 - 1f) / 2f;
					((Rect)(ref r))..ctor(((Rect)(ref r)).x - num20, ((Rect)(ref r)).y - num21, ((Rect)(ref r)).width * num19, ((Rect)(ref r)).height * num19);
				}
				FillRect(new Rect(((Rect)(ref r)).x + 4f, ((Rect)(ref r)).y + 6f, ((Rect)(ref r)).width, ((Rect)(ref r)).height), new Color(0f, 0f, 0f, 0.35f));
				FillRect(r, flag2 ? new Color(0.98f, 0.82f, 0.22f, 1f) : new Color(0.1f, 0.12f, 0.16f, 1f));
				FillRect(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, ((Rect)(ref r)).width, 2f), new Color(1f, 1f, 1f, flag2 ? 0.18f : 0.08f));
				FillRect(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).yMax - 2f, ((Rect)(ref r)).width, 2f), new Color(0f, 0f, 0f, 0.35f));
				Rect r2 = Inset(r, 3f);
				FillRect(r2, flag2 ? new Color(0.16f, 0.12f, 0.05f, 0.95f) : new Color(0.04f, 0.05f, 0.07f, 0.95f));
				FillRect(new Rect(((Rect)(ref r2)).x, ((Rect)(ref r2)).y, ((Rect)(ref r2)).width, 16f), new Color(1f, 1f, 1f, flag2 ? 0.06f : 0.03f));
				GUIStyle val3 = new GUIStyle(GUI.skin.label)
				{
					alignment = (TextAnchor)1,
					fontStyle = (FontStyle)(flag2 ? 1 : 0),
					fontSize = 15
				};
				GUI.Label(new Rect(((Rect)(ref r2)).x, ((Rect)(ref r2)).y + 6f, ((Rect)(ref r2)).width, 22f), _currentOptions[i].Label, val3);
				((Rect)(ref val4))..ctor(((Rect)(ref r2)).x + (((Rect)(ref r2)).width - 56f) / 2f, ((Rect)(ref r2)).y + ((Rect)(ref r2)).height - 24f, 56f, 18f);
				FillRect(val4, new Color(0.2f, 0.42f, 0.26f, 0.95f));
				FillRect(new Rect(((Rect)(ref val4)).x, ((Rect)(ref val4)).y, ((Rect)(ref val4)).width, 2f), new Color(1f, 1f, 1f, 0.1f));
				FillRect(new Rect(((Rect)(ref val4)).x, ((Rect)(ref val4)).yMax - 2f, ((Rect)(ref val4)).width, 2f), new Color(0f, 0f, 0f, 0.25f));
				GUIStyle val5 = new GUIStyle(GUI.skin.label)
				{
					alignment = (TextAnchor)4,
					fontSize = 12,
					fontStyle = (FontStyle)1
				};
				GUI.Label(val4, $"Lv {_randRunLevel}", val5);
				if (_randLanding && flag)
				{
					float num22 = 0.35f + 0.35f * Mathf.PingPong(Time.time * 4f, 1f);
					((Color)(ref c))..ctor(1f, 1f, 1f, num22);
					Rect r3 = Inset(r, -2f);
					Rect r4 = Inset(r, -4f);
					DrawBorder(r3, c, 2f);
					DrawBorder(r4, new Color(1f, 0.95f, 0.6f, num22 * 0.6f), 2f);
				}
			}
			Rect val6 = default(Rect);
			((Rect)(ref val6))..ctor(((Rect)(ref panel)).x, ((Rect)(ref panel)).yMax - 42f, ((Rect)(ref panel)).width, 24f);
			GUIStyle val7 = new GUIStyle(GUI.skin.label)
			{
				alignment = (TextAnchor)4,
				fontSize = 12,
				fontStyle = (FontStyle)2
			};
			GUI.Label(val6, $"Run Level: {_randRunLevel}", val7);
		}

		private static void DrawBorder(Rect r, Color c, float thickness)
		{
			//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_0007: 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_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			Color color = GUI.color;
			GUI.color = c;
			GUI.DrawTexture(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, ((Rect)(ref r)).width, thickness), (Texture)(object)Texture2D.whiteTexture);
			GUI.DrawTexture(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).yMax - thickness, ((Rect)(ref r)).width, thickness), (Texture)(object)Texture2D.whiteTexture);
			GUI.DrawTexture(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, thickness, ((Rect)(ref r)).height), (Texture)(object)Texture2D.whiteTexture);
			GUI.DrawTexture(new Rect(((Rect)(ref r)).xMax - thickness, ((Rect)(ref r)).y, thickness, ((Rect)(ref r)).height), (Texture)(object)Texture2D.whiteTexture);
			GUI.color = color;
		}

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

		private AudioClip MakeBeepClip(float seconds, float freq)
		{
			int num = 44100;
			int num2 = Mathf.CeilToInt((float)num * seconds);
			AudioClip val = AudioClip.Create("Empress_Tone", num2, 1, num, false);
			float[] array = new float[num2];
			for (int i = 0; i < num2; i++)
			{
				float num3 = (float)i / (float)num;
				array[i] = Mathf.Sin(MathF.PI * 2f * freq * num3) * Mathf.Exp(-3.2f * num3);
			}
			val.SetData(array, 0);
			return val;
		}

		private void ForceCursor(bool on)
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (on)
				{
					if (!_cursorForced)
					{
						_priorLock = Cursor.lockState;
						_priorVisible = Cursor.visible;
						_cursorForced = true;
					}
					Cursor.lockState = (CursorLockMode)0;
					Cursor.visible = true;
				}
				else if (_cursorForced)
				{
					Cursor.lockState = _priorLock;
					Cursor.visible = _priorVisible;
					_cursorForced = false;
				}
			}
			catch
			{
			}
		}

		private void TryForceLevelFromWinner(int winnerIndex, string winnerLabel, int? levelsCompletedOverride)
		{
			try
			{
				RunManager instance = RunManager.instance;
				if (!Object.op_Implicit((Object)(object)instance))
				{
					VoteNextMapPlugin.ForceVanillaAdvance("RunManager missing");
					return;
				}
				Level val = null;
				if (winnerIndex >= 0 && winnerIndex < _currentOptions.Count)
				{
					List<string> names = _currentOptions[winnerIndex].LevelNames;
					foreach (string i in names)
					{
						Level val2 = ((IEnumerable<Level>)instance.levels).FirstOrDefault((Func<Level, bool>)((Level l) => Object.op_Implicit((Object)(object)l) && ((Object)l).name == i));
						if (Object.op_Implicit((Object)(object)val2))
						{
							val = val2;
							break;
						}
					}
					if (!Object.op_Implicit((Object)(object)val))
					{
						List<Level> source = new List<Level> { instance.levelLobby, instance.levelLobbyMenu, instance.levelShop, instance.levelTutorial, instance.levelArena, instance.levelMainMenu, instance.levelRecording, instance.levelSplashScreen };
						val = ((IEnumerable<Level>)source).FirstOrDefault((Func<Level, bool>)((Level l) => Object.op_Implicit((Object)(object)l) && names.Contains(((Object)l).name)));
					}
				}
				if (!Object.op_Implicit((Object)(object)val))
				{
					VoteNextMapPlugin.ForceVanillaAdvance("Winner option has no resolvable Level");
					return;
				}
				int num = levelsCompletedOverride ?? instance.levelsCompleted;
				RunManagerPUN runManagerPUN = instance.runManagerPUN;
				if (Object.op_Implicit((Object)(object)runManagerPUN) && Object.op_Implicit((Object)(object)runManagerPUN.photonView))
				{
					runManagerPUN.photonView.RPC("UpdateLevelRPC", (RpcTarget)4, new object[3]
					{
						((Object)val).name,
						num,
						false
					});
				}
				instance.UpdateLevel(((Object)val).name, num, false);
				instance.RestartScene();
			}
			catch (Exception arg)
			{
				Debug.LogError((object)$"[VoteNextMap] Force level failed: {arg}");
				VoteNextMapPlugin.ForceVanillaAdvance("Exception during force level");
			}
		}
	}
}