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 MenuLib;
using MenuLib.MonoBehaviors;
using Microsoft.CodeAnalysis;
using MonoMod.RuntimeDetour;
using REPOLib.Modules;
using Sirenix.Utilities;
using TMPro;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("RAMP")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("REPO Mod to vote for a map out of a random selection based on MapVote")]
[assembly: AssemblyFileVersion("1.3.1.0")]
[assembly: AssemblyInformationalVersion("1.3.1+0dfc7ed5e892014af8072956db21b6e2e0e3f5ad")]
[assembly: AssemblyProduct("MapVotePlus")]
[assembly: AssemblyTitle("RAMP.MapVotePlus")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/sophie-maney/MapVotePlus")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.3.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 MapVotePlus
{
internal class CompatibilityPatches
{
private static readonly Dictionary<string, Action> Patches = new Dictionary<string, Action>();
public static void PopulatePatches()
{
Patches.Add("ViViKo.StartInShop", delegate
{
MapVotePlus.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();
MapVotePlus.Logger.LogInfo((object)("Ran Compatibility Patch for " + plugin.Key));
});
}
}
internal class DebugManager
{
public static void InitializeDebug()
{
PopulateMockData();
}
private static void PopulateMockData()
{
MapVotePlus.CurrentVotes[10] = "Level - Arctic";
MapVotePlus.CurrentVotes[11] = "Level - Manor";
MapVotePlus.CurrentVotes[12] = "Level - Wizard";
MapVotePlus.CurrentVotes[13] = "Level - Wizard";
MapVotePlus.CurrentVotes[14] = "Level - Wizard";
MapVotePlus.CurrentVotes[15] = "Random";
}
}
internal static class LevelColorDictionary
{
private static readonly Dictionary<string, string> _dictionary = new Dictionary<string, string>
{
{ "Random", "#ff0000" },
{ "Level - Manor", "#ff7330" },
{ "Level - Arctic", "#01ffe6" },
{ "Level - Wizard", "#a55bf1" },
{ "Level - Museum", "#ff7373" },
{ "Level - Hospital", "#95ff92" },
{ "Level - Stronghold", "#a89400" },
{ "Level - Garden", "#5f8e00" },
{ "Level - Bunker", "#bd955d" }
};
public static string GetColor(string key)
{
string value;
return _dictionary.TryGetValue(key, out value) ? value : "#ffffff";
}
}
[BepInPlugin("RAMP.MapVotePlus", "MapVotePlus", "1.3.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
internal sealed class MapVotePlus : BaseUnityPlugin
{
[Serializable]
[CompilerGenerated]
private sealed class <>c
{
public static readonly <>c <>9 = new <>c();
public static Predicate<Level> <>9__34_0;
public static Func<KeyValuePair<string, PluginInfo>, string> <>9__38_0;
public static BuilderDelegate <>9__41_0;
public static Action<KeyValuePair<int, string>> <>9__48_0;
public static Func<VoteOptionButton, global::<>f__AnonymousType0<VoteOptionButton, int>> <>9__51_0;
public static Func<global::<>f__AnonymousType0<VoteOptionButton, int>, int> <>9__51_1;
public static Func<global::<>f__AnonymousType0<VoteOptionButton, int>, VoteOptionButton> <>9__51_2;
public static Predicate<Level> <>9__55_0;
public static Func<Level, bool> <>9__56_0;
public static Func<Level, string> <>9__57_1;
public static Func<Level, string> <>9__57_2;
public static Func<Level, int, (Level level, int index)> <>9__58_2;
public static Action <>9__58_5;
public static ScrollViewBuilderDelegate <>9__58_1;
public static Action<VoteOptionButton> <>9__59_0;
public static Predicate<VoteOptionButton> <>9__60_0;
public static Func<VoteOptionButton, int> <>9__60_1;
public static Func<IGrouping<int, VoteOptionButton>, int> <>9__60_2;
public static Predicate<VoteOptionButton> <>9__60_5;
public static Predicate<VoteOptionButton> <>9__60_3;
public static Predicate<VoteOptionButton> <>9__60_6;
public static Predicate<VoteOptionButton> <>9__60_4;
internal bool <HookRunManagerSetRunLevel>b__34_0(Level x)
{
return ((Object)x).name == WonMap;
}
internal string <Awake>b__38_0(KeyValuePair<string, PluginInfo> x)
{
return x.Key;
}
internal void <Initialize>b__41_0(Transform parent)
{
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: 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)
<>c__DisplayClass41_0 CS$<>8__locals0 = new <>c__DisplayClass41_0
{
enabled = (((Object)RunManager.instance.levelCurrent).name == "Level - Lobby")
};
MenuAPI.CreateREPOButton(Utilities.ColorString("Vote Map", CS$<>8__locals0.enabled ? Color.yellow : Color.black) ?? "", (Action)delegate
{
if (CS$<>8__locals0.enabled)
{
CreateVotePopup(isInMenu: true);
}
}, parent, new Vector2(126f, 122f));
}
internal void <HandleOnSyncVotes>b__48_0(KeyValuePair<int, string> x)
{
CurrentVotes[x.Key] = x.Value;
}
internal global::<>f__AnonymousType0<VoteOptionButton, int> <GetSortedVoteOptions>b__51_0(VoteOptionButton b)
{
return new
{
Item = b,
Count = b.GetVotes(CurrentVotes.Values)
};
}
internal int <GetSortedVoteOptions>b__51_1(global::<>f__AnonymousType0<VoteOptionButton, int> b)
{
return b.Count;
}
internal VoteOptionButton <GetSortedVoteOptions>b__51_2(global::<>f__AnonymousType0<VoteOptionButton, int> b)
{
return b.Item;
}
internal bool <GetEligibleLevels>b__55_0(Level level)
{
return !HasBeenLastPlayed(((Object)level).name);
}
internal bool <GetLevels>b__56_0(Level l)
{
return CurrentVoteLevels.Contains(((Object)l).name);
}
internal string <CreateVotePopup>b__57_1(Level x)
{
return ((Object)x).name;
}
internal string <CreateVotePopup>b__57_2(Level x)
{
return ((Object)x).name;
}
internal (Level level, int index) <GenerateVoteOptions>b__58_2(Level level, int index)
{
return (level, index);
}
internal RectTransform <GenerateVoteOptions>b__58_1(Transform parent)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
REPOButton val = MenuAPI.CreateREPOButton((string)null, (Action)delegate
{
//IL_002c: 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", val, _isRandomButton: true));
return ((REPOElement)val).rectTransform;
}
internal void <GenerateVoteOptions>b__58_5()
{
//IL_002c: 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 void <UpdateButtonLabels>b__59_0(VoteOptionButton b)
{
b.UpdateLabel(_highlight: false, HasBeenLastPlayed(b.Level));
}
internal bool <GetEligibleOptions>b__60_0(VoteOptionButton x)
{
return !x.IsRandomButton;
}
internal int <GetEligibleOptions>b__60_1(VoteOptionButton x)
{
return x.GetVotes(CurrentVotes.Values);
}
internal int <GetEligibleOptions>b__60_2(IGrouping<int, VoteOptionButton> x)
{
return x.Key;
}
internal bool <GetEligibleOptions>b__60_5(VoteOptionButton x)
{
return x.Level == "Random";
}
internal bool <GetEligibleOptions>b__60_3(VoteOptionButton x)
{
return !HasBeenLastPlayed(x.Level);
}
internal bool <GetEligibleOptions>b__60_6(VoteOptionButton x)
{
return !x.IsRandomButton;
}
internal bool <GetEligibleOptions>b__60_4(VoteOptionButton x)
{
return x.IsRandomButton;
}
}
[CompilerGenerated]
private sealed class <>c__DisplayClass41_0
{
public bool enabled;
internal void <Initialize>b__1()
{
if (enabled)
{
CreateVotePopup(isInMenu: true);
}
}
}
[CompilerGenerated]
private sealed class <>c__DisplayClass62_0
{
public string winningMap;
internal bool <OnVotingDone>b__0(VoteOptionButton x)
{
return x.Level == winningMap;
}
}
[CompilerGenerated]
private sealed class <BlinkButton>d__63 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public VoteOptionButton voteOption;
private int <maxBlinks>5__1;
private int <currentBlink>5__2;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <BlinkButton>d__63(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Expected O, but got Unknown
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<maxBlinks>5__1 = (int)Mathf.Ceil(6f);
<currentBlink>5__2 = 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__2++;
break;
}
if (<currentBlink>5__2 < <maxBlinks>5__1)
{
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__62 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public string winningMap;
private <>c__DisplayClass62_0 <>8__1;
private List<VoteOptionButton> <eligibleOptions>5__2;
private int <winningIndex>5__3;
private VoteOptionButton <wonOption>5__4;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <OnVotingDone>d__62(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>8__1 = null;
<eligibleOptions>5__2 = null;
<wonOption>5__4 = null;
<>1__state = -2;
}
private bool MoveNext()
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>8__1 = new <>c__DisplayClass62_0();
<>8__1.winningMap = winningMap;
DisableInput = true;
ShouldHookRunMangerSetRunLevel = true;
WonMap = <>8__1.winningMap;
<eligibleOptions>5__2 = GetEligibleOptions();
if (<eligibleOptions>5__2.Count > 1)
{
<winningIndex>5__3 = <eligibleOptions>5__2.FindIndex((VoteOptionButton x) => x.Level == <>8__1.winningMap);
<>2__current = ((MonoBehaviour)Instance).StartCoroutine(SpinWheelOptions(<eligibleOptions>5__2, <winningIndex>5__3));
<>1__state = 1;
return true;
}
<wonOption>5__4 = <eligibleOptions>5__2.FirstOrDefault();
if (<wonOption>5__4 != null)
{
<>2__current = ((MonoBehaviour)Instance).StartCoroutine(BlinkButton(<wonOption>5__4));
<>1__state = 3;
return true;
}
goto IL_016b;
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;
goto IL_016b;
}
IL_016b:
<wonOption>5__4 = null;
break;
}
DisableInput = false;
if (SemiFunc.RunIsLobby())
{
CreateNextMapLabel(WonMap);
REPOPopupPage? votePopup = VotePopup;
if (votePopup != 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__64 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public List<VoteOptionButton> eligibleOptions;
public int winningIndex;
private float <delay>5__1;
private int <index>5__2;
private int <endIndex>5__3;
private int <recentIndex>5__4;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <SpinWheelOptions>d__64(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Expected O, but got Unknown
int num = <>1__state;
if (num != 0)
{
if (num != 1)
{
return false;
}
<>1__state = -1;
if (<delay>5__1 > 0.4f && <index>5__2 == <endIndex>5__3)
{
goto IL_0136;
}
<delay>5__1 *= 1.15f;
<recentIndex>5__4 = <index>5__2;
<index>5__2 = (<index>5__2 + 1) % eligibleOptions.Count;
}
else
{
<>1__state = -1;
<delay>5__1 = 0.05f;
<index>5__2 = 0;
<endIndex>5__3 = winningIndex;
<recentIndex>5__4 = -1;
}
if (<index>5__2 != <endIndex>5__3 || <delay>5__1 < 0.5f)
{
eligibleOptions[<index>5__2].UpdateLabel(_highlight: true);
if (<recentIndex>5__4 >= 0)
{
eligibleOptions[<recentIndex>5__4].UpdateLabel();
}
<>2__current = (object)new WaitForSeconds(<delay>5__1);
<>1__state = 1;
return true;
}
goto IL_0136;
IL_0136:
eligibleOptions[<recentIndex>5__4].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__54 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
private string <format>5__1;
private NumberFormatInfo <nfi>5__2;
private string <map>5__3;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <StartCountdown>d__54(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<format>5__1 = null;
<nfi>5__2 = null;
<map>5__3 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_016b: Unknown result type (might be due to invalid IL or missing references)
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__1 = "00.00";
<nfi>5__2 = 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__1, <nfi>5__2) + "</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())
{
<map>5__3 = GetWinningMap();
NetworkedEvent? onVoteEndedEvent = OnVoteEndedEvent;
if (onVoteEndedEvent != null)
{
onVoteEndedEvent.RaiseEvent((object)<map>5__3, NetworkingEvents.RaiseOthers, SendOptions.SendReliable);
}
((MonoBehaviour)Instance).StartCoroutine(OnVotingDone(<map>5__3));
<map>5__3 = null;
}
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__53 : 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__53(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: 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("MapVotePlus");
public static NetworkedEvent? OnVoteEvent;
public static NetworkedEvent? OnVoteEndedEvent;
public static NetworkedEvent? OnSyncVotes;
public static NetworkedEvent? OnSyncLastMapPlayed;
public static NetworkedEvent? OnStartCountdown;
public static NetworkedEvent? OnMapsRandomized;
public static NetworkedEvent? OnPlayerConnected;
public static ConfigEntry<int> VotingTime;
public static ConfigEntry<bool> HideInMenu;
public static ConfigEntry<bool> NoRepeatedMaps;
public static ConfigEntry<int> VoteableLevelNumber;
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 List<string> CurrentVoteLevels = new List<string>();
public static MapVotePlus Instance;
private static readonly 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 readonly 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_006a: Unknown result type (might be due to invalid IL or missing references)
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_005c: Unknown result type (might be due to invalid IL or missing references)
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_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Expected O, but got Unknown
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Expected O, but got Unknown
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Expected O, but got Unknown
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: 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", true, 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>()));
VoteableLevelNumber = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Number of voteable levels", 3, new ConfigDescription("The number of levels that can be voted for. 0 = all levels", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 10), Array.Empty<object>()));
CompatibilityPatches.RunPatches(Chainloader.PluginInfos.Select((KeyValuePair<string, PluginInfo> x) => x.Key).ToList());
Initialize();
Logger.LogDebug((object)"Loaded MapVotePlus V1.3.1!");
}
internal void Patch()
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected O, but got Unknown
//IL_0027: 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_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Expected O, but got Unknown
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Expected O, but got Unknown
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Expected O, but got Unknown
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Expected O, but got Unknown
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: Expected O, but got Unknown
//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
//IL_00fd: Expected O, but got Unknown
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Expected O, but got Unknown
//IL_013b: Unknown result type (might be due to invalid IL or missing references)
//IL_0140: Unknown result type (might be due to invalid IL or missing references)
//IL_0146: 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);
OnMapsRandomized = new NetworkedEvent("OnMapsRandomized", (Action<EventData>)HandleOnMapsRandomized);
OnPlayerConnected = new NetworkedEvent("OnPlayerConnected", (Action<EventData>)HandleOnPlayerConnected);
object obj = <>c.<>9__41_0;
if (obj == null)
{
BuilderDelegate val = delegate(Transform parent)
{
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: 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)
bool enabled = ((Object)RunManager.instance.levelCurrent).name == "Level - Lobby";
MenuAPI.CreateREPOButton(Utilities.ColorString("Vote Map", enabled ? Color.yellow : Color.black) ?? "", (Action)delegate
{
if (enabled)
{
CreateVotePopup(isInMenu: true);
}
}, parent, new Vector2(126f, 122f));
};
<>c.<>9__41_0 = val;
obj = (object)val;
}
MenuAPI.AddElementToEscapeMenu((BuilderDelegate)obj);
}
public static bool HasBeenLastPlayed(string? level)
{
if (level == null || !NoRepeatedMaps.Value)
{
return false;
}
return LastMapPlayed == level && LastMapPlayed != WonMap;
}
public static void Reset()
{
CurrentVotes.Values.Clear();
VoteOptionButtons.Clear();
CurrentVoteLevels.Clear();
OwnVoteLevel = null;
UpdateButtonLabels();
}
private static void HandleOnPlayerConnected(EventData data)
{
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
if (SemiFunc.IsMasterClientOrSingleplayer())
{
Logger.LogMessage((object)"Received player connected event, sending level data");
NetworkedEvent? onMapsRandomized = OnMapsRandomized;
if (onMapsRandomized != null)
{
onMapsRandomized.RaiseEvent((object)CurrentVoteLevels.ToArray(), NetworkingEvents.RaiseOthers, SendOptions.SendReliable);
}
}
}
private static void HandleOnMapsRandomized(EventData data)
{
if (!SemiFunc.IsMasterClientOrSingleplayer())
{
CurrentVoteLevels = ((string[])data.CustomData).ToList();
Logger.LogMessage((object)$"Randomized maps received, generating {CurrentVoteLevels.Count} vote options");
CreateVotePopup(isInMenu: true);
}
}
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));
}
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_001b: 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__53))]
public static IEnumerator WaitForVote()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <WaitForVote>d__53(0);
}
[IteratorStateMachine(typeof(<StartCountdown>d__54))]
public static IEnumerator StartCountdown()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <StartCountdown>d__54(0);
}
public static List<Level> GetEligibleLevels(RunManager? runManager = null)
{
if (runManager == null)
{
runManager = Object.FindObjectOfType<RunManager>();
}
List<Level> list = runManager.levels;
if (NoRepeatedMaps.Value)
{
list = list.FindAll((Level level) => !HasBeenLastPlayed(((Object)level).name));
}
return list;
}
public static List<Level> GetLevels(bool reRandomize = true)
{
RunManager val = Object.FindObjectOfType<RunManager>();
if (!reRandomize)
{
return val.levels.Where((Level l) => CurrentVoteLevels.Contains(((Object)l).name)).ToList();
}
if (VoteableLevelNumber.Value <= 0)
{
Logger.LogMessage((object)"Starting a vote for all levels");
return val.levels;
}
List<Level> eligibleLevels = GetEligibleLevels(val);
int count = eligibleLevels.Count;
int num = ((count < VoteableLevelNumber.Value) ? count : VoteableLevelNumber.Value);
for (int num2 = eligibleLevels.Count - 1; num2 > 0; num2--)
{
int num3 = Random.Range(0, num2 + 1);
List<Level> list = eligibleLevels;
int index = num2;
int index2 = num3;
Level value = eligibleLevels[num3];
Level value2 = eligibleLevels[num2];
list[index] = value;
eligibleLevels[index2] = value2;
}
Logger.LogMessage((object)$"Starting a vote for {num} levels");
return eligibleLevels.ToList().Take(num).ToList();
}
public static void CreateVotePopup(bool isInMenu = false, bool isInLobby = false)
{
//IL_0174: Unknown result type (might be due to invalid IL or missing references)
//IL_017e: Expected O, but got Unknown
//IL_013e: Unknown result type (might be due to invalid IL or missing references)
MenuAPI.CloseAllPagesAddedOnTop();
VoteOptionButtons.Clear();
REPOPopupPage? votePopup = VotePopup;
if (votePopup != null)
{
votePopup.ClosePage(true);
}
VotePopup = null;
if (((Object)RunManager.instance.levelCurrent).name == "Level - Lobby")
{
GameDirector.instance.DisableInput = true;
}
RunManager val = Object.FindObjectOfType<RunManager>();
if (SemiFunc.IsMasterClientOrSingleplayer())
{
if (CurrentVoteLevels.Count <= 0)
{
List<Level> levels = GetLevels();
CurrentVoteLevels = levels.Select((Level x) => ((Object)x).name).ToList();
Logger.LogMessage((object)$"{CurrentVoteLevels.Count} random maps selected, sending to clients");
}
else
{
List<Level> levels2 = GetLevels(reRandomize: false);
CurrentVoteLevels = levels2.Select((Level x) => ((Object)x).name).ToList();
}
NetworkedEvent? onMapsRandomized = OnMapsRandomized;
if (onMapsRandomized != null)
{
onMapsRandomized.RaiseEvent((object)CurrentVoteLevels.ToArray(), NetworkingEvents.RaiseOthers, SendOptions.SendReliable);
}
GenerateVoteOptions(isInMenu, isInLobby);
}
else
{
GenerateVoteOptions(isInMenu, isInLobby);
}
VotePopup.AddElement((BuilderDelegate)delegate(Transform parent)
{
//IL_001c: 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 GenerateVoteOptions(bool isInMenu = false, bool isInLobby = false)
{
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Expected O, but got Unknown
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Expected O, but got Unknown
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_0119: Unknown result type (might be due to invalid IL or missing references)
//IL_011f: Expected O, but got Unknown
List<Level> levels = GetLevels(reRandomize: false);
VotePopup = MenuAPI.CreateREPOPopupPage("Vote map", true, !isInMenu, 0f, (Vector2?)(isInMenu ? new Vector2(40f, 0f) : new Vector2(-100f, 0f)));
VotePopup.onEscapePressed = (ShouldCloseMenuDelegate)(() => !isInLobby);
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_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
REPOButton val5 = MenuAPI.CreateREPOButton((string)null, (Action)delegate
{
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
if (!DisableInput)
{
OwnVoteLevel = name;
NetworkedEvent? onVoteEvent2 = OnVoteEvent;
if (onVoteEvent2 != null)
{
onVoteEvent2.RaiseEvent((object)name, NetworkingEvents.RaiseAll, SendOptions.SendReliable);
}
}
}, parent, default(Vector2));
if (HasBeenLastPlayed(name))
{
((Component)val5).gameObject.GetComponent<MenuButton>().disabled = true;
}
HorizontalLayoutGroup val6 = ComponentHolderProtocol.AddComponent<HorizontalLayoutGroup>((Object)(object)val5);
((HorizontalOrVerticalLayoutGroup)val6).spacing = 235f;
GameObject val7 = Object.Instantiate<GameObject>(((Component)val5.labelTMP).gameObject, ((Component)val5).transform);
TextMeshProUGUI component2 = val7.GetComponent<TextMeshProUGUI>();
((TMP_Text)component2).horizontalAlignment = (HorizontalAlignmentOptions)4;
VoteOptionButtons.Add(new VoteOptionButton(name, val5));
return ((REPOElement)val5).rectTransform;
}, 0f, 0f);
}
REPOPopupPage? votePopup = VotePopup;
object obj = <>c.<>9__58_1;
if (obj == null)
{
ScrollViewBuilderDelegate val = delegate(Transform parent)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
REPOButton val2 = MenuAPI.CreateREPOButton((string)null, (Action)delegate
{
//IL_002c: 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 val3 = ComponentHolderProtocol.AddComponent<HorizontalLayoutGroup>((Object)(object)val2);
((HorizontalOrVerticalLayoutGroup)val3).spacing = 235f;
GameObject val4 = Object.Instantiate<GameObject>(((Component)val2.labelTMP).gameObject, ((Component)val2).transform);
TextMeshProUGUI component = val4.GetComponent<TextMeshProUGUI>();
((TMP_Text)component).horizontalAlignment = (HorizontalAlignmentOptions)4;
VoteOptionButtons.Add(new VoteOptionButton("Random", val2, _isRandomButton: true));
return ((REPOElement)val2).rectTransform;
};
<>c.<>9__58_1 = val;
obj = (object)val;
}
votePopup.AddElementToScrollView((ScrollViewBuilderDelegate)obj, 0f, 0f);
}
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__62))]
public static IEnumerator OnVotingDone(string winningMap)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <OnVotingDone>d__62(0)
{
winningMap = winningMap
};
}
[IteratorStateMachine(typeof(<BlinkButton>d__63))]
public static IEnumerator BlinkButton(VoteOptionButton voteOption)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <BlinkButton>d__63(0)
{
voteOption = voteOption
};
}
[IteratorStateMachine(typeof(<SpinWheelOptions>d__64))]
public static IEnumerator SpinWheelOptions(List<VoteOptionButton> eligibleOptions, int winningIndex)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <SpinWheelOptions>d__64(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_0011: 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, REPOButton _button, bool _isRandomButton = false)
{
Level = _level;
Button = _button;
IsRandomButton = _isRandomButton;
base..ctor();
}
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_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_018b: Unknown result type (might be due to invalid IL or missing references)
//IL_019f: Unknown result type (might be due to invalid IL or missing references)
Dictionary<int, string> values = MapVotePlus.CurrentVotes.Values;
bool flag = MapVotePlus.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 : Color.white));
string text = (_highlight ? ("#" + XColor.ToHexString(Color.green)) : (flag ? ("#" + XColor.ToHexString(Color.yellow)) : LevelColorDictionary.GetColor(Level)));
StringBuilder stringBuilder = new StringBuilder();
if (_disabled)
{
stringBuilder.Append("<s>");
}
stringBuilder.Append("<mspace=0.25em>[" + Utilities.ColorString(_highlight ? "O" : (flag ? "X" : " "), color) + "]</mspace> ");
if (!_disabled)
{
stringBuilder.Append("<color=" + text + ">");
}
stringBuilder.Append((IsRandomButton ? "Random" : Utilities.RemoveLevelPrefix(Level)) ?? "");
if (!_disabled)
{
stringBuilder.Append("</color>");
}
if (_disabled)
{
stringBuilder.Append("</s>");
}
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.gray);
((TMP_Text)Button.labelTMP).text = $"{stringBuilder}";
}
}
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;
MapVotePlus.UpdateButtonLabels();
}
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "RAMP.MapVotePlus";
public const string PLUGIN_NAME = "MapVotePlus";
public const string PLUGIN_VERSION = "1.3.1";
}
}
namespace MapVotePlus.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)MapVotePlus.Instance).StartCoroutine(MapVotePlus.WaitForVote());
MapVotePlus.CreateVotePopup();
}
}
}
[HarmonyPatch(typeof(MenuManager))]
internal class MenuManagerPatch
{
[HarmonyPatch("PageOpen")]
[HarmonyPostfix]
private static void PageOpenPostfix(MenuPageIndex menuPageIndex)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Invalid comparison between Unknown and I4
if ((int)menuPageIndex == 8)
{
if (SemiFunc.IsMasterClientOrSingleplayer())
{
MapVotePlus.Reset();
MapVotePlus.WonMap = null;
}
if (!MapVotePlus.HideInMenu.Value)
{
MapVotePlus.CreateVotePopup(isInMenu: true, isInLobby: true);
}
bool flag = false;
}
}
}
[HarmonyPatch(typeof(MenuPageLobby))]
internal class SteamManagerPatch
{
[HarmonyPatch("PlayerAdd")]
[HarmonyPostfix]
public static void PostfixJoiningPlayer()
{
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
if (SemiFunc.IsMasterClient())
{
NetworkedEvent? onSyncVotes = MapVotePlus.OnSyncVotes;
if (onSyncVotes != null)
{
onSyncVotes.RaiseEvent((object)MapVotePlus.CurrentVotes.Values, NetworkingEvents.RaiseAll, SendOptions.SendReliable);
}
NetworkedEvent? onSyncLastMapPlayed = MapVotePlus.OnSyncLastMapPlayed;
if (onSyncLastMapPlayed != null)
{
onSyncLastMapPlayed.RaiseEvent((object)MapVotePlus.LastMapPlayed, NetworkingEvents.RaiseOthers, SendOptions.SendReliable);
}
}
else
{
NetworkedEvent? onPlayerConnected = MapVotePlus.OnPlayerConnected;
if (onPlayerConnected != null)
{
onPlayerConnected.RaiseEvent((object)"", NetworkingEvents.RaiseAll, SendOptions.SendReliable);
}
}
}
}
}