Files
MMOKitchen/Patches/SteamPlatformPatch.cs
T

34 lines
1.1 KiB
C#
Raw Normal View History

2024-04-01 08:12:01 +11:00
using HarmonyLib;
using Kitchen.NetworkSupport;
using System;
2024-08-10 05:00:57 +10:00
using System.Collections.Generic;
2024-04-01 08:12:01 +11:00
using System.Reflection;
2024-08-10 05:00:57 +10:00
using System.Reflection.Emit;
2024-04-01 08:12:01 +11:00
namespace MMOKitchen.Patches
{
/*
* This patch is used to change how many players can join the lobby using Steam.
*/
2024-08-10 05:00:57 +10:00
[HarmonyPatch(typeof(SteamPlatform))]
2024-04-01 08:12:01 +11:00
public class SteamPlatformPatch
2024-08-10 05:00:57 +10:00
{
private static MethodBase TargetMethod()
2024-04-01 08:12:01 +11:00
{
2024-08-10 05:00:57 +10:00
Type type = AccessTools.FirstInner(typeof(SteamPlatform), t => t.Name.Contains("<CreateNewLobby>d__26"));
return AccessTools.FirstMethod(type, method => method.Name.Contains("MoveNext"));
}
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
CodeMatcher matcher = new(instructions);
matcher.MatchForward(false, new CodeMatch(OpCodes.Ldc_I4_2), new CodeMatch(OpCodes.Bne_Un), new CodeMatch(OpCodes.Ldc_I4_4))
.Advance(2)
.Set(OpCodes.Ldc_I4, Mod.MaxPlayers);
return matcher.InstructionEnumeration();
2024-04-01 08:12:01 +11:00
}
}
}