INTERNAL REWRITE! server configs

This commit is contained in:
2025-08-12 03:10:25 -04:00
parent 1c51b37a7c
commit 7fc0d6c5b0
23 changed files with 645 additions and 564 deletions

View File

@@ -4,7 +4,7 @@ using System.Reflection;
using HarmonyLib;
using Mapster;
using RecRoom.Core.GameManagement;
using RecRoom.Protobuf;
using undead_universal_patch_il2cpp.Core.Config;
using undead_universal_patch_il2cpp.Core;
using undead_universal_patch_il2cpp.Core.UndeadGameManager;
@@ -15,29 +15,16 @@ 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 PatchTypesResult patchResult = Util.ConfigPreparePatchTypes(
GameManagerConfig.StaticGameConfig,
"GameConfigurator event patch",
"GameConfigurationTool",
"SetGameConfiguration"
);
static Type targetType = AccessTools.TypeByName(TargetTypeName);
static MethodInfo targetMethod = AccessTools.Method(targetType, TargetMethodName);
static bool Prepare() => patchResult.Success;
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;
static MethodBase TargetMethod() => patchResult.Method;
public static void Prefix(ref GameConfigurationAsset config, ref bool showNotification)
{
@@ -47,14 +34,14 @@ public class GameConfiguratorPatch
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");
if (GenericConfig.PatchDebug.Value) UniversalPatchPlugin.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}'");
if (GenericConfig.PatchDebug.Value) UniversalPatchPlugin.Log.LogDebug($"Applied external game configuration for '{config.Name}'");
}
}