2.0.0 - any gameconfigurationasset can be changed! breaking public API

This commit is contained in:
2025-08-10 18:04:52 -04:00
parent 8f4ffff08a
commit 48ca74d2db
12 changed files with 464 additions and 117 deletions

View File

@@ -1,30 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Mapster;
using RecRoom.Core.GameManagement;
using RecRoom.Protobuf;
using undead_universal_patch_il2cpp.Core;
using undead_universal_patch_il2cpp.Core.UndeadGameManager;
namespace undead_universal_patch_il2cpp.Patches.UndeadGameManager;
[HarmonyPatch]
public class TeamConfiguratorPatch
public class GameConfiguratorPatch
{
static List<GameConfiguration> gameConfig = TeamConfigurator.config.Get();
static Dictionary<string, GameConfigurationAssetDTO> gameConfig = GameConfigurator.config.Get();
static string TargetTypeName = "GameConfigurationTool";
static string TargetMethodName = "SetGameConfiguration";
static string Description = "TeamConfigurator event patch";
static string Description = "GameConfigurator event patch";
static Type targetType = AccessTools.TypeByName(TargetTypeName);
static MethodInfo targetMethod = AccessTools.Method(targetType, TargetMethodName);
public static bool Prepare()
{
if (!GameManagerConfig.StaticGameTeamConfig.Value) return false;
if (!GameManagerConfig.StaticGameConfig.Value) return false;
if (targetMethod == null)
{
Plugin.Log.LogWarning($"'{Description}' disabled. The method for this patch was not found.");
@@ -37,22 +37,24 @@ public class TeamConfiguratorPatch
public static MethodBase TargetMethod() => targetMethod;
public static GameConfigurationData res;
public static void Prefix(ref GameConfigurationAsset config, ref bool showNotification)
{
var conf = config;
showNotification = GenericConfig.PatchDebug.Value;
var teamConf = gameConfig.Find(match => match.GameName == conf.Name);
if (teamConf == null)
var gameConf = gameConfig.GetValueOrDefault(conf.Name, null);
if (gameConf == null)
{
if (GenericConfig.PatchDebug.Value) Plugin.Log.LogDebug($"'{config.Name}' does not have explicit team configurations");
if (GenericConfig.PatchDebug.Value) Plugin.Log.LogDebug($"Game '{conf.Name}' does not have external configuration");
return;
}
var arr = new Il2CppStructArray<TeamConfiguration>(teamConf.TeamConfigurations.Count);
for (int i = 0; i < arr.Length; i++) arr[i] = new TeamConfiguration { MaxTeamSize = teamConf.TeamConfigurations[i].Size };
config.TeamConfigurations = arr;
gameConf.Adapt(conf);
if (GenericConfig.PatchDebug.Value) Plugin.Log.LogDebug($"New team configuration length for '{config.Name}': {arr.Length}");
config = conf;
if (GenericConfig.PatchDebug.Value) Plugin.Log.LogDebug($"Applied external game configuration for '{config.Name}'");
}
}