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 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}'"); } }