This repository has been archived on 2026-05-30. You can view files and clone it, but cannot push or open issues or pull requests.
Files
2025-09-19 22:35:28 -04:00

52 lines
1.6 KiB
C#

using System.Collections.Generic;
using System.Reflection;
using HarmonyLib;
using Mapster;
using RecRoom.Core.GameManagement;
using undead_universal_patch_il2cpp.Core.Config;
using undead_universal_patch_il2cpp.Core;
using undead_universal_patch_il2cpp.Core.Content.UndeadGameManager;
namespace undead_universal_patch_il2cpp.Patches.UndeadGameManager;
[HarmonyPatch]
public class GameConfiguratorPatch
{
public static Dictionary<string, GameConfigurationAssetDTO> gameConfig = null;
static PatchTypesResult patchResult = Util.ConfigPreparePatchTypes(
GameManagerConfig.StaticGameConfig,
"GameConfigurator event patch",
"GameConfigurationTool",
"SetGameConfiguration"
);
static bool Prepare() => patchResult.Success;
static MethodBase TargetMethod() => patchResult.Method;
public static void Prefix(ref GameConfigurationAsset config, ref bool showNotification)
{
if (gameConfig == null)
{
Util.ConditionalDebug("gameconfigassets was not yet fetched!");
return;
}
var conf = config;
showNotification = GenericConfig.PatchDebug.Value;
var gameConf = gameConfig.GetValueOrDefault(conf.Name, null);
if (gameConf == null)
{
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) UniversalPatchPlugin.Log.LogDebug($"Applied external game configuration for '{config.Name}'");
}
}