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("MapVoting")]
[assembly: AssemblyTitle("MapVoting")]
[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.6.1")]
public class VoteNextMapPlugin : BaseUnityPlugin
{
public const string PluginGuid = "Empress.VoteNextMap";
public const string PluginName = "Vote Next Map";
public const string PluginVersion = "1.6.1";
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 ConfigEntry<float> SoloLandingHold;
internal static readonly List<VoteOption> Options = new List<VoteOption>();
internal static bool IsSolo => !GameManager.Multiplayer();
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).");
SoloLandingHold = ((BaseUnityPlugin)this).Config.Bind<float>("Randomizer", "SoloLandingHold", 0.85f, "Extra seconds to hold the winner tile on screen in Singleplayer after landing, before changing level.");
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.6.1", 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 (!IsSolo && 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 (!VoteNextMapPlugin.IsSolo && !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_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: Expected O, but got Unknown
//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0101: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: 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();
if (!VoteNextMapPlugin.IsSolo)
{
<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);
<content>5__2 = null;
}
else
{
<>4__this.CloseLocalVote(<result>5__1.winnerIndex, <result>5__1.winnerLabel);
}
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_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Expected O, but got Unknown
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Expected O, but got Unknown
//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: 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_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(0.85f + (VoteNextMapPlugin.IsSolo ? VoteNextMapPlugin.SoloLandingHold.Value : 0f));
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
<label>5__1 = <>4__this._currentOptions[<>4__this._randWinnerIndex].Label;
if (!VoteNextMapPlugin.IsSolo)
{
<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);
<content>5__2 = null;
}
else
{
<>4__this.CloseLocalRandom(<>4__this._randWinnerIndex, <label>5__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 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_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Expected O, but got Unknown
//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
//IL_01c0: Expected O, but got Unknown
//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
if (IsRandomizing || IsVoteActive)
{
return;
}
if (!VoteNextMapPlugin.IsSolo)
{
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);
}
else
{
int minValue2 = Math.Min(runLevelMin, runLevelMax);
int num5 = Math.Max(runLevelMin, runLevelMax);
if (num5 < 1)
{
minValue2 = 1;
num5 = 1;
}
int seed = Environment.TickCount ^ Guid.NewGuid().GetHashCode();
Random random2 = new Random(seed);
int winnerIndex = ((options.Count > 0) ? random2.Next(0, options.Count) : 0);
int runLevel = random2.Next(minValue2, num5 + 1);
string[] optionLabels = options.Select((VoteOption o) => o.Label).ToArray();
string[] levelGroups = options.Select((VoteOption o) => string.Join("|", o.LevelNames ?? new List<string>())).ToArray();
OpenLocalRandom(optionLabels, levelGroups, duration, cyclesPerSec, easeOut, seed, winnerIndex, tickPitch, runLevel);
}
}
public void StartNetworkedVote(List<VoteOption> options, int durationSeconds, bool allowAbstain, string tiebreakRule)
{
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Expected O, but got Unknown
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
if (IsVoteActive || IsRandomizing)
{
return;
}
if (!VoteNextMapPlugin.IsSolo)
{
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);
}
else
{
string[] optionLabels = options.Select((VoteOption o) => o.Label).ToArray();
string[] levelGroups = options.Select((VoteOption o) => string.Join("|", o.LevelNames ?? new List<string>())).ToArray();
OpenLocalVote(optionLabels, levelGroups, durationSeconds, allowAbstain, tiebreakRule ?? "Host");
((MonoBehaviour)this).StartCoroutine(HostCountdownVote());
}
}
public void OnEvent(EventData photonEvent)
{
try
{
if (VoteNextMapPlugin.IsSolo)
{
return;
}
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 (!VoteNextMapPlugin.IsSolo && PhotonNetwork.IsMasterClient)
{
((MonoBehaviour)this).StartCoroutine(HostCountdownVote());
}
}
private void CloseLocalVote(int winnerIndex, string winnerLabel)
{
if (IsVoteActive)
{
IsVoteActive = false;
ForceCursor(on: false);
if (VoteNextMapPlugin.IsSolo || 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))
{
if (!VoteNextMapPlugin.IsSolo)
{
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 (VoteNextMapPlugin.IsSolo || 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_028d: Unknown result type (might be due to invalid IL or missing references)
//IL_0379: Unknown result type (might be due to invalid IL or missing references)
//IL_0195: Unknown result type (might be due to invalid IL or missing references)
//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
//IL_0303: Expected O, but got Unknown
//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
//IL_01fa: Expected O, but got Unknown
//IL_03d6: Unknown result type (might be due to invalid IL or missing references)
//IL_03db: Unknown result type (might be due to invalid IL or missing references)
//IL_03dd: Unknown result type (might be due to invalid IL or missing references)
//IL_03e2: Unknown result type (might be due to invalid IL or missing references)
//IL_03ec: Expected O, but got Unknown
//IL_03f0: Unknown result type (might be due to invalid IL or missing references)
//IL_03f5: Unknown result type (might be due to invalid IL or missing references)
//IL_03f7: Unknown result type (might be due to invalid IL or missing references)
//IL_03fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0406: 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;
float num5 = (((Rect)(ref val3)).width - (float)(num4 - 1) * 10f) / (float)num4;
float num6 = 48f;
int num7 = 0;
Rect val4 = default(Rect);
for (int i = 0; i < _currentOptions.Count; i++)
{
int num8 = num7 / num4;
int num9 = num7 % num4;
((Rect)(ref val4))..ctor(((Rect)(ref val3)).x + (float)num9 * (num5 + 10f), ((Rect)(ref val3)).y + (float)num8 * (num6 + 8f), num5, num6);
int value;
int num10 = (_tally.TryGetValue(i, out value) ? value : 0);
string label = _currentOptions[i].Label;
string text2 = ((_localChoice == i) ? $"> {label} — {num10}" : $"{label} — {num10}");
if (GUI.Button(val4, text2))
{
_localChoice = i;
if (!VoteNextMapPlugin.IsSolo)
{
object[] array = new object[2]
{
PhotonNetwork.LocalPlayer.ActorNumber,
i
};
PhotonNetwork.RaiseEvent((byte)42, (object)array, new RaiseEventOptions
{
Receivers = (ReceiverGroup)2
}, SendOptions.SendReliable);
}
else
{
_votesByActor[0] = i;
RecountTally();
}
}
num7++;
}
if (_allowAbstain)
{
int num11 = num7 / num4;
int num12 = num7 % num4;
Rect val5 = default(Rect);
((Rect)(ref val5))..ctor(((Rect)(ref val3)).x + (float)num12 * (num5 + 10f), ((Rect)(ref val3)).y + (float)num11 * (num6 + 8f), num5, num6);
if (GUI.Button(val5, (_localChoice == -1) ? "> Abstain" : "Abstain"))
{
_localChoice = -1;
if (!VoteNextMapPlugin.IsSolo)
{
object[] array2 = new object[2]
{
PhotonNetwork.LocalPlayer.ActorNumber,
-1
};
PhotonNetwork.RaiseEvent((byte)42, (object)array2, new RaiseEventOptions
{
Receivers = (ReceiverGroup)2
}, SendOptions.SendReliable);
}
else
{
_votesByActor[0] = -1;
RecountTally();
}
}
}
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);
bool flag2 = (GUI.enabled = (!VoteNextMapPlugin.IsSolo && PhotonNetwork.IsMasterClient) || VoteNextMapPlugin.IsSolo);
if (GUI.Button(val6, flag2 ? "Close Now" : "Waiting for Host…"))
{
(int, string) tuple = ComputeWinner();
if (!VoteNextMapPlugin.IsSolo)
{
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);
}
else
{
CloseLocalVote(tuple.Item1, tuple.Item2);
}
}
GUI.enabled = true;
}
private void DrawRandomizerUI(Rect panel)
{
//IL_089e: Unknown result type (might be due to invalid IL or missing references)
//IL_08a3: Unknown result type (might be due to invalid IL or missing references)
//IL_08ab: Unknown result type (might be due to invalid IL or missing references)
//IL_08b4: Unknown result type (might be due to invalid IL or missing references)
//IL_08be: Expected O, but got Unknown
//IL_08be: Unknown result type (might be due to invalid IL or missing references)
//IL_0486: Unknown result type (might be due to invalid IL or missing references)
//IL_049f: Unknown result type (might be due to invalid IL or missing references)
//IL_04aa: Unknown result type (might be due to invalid IL or missing references)
//IL_04df: Unknown result type (might be due to invalid IL or missing references)
//IL_04c4: Unknown result type (might be due to invalid IL or missing references)
//IL_0504: Unknown result type (might be due to invalid IL or missing references)
//IL_0528: Unknown result type (might be due to invalid IL or missing references)
//IL_0553: Unknown result type (might be due to invalid IL or missing references)
//IL_056c: Unknown result type (might be due to invalid IL or missing references)
//IL_0577: Unknown result type (might be due to invalid IL or missing references)
//IL_057e: Unknown result type (might be due to invalid IL or missing references)
//IL_0583: Unknown result type (might be due to invalid IL or missing references)
//IL_0585: Unknown result type (might be due to invalid IL or missing references)
//IL_05ba: Unknown result type (might be due to invalid IL or missing references)
//IL_059f: Unknown result type (might be due to invalid IL or missing references)
//IL_05df: Unknown result type (might be due to invalid IL or missing references)
//IL_0603: Unknown result type (might be due to invalid IL or missing references)
//IL_0618: Unknown result type (might be due to invalid IL or missing references)
//IL_061d: Unknown result type (might be due to invalid IL or missing references)
//IL_0625: Unknown result type (might be due to invalid IL or missing references)
//IL_0634: Unknown result type (might be due to invalid IL or missing references)
//IL_063f: Expected O, but got Unknown
//IL_065f: Unknown result type (might be due to invalid IL or missing references)
//IL_06bf: Unknown result type (might be due to invalid IL or missing references)
//IL_06d5: Unknown result type (might be due to invalid IL or missing references)
//IL_06fa: Unknown result type (might be due to invalid IL or missing references)
//IL_0713: Unknown result type (might be due to invalid IL or missing references)
//IL_073e: Unknown result type (might be due to invalid IL or missing references)
//IL_0757: Unknown result type (might be due to invalid IL or missing references)
//IL_076c: Unknown result type (might be due to invalid IL or missing references)
//IL_0771: Unknown result type (might be due to invalid IL or missing references)
//IL_0779: Unknown result type (might be due to invalid IL or missing references)
//IL_0782: Unknown result type (might be due to invalid IL or missing references)
//IL_078c: Expected O, but got Unknown
//IL_078c: Unknown result type (might be due to invalid IL or missing references)
//IL_07f9: Unknown result type (might be due to invalid IL or missing references)
//IL_0800: Unknown result type (might be due to invalid IL or missing references)
//IL_0805: 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)
//IL_080e: Unknown result type (might be due to invalid IL or missing references)
//IL_0813: Unknown result type (might be due to invalid IL or missing references)
//IL_0815: Unknown result type (might be due to invalid IL or missing references)
//IL_0817: Unknown result type (might be due to invalid IL or missing references)
//IL_0824: Unknown result type (might be due to invalid IL or missing references)
//IL_083d: 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 (!VoteNextMapPlugin.IsSolo && PhotonNetwork.IsMasterClient && !_randSentClose)
{
_randSentClose = true;
((MonoBehaviour)this).StartCoroutine(LandAndClose());
}
if (VoteNextMapPlugin.IsSolo && !_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 (!VoteNextMapPlugin.IsSolo && 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");
}
}
}
}