using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using Multiplayer;
using TMPro;
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(".NETFramework,Version=v4.0", FrameworkDisplayName = ".NET Framework 4")]
[assembly: AssemblyCompany("Permamiss")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Allows the configuration of the Max Player limit beyond vanilla capacity")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Configure_Max_Players")]
[assembly: AssemblyTitle("Configure_Max_Players")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace ConfigureMaxPlayers
{
[BepInPlugin("Configure_Max_Players", "Configure_Max_Players", "1.0.0")]
[BepInProcess("Human.exe")]
internal class Plugin : BaseUnityPlugin
{
[CompilerGenerated]
private sealed class <Start>d__7 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public Plugin <>4__this;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <Start>d__7(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Expected O, but got Unknown
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: 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
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitUntil((Func<bool>)delegate
{
if (Object.FindObjectsOfType<MenuSelector>().Length == 0)
{
return false;
}
playerCountSelector = (from menuSelector in Object.FindObjectsOfType<MenuSelector>()
where ((Object)menuSelector).name == "PlayerCountSelector"
select menuSelector).First();
return Object.op_Implicit((Object)(object)playerCountSelector);
});
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
<>2__current = (object)new WaitUntil((Func<bool>)delegate
{
mpLobbySettingsMenu = Object.FindObjectOfType<MultiplayerLobbySettingsMenu>();
return Object.op_Implicit((Object)(object)mpLobbySettingsMenu);
});
<>1__state = 2;
return true;
case 2:
<>1__state = -1;
<>2__current = (object)new WaitUntil((Func<bool>)delegate
{
rightArrow = ((Component)(from image in ((Component)playerCountSelector).GetComponentsInChildren<Image>()
where ((Object)image).name == "Right"
select image).First()).gameObject;
return Object.op_Implicit((Object)(object)rightArrow);
});
<>1__state = 3;
return true;
case 3:
<>1__state = -1;
SetMaxPlayerRange(playerCountSelector, configMaxPlayerRange.Value);
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
internal static ManualLogSource Logger;
internal static MenuSelector playerCountSelector;
internal static ConfigFile theConfig;
internal static ConfigEntry<int> configMaxPlayerRange;
internal static MultiplayerLobbySettingsMenu mpLobbySettingsMenu;
internal static GameObject rightArrow;
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
Logger.LogInfo((object)"Plugin Configure_Max_Players is loaded!");
theConfig = ((BaseUnityPlugin)this).Config;
configMaxPlayerRange = theConfig.Bind<int>("General", "Max Player Range", 64, "Set maximum range for maximum players for online lobby settings");
Shell.RegisterCommand("maxplayerrange", (Action<string>)delegate(string txt)
{
if (!string.IsNullOrEmpty(txt))
{
string[] array2 = txt.Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
if (array2.Length == 1 && int.TryParse(array2[0], out var result2))
{
result2 = Mathf.Max(8, result2);
if (Options.lobbyMaxPlayers > result2)
{
mpLobbySettingsMenu.MaxPlayersChanged(result2 - 2);
}
SetMaxPlayerRange(playerCountSelector, result2, updateConfig: true);
}
}
}, "maxplayerrange <number>\r\nSet maximum range for maximum players for online lobby settings");
Shell.RegisterCommand("maxplayers", (Action<string>)delegate(string txt)
{
if (!string.IsNullOrEmpty(txt))
{
string[] array = txt.Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
if (array.Length == 1 && int.TryParse(array[0], out var result))
{
result = Mathf.Max(2, result);
mpLobbySettingsMenu.MaxPlayersChanged(result - 2);
playerCountSelector.selectedIndex = result - 2;
SetMaxPlayerRange(playerCountSelector, result);
}
}
}, "maxplayers <number>\r\nSet maximum player count for online lobby settings");
}
private IEnumerator Start()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <Start>d__7(0)
{
<>4__this = this
};
}
protected static void SetMaxPlayerRange(MenuSelector instance, int newMaxPlayerCount, bool updateConfig = false)
{
newMaxPlayerCount = Mathf.Max(8, newMaxPlayerCount);
int num = instance.optionLabels.Length + 1;
int num2 = newMaxPlayerCount - num;
if (num2 != 0)
{
Logger.LogInfo((object)string.Format("{0} maximum number of players from {1} to {2} ({3})", (num2 > 0) ? "Increasing" : "Decreasing", num, newMaxPlayerCount, (num2 > 0) ? ("+" + num2) : ((object)num2)));
TextMeshProUGUI textObject = instance.optionLabels[0];
List<TextMeshProUGUI> list = instance.optionLabels.ToList();
for (int i = 0; i < num2; i++)
{
TextMeshProUGUI val = Clone_TextMeshProUGUI(textObject);
string text = (instance.optionLabels.Length + i + 2).ToString();
((TMP_Text)val).SetText(text);
((Object)val).name = text;
list.Add(val);
}
for (int j = 0; j < -num2; j++)
{
GameObject gameObject = ((Component)list.ElementAt(list.Count - 1)).gameObject;
list.RemoveAt(list.Count - 1);
Object.Destroy((Object)(object)gameObject);
}
rightArrow.transform.SetSiblingIndex(list.Count + 1);
instance.optionLabels = list.ToArray();
Logger.LogInfo((object)$"Successfully set max player count to {newMaxPlayerCount}!");
if (updateConfig)
{
configMaxPlayerRange.Value = newMaxPlayerCount;
theConfig.Save();
}
}
instance.RebindValue();
}
private static TextMeshProUGUI Clone_TextMeshProUGUI(TextMeshProUGUI textObject)
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
GameObject gameObject = ((Component)Object.Instantiate<TextMeshProUGUI>(textObject)).gameObject;
gameObject.transform.SetParent(((TMP_Text)textObject).transform.parent);
gameObject.transform.SetPositionAndRotation(((TMP_Text)textObject).transform.position, ((TMP_Text)textObject).transform.rotation);
gameObject.transform.localScale = ((TMP_Text)textObject).transform.localScale;
return gameObject.GetComponent<TextMeshProUGUI>();
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "Configure_Max_Players";
public const string PLUGIN_NAME = "Configure_Max_Players";
public const string PLUGIN_VERSION = "1.0.0";
}
}