v0.3.0
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
using HarmonyLib;
|
||||
using Kitchen.NetworkSupport;
|
||||
using Steamworks;
|
||||
using Steamworks.Data;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MMOKitchen.Patches
|
||||
{
|
||||
/*
|
||||
* This patch is used to change how many players can join the lobby using Steam.
|
||||
*/
|
||||
|
||||
[HarmonyPatch(typeof(SteamPlatform), "CreateNewLobby")]
|
||||
public class SteamPlatformPatch
|
||||
{
|
||||
public static bool Prefix(SteamPlatform __instance, Action<bool, Lobby> callback)
|
||||
{
|
||||
if (__instance.IsReady)
|
||||
{
|
||||
SteamMatchmaking.CreateLobbyAsync(Mod.MaxPlayers).ContinueWith(delegate (Task<Lobby?> task)
|
||||
{
|
||||
if (task.IsCompleted && task.Result != null)
|
||||
{
|
||||
Lobby valueOrDefault = task.Result.GetValueOrDefault();
|
||||
__instance.CurrentInviteLobby = valueOrDefault;
|
||||
|
||||
MethodInfo performSetPermissions = AccessTools.Method(typeof(SteamPlatform), "PerformSetPermissions");
|
||||
performSetPermissions.Invoke(__instance, new object[] { __instance.Permissions });
|
||||
callback(true, valueOrDefault);
|
||||
}
|
||||
else
|
||||
{
|
||||
callback(false, default(Lobby));
|
||||
}
|
||||
});
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user