Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of MapVoteWithPreview v0.0.1
plugins\MapVoteWithPreview.dll
Decompiled 4 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using ExitGames.Client.Photon; using HarmonyLib; using MapVoteWithPreview.Preview; using MenuLib; using MenuLib.MonoBehaviors; using Microsoft.CodeAnalysis; using MonoMod.RuntimeDetour; using Photon.Pun; using REPOLib.Modules; using Sirenix.Serialization.Utilities; using TMPro; using Unity.VisualScripting; using UnityEngine; using UnityEngine.Rendering; using UnityEngine.Rendering.PostProcessing; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("Autodesk.Fbx")] [assembly: IgnoresAccessChecksTo("Discord.Sdk")] [assembly: IgnoresAccessChecksTo("Domain_Reload")] [assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")] [assembly: IgnoresAccessChecksTo("FbxBuildTestAssets")] [assembly: IgnoresAccessChecksTo("Klattersynth")] [assembly: IgnoresAccessChecksTo("Photon3Unity3D")] [assembly: IgnoresAccessChecksTo("PhotonChat")] [assembly: IgnoresAccessChecksTo("PhotonRealtime")] [assembly: IgnoresAccessChecksTo("PhotonUnityNetworking")] [assembly: IgnoresAccessChecksTo("PhotonUnityNetworking.Utilities")] [assembly: IgnoresAccessChecksTo("PhotonVoice.API")] [assembly: IgnoresAccessChecksTo("PhotonVoice")] [assembly: IgnoresAccessChecksTo("PhotonVoice.PUN")] [assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime")] [assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime.Public")] [assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Attributes")] [assembly: IgnoresAccessChecksTo("Sirenix.Serialization.Config")] [assembly: IgnoresAccessChecksTo("Sirenix.Serialization")] [assembly: IgnoresAccessChecksTo("Sirenix.Utilities")] [assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")] [assembly: IgnoresAccessChecksTo("Unity.Burst")] [assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")] [assembly: IgnoresAccessChecksTo("Unity.Collections")] [assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")] [assembly: IgnoresAccessChecksTo("Unity.Formats.Fbx.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")] [assembly: IgnoresAccessChecksTo("Unity.Mathematics")] [assembly: IgnoresAccessChecksTo("Unity.MemoryProfiler")] [assembly: IgnoresAccessChecksTo("Unity.Postprocessing.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")] [assembly: IgnoresAccessChecksTo("Unity.Splines")] [assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")] [assembly: IgnoresAccessChecksTo("Unity.Timeline")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Antlr3.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Core")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Flow")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.State")] [assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.UI")] [assembly: IgnoresAccessChecksTo("websocket-sharp")] [assembly: AssemblyCompany("MapVoteWithPreview")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.0.1.0")] [assembly: AssemblyInformationalVersion("0.0.1+02b8c9f70d6ecfad7f02070e4f530e23577b3e68")] [assembly: AssemblyProduct("MapVoteWithPreview")] [assembly: AssemblyTitle("MapVoteWithPreview")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.1.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 MapVoteWithPreview { internal class CompatibilityPatches { private static Dictionary<string, Action> Patches = new Dictionary<string, Action>(); public static void PopulatePatches() { Patches.Add("ViViKo.StartInShop", delegate { MapVote.HideInMenu.Value = true; }); } public static void RunPatches(List<string> pluginGUIDs) { List<string> pluginGUIDs2 = pluginGUIDs; PopulatePatches(); LinqExtensions.ForEach<KeyValuePair<string, Action>>(Patches.Where<KeyValuePair<string, Action>>((KeyValuePair<string, Action> x) => pluginGUIDs2.Contains(x.Key)), (Action<KeyValuePair<string, Action>>)delegate(KeyValuePair<string, Action> plugin) { plugin.Value(); MapVote.Logger.LogInfo((object)("Ran Compatibility Patch for " + plugin.Key)); }); } } internal class DebugManager { public static void InitializeDebug() { PopulateMockData(); } private static void PopulateMockData() { MapVote.CurrentVotes[10] = "Level - Arctic"; MapVote.CurrentVotes[11] = "Level - Manor"; MapVote.CurrentVotes[12] = "Level - Wizard"; MapVote.CurrentVotes[13] = "Level - Wizard"; MapVote.CurrentVotes[14] = "Level - Wizard"; MapVote.CurrentVotes[15] = "Random"; } } internal static class LevelColorDictionary { private static readonly Dictionary<string, string> _dictionary = new Dictionary<string, string> { { "Random", "#21D710" }, { "Level - Manor", "#E79F0E" }, { "Level - Arctic", "#75DCD9" }, { "Level - Wizard", "#CB11CE" }, { "Level - Stronghold", "#A56695" }, { "Level - Museum", "#915829" }, { "Level - Bunker", "#D6C87E" }, { "Level - MtHolly", "#508AE1" }, { "Level - Garden", "#04A831" }, { "Level - Facility", "#A3BA8C" }, { "Level - Hospital", "#D53C35" }, { "Level - Backrooms", "#B7C13D" }, { "Level - DampMine", "#FA7902" } }; public static string GetColor(string key) { if (!_dictionary.TryGetValue(key, out string value)) { return "#ffffff"; } return value; } } [BepInPlugin("MapVoteWithPreview", "MapVoteWithPreview", "0.0.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] internal sealed class MapVote : BaseUnityPlugin { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static Predicate<Level> <>9__35_0; public static Func<KeyValuePair<string, PluginInfo>, string> <>9__39_0; public static Action <>9__42_1; public static BuilderDelegate <>9__42_0; public static Action<KeyValuePair<int, string>> <>9__47_0; public static Func<VoteOptionButton, global::<>f__AnonymousType0<VoteOptionButton, int>> <>9__52_0; public static Func<global::<>f__AnonymousType0<VoteOptionButton, int>, int> <>9__52_1; public static Func<global::<>f__AnonymousType0<VoteOptionButton, int>, VoteOptionButton> <>9__52_2; public static Action <>9__56_2; public static ScrollViewBuilderDelegate <>9__56_0; public static Func<Level, int, (Level level, int index)> <>9__56_3; public static Action<VoteOptionButton> <>9__57_0; public static Predicate<VoteOptionButton> <>9__58_0; public static Func<VoteOptionButton, int> <>9__58_1; public static Func<IGrouping<int, VoteOptionButton>, int> <>9__58_2; public static Predicate<VoteOptionButton> <>9__58_3; public static Predicate<VoteOptionButton> <>9__58_4; public static Predicate<VoteOptionButton> <>9__58_5; public static Predicate<VoteOptionButton> <>9__58_6; internal bool <HookRunManagerSetRunLevel>b__35_0(Level x) { return ((Object)x).name == WonMap; } internal string <Awake>b__39_0(KeyValuePair<string, PluginInfo> x) { return x.Key; } internal void <Initialize>b__42_0(Transform parent) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) MenuAPI.CreateREPOButton("Map Vote", (Action)delegate { CreateVotePopup(isInMenu: true); }, parent, new Vector2(175.2f, 62.8f)); } internal void <Initialize>b__42_1() { CreateVotePopup(isInMenu: true); } internal void <HandleOnSyncVotes>b__47_0(KeyValuePair<int, string> x) { CurrentVotes[x.Key] = x.Value; } internal global::<>f__AnonymousType0<VoteOptionButton, int> <GetSortedVoteOptions>b__52_0(VoteOptionButton b) { return new { Item = b, Count = b.GetVotes(CurrentVotes.Values) }; } internal int <GetSortedVoteOptions>b__52_1(global::<>f__AnonymousType0<VoteOptionButton, int> b) { return b.Count; } internal VoteOptionButton <GetSortedVoteOptions>b__52_2(global::<>f__AnonymousType0<VoteOptionButton, int> b) { return b.Item; } internal RectTransform <CreateVotePopup>b__56_0(Transform parent) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) REPOButton val = MenuAPI.CreateREPOButton((string)null, (Action)delegate { //IL_0026: Unknown result type (might be due to invalid IL or missing references) if (!DisableInput) { OwnVoteLevel = "Random"; NetworkedEvent? onVoteEvent = OnVoteEvent; if (onVoteEvent != null) { onVoteEvent.RaiseEvent((object)"Random", NetworkingEvents.RaiseAll, SendOptions.SendReliable); } } }, parent, default(Vector2)); HorizontalLayoutGroup val2 = ComponentHolderProtocol.AddComponent<HorizontalLayoutGroup>((Object)(object)val); ((HorizontalOrVerticalLayoutGroup)val2).spacing = 235f; GameObject val3 = Object.Instantiate<GameObject>(((Component)val.labelTMP).gameObject, ((Component)val).transform); TextMeshProUGUI component = val3.GetComponent<TextMeshProUGUI>(); ((TMP_Text)component).horizontalAlignment = (HorizontalAlignmentOptions)4; VoteOptionButtons.Add(new VoteOptionButton("Random", 0, val, _isRandomButton: true)); return ((REPOElement)val).rectTransform; } internal void <CreateVotePopup>b__56_2() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) if (!DisableInput) { OwnVoteLevel = "Random"; NetworkedEvent? onVoteEvent = OnVoteEvent; if (onVoteEvent != null) { onVoteEvent.RaiseEvent((object)"Random", NetworkingEvents.RaiseAll, SendOptions.SendReliable); } } } internal (Level level, int index) <CreateVotePopup>b__56_3(Level level, int index) { return (level, index); } internal void <UpdateButtonLabels>b__57_0(VoteOptionButton b) { b.UpdateLabel(_highlight: false, HasBeenLastPlayed(b.Level)); } internal bool <GetEligibleOptions>b__58_0(VoteOptionButton x) { return !x.IsRandomButton; } internal int <GetEligibleOptions>b__58_1(VoteOptionButton x) { return x.GetVotes(CurrentVotes.Values); } internal int <GetEligibleOptions>b__58_2(IGrouping<int, VoteOptionButton> x) { return x.Key; } internal bool <GetEligibleOptions>b__58_3(VoteOptionButton x) { return x.Level == "Random"; } internal bool <GetEligibleOptions>b__58_4(VoteOptionButton x) { return !HasBeenLastPlayed(x.Level); } internal bool <GetEligibleOptions>b__58_5(VoteOptionButton x) { return !x.IsRandomButton; } internal bool <GetEligibleOptions>b__58_6(VoteOptionButton x) { return x.IsRandomButton; } } [CompilerGenerated] private sealed class <>c__DisplayClass60_0 { public string winningMap; internal bool <OnVotingDone>b__0(VoteOptionButton x) { return x.Level == winningMap; } } [CompilerGenerated] private sealed class <BlinkButton>d__61 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public VoteOptionButton voteOption; private int <maxBlinks>5__2; private int <currentBlink>5__3; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <BlinkButton>d__61(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <maxBlinks>5__2 = (int)Mathf.Ceil(6f); <currentBlink>5__3 = 0; break; case 1: <>1__state = -1; voteOption.UpdateLabel(); <>2__current = (object)new WaitForSeconds(0.25f); <>1__state = 2; return true; case 2: <>1__state = -1; <currentBlink>5__3++; break; } if (<currentBlink>5__3 < <maxBlinks>5__2) { voteOption.UpdateLabel(_highlight: true); <>2__current = (object)new WaitForSeconds(0.25f); <>1__state = 1; return true; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <OnVotingDone>d__60 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public string winningMap; private List<VoteOptionButton> <eligibleOptions>5__2; private int <winningIndex>5__3; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <OnVotingDone>d__60(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <eligibleOptions>5__2 = null; <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: { <>1__state = -1; <>c__DisplayClass60_0 CS$<>8__locals0 = new <>c__DisplayClass60_0 { winningMap = winningMap }; MapPreviewManager.ForceClose(); DisableInput = true; ShouldHookRunMangerSetRunLevel = true; WonMap = CS$<>8__locals0.winningMap; <eligibleOptions>5__2 = GetEligibleOptions(); if (<eligibleOptions>5__2.Count > 1) { <winningIndex>5__3 = <eligibleOptions>5__2.FindIndex((VoteOptionButton x) => x.Level == CS$<>8__locals0.winningMap); <>2__current = ((MonoBehaviour)Instance).StartCoroutine(SpinWheelOptions(<eligibleOptions>5__2, <winningIndex>5__3)); <>1__state = 1; return true; } VoteOptionButton voteOptionButton = <eligibleOptions>5__2.FirstOrDefault(); if (voteOptionButton != null) { <>2__current = ((MonoBehaviour)Instance).StartCoroutine(BlinkButton(voteOptionButton)); <>1__state = 3; return true; } break; } case 1: <>1__state = -1; <>2__current = ((MonoBehaviour)Instance).StartCoroutine(BlinkButton(<eligibleOptions>5__2[<winningIndex>5__3])); <>1__state = 2; return true; case 2: <>1__state = -1; break; case 3: <>1__state = -1; break; } DisableInput = false; if (SemiFunc.RunIsLobby()) { CreateNextMapLabel(WonMap); if ((Object)(object)VotePopup != (Object)null) { VotePopup.ClosePage(true); } MenuAPI.CloseAllPagesAddedOnTop(); } if (SemiFunc.IsMasterClient() && SemiFunc.RunIsLobbyMenu()) { MenuPageLobby.instance.ButtonStart(); } Reset(); 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 <SpinWheelOptions>d__62 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public int winningIndex; public List<VoteOptionButton> eligibleOptions; private float <delay>5__2; private int <index>5__3; private int <endIndex>5__4; private int <recentIndex>5__5; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <SpinWheelOptions>d__62(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Expected O, but got Unknown int num = <>1__state; if (num != 0) { if (num != 1) { return false; } <>1__state = -1; if (<delay>5__2 > 0.4f && <index>5__3 == <endIndex>5__4) { goto IL_0112; } <delay>5__2 *= 1.15f; <recentIndex>5__5 = <index>5__3; <index>5__3 = (<index>5__3 + 1) % eligibleOptions.Count; } else { <>1__state = -1; <delay>5__2 = 0.05f; <index>5__3 = 0; <endIndex>5__4 = winningIndex; <recentIndex>5__5 = -1; } if (<index>5__3 != <endIndex>5__4 || <delay>5__2 < 0.5f) { eligibleOptions[<index>5__3].UpdateLabel(_highlight: true); if (<recentIndex>5__5 >= 0) { eligibleOptions[<recentIndex>5__5].UpdateLabel(); } <>2__current = (object)new WaitForSeconds(<delay>5__2); <>1__state = 1; return true; } goto IL_0112; IL_0112: eligibleOptions[<recentIndex>5__5].UpdateLabel(); 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 <StartCountdown>d__55 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; private string <format>5__2; private NumberFormatInfo <nfi>5__3; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <StartCountdown>d__55(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <format>5__2 = null; <nfi>5__3 = null; <>1__state = -2; } private bool MoveNext() { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; if (SemiFunc.IsMasterClientOrSingleplayer()) { VotingTimeLeft = VotingTime.Value; NetworkedEvent? onStartCountdown = OnStartCountdown; if (onStartCountdown != null) { onStartCountdown.RaiseEvent((object)VotingTimeLeft, NetworkingEvents.RaiseOthers, SendOptions.SendReliable); } } <format>5__2 = "00.00"; <nfi>5__3 = new NumberFormatInfo { NumberDecimalSeparator = ":" }; break; case 1: <>1__state = -1; break; } if (VotingTimeLeft > 0f) { VotingTimeLeft -= Time.deltaTime; if ((Object)(object)VotingTimeLabel != (Object)null) { ((TMP_Text)VotingTimeLabel.labelTMP).text = "<mspace=0.5em>" + VotingTimeLeft.ToString(<format>5__2, <nfi>5__3) + "</mspace> Seconds Left"; } <>2__current = null; <>1__state = 1; return true; } if ((Object)(object)VotingTimeLabel != (Object)null && (Object)(object)((Component)VotingTimeLabel).gameObject != (Object)null) { Object.Destroy((Object)(object)((Component)VotingTimeLabel).gameObject); } if (SemiFunc.IsMasterClientOrSingleplayer()) { string winningMap = GetWinningMap(); NetworkedEvent? onVoteEndedEvent = OnVoteEndedEvent; if (onVoteEndedEvent != null) { onVoteEndedEvent.RaiseEvent((object)winningMap, NetworkingEvents.RaiseOthers, SendOptions.SendReliable); } ((MonoBehaviour)Instance).StartCoroutine(OnVotingDone(winningMap)); } 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 <WaitForVote>d__54 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <WaitForVote>d__54(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; break; case 1: <>1__state = -1; break; } if (CurrentVotes.Values.Count <= 0) { UpdateButtonLabels(); <>2__current = (object)new WaitForSeconds(0.5f); <>1__state = 1; return true; } if (!SemiFunc.IsMasterClientOrSingleplayer()) { return false; } ((MonoBehaviour)Instance).StartCoroutine(StartCountdown()); return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public const string VOTE_RANDOM_LABEL = "Random"; public const string TRUCK_LEVEL_NAME = "Level - Lobby"; public const string SHOP_LEVEL_NAME = "Level - Shop"; public const string REQUEST_VOTE_LEVEL = "Level - Lobby"; public const bool IS_DEBUG = false; internal static readonly ManualLogSource Logger = Logger.CreateLogSource("MapVoteWithPreview"); public static NetworkedEvent? OnVoteEvent; public static NetworkedEvent? OnVoteEndedEvent; public static NetworkedEvent? OnSyncVotes; public static NetworkedEvent? OnSyncLastMapPlayed; public static NetworkedEvent? OnStartCountdown; public static NetworkedEvent? OnPreviewStart; public static NetworkedEvent? OnPreviewEnd; public static ConfigEntry<int> VotingTime; public static ConfigEntry<bool> HideInMenu; public static ConfigEntry<bool> NoRepeatedMaps; public static ConfigEntry<bool> PreviewEnabled; public static ConfigEntry<float> FreecamSpeed; public static VotesDictionary CurrentVotes = new VotesDictionary(); public static readonly List<VoteOptionButton> VoteOptionButtons = new List<VoteOptionButton>(); public static string? OwnVoteLevel; public static string? WonMap; public static REPOPopupPage? VotePopup; public static float VotingTimeLeft = 0f; public static REPOLabel? VotingTimeLabel; public static bool DisableInput = false; public static bool ShouldHookRunMangerSetRunLevel = false; public static string? LastMapPlayed; public static MapVote Instance; public static Dictionary<string, string> PreviewingPlayers = new Dictionary<string, string>(); private static Hook RunManagerSetRunLevelHook = new Hook((MethodBase)AccessTools.DeclaredMethod(typeof(RunManager), "SetRunLevel", (Type[])null, (Type[])null), (Delegate)new Action<Action<RunManager>, RunManager>(HookRunManagerSetRunLevel)); private static int ButtonStartHookRunAmount = 0; private static Hook ButtonStartHook = new Hook((MethodBase)AccessTools.DeclaredMethod(typeof(MenuPageLobby), "ButtonStart", (Type[])null, (Type[])null), (Delegate)new Action<Action<MenuPageLobby>, MenuPageLobby>(HookButtonStart)); internal Harmony? Harmony { get; set; } private static void HookRunManagerSetRunLevel(Action<RunManager> orig, RunManager self) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) MapPreviewManager.ForceClose(); if (SemiFunc.IsMasterClientOrSingleplayer() && ShouldHookRunMangerSetRunLevel) { self.levelCurrent = self.levels.Find((Level x) => ((Object)x).name == WonMap); ShouldHookRunMangerSetRunLevel = false; LastMapPlayed = WonMap; NetworkedEvent? onSyncLastMapPlayed = OnSyncLastMapPlayed; if (onSyncLastMapPlayed != null) { onSyncLastMapPlayed.RaiseEvent((object)LastMapPlayed, NetworkingEvents.RaiseOthers, SendOptions.SendReliable); } Reset(); WonMap = null; } else { orig(self); } } private static void HookButtonStart(Action<MenuPageLobby> orig, MenuPageLobby self) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) MapPreviewManager.ForceClose(); if (DisableInput) { return; } if (ButtonStartHookRunAmount > 0 || HideInMenu.Value) { ButtonStartHookRunAmount = 0; orig(self); return; } ButtonStartHookRunAmount++; string winningMap = GetWinningMap(); NetworkedEvent? onVoteEndedEvent = OnVoteEndedEvent; if (onVoteEndedEvent != null) { onVoteEndedEvent.RaiseEvent((object)winningMap, NetworkingEvents.RaiseOthers, SendOptions.SendReliable); } ((MonoBehaviour)Instance).StartCoroutine(OnVotingDone(winningMap)); } public void Awake() { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Expected O, but got Unknown //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Expected O, but got Unknown //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Expected O, but got Unknown //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Expected O, but got Unknown //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Expected O, but got Unknown Instance = this; ((Component)this).gameObject.transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; Patch(); VotingTime = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Voting Time", 10, new ConfigDescription("The amount of seconds until the voting ends, after the first player voted.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(3, 30), Array.Empty<object>())); HideInMenu = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Hide in Menu", false, new ConfigDescription("When true - hides the Menu in the lobby menu and randomly selects a random map - Voting is still enabled in the truck", (AcceptableValueBase)null, Array.Empty<object>())); NoRepeatedMaps = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "No Repeated Maps", false, new ConfigDescription("When true - disallows votes for the most recently played map - You won't play the same map twice in a row", (AcceptableValueBase)null, Array.Empty<object>())); PreviewEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Preview", "Preview Enabled", true, new ConfigDescription("When true - enables the map preview freecam feature", (AcceptableValueBase)null, Array.Empty<object>())); FreecamSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Preview", "Freecam Speed", 10f, new ConfigDescription("Speed of the freecam when previewing a map", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 50f), Array.Empty<object>())); GameObject val = new GameObject("MapPreviewManager"); val.transform.parent = null; ((Object)val).hideFlags = (HideFlags)61; val.AddComponent<MapPreviewManager>(); CompatibilityPatches.RunPatches(Chainloader.PluginInfos.Select((KeyValuePair<string, PluginInfo> x) => x.Key).ToList()); Initialize(); Logger.LogDebug((object)"Loaded MapVoteWithPreview V0.0.1!"); } internal void Patch() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_0025: Expected O, but got Unknown try { if (Harmony == null) { Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID); Harmony val2 = val; Harmony = val; } Harmony.PatchAll(); } catch (Exception ex) { Logger.LogError((object)ex); } } internal void Unpatch() { Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } } internal static void Initialize() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Expected O, but got Unknown //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Expected O, but got Unknown //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Expected O, but got Unknown //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Expected O, but got Unknown //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Expected O, but got Unknown OnVoteEvent = new NetworkedEvent("OnVoteEvent", (Action<EventData>)HandleOnVoteEvent); OnVoteEndedEvent = new NetworkedEvent("OnVoteEndedEvent", (Action<EventData>)HandleOnVoteEndEvent); OnSyncVotes = new NetworkedEvent("OnSyncVotes", (Action<EventData>)HandleOnSyncVotes); OnSyncLastMapPlayed = new NetworkedEvent("OnSyncLastMapPlayed", (Action<EventData>)HandleOnSyncLastMapPlayed); OnStartCountdown = new NetworkedEvent("OnStartCountdown", (Action<EventData>)HandleOnStartCountdown); OnPreviewStart = new NetworkedEvent("OnPreviewStart", (Action<EventData>)HandleOnPreviewStart); OnPreviewEnd = new NetworkedEvent("OnPreviewEnd", (Action<EventData>)HandleOnPreviewEnd); if (HideInMenu.Value) { return; } object obj = <>c.<>9__42_0; if (obj == null) { BuilderDelegate val = delegate(Transform parent) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) MenuAPI.CreateREPOButton("Map Vote", (Action)delegate { CreateVotePopup(isInMenu: true); }, parent, new Vector2(175.2f, 62.8f)); }; <>c.<>9__42_0 = val; obj = (object)val; } MenuAPI.AddElementToLobbyMenu((BuilderDelegate)obj); } public static bool HasBeenLastPlayed(string? level) { if (level == null || !NoRepeatedMaps.Value) { return false; } if (LastMapPlayed == level) { return LastMapPlayed != WonMap; } return false; } public static void Reset() { CurrentVotes.Values.Clear(); VoteOptionButtons.Clear(); OwnVoteLevel = null; UpdateButtonLabels(); } private static void HandleOnSyncLastMapPlayed(EventData data) { string lastMapPlayed = (string)data.CustomData; LastMapPlayed = lastMapPlayed; WonMap = null; } private static void HandleOnStartCountdown(EventData data) { if (!SemiFunc.IsMasterClient()) { float votingTimeLeft = (float)data.CustomData; VotingTimeLeft = votingTimeLeft; ((MonoBehaviour)Instance).StartCoroutine(StartCountdown()); } } private static void HandleOnSyncVotes(EventData data) { if (SemiFunc.IsMasterClient()) { UpdateButtonLabels(); return; } Dictionary<int, string> dictionary = (Dictionary<int, string>)data.CustomData; if (dictionary != null) { Reset(); WonMap = null; LinqExtensions.ForEach<KeyValuePair<int, string>>((IEnumerable<KeyValuePair<int, string>>)dictionary, (Action<KeyValuePair<int, string>>)delegate(KeyValuePair<int, string> x) { CurrentVotes[x.Key] = x.Value; }); UpdateButtonLabels(); } } private static void HandleOnVoteEvent(EventData data) { string value = (string)data.CustomData; CurrentVotes[data.sender] = value; } private static void HandleOnVoteEndEvent(EventData data) { string winningMap = (string)data.CustomData; ((MonoBehaviour)Instance).StartCoroutine(OnVotingDone(winningMap)); } private static void HandleOnPreviewStart(EventData data) { MapPreviewManager.HandlePreviewStart(data); } private static void HandleOnPreviewEnd(EventData data) { MapPreviewManager.HandlePreviewEnd(data); } public static List<VoteOptionButton> GetSortedVoteOptions() { return (from b in VoteOptionButtons select new { Item = b, Count = b.GetVotes(CurrentVotes.Values) } into b orderby b.Count descending select b.Item).ToList(); } public static void CreateNextMapLabel(string mapName) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) REPOLabel val = MenuAPI.CreateREPOLabel((string)null, GameObject.Find("Game Hud").transform, new Vector2(-100f, 110f)); ((TMP_Text)val.labelTMP).horizontalAlignment = (HorizontalAlignmentOptions)2; ((TMP_Text)val.labelTMP).text = "Next Map: <color=" + LevelColorDictionary.GetColor(mapName) + "><size=32>" + Utilities.RemoveLevelPrefix(mapName) + "</size></color>"; } [IteratorStateMachine(typeof(<WaitForVote>d__54))] public static IEnumerator WaitForVote() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <WaitForVote>d__54(0); } [IteratorStateMachine(typeof(<StartCountdown>d__55))] public static IEnumerator StartCountdown() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <StartCountdown>d__55(0); } public static void CreateVotePopup(bool isInMenu = false) { //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Expected O, but got Unknown //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Expected O, but got Unknown //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Expected O, but got Unknown MenuAPI.CloseAllPagesAddedOnTop(); VoteOptionButtons.Clear(); if ((Object)(object)VotePopup != (Object)null) { VotePopup.ClosePage(true); VotePopup = null; } if (((Object)RunManager.instance.levelCurrent).name == "Level - Lobby") { GameDirector.instance.DisableInput = true; } VotePopup = MenuAPI.CreateREPOPopupPage("Next map", true, !isInMenu, 0f, (Vector2?)(isInMenu ? new Vector2(40f, 0f) : new Vector2(-100f, 0f))); RunManager val = Object.FindObjectOfType<RunManager>(); List<Level> levels = val.levels; REPOPopupPage? votePopup = VotePopup; object obj = <>c.<>9__56_0; if (obj == null) { ScrollViewBuilderDelegate val2 = delegate(Transform parent) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) REPOButton val6 = MenuAPI.CreateREPOButton((string)null, (Action)delegate { //IL_0026: Unknown result type (might be due to invalid IL or missing references) if (!DisableInput) { OwnVoteLevel = "Random"; NetworkedEvent? onVoteEvent2 = OnVoteEvent; if (onVoteEvent2 != null) { onVoteEvent2.RaiseEvent((object)"Random", NetworkingEvents.RaiseAll, SendOptions.SendReliable); } } }, parent, default(Vector2)); HorizontalLayoutGroup val7 = ComponentHolderProtocol.AddComponent<HorizontalLayoutGroup>((Object)(object)val6); ((HorizontalOrVerticalLayoutGroup)val7).spacing = 235f; GameObject val8 = Object.Instantiate<GameObject>(((Component)val6.labelTMP).gameObject, ((Component)val6).transform); TextMeshProUGUI component2 = val8.GetComponent<TextMeshProUGUI>(); ((TMP_Text)component2).horizontalAlignment = (HorizontalAlignmentOptions)4; VoteOptionButtons.Add(new VoteOptionButton("Random", 0, val6, _isRandomButton: true)); return ((REPOElement)val6).rectTransform; }; <>c.<>9__56_0 = val2; obj = (object)val2; } votePopup.AddElementToScrollView((ScrollViewBuilderDelegate)obj, 0f, 0f); foreach (var item3 in levels.Select((Level level, int index) => (level, index))) { Level item = item3.Item1; int item2 = item3.Item2; string name = ((Object)item).name; VotePopup.AddElementToScrollView((ScrollViewBuilderDelegate)delegate(Transform parent) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) REPOButton val3 = MenuAPI.CreateREPOButton((string)null, (Action)delegate { //IL_004c: Unknown result type (might be due to invalid IL or missing references) if (!DisableInput) { if (Input.GetKey((KeyCode)304) && PreviewEnabled.Value) { MapPreviewManager.StartPreview(name); } else { OwnVoteLevel = name; NetworkedEvent? onVoteEvent = OnVoteEvent; if (onVoteEvent != null) { onVoteEvent.RaiseEvent((object)name, NetworkingEvents.RaiseAll, SendOptions.SendReliable); } } } }, parent, default(Vector2)); if (HasBeenLastPlayed(name)) { ((Component)val3).gameObject.GetComponent<MenuButton>().disabled = true; } HorizontalLayoutGroup val4 = ComponentHolderProtocol.AddComponent<HorizontalLayoutGroup>((Object)(object)val3); ((HorizontalOrVerticalLayoutGroup)val4).spacing = 235f; GameObject val5 = Object.Instantiate<GameObject>(((Component)val3.labelTMP).gameObject, ((Component)val3).transform); TextMeshProUGUI component = val5.GetComponent<TextMeshProUGUI>(); ((TMP_Text)component).horizontalAlignment = (HorizontalAlignmentOptions)4; VoteOptionButtons.Add(new VoteOptionButton(name, 0, val3)); return ((REPOElement)val3).rectTransform; }, 0f, 0f); } VotePopup.AddElement((BuilderDelegate)delegate(Transform parent) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) VotingTimeLabel = MenuAPI.CreateREPOLabel((string)null, parent, new Vector2(isInMenu ? 394f : 254f, 30f)); }); VotePopup.OpenPage(true); UpdateButtonLabels(); ((Component)VotePopup).GetComponent<MenuPage>().PageStateSet((PageState)1); } public static void UpdateButtonLabels() { VoteOptionButtons.ForEach(delegate(VoteOptionButton b) { b.UpdateLabel(_highlight: false, HasBeenLastPlayed(b.Level)); }); } public static List<VoteOptionButton> GetEligibleOptions() { if (CurrentVotes.Values.Count == 0) { return VoteOptionButtons.FindAll((VoteOptionButton x) => !x.IsRandomButton); } List<VoteOptionButton> list = new List<VoteOptionButton>(); List<VoteOptionButton> sortedVoteOptions = GetSortedVoteOptions(); List<VoteOptionButton> list2 = (from x in sortedVoteOptions group x by x.GetVotes(CurrentVotes.Values) into x orderby x.Key descending select x).FirstOrDefault().ToList(); list = ((list2.Find((VoteOptionButton x) => x.Level == "Random") == null) ? (list2 ?? list) : VoteOptionButtons); if (NoRepeatedMaps.Value) { list = list.FindAll((VoteOptionButton x) => !HasBeenLastPlayed(x.Level)); } if (list.FindAll((VoteOptionButton x) => !x.IsRandomButton).Count <= 0) { list = VoteOptionButtons; } list.RemoveAll((VoteOptionButton x) => x.IsRandomButton); return list; } public static string GetWinningMap() { List<VoteOptionButton> eligibleOptions = GetEligibleOptions(); int index = Random.RandomRangeInt(0, eligibleOptions.Count); return eligibleOptions[index].Level; } [IteratorStateMachine(typeof(<OnVotingDone>d__60))] public static IEnumerator OnVotingDone(string winningMap) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <OnVotingDone>d__60(0) { winningMap = winningMap }; } [IteratorStateMachine(typeof(<BlinkButton>d__61))] public static IEnumerator BlinkButton(VoteOptionButton voteOption) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <BlinkButton>d__61(0) { voteOption = voteOption }; } [IteratorStateMachine(typeof(<SpinWheelOptions>d__62))] public static IEnumerator SpinWheelOptions(List<VoteOptionButton> eligibleOptions, int winningIndex) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <SpinWheelOptions>d__62(0) { eligibleOptions = eligibleOptions, winningIndex = winningIndex }; } } internal sealed class Utilities { public static string ColorString(string text, string colorHex) { return "<color=#" + colorHex + ">" + text + "</color>"; } public static string ColorString(string text, Color color) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) return "<color=#" + XColor.ToHexString(color) + ">" + text + "</color>"; } public static string RemoveLevelPrefix(string text) { return text.Replace("Level - ", ""); } } internal sealed class VoteOptionButton { public string Level { get; set; } public REPOButton Button { get; set; } public bool IsRandomButton { get; set; } public VoteOptionButton(string _level, int _votes, REPOButton _button, bool _isRandomButton = false) { Level = _level; Button = _button; IsRandomButton = _isRandomButton; } public int GetVotes(Dictionary<int, string> votes) { int num = 0; foreach (KeyValuePair<int, string> vote in votes) { if (vote.Value == Level) { num++; } } return num; } public void UpdateLabel(bool _highlight = false, bool _disabled = false) { //IL_005f: 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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) Dictionary<int, string> values = MapVote.CurrentVotes.Values; bool flag = MapVote.OwnVoteLevel == Level; int num = Math.Max(Math.Min(GameDirector.instance.PlayerList.Count, 12), 4); int votes = GetVotes(values); Color color = (_disabled ? Color.gray : (_highlight ? Color.green : (flag ? Color.yellow : Color.white))); StringBuilder stringBuilder = new StringBuilder(); if (_disabled) { stringBuilder.Append("<s>"); } stringBuilder.Append("<mspace=0.25em>[" + Utilities.ColorString((flag || _highlight) ? "X" : " ", color) + "]</mspace> "); if (!_disabled) { stringBuilder.Append("<color=" + LevelColorDictionary.GetColor(Level) + ">"); } stringBuilder.Append((IsRandomButton ? "Random" : Utilities.RemoveLevelPrefix(Level)) ?? ""); if (!_disabled) { stringBuilder.Append("</color>"); } if (_disabled) { stringBuilder.Append("</s>"); } if (!IsRandomButton && MapVote.PreviewingPlayers.Values.Any((string v) => v == Level)) { stringBuilder.Append(Utilities.ColorString(" (previewing)", Color.gray)); } Transform child = ((Component)Button).transform.GetChild(1); ((TMP_Text)((Component)child).GetComponent<TextMeshProUGUI>()).text = Utilities.ColorString(new string('I', votes), Color.green) + Utilities.ColorString(new string('I', num - votes), Color.white); ((TMP_Text)Button.labelTMP).text = stringBuilder.ToString() ?? ""; } } public class VotesDictionary { public readonly Dictionary<int, string> Values = new Dictionary<int, string>(); public string this[int key] { get { return Values[key]; } set { Values[key] = value; MapVote.UpdateButtonLabels(); } } } public static class MyPluginInfo { public const string PLUGIN_GUID = "MapVoteWithPreview"; public const string PLUGIN_NAME = "MapVoteWithPreview"; public const string PLUGIN_VERSION = "0.0.1"; } } namespace MapVoteWithPreview.Preview { public class FreecamController : MonoBehaviour { private float _yaw; private float _pitch; private float _speed; private PostProcessVolume _ppVolume; private RenderTexture _renderTexture; private Camera _camera; public void Initialize(float speed, Vector3 startPosition) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Expected O, but got Unknown //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) _speed = speed; ((Component)this).transform.position = startPosition; Camera val = ((Component)this).gameObject.AddComponent<Camera>(); val.nearClipPlane = 0.1f; val.farClipPlane = 1000f; val.fieldOfView = 75f; val.depth = 100f; int num = Screen.width / 3; int num2 = Screen.height / 3; RenderTexture val2 = new RenderTexture(num, num2, 24); ((Texture)val2).filterMode = (FilterMode)0; val.targetTexture = val2; _renderTexture = val2; _camera = val; try { PostProcessLayer val3 = ((Component)this).gameObject.AddComponent<PostProcessLayer>(); val3.volumeTrigger = ((Component)this).transform; val3.volumeLayer = LayerMask.op_Implicit(-1); PostProcessResources[] array = Resources.FindObjectsOfTypeAll<PostProcessResources>(); if (array != null && array.Length != 0) { val3.Init(array[0]); } } catch (Exception ex) { MapVote.Logger.LogWarning((object)("[PREVIEW] PostProcessLayer setup failed: " + ex.Message)); } ((Component)this).gameObject.AddComponent<AudioListener>(); _yaw = ((Component)this).transform.eulerAngles.y; _pitch = ((Component)this).transform.eulerAngles.x; Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; } public void ApplyLevelEffects(Level level) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("PreviewPostProcess"); ((Object)val).hideFlags = (HideFlags)61; val.transform.SetParent(((Component)this).transform, false); _ppVolume = val.AddComponent<PostProcessVolume>(); _ppVolume.isGlobal = true; _ppVolume.priority = 100f; PostProcessProfile val2 = ScriptableObject.CreateInstance<PostProcessProfile>(); Bloom val3 = ScriptableObject.CreateInstance<Bloom>(); ((ParameterOverride<bool>)(object)((PostProcessEffectSettings)val3).enabled).value = true; ((ParameterOverride)val3.intensity).overrideState = true; ((ParameterOverride<float>)(object)val3.intensity).value = Mathf.Min(level.BloomIntensity * 0.3f, 3f); ((ParameterOverride)val3.threshold).overrideState = true; ((ParameterOverride<float>)(object)val3.threshold).value = Mathf.Max(level.BloomThreshold, 1f); val2.AddSettings((PostProcessEffectSettings)(object)val3); ColorGrading val4 = ScriptableObject.CreateInstance<ColorGrading>(); ((ParameterOverride<bool>)(object)((PostProcessEffectSettings)val4).enabled).value = true; ((ParameterOverride)val4.colorFilter).overrideState = true; ((ParameterOverride<Color>)(object)val4.colorFilter).value = level.ColorFilter; ((ParameterOverride)val4.temperature).overrideState = true; ((ParameterOverride<float>)(object)val4.temperature).value = level.ColorTemperature; val2.AddSettings((PostProcessEffectSettings)(object)val4); Vignette val5 = ScriptableObject.CreateInstance<Vignette>(); ((ParameterOverride<bool>)(object)((PostProcessEffectSettings)val5).enabled).value = true; ((ParameterOverride)val5.color).overrideState = true; ((ParameterOverride<Color>)(object)val5.color).value = level.VignetteColor; ((ParameterOverride)val5.intensity).overrideState = true; ((ParameterOverride<float>)(object)val5.intensity).value = level.VignetteIntensity; ((ParameterOverride)val5.smoothness).overrideState = true; ((ParameterOverride<float>)(object)val5.smoothness).value = level.VignetteSmoothness; val2.AddSettings((PostProcessEffectSettings)(object)val5); ChromaticAberration val6 = ScriptableObject.CreateInstance<ChromaticAberration>(); ((ParameterOverride<bool>)(object)((PostProcessEffectSettings)val6).enabled).value = true; ((ParameterOverride)val6.intensity).overrideState = true; ((ParameterOverride<float>)(object)val6.intensity).value = 0.15f; val2.AddSettings((PostProcessEffectSettings)(object)val6); Grain val7 = ScriptableObject.CreateInstance<Grain>(); ((ParameterOverride<bool>)(object)((PostProcessEffectSettings)val7).enabled).value = true; ((ParameterOverride)val7.intensity).overrideState = true; ((ParameterOverride<float>)(object)val7.intensity).value = 0.3f; ((ParameterOverride)val7.size).overrideState = true; ((ParameterOverride<float>)(object)val7.size).value = 1.2f; val2.AddSettings((PostProcessEffectSettings)(object)val7); MotionBlur val8 = ScriptableObject.CreateInstance<MotionBlur>(); ((ParameterOverride<bool>)(object)((PostProcessEffectSettings)val8).enabled).value = true; ((ParameterOverride)val8.shutterAngle).overrideState = true; ((ParameterOverride<float>)(object)val8.shutterAngle).value = 150f; ((ParameterOverride)val8.sampleCount).overrideState = true; ((ParameterOverride<int>)(object)val8.sampleCount).value = 8; val2.AddSettings((PostProcessEffectSettings)(object)val8); AutoExposure val9 = ScriptableObject.CreateInstance<AutoExposure>(); ((ParameterOverride<bool>)(object)((PostProcessEffectSettings)val9).enabled).value = true; ((ParameterOverride)val9.minLuminance).overrideState = true; ((ParameterOverride<float>)(object)val9.minLuminance).value = -2f; ((ParameterOverride)val9.maxLuminance).overrideState = true; ((ParameterOverride<float>)(object)val9.maxLuminance).value = 2f; val2.AddSettings((PostProcessEffectSettings)(object)val9); _ppVolume.profile = val2; MapVote.Logger.LogInfo((object)$"[PREVIEW] Applied post-processing: bloom={level.BloomIntensity}, colorFilter={level.ColorFilter}, vignette={level.VignetteIntensity}, +chromaticAberration, grain, motionBlur, autoExposure"); } private void Update() { //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: 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_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: 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_0102: 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_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) if (Input.GetMouseButton(1)) { Cursor.lockState = (CursorLockMode)1; Cursor.visible = false; _yaw += Input.GetAxis("Mouse X") * 3f; _pitch -= Input.GetAxis("Mouse Y") * 3f; _pitch = Mathf.Clamp(_pitch, -90f, 90f); ((Component)this).transform.rotation = Quaternion.Euler(_pitch, _yaw, 0f); } else { Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; } float num = _speed; if (Input.GetKey((KeyCode)304)) { num *= 3f; } Vector3 val = Vector3.zero; if (Input.GetKey((KeyCode)119)) { val += ((Component)this).transform.forward; } if (Input.GetKey((KeyCode)115)) { val -= ((Component)this).transform.forward; } if (Input.GetKey((KeyCode)97)) { val -= ((Component)this).transform.right; } if (Input.GetKey((KeyCode)100)) { val += ((Component)this).transform.right; } if (Input.GetKey((KeyCode)32)) { val += Vector3.up; } if (Input.GetKey((KeyCode)306)) { val -= Vector3.up; } Transform transform = ((Component)this).transform; transform.position += ((Vector3)(ref val)).normalized * num * Time.deltaTime; } private void OnGUI() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Invalid comparison between Unknown and I4 //IL_0031: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_renderTexture != (Object)null && (int)Event.current.type == 7) { GUI.DrawTexture(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), (Texture)(object)_renderTexture, (ScaleMode)0); } } private void OnDestroy() { Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; if ((Object)(object)_ppVolume != (Object)null && (Object)(object)_ppVolume.profile != (Object)null) { Object.Destroy((Object)(object)_ppVolume.profile); } if ((Object)(object)_renderTexture != (Object)null) { if ((Object)(object)_camera != (Object)null) { _camera.targetTexture = null; } Object.Destroy((Object)(object)_renderTexture); } } } public enum PreviewState { Idle, Loading, Previewing, Unloading } public class MapPreviewManager : MonoBehaviour { private class PreviewTile { public int x; public int y; public bool active; public bool first; public Type type; public bool connectedTop; public bool connectedBot; public bool connectedRight; public bool connectedLeft; public int connections; } [CompilerGenerated] private sealed class <>c__DisplayClass28_0 { public string levelName; internal bool <BuildPreview>b__0(Level l) { return ((Object)l).name == levelName; } } [CompilerGenerated] private sealed class <BuildGridPreview>d__32 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public Level level; private Vector3 <previewOrigin>5__2; private List<GameObject> <modulesToSpawn>5__3; private int <totalModules>5__4; private int <gridSize>5__5; private int <i>5__6; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <BuildGridPreview>d__32(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <modulesToSpawn>5__3 = null; <>1__state = -2; } private bool MoveNext() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) int num = <>1__state; if (num != 0) { if (num != 1) { return false; } <>1__state = -1; goto IL_02a7; } <>1__state = -1; <previewOrigin>5__2 = new Vector3(0f, -3000f, 0f); _previewRoot = new GameObject("MapPreviewRoot"); _previewRoot.transform.position = <previewOrigin>5__2; <modulesToSpawn>5__3 = new List<GameObject>(); if (level.StartRooms != null) { foreach (PrefabRef startRoom in level.StartRooms) { if (startRoom != null) { GameObject prefab = startRoom.Prefab; if ((Object)(object)prefab != (Object)null) { <modulesToSpawn>5__3.Add(prefab); } } } } AddPrefabRefs(<modulesToSpawn>5__3, level.ModulesNormal1); AddPrefabRefs(<modulesToSpawn>5__3, level.ModulesNormal2); AddPrefabRefs(<modulesToSpawn>5__3, level.ModulesNormal3); AddPrefabRefs(<modulesToSpawn>5__3, level.ModulesPassage1); AddPrefabRefs(<modulesToSpawn>5__3, level.ModulesPassage2); AddPrefabRefs(<modulesToSpawn>5__3, level.ModulesPassage3); AddPrefabRefs(<modulesToSpawn>5__3, level.ModulesDeadEnd1); AddPrefabRefs(<modulesToSpawn>5__3, level.ModulesDeadEnd2); AddPrefabRefs(<modulesToSpawn>5__3, level.ModulesDeadEnd3); AddPrefabRefs(<modulesToSpawn>5__3, level.ModulesExtraction1); AddPrefabRefs(<modulesToSpawn>5__3, level.ModulesExtraction2); AddPrefabRefs(<modulesToSpawn>5__3, level.ModulesExtraction3); if (<modulesToSpawn>5__3.Count == 0) { return false; } <totalModules>5__4 = <modulesToSpawn>5__3.Count; <gridSize>5__5 = Mathf.CeilToInt(Mathf.Sqrt((float)<totalModules>5__4)); <i>5__6 = 0; goto IL_02b9; IL_02b9: if (<i>5__6 < <totalModules>5__4) { int num2 = <i>5__6 / <gridSize>5__5; int num3 = <i>5__6 % <gridSize>5__5; Vector3 val = <previewOrigin>5__2 + new Vector3((float)num3 * 15f, 0f, (float)num2 * 15f); GameObject obj = Object.Instantiate<GameObject>(<modulesToSpawn>5__3[<i>5__6], val, Quaternion.identity, _previewRoot.transform); StripComponents(obj); if (<i>5__6 % 3 == 2) { <>2__current = null; <>1__state = 1; return true; } goto IL_02a7; } return false; IL_02a7: <i>5__6++; goto IL_02b9; } 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 <BuildPreview>d__28 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public string levelName; private <>c__DisplayClass28_0 <>8__1; private Level <level>5__2; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <BuildPreview>d__28(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>8__1 = null; <level>5__2 = null; <>1__state = -2; } private bool MoveNext() { //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0137: 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_0242: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Expected O, but got Unknown //IL_0292: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: { <>1__state = -1; <>8__1 = new <>c__DisplayClass28_0(); <>8__1.levelName = levelName; State = PreviewState.Loading; MapVote.Logger.LogInfo((object)("[PREVIEW] Building preview for: " + <>8__1.levelName)); RunManager val = Object.FindObjectOfType<RunManager>(); if ((Object)(object)val == (Object)null) { MapVote.Logger.LogError((object)"[PREVIEW] RunManager not found"); State = PreviewState.Idle; return false; } <level>5__2 = val.levels.Find((Level l) => ((Object)l).name == <>8__1.levelName); if ((Object)(object)<level>5__2 == (Object)null) { MapVote.Logger.LogError((object)("[PREVIEW] Level '" + <>8__1.levelName + "' not found")); State = PreviewState.Idle; return false; } if ((Object)(object)MapVote.VotePopup != (Object)null) { MapVote.VotePopup.ClosePage(true); } LevelGenerator levelGen = Object.FindObjectOfType<LevelGenerator>(); DisableLobby(); _savedFog = RenderSettings.fog; _savedFogColor = RenderSettings.fogColor; _savedFogStart = RenderSettings.fogStartDistance; _savedFogEnd = RenderSettings.fogEndDistance; _savedFogMode = RenderSettings.fogMode; _savedAmbientLight = RenderSettings.ambientLight; bool flag = false; try { flag = TryProceduralGeneration(val, <level>5__2, levelGen); } catch (Exception ex) { MapVote.Logger.LogWarning((object)("[PREVIEW] Procedural generation failed: " + ex.Message + ", falling back to grid")); } if (!flag) { <>2__current = ((MonoBehaviour)Instance).StartCoroutine(BuildGridPreview(<level>5__2)); <>1__state = 1; return true; } break; } case 1: <>1__state = -1; break; } RenderSettings.fog = true; RenderSettings.fogColor = <level>5__2.FogColor; RenderSettings.fogMode = (FogMode)1; RenderSettings.fogStartDistance = <level>5__2.FogStartDistance; RenderSettings.fogEndDistance = ((<level>5__2.FogEndDistance > 0f) ? <level>5__2.FogEndDistance : 15f); RenderSettings.ambientLight = <level>5__2.AmbientColor; RenderSettings.ambientIntensity = 1f; RenderSettings.ambientMode = (AmbientMode)3; Vector3 startPosition = (Vector3)(((Object)(object)_previewRoot != (Object)null) ? (_previewRoot.transform.position + new Vector3(15f, 8f, 15f)) : new Vector3(0f, 5f, 0f)); GameObject val2 = new GameObject("MapPreviewFreecam"); ((Object)val2).hideFlags = (HideFlags)61; _freecam = val2.AddComponent<FreecamController>(); _freecam.Initialize(MapVote.FreecamSpeed.Value, startPosition); _freecam.ApplyLevelEffects(<level>5__2); BroadcastPreviewStart(<>8__1.levelName); State = PreviewState.Previewing; MapVote.Logger.LogInfo((object)("[PREVIEW] Now previewing: " + <>8__1.levelName)); return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private static string _previewLevelName; private static FreecamController _freecam; private static GameObject _previewRoot; private static List<GameObject> _disabledRootObjects = new List<GameObject>(); private static bool _cancelRequested; private static bool _savedFog; private static Color _savedFogColor; private static float _savedFogStart; private static float _savedFogEnd; private static FogMode _savedFogMode; private static Color _savedAmbientLight; private const float MODULE_SPACING = 15f; private static Level _savedLevel; private static readonly HashSet<string> KEEP_ACTIVE = new HashSet<string> { "MapPreviewRoot", "MapPreviewFreecam", "MapVotePreview", "MapVoteWithPreview", "REPOPingMod", "BepInEx_Manager", "PhotonMono", "PunVoiceClient(Clone)", "NetworkManager", "Steam Manager", "PhotonHandler" }; public static MapPreviewManager Instance { get; private set; } public static PreviewState State { get; private set; } = PreviewState.Idle; private void Awake() { if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this) { Object.Destroy((Object)(object)this); } else { Instance = this; } } public static void StartPreview(string levelName) { if (State == PreviewState.Idle && MapVote.PreviewEnabled.Value && !((Object)(object)Instance == (Object)null)) { _previewLevelName = levelName; _cancelRequested = false; ((MonoBehaviour)Instance).StartCoroutine(BuildPreview(levelName)); } } public static void StopPreview() { if (State == PreviewState.Previewing && !((Object)(object)Instance == (Object)null)) { CleanupPreview(); RestoreLobby(); BroadcastPreviewEnd(); bool isInMenu = ((Object)RunManager.instance.levelCurrent).name != "Level - Lobby"; MapVote.CreateVotePopup(isInMenu); State = PreviewState.Idle; _previewLevelName = null; MapVote.Logger.LogInfo((object)"[PREVIEW] Preview closed"); } } public static void ForceClose() { if (State != 0) { _cancelRequested = true; if ((Object)(object)Instance != (Object)null) { ((MonoBehaviour)Instance).StopAllCoroutines(); } CleanupPreview(); RestoreLobby(); BroadcastPreviewEnd(); State = PreviewState.Idle; _previewLevelName = null; _cancelRequested = false; } } private static void CleanupPreview() { if ((Object)(object)_freecam != (Object)null) { Object.Destroy((Object)(object)((Component)_freecam).gameObject); _freecam = null; } if ((Object)(object)_previewRoot != (Object)null) { Object.Destroy((Object)(object)_previewRoot); _previewRoot = null; } } public static void HandlePreviewStart(EventData data) { string text = (string)data.CustomData; string[] array = text.Split('|'); if (array.Length >= 2) { MapVote.PreviewingPlayers[array[0]] = array[1]; MapVote.UpdateButtonLabels(); } } public static void HandlePreviewEnd(EventData data) { string key = (string)data.CustomData; MapVote.PreviewingPlayers.Remove(key); MapVote.UpdateButtonLabels(); } [IteratorStateMachine(typeof(<BuildPreview>d__28))] private static IEnumerator BuildPreview(string levelName) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <BuildPreview>d__28(0) { levelName = levelName }; } private static bool GridCheck(PreviewTile[,] grid, int x, int y, int w, int h) { if (x >= 0 && x < w && y >= 0 && y < h) { return grid[x, y].active; } return false; } private static bool TryProceduralGeneration(RunManager runManager, Level level, LevelGenerator levelGen) { //IL_0839: Unknown result type (might be due to invalid IL or missing references) //IL_07db: 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_07f4: Unknown result type (might be due to invalid IL or missing references) //IL_07f6: Unknown result type (might be due to invalid IL or missing references) //IL_08b6: Unknown result type (might be due to invalid IL or missing references) //IL_08d6: Unknown result type (might be due to invalid IL or missing references) //IL_08db: Unknown result type (might be due to invalid IL or missing references) //IL_08e0: Unknown result type (might be due to invalid IL or missing references) //IL_08e2: Unknown result type (might be due to invalid IL or missing references) //IL_08e7: Unknown result type (might be due to invalid IL or missing references) //IL_08f7: Unknown result type (might be due to invalid IL or missing references) //IL_08fd: Invalid comparison between Unknown and I4 //IL_09c6: Unknown result type (might be due to invalid IL or missing references) //IL_09cc: Invalid comparison between Unknown and I4 //IL_0934: Unknown result type (might be due to invalid IL or missing references) //IL_0939: Unknown result type (might be due to invalid IL or missing references) //IL_0a03: Unknown result type (might be due to invalid IL or missing references) //IL_0a08: Unknown result type (might be due to invalid IL or missing references) //IL_05f6: Unknown result type (might be due to invalid IL or missing references) //IL_0600: Expected O, but got Unknown //IL_060a: Unknown result type (might be due to invalid IL or missing references) //IL_0cb0: Unknown result type (might be due to invalid IL or missing references) //IL_0cbd: Unknown result type (might be due to invalid IL or missing references) //IL_0cbf: Unknown result type (might be due to invalid IL or missing references) //IL_0cc1: Unknown result type (might be due to invalid IL or missing references) //IL_0cce: Unknown result type (might be due to invalid IL or missing references) //IL_0cec: Unknown result type (might be due to invalid IL or missing references) //IL_0cee: Unknown result type (might be due to invalid IL or missing references) //IL_0cf0: Unknown result type (might be due to invalid IL or missing references) //IL_04c7: Unknown result type (might be due to invalid IL or missing references) //IL_0ea8: Unknown result type (might be due to invalid IL or missing references) //IL_0ebb: Unknown result type (might be due to invalid IL or missing references) //IL_0ec0: Unknown result type (might be due to invalid IL or missing references) //IL_0ec5: Unknown result type (might be due to invalid IL or missing references) //IL_0f03: Unknown result type (might be due to invalid IL or missing references) //IL_0f05: Unknown result type (might be due to invalid IL or missing references) //IL_0f07: Unknown result type (might be due to invalid IL or missing references) //IL_0f22: Unknown result type (might be due to invalid IL or missing references) //IL_0f24: Unknown result type (might be due to invalid IL or missing references) //IL_0f8a: Unknown result type (might be due to invalid IL or missing references) //IL_0f9d: Unknown result type (might be due to invalid IL or missing references) //IL_0fa2: Unknown result type (might be due to invalid IL or missing references) //IL_0fa7: Unknown result type (might be due to invalid IL or missing references) //IL_0fe5: Unknown result type (might be due to invalid IL or missing references) //IL_0fe7: Unknown result type (might be due to invalid IL or missing references) //IL_0fe9: Unknown result type (might be due to invalid IL or missing references) //IL_1004: Unknown result type (might be due to invalid IL or missing references) //IL_1015: Unknown result type (might be due to invalid IL or missing references) //IL_0732: Unknown result type (might be due to invalid IL or missing references) //IL_0734: 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_107b: Unknown result type (might be due to invalid IL or missing references) //IL_108e: Unknown result type (might be due to invalid IL or missing references) //IL_1093: Unknown result type (might be due to invalid IL or missing references) //IL_1098: Unknown result type (might be due to invalid IL or missing references) //IL_10d6: Unknown result type (might be due to invalid IL or missing references) //IL_10d8: Unknown result type (might be due to invalid IL or missing references) //IL_10da: Unknown result type (might be due to invalid IL or missing references) //IL_10f5: Unknown result type (might be due to invalid IL or missing references) //IL_10f7: Unknown result type (might be due to invalid IL or missing references) //IL_0bab: Unknown result type (might be due to invalid IL or missing references) //IL_0b95: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Unknown result type (might be due to invalid IL or missing references) //IL_032e: Unknown result type (might be due to invalid IL or missing references) //IL_115d: Unknown result type (might be due to invalid IL or missing references) //IL_1170: Unknown result type (might be due to invalid IL or missing references) //IL_1175: Unknown result type (might be due to invalid IL or missing references) //IL_117a: Unknown result type (might be due to invalid IL or missing references) //IL_11b8: Unknown result type (might be due to invalid IL or missing references) //IL_11ba: Unknown result type (might be due to invalid IL or missing references) //IL_11bc: Unknown result type (might be due to invalid IL or missing references) //IL_11d7: Unknown result type (might be due to invalid IL or missing references) //IL_11d9: Unknown result type (might be due to invalid IL or missing references) //IL_0c15: Unknown result type (might be due to invalid IL or missing references) //IL_0bff: Unknown result type (might be due to invalid IL or missing references) //IL_0bb0: Unknown result type (might be due to invalid IL or missing references) //IL_0c1a: Unknown result type (might be due to invalid IL or missing references) MapVote.Logger.LogInfo((object)"[PREVIEW] Attempting procedural generation (exact game algorithm)..."); _savedLevel = runManager.levelCurrent; float num = 5f; float num2 = 3f; float num3 = num2 * num; int num4 = 9; int num5 = 9; int num6 = Mathf.Max((level.ModuleAmount > 0) ? level.ModuleAmount : 6, 6); num6 = Mathf.Min(num6 * 2, num4 * num5 - 1); int num7 = Mathf.CeilToInt((float)num6 / 3f); int num8 = ((num6 >= 15) ? 4 : ((num6 >= 10) ? 3 : ((num6 >= 8) ? 2 : ((num6 >= 6) ? 1 : 0)))); PreviewTile[,] array = new PreviewTile[num4, num5]; for (int i = 0; i < num4; i++) { for (int j = 0; j < num5; j++) { array[i, j] = new PreviewTile { x = i, y = j }; } } int num9 = num4 / 2; int num10 = 0; array[num9, num10].active = true; array[num9, num10].first = true; int num11 = num6; int num12 = num9; int num13 = num10; int num14 = 10000; while (num11 > 0 && num14-- > 0) { int num15 = -999; int num16 = -999; while (num12 + num15 < 0 || num12 + num15 >= num4 || num13 + num16 < 0 || num13 + num16 >= num5) { num15 = 0; num16 = 0; switch ((num13 == 1) ? Random.Range(0, 3) : Random.Range(0, 4)) { case 0: num15 = -1; break; case 1: num15 = 1; break; case 2: num16 = 1; break; case 3: num16 = -1; break; } } num12 += num15; num13 += num16; if (!array[num12, num13].active) { array[num12, num13].active = true; num11--; } } List<PreviewTile> list = new List<PreviewTile>(); for (int k = 0; k < num4; k++) { for (int l = 0; l < num5; l++) { if (!array[k, l].active) { int num17 = 0; if (GridCheck(array, k, l + 1, num4, num5)) { num17++; } if (GridCheck(array, k + 1, l, num4, num5)) { num17++; } if (GridCheck(array, k, l - 1, num4, num5)) { num17++; } if (GridCheck(array, k - 1, l, num4, num5)) { num17++; } if (num17 == 1) { list.Add(array[k, l]); } } } } PreviewTile item = new PreviewTile { x = num9, y = -1 }; List<PreviewTile> list2 = new List<PreviewTile> { item }; int num18 = num8; while (num18 > 0 && list.Count > 0) { PreviewTile previewTile = null; float num19 = 0f; foreach (PreviewTile item2 in list) { float num20 = float.MaxValue; foreach (PreviewTile item3 in list2) { float num21 = Vector2.Distance(new Vector2((float)item3.x, (float)item3.y), new Vector2((float)item2.x, (float)item2.y)); if (num21 < num20) { num20 = num21; } } if (num20 > num19) { num19 = num20; previewTile = item2; } } if (previewTile == null) { break; } previewTile.type = (Type)3; previewTile.active = true; list2.Add(previewTile); list.Remove(previewTile); bool flag = true; while (flag) { flag = false; foreach (PreviewTile item4 in list) { if ((item4.x == previewTile.x && item4.y == previewTile.y - 1) || (item4.x == previewTile.x + 1 && item4.y == previewTile.y) || (item4.x == previewTile.x && item4.y == previewTile.y + 1) || (item4.x == previewTile.x - 1 && item4.y == previewTile.y)) { list.Remove(item4); flag = true; break; } } } num18--; } int num22 = num7; while (num22 > 0 && list.Count > 0) { PreviewTile previewTile2 = list[Random.Range(0, list.Count)]; previewTile2.type = (Type)2; previewTile2.active = true; list2.Add(previewTile2); list.Remove(previewTile2); bool flag2 = true; while (flag2) { flag2 = false; foreach (PreviewTile item5 in list) { if ((item5.x == previewTile2.x && item5.y == previewTile2.y - 1) || (item5.x == previewTile2.x + 1 && item5.y == previewTile2.y) || (item5.x == previewTile2.x && item5.y == previewTile2.y + 1) || (item5.x == previewTile2.x - 1 && item5.y == previewTile2.y)) { list.Remove(item5); flag2 = true; break; } } } num22--; } Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(0f, -3000f, 0f); _previewRoot = new GameObject("MapPreviewRoot"); _previewRoot.transform.position = val; List<GameObject> list3 = new List<GameObject>(); AddPrefabRefs(list3, level.ModulesNormal1); AddPrefabRefs(list3, level.ModulesNormal2); AddPrefabRefs(list3, level.ModulesNormal3); List<GameObject> list4 = new List<GameObject>(); AddPrefabRefs(list4, level.ModulesPassage1); AddPrefabRefs(list4, level.ModulesPassage2); AddPrefabRefs(list4, level.ModulesPassage3); List<GameObject> list5 = new List<GameObject>(); AddPrefabRefs(list5, level.ModulesDeadEnd1); AddPrefabRefs(list5, level.ModulesDeadEnd2); AddPrefabRefs(list5, level.ModulesDeadEnd3); List<GameObject> list6 = new List<GameObject>(); AddPrefabRefs(list6, level.ModulesExtraction1); AddPrefabRefs(list6, level.ModulesExtraction2); AddPrefabRefs(list6, level.ModulesExtraction3); if (level.StartRooms != null && level.StartRooms.Count > 0) { PrefabRef val2 = level.StartRooms[Random.Range(0, level.StartRooms.Count)]; if (val2 != null && (Object)(object)val2.Prefab != (Object)null) { MapVote.Logger.LogInfo((object)"[PREVIEW] Start room at origin (0,0,0) — game exact"); GameObject val3 = Object.Instantiate<GameObject>(val2.Prefab, val, Quaternion.identity, _previewRoot.transform); Module component = val3.GetComponent<Module>(); if ((Object)(object)component != (Object)null) { component.ConnectingTop = true; component.ConnectingBottom = true; component.ConnectingRight = false; component.ConnectingLeft = false; component.First = true; component.SetupDone = true; ModulePropSwitch[] componentsInChildren = val3.GetComponentsInChildren<ModulePropSwitch>(true); foreach (ModulePropSwitch val4 in componentsInChildren) { val4.Module = component; try { val4.Setup(); } catch { } } } StripComponents(val3); } } if ((Object)(object)level.ConnectObject != (Object)null) { Vector3 val5 = val; MapVote.Logger.LogInfo((object)"[CONN] Truck connection at pos=(0,0,0)"); GameObject obj2 = Object.Instantiate<GameObject>(level.ConnectObject, val5, Quaternion.identity, _previewRoot.transform); StripComponents(obj2); } MapVote.Logger.LogInfo((object)$"[PREVIEW] Start room at grid({num9},{num10}), world origin={val}, moduleWidth={num3}"); MapVote.Logger.LogInfo((object)$"[PREVIEW] Start grid formula: x={(float)num9 * num3 - (float)(num4 / 2) * num3}, z={(float)num10 * num3 + num3 / 2f}"); int num23 = 0; int num24 = 0; for (int n = 0; n < num4; n++) { for (int num25 = 0; num25 < num5; num25++) { if (!array[n, num25].active) { continue; } Vector3 val6 = val + new Vector3((float)n * num3 - (float)(num4 / 2) * num3, 0f, (float)num25 * num3 + num3 / 2f); Vector3 val7 = Vector3.zero; GameObject val8 = null; if ((int)array[n, num25].type == 3) { if (list6.Count > 0) { val8 = list6[Random.Range(0, list6.Count)]; } if (GridCheck(array, n, num25 - 1, num4, num5)) { val7 = Vector3.zero; } if (GridCheck(array, n - 1, num25, num4, num5)) { ((Vector3)(ref val7))..ctor(0f, 90f, 0f); } if (GridCheck(array, n, num25 + 1, num4, num5)) { ((Vector3)(ref val7))..ctor(0f, 180f, 0f); } if (GridCheck(array, n + 1, num25, num4, num5)) { ((Vector3)(ref val7))..ctor(0f, -90f, 0f); } } else if ((int)array[n, num25].type == 2) { if (list5.Count > 0) { val8 = list5[Random.Range(0, list5.Count)]; } if (GridCheck(array, n, num25 - 1, num4, num5)) { val7 = Vector3.zero; } if (GridCheck(array, n - 1, num25, num4, num5)) { ((Vector3)(ref val7))..ctor(0f, 90f, 0f); } if (GridCheck(array, n, num25 + 1, num4, num5)) { ((Vector3)(ref val7))..ctor(0f, 180f, 0f); } if (GridCheck(array, n + 1, num25, num4, num5)) { ((Vector3)(ref val7))..ctor(0f, -90f, 0f); } } else { bool flag3 = num24 < ((level.PassageMaxAmount > 0) ? level.PassageMaxAmount : 2); bool flag4 = GridCheck(array, n, num25 + 1, num4, num5) && (GridCheck(array, n, num25 - 1, num4, num5) || array[n, num25].first) && !GridCheck(array, n + 1, num25, num4, num5) && !GridCheck(array, n - 1, num25, num4, num5); bool flag5 = !array[n, num25].first && GridCheck(array, n + 1, num25, num4, num5) && GridCheck(array, n - 1, num25, num4, num5) && !GridCheck(array, n, num25 + 1, num4, num5) && !GridCheck(array, n, num25 - 1, num4, num5); if (flag3 && flag4 && list4.Count > 0) { val8 = list4[Random.Range(0, list4.Count)]; val7 = (Vector3)((Random.Range(0, 100) < 50) ? new Vector3(0f, 180f, 0f) : Vector3.zero); num24++; } else if (flag3 && flag5 && list4.Count > 0) { val8 = list4[Random.Range(0, list4.Count)]; val7 = ((Random.Range(0, 100) < 50) ? new Vector3(0f, -90f, 0f) : new Vector3(0f, 90f, 0f)); num24++; } else { if (list3.Count > 0) { val8 = list3[Random.Range(0, list3.Count)]; } float[] array2 = new float[4] { 0f, 90f, 180f, 270f }; ((Vector3)(ref val7))..ctor(0f, array2[Random.Range(0, 4)], 0f); } } if (!((Object)(object)val8 != (Object)null)) { continue; } MapVote.Logger.LogInfo((object)$"[PREVIEW] Module grid({n},{num25}) type={array[n, num25].type} pos={val6 - val} rot={val7} prefab={((Object)val8).name}"); GameObject val9 = Object.Instantiate<GameObject>(val8, val6, Quaternion.Euler(val7), _previewRoot.transform); bool connectingTop = GridCheck(array, n, num25 + 1, num4, num5); bool connectingBottom = GridCheck(array, n, num25 - 1, num4, num5) || array[n, num25].first; bool connectingRight = GridCheck(array, n + 1, num25, num4, num5); bool connectingLeft = GridCheck(array, n - 1, num25, num4, num5); Module component2 = val9.GetComponent<Module>(); if ((Object)(object)component2 != (Object)null) { component2.ConnectingTop = connectingTop; component2.ConnectingBottom = connectingBottom; component2.ConnectingRight = connectingRight; component2.ConnectingLeft = connectingLeft; component2.First = array[n, num25].first; component2.SetupDone = true; ModulePropSwitch[] componentsInChildren2 = val9.GetComponentsInChildren<ModulePropSwitch>(true); foreach (ModulePropSwitch val10 in componentsInChildren2) { val10.Module = component2; try { val10.Setup(); } catch { } } } StripComponents(val9); num23++; } } if ((Object)(object)level.ConnectObject != (Object)null) { for (int num27 = 0; num27 < num4; num27++) { for (int num28 = 0; num28 < num5; num28++) { if (array[num27, num28].active) { float num29 = (float)num27 * num3 - (float)(num4 / 2) * num3; float num30 = (float)num28 * num3 + num3 / 2f; if (num28 + 1 < num5 && array[num27, num28 + 1].active && !array[num27, num28 + 1].connectedBot) { Vector3 val11 = val + new Vector3(num29, 0f, num30 + num3 / 2f); MapVote.Logger.LogInfo((object)$"[CONN] Top: grid({num27},{num28})->({num27},{num28 + 1}) pos={val11 - val}"); GameObject obj4 = Object.Instantiate<GameObject>(level.ConnectObject, val11, Quaternion.identity, _previewRoot.transform); StripComponents(obj4); array[num27, num28].connectedTop = true; } if (num27 + 1 < num4 && array[num27 + 1, num28].active && !array[num27 + 1, num28].connectedLeft) { Vector3 val12 = val + new Vector3(num29 + num3 / 2f, 0f, num30); MapVote.Logger.LogInfo((object)$"[CONN] Right: grid({num27},{num28})->({num27 + 1},{num28}) pos={val12 - val} rot=90"); GameObject obj5 = Object.Instantiate<GameObject>(level.ConnectObject, val12, Quaternion.Euler(0f, 90f, 0f), _previewRoot.transform); StripComponents(obj5); array[num27, num28].connectedRight = true; } if (num28 - 1 >= 0 && array[num27, num28 - 1].active && !array[num27, num28 - 1].connectedTop) { Vector3 val13 = val + new Vector3(num29, 0f, num30 - num3 / 2f); MapVote.Logger.LogInfo((object)$"[CONN] Bottom: grid({num27},{num28})->({num27},{num28 - 1}) pos={val13 - val}"); GameObject obj6 = Object.Instantiate<GameObject>(level.ConnectObject, val13, Quaternion.identity, _previewRoot.transform); StripComponents(obj6); array[num27, num28].connectedBot = true; } if (num27 - 1 >= 0 && array[num27 - 1, num28].active && !array[num27 - 1, num28].connectedRight) { Vector3 val14 = val + new Vector3(num29 - num3 / 2f, 0f, num30); MapVote.Logger.LogInfo((object)$"[CONN] Left: grid({num27},{num28})->({num27 - 1},{num28}) pos={val14 - val}"); GameObject obj7 = Object.Instantiate<GameObject>(level.ConnectObject, val14, Quaternion.identity, _previewRoot.transform); StripComponents(obj7); array[num27, num28].connectedLeft = true; } } } } } runManager.levelCurrent = _savedLevel; MapVote.Logger.LogInfo((object)$"[PREVIEW] Procedural generation complete: {num23} modules + start room on {num4}x{num5} grid"); return num23 > 0; } [IteratorStateMachine(typeof(<BuildGridPreview>d__32))] private static IEnumerator BuildGridPreview(Level level) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <BuildGridPreview>d__32(0) { level = level }; } private static void AddPrefabRefs(List<GameObject> list, List<PrefabRef> source) { if (source == null) { return; } foreach (PrefabRef item in source) { if (item != null) { GameObject prefab = item.Prefab; if ((Object)(object)prefab != (Object)null) { list.Add(prefab); } } } } private static void StripComponents(GameObject obj) { MonoBehaviour[] componentsInChildren = obj.GetComponentsInChildren<MonoBehaviour>(true); foreach (MonoBehaviour val in componentsInChildren) { if ((Object)(object)val != (Object)null) { ((Behaviour)val).enabled = false; } } Collider[] componentsInChildren2 = obj.GetComponentsInChildren<Collider>(true); foreach (Collider val2 in componentsInChildren2) { if ((Object)(object)val2 != (Object)null) { val2.enabled = false; } } Rigidbody[] componentsInChildren3 = obj.GetComponentsInChildren<Rigidbody>(true); foreach (Rigidbody val3 in componentsInChildren3) { if ((Object)(object)val3 != (Object)null) { val3.isKinematic = true; } } AudioSource[] componentsInChildren4 = obj.GetComponentsInChildren<AudioSource>(true); foreach (AudioSource val4 in componentsInChildren4) { if ((Object)(object)val4 != (Object)null) { ((Behaviour)val4).enabled = false; } } Animator[] componentsInChildren5 = obj.GetComponentsInChildren<Animator>(true); foreach (Animator val5 in componentsInChildren5) { if ((Object)(object)val5 != (Object)null) { ((Behaviour)val5).enabled = false; } } ParticleSystem[] componentsInChildren6 = obj.GetComponentsInChildren<ParticleSystem>(true); foreach (ParticleSystem val6 in componentsInChildren6) { if ((Object)(object)val6 != (Object)null) { val6.Stop(); } } } private static void DisableLobby() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: 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_004b: Invalid comparison between Unknown and I4 _disabledRootObjects.Clear(); Scene activeScene = SceneManager.GetActiveScene(); GameObject[] rootGameObjects = ((Scene)(ref activeScene)).GetRootGameObjects(); foreach (GameObject val in rootGameObjects) { if (!((Object)(object)val == (Object)null) && val.activeSelf && !KEEP_ACTIVE.Contains(((Object)val).name) && (int)((Object)val).hideFlags != 61) { val.SetActive(false); _disabledRootObjects.Add(val); } } MapVote.Logger.LogInfo((object)$"[PREVIEW] Disabled {_disabledRootObjects.Count} root objects"); } private static void RestoreLobby() { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) foreach (GameObject disabledRootObject in _disabledRootObjects) { if ((Object)(object)disabledRootObject != (Object)null) { disabledRootObject.SetActive(true); } } RenderSettings.fog = _savedFog; RenderSettings.fogColor = _savedFogColor; RenderSettings.fogStartDistance = _savedFogStart; RenderSettings.fogEndDistance = _savedFogEnd; RenderSettings.fogMode = _savedFogMode; RenderSettings.ambientLight = _savedAmbientLight; MapVote.Logger.LogInfo((object)$"[PREVIEW] Re-enabled {_disabledRootObjects.Count} root objects"); _disabledRootObjects.Clear(); } private static void BroadcastPreviewStart(string levelName) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.IsMultiplayer()) { string nickName = PhotonNetwork.LocalPlayer.NickName; NetworkedEvent? onPreviewStart = MapVote.OnPreviewStart; if (onPreviewStart != null) { onPreviewStart.RaiseEvent((object)(nickName + "|" + levelName), NetworkingEvents.RaiseOthers, SendOptions.SendReliable); } } } private static void BroadcastPreviewEnd() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.IsMultiplayer()) { string nickName = PhotonNetwork.LocalPlayer.NickName; NetworkedEvent? onPreviewEnd = MapVote.OnPreviewEnd; if (onPreviewEnd != null) { onPreviewEnd.RaiseEvent((object)nickName, NetworkingEvents.RaiseOthers, SendOptions.SendReliable); } } } private void OnGUI() { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) if (State == PreviewState.Previewing) { float num = 150f; float num2 = 40f; float num3 = ((float)Screen.width - num) / 2f; float num4 = (float)Screen.height - num2 - 20f; if (GUI.Button(new Rect(num3, num4, num, num2), "Back to Vote")) { StopPreview(); } string text = Utilities.RemoveLevelPrefix(_previewLevelName ?? ""); GUIStyle val = new GUIStyle(GUI.skin.label) { fontSize = 16 }; val.normal.textColor = Color.white; GUI.Label(new Rect(10f, 10f, 600f, 30f), "Previewing: " + text + " | WASD move | Mouse look | Shift fast | Space/Ctrl up/down", val); } } } } namespace MapVoteWithPreview.Patches { [HarmonyPatch(typeof(HealthUI))] public class HealthUIPatch { [HarmonyPatch("Start")] [HarmonyPostfix] private static void PostfixStart(HealthUI __instance) { if (((Object)RunManager.instance.levelCurrent).name == "Level - Lobby") { ((MonoBehaviour)MapVote.Instance).StartCoroutine(MapVote.WaitForVote()); MapVote.CreateVotePopup(); } } } [HarmonyPatch(typeof(MenuManager))] internal class MenuManagerPatch { [HarmonyPatch("PageOpen")] [HarmonyPostfix] private static void PageOpenPostfix(MenuPageIndex menuPageIndex) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 if ((int)menuPageIndex == 8) { if (SemiFunc.IsMasterClientOrSingleplayer()) { MapVote.Reset(); MapVote.WonMap = null; } if (!MapVote.HideInMenu.Value) { MapVote.CreateVotePopup(isInMenu: true); } } } } [HarmonyPatch(typeof(MenuPageLobby))] internal class SteamManagerPatch { [HarmonyPatch("PlayerAdd")] [HarmonyPostfix] public static void PostfixJoiningPlayer() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_00