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

@@ -0,0 +1,60 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using HarmonyLib;
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 GameConfiguratorPatch
{
static Dictionary<string, GameConfigurationAssetDTO> gameConfig = GameConfigurator.config.Get();
static string TargetTypeName = "GameConfigurationTool";
static string TargetMethodName = "SetGameConfiguration";
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.StaticGameConfig.Value) return false;
if (targetMethod == null)
{
Plugin.Log.LogWarning($"'{Description}' disabled. The method for this patch was not found.");
return false;
}
Plugin.Log.LogInfo($"'{Description}' succeeded validation.");
return true;
}
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 gameConf = gameConfig.GetValueOrDefault(conf.Name, null);
if (gameConf == null)
{
if (GenericConfig.PatchDebug.Value) Plugin.Log.LogDebug($"Game '{conf.Name}' does not have external configuration");
return;
}
gameConf.Adapt(conf);
config = conf;
if (GenericConfig.PatchDebug.Value) Plugin.Log.LogDebug($"Applied external game configuration for '{config.Name}'");
}
}