Files
undead-universal-patch-il2cpp/Patches/GameManager/GameConfigurator.cs

47 lines
1.5 KiB
C#

using System;
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
{
static Dictionary<string, GameConfigurationAssetDTO> gameConfig = GameConfigurator.config.Get();
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)
{
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}'");
}
}