using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using Fusion;
using HarmonyLib;
using Il2CppInterop.Runtime.Injection;
using Il2CppSystem;
using MoreShiftAtMidnightPlayers.Patches;
using Steamworks;
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(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("MoreShiftAtMidnightPlayers")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+7d54229e3dc761247b4e7af5bcb6742a894cafbf")]
[assembly: AssemblyProduct("MoreShiftAtMidnightPlayers")]
[assembly: AssemblyTitle("MoreShiftAtMidnightPlayers")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace MoreShiftAtMidnightPlayers
{
[BepInPlugin("com.curiosity.moreshiftatmidnightplayers", "MoreShiftAtMidnightPlayers", "1.0.0")]
internal class Plugin : BasePlugin
{
internal static ManualLogSource MyLog;
internal static ConfigEntry<int> MaxPlayers;
internal static int SelectedMaxPlayers = 3;
public override void Load()
{
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Expected O, but got Unknown
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Expected O, but got Unknown
MyLog = ((BasePlugin)this).Log;
MyLog.LogInfo((object)"MoreShiftAtMidnightPlayers is loading...");
MaxPlayers = ((BasePlugin)this).Config.Bind<int>("General", "MaxPlayers", 32, new ConfigDescription("Max players per session", (AcceptableValueBase)(object)new AcceptableValueRange<int>(2, 99), Array.Empty<object>()));
ClassInjector.RegisterTypeInIl2Cpp<TextToggler>();
Harmony val = new Harmony("com.curiosity.moreshiftatmidnightplayers");
val.PatchAll();
MyLog.LogInfo((object)"Patches applied.");
}
}
}
namespace MoreShiftAtMidnightPlayers.Patches
{
[HarmonyPatch(typeof(CreateLobbySettings), "UpdateDropdownLanguage")]
internal class ExtendDropdownPatch
{
public static void Postfix(CreateLobbySettings __instance)
{
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Expected O, but got Unknown
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Expected O, but got Unknown
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Expected O, but got Unknown
bool flag = default(bool);
try
{
TMP_Dropdown maxPlayersDropdown = __instance.maxPlayersDropdown;
if (!((Object)(object)maxPlayersDropdown == (Object)null) && maxPlayersDropdown.options != null)
{
int value = Plugin.MaxPlayers.Value;
while (maxPlayersDropdown.options.Count < value)
{
int num = maxPlayersDropdown.options.Count + 1;
maxPlayersDropdown.options.Add(new OptionData(num.ToString()));
}
maxPlayersDropdown.RefreshShownValue();
ManualLogSource myLog = Plugin.MyLog;
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(29, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Dropdown extended to ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(value);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" options");
}
myLog.LogInfo(val);
}
}
catch (Exception ex)
{
ManualLogSource myLog2 = Plugin.MyLog;
BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(27, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Failed to extend dropdown: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
}
myLog2.LogError(val2);
}
}
}
[HarmonyPatch(typeof(NetworkRunner), "StartGame")]
internal class FusionStartGamePatch
{
public static void Prefix(StartGameArgs args)
{
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Expected O, but got Unknown
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Expected O, but got Unknown
bool flag = default(bool);
try
{
args.PlayerCount = new Nullable<int>(Plugin.SelectedMaxPlayers);
ManualLogSource myLog = Plugin.MyLog;
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(32, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Set StartGameArgs.PlayerCount = ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(Plugin.SelectedMaxPlayers);
}
myLog.LogInfo(val);
}
catch (Exception ex)
{
ManualLogSource myLog2 = Plugin.MyLog;
BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(27, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Failed to set PlayerCount: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
}
myLog2.LogError(val2);
}
}
}
[HarmonyPatch(typeof(PlatformManager_Steam), "HostLobby")]
internal class HostLobbyPatch
{
public static void Postfix()
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Expected O, but got Unknown
PlatformManager.s_MAXPLAYERS = Plugin.SelectedMaxPlayers;
ManualLogSource myLog = Plugin.MyLog;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(35, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Set PlatformManager.s_MAXPLAYERS = ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(Plugin.SelectedMaxPlayers);
}
myLog.LogInfo(val);
}
}
[HarmonyPatch(typeof(MainMenu), "Start")]
public static class MainMenuEasterEggPatch
{
public static void Postfix(MainMenu __instance)
{
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_013b: Expected O, but got Unknown
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Expected O, but got Unknown
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
try
{
GameObject val = new GameObject("Text");
Canvas val2 = Object.FindObjectOfType<Canvas>();
if ((Object)(object)val2 == (Object)null)
{
Plugin.MyLog.LogWarning((object)"No canvas found to attach text to.");
return;
}
val.transform.SetParent(((Component)val2).transform, false);
TextMeshProUGUI val3 = val.AddComponent<TextMeshProUGUI>();
((TMP_Text)val3).text = "ichiban kasuga";
((TMP_Text)val3).fontSize = 22f;
((Graphic)val3).color = Color.yellow;
((TMP_Text)val3).alignment = (TextAlignmentOptions)260;
RectTransform component = val.GetComponent<RectTransform>();
component.anchorMin = new Vector2(1f, 1f);
component.anchorMax = new Vector2(1f, 1f);
component.pivot = new Vector2(1f, 1f);
component.anchoredPosition = new Vector2(-20f, -100f);
component.sizeDelta = new Vector2(300f, 50f);
val.SetActive(false);
TextToggler textToggler = ((Component)val2).gameObject.AddComponent<TextToggler>();
textToggler.targetText = val;
Plugin.MyLog.LogInfo((object)"Text added to main menu.");
}
catch (Exception ex)
{
ManualLogSource myLog = Plugin.MyLog;
bool flag = default(bool);
BepInExErrorLogInterpolatedStringHandler val4 = new BepInExErrorLogInterpolatedStringHandler(20, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("Failed to add text: ");
((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(ex.Message);
}
myLog.LogError(val4);
}
}
}
[HarmonyPatch(typeof(CreateLobbySettings), "StartLobby")]
public static class ReadDropdownPatch
{
public static void Prefix(CreateLobbySettings __instance)
{
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Expected O, but got Unknown
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Expected O, but got Unknown
bool flag = default(bool);
try
{
int value = __instance.maxPlayersDropdown.value + 1;
Plugin.SelectedMaxPlayers = Math.Clamp(value, 1, Plugin.MaxPlayers.Value);
ManualLogSource myLog = Plugin.MyLog;
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(28, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Host selected max players = ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(Plugin.SelectedMaxPlayers);
}
myLog.LogInfo(val);
}
catch (Exception ex)
{
ManualLogSource myLog2 = Plugin.MyLog;
BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(35, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Failed to read dropdown selection: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
}
myLog2.LogError(val2);
}
}
}
[HarmonyPatch(typeof(SteamMatchmaking), "CreateLobby")]
internal class SteamLobbyPatch
{
public static void Prefix(ref int cMaxMembers)
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Expected O, but got Unknown
cMaxMembers = Plugin.SelectedMaxPlayers;
ManualLogSource myLog = Plugin.MyLog;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(23, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Overrode lobby size to ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(Plugin.SelectedMaxPlayers);
}
myLog.LogInfo(val);
}
}
public class TextToggler : MonoBehaviour
{
public GameObject targetText;
public TextToggler(IntPtr ptr)
: base(ptr)
{
}
private void Update()
{
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Expected O, but got Unknown
if (!Input.GetKeyDown((KeyCode)92))
{
return;
}
Plugin.MyLog.LogInfo((object)"Backslash pressed!");
if ((Object)(object)targetText != (Object)null)
{
targetText.SetActive(!targetText.activeSelf);
ManualLogSource myLog = Plugin.MyLog;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(25, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Text visibility toggled: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(targetText.activeSelf);
}
myLog.LogInfo(val);
}
else
{
Plugin.MyLog.LogWarning((object)"targetText is null!");
}
}
}
}