using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using Gameplay.GalaxyMap;
using Gameplay.MissionDifficulty;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Steamworks;
using UI.Settings;
using UnityEngine.UI;
using UnityEngine.UIElements;
[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: AssemblyCompany("HobosInSpace")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyDescription("This mod increases the player max to 8 per lobby.")]
[assembly: AssemblyFileVersion("0.0.3.0")]
[assembly: AssemblyInformationalVersion("0.0.3+1520529dddbcc046d75823b85993a6297cedd341")]
[assembly: AssemblyProduct("Voider_Crew")]
[assembly: AssemblyTitle("Voider Crew")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/bls220/Void_Crew_Mods/tree/main/Voider_Crew")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.3.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 Voider_Crew
{
[BepInPlugin("Space.HobosIn.Voider_Crew", "Voider_Crew", "0.0.3")]
public class Plugin : BaseUnityPlugin
{
[HarmonyPatch(typeof(DifficultyPlayerCountTable))]
private static class DifficultyPlayerCountTablePatch
{
[HarmonyFinalizer]
[HarmonyPatch("GetConfig")]
private static Exception? GetConfig_Finalizer(int playerCount, Exception? __exception, DifficultyPlayerCountTable __instance, ref DifficultyConfig __result)
{
if (__exception == null || playerCount <= 4)
{
ManualLogSource? staticLogger = StaticLogger;
if (staticLogger != null)
{
staticLogger.LogDebug((object)$"Found Difficulty config for {playerCount:D} players. Config = {__result}");
}
return __exception;
}
ManualLogSource? staticLogger2 = StaticLogger;
if (staticLogger2 != null)
{
staticLogger2.LogDebug((object)$"Did NOT find Difficulty config for {playerCount:D} players. Config = {__result}");
}
try
{
__result = __instance.GetConfig(4);
return null;
}
catch (Exception)
{
return __exception;
}
}
}
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
private static class MatchmakingRoomSetupPatch
{
private static IntSetting Patch()
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Expected O, but got Unknown
IntSetting setting = new IntSetting(NewMaxPlayers, 1, NewMaxPlayers);
((Setting<int>)(object)setting).OnValueChanged = (Action<int>)Delegate.Combine(((Setting<int>)(object)setting).OnValueChanged, (Action<int>)delegate(int newVal)
{
OnPlayerLimitChanged(setting, newVal);
});
return setting;
}
private static void OnPlayerLimitChanged(IntSetting setting, int newValue)
{
if (PhotonNetwork.IsMasterClient)
{
((Setting<int>)(object)setting).SetValue(Instance.CurrentMaxPlayer, true);
}
ManualLogSource? staticLogger = StaticLogger;
if (staticLogger != null)
{
staticLogger.LogDebug((object)$"Player limit changed to: {newValue}, setting = {setting.Value}");
}
}
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> Constructor_Transpiler(IEnumerable<CodeInstruction> codeInstructionsEnumerable)
{
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Expected O, but got Unknown
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Expected O, but got Unknown
List<CodeInstruction> list = codeInstructionsEnumerable.ToList();
for (int i = 0; i < list.Count; i++)
{
CodeInstruction val = list[i];
if (val.opcode == OpCodes.Stfld && val.operand == AccessTools.Field(typeof(MatchmakingRoomSetup), "playerLimit"))
{
list.Insert(i, new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MatchmakingRoomSetupPatch), "Patch", (Type[])null, (Type[])null)));
list.Insert(i, new CodeInstruction(OpCodes.Pop, (object)null));
break;
}
}
return list;
}
[HarmonyPostfix]
private static void Constructor_Postfix(VisualElement root)
{
SliderIntSettingEntryVE val = UQueryExtensions.Q<SliderIntSettingEntryVE>(root, "PlayerSlider", new string[2]);
if (val == null)
{
ManualLogSource? staticLogger = StaticLogger;
if (staticLogger != null)
{
staticLogger.LogError((object)"Unable to find the PlayerSlider");
}
return;
}
object? value = AccessTools.Field(typeof(SliderIntSettingEntryVE), "slider").GetValue(val);
SliderInt val2 = (SliderInt)((value is SliderInt) ? value : null);
if (val2 == null)
{
ManualLogSource? staticLogger2 = StaticLogger;
if (staticLogger2 != null)
{
staticLogger2.LogError((object)"Unable to find the PlayerSlider.slider");
}
return;
}
((BaseSlider<int>)(object)val2).highValue = NewMaxPlayers;
INotifyValueChangedExtensions.RegisterValueChangedCallback<int>((INotifyValueChanged<int>)(object)val2, (EventCallback<ChangeEvent<int>>)delegate(ChangeEvent<int> evt)
{
ManualLogSource? staticLogger3 = StaticLogger;
if (staticLogger3 != null)
{
staticLogger3.LogDebug((object)$"Player limit slider changed to {evt.newValue}");
}
Instance.CurrentMaxPlayer = evt.newValue;
});
}
}
[HarmonyPatch]
private static class PhotonServicePatch
{
[HarmonyPrefix]
[HarmonyPatch(typeof(PhotonService), "SetCurrentRoomPlayerLimit", new Type[] { typeof(int) })]
private static bool SetCurrentRoomPlayerLimitPatch(int limit)
{
ManualLogSource? staticLogger = StaticLogger;
if (staticLogger != null)
{
staticLogger.LogDebug((object)$"PhotonService: Changed Player limit: {limit}");
}
return PhotonNetwork.IsMasterClient;
}
}
[HarmonyPatch(typeof(QuestInfoPopUp))]
private static class QuestInfoPopUpPatch
{
[HarmonyPostfix]
[HarmonyPatch("OnPlayerCountUpdated")]
private static void OnPlayerCountUpdated_Postfix(ref Button ___startButton)
{
((Selectable)___startButton).interactable = true;
}
}
[HarmonyPatch(typeof(SteamMatchmaking))]
private static class SteamMatchmakingPatch
{
[HarmonyPrefix]
[HarmonyPatch("CreateLobby")]
private static void CreateLobby_Prefix(ELobbyType eLobbyType, ref int cMaxMembers)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
ManualLogSource? staticLogger = StaticLogger;
if (staticLogger != null)
{
staticLogger.LogDebug((object)$"Intercepted CreateLobby with LobbyType: {eLobbyType}, MaxMembers: {cMaxMembers}. Changing to {NewMaxPlayers}");
}
cMaxMembers = NewMaxPlayers;
}
}
private static readonly Harmony _harmony = new Harmony("Space.HobosIn.Voider_Crew");
public static ManualLogSource? StaticLogger { get; private set; }
public static Plugin Instance { get; private set; } = null;
protected static int NewMaxPlayers { get; private set; } = 8;
private int CurrentMaxPlayer { get; set; } = 4;
protected Plugin()
{
Instance = this;
}
private void Awake()
{
//IL_0032: Expected O, but got Unknown
StaticLogger = ((BaseUnityPlugin)Instance).Logger;
((BaseUnityPlugin)this).Logger.LogDebug((object)"Plugin Space.HobosIn.Voider_Crew is loading!");
try
{
_harmony.PatchAll();
}
catch (HarmonyException val)
{
HarmonyException val2 = val;
((BaseUnityPlugin)this).Logger.LogError((object)((Exception)(object)val2).Message);
((BaseUnityPlugin)this).Logger.LogError((object)"Plugin Space.HobosIn.Voider_Crew failed to patch!");
return;
}
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin Space.HobosIn.Voider_Crew is loaded!");
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "Space.HobosIn.Voider_Crew";
public const string PLUGIN_NAME = "Voider_Crew";
public const string PLUGIN_VERSION = "0.0.3";
}
}