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

@@ -1,16 +1,19 @@
using System;
using System.Text.Json;
using System.Collections.Generic;
using System.Linq;
using BepInEx;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Mapster;
using undead_universal_patch_il2cpp.Core;
using undead_universal_patch_il2cpp.Core.AssetChanges;
using undead_universal_patch_il2cpp.Core.UndeadGameManager;
namespace undead_universal_patch_il2cpp;
[BepInPlugin("dev.proxnet.recroom.universalpatch.noneac.il2cpp", "Undead Universal Patch", "1.4.0")]
[BepInPlugin("dev.proxnet.recroom.universalpatch.noneac.il2cpp", "Undead Universal Patch", "1.4.1")]
public class Plugin : BasePlugin
{
public static new readonly ManualLogSource Log = Logger.CreateLogSource("UUPatch");
@@ -51,8 +54,8 @@ public class Plugin : BasePlugin
$"Use patches from '{AGRoomChanges.config.path}' to change the properties of internal AGRooms. See README.md");
GameManagerConfig.AnyGameFreeSpawn = Config.Bind("GameManagerConfig", "AnyGameFreeSpawn", GameManagerConfigDefaults.AnyGameFreeSpawn,
$"Use patches from '{GameFreeSpawns.config.path}' to spawn in any valid player spawnpoint in specified games. See README.md");
GameManagerConfig.StaticGameTeamConfig = Config.Bind("GameManagerConfig", "StaticGameTeamConfig", GameManagerConfigDefaults.StaticGameTeamConfig,
$"Use patches from '{TeamConfigurator.config.path}' to set the static configuration of teams in specified games. See README.md");
GameManagerConfig.StaticGameConfig = Config.Bind("GameManagerConfig", "StaticGameConfig", GameManagerConfigDefaults.StaticGameConfig,
$"Use patches from '{GameConfigurator.config.path}' to set new configurations for built-in games. See README.md");
PhotonConfig.PatchPhotonIds = Config.Bind("Photon", "PatchPhotonIds", PhotonConfigDefaults.PatchPhotonIds,
"Patch Photon configuration.");
@@ -117,12 +120,19 @@ public class Plugin : BasePlugin
{
Log.LogError($"Could not load change patches: {ex}");
}
TypeAdapterConfig.GlobalSettings
.ForType<List<TeamConfigurationDTO>, Il2CppStructArray<TeamConfiguration>>()
.MapWith(src => new Il2CppStructArray<TeamConfiguration>(src.Select(x => x.Adapt<TeamConfiguration>()).ToArray()));
TypeAdapterConfig.GlobalSettings
.ForType<List<StatConfigurationDTO>, Il2CppReferenceArray<StatConfiguration>>()
.MapWith(src => new Il2CppReferenceArray<StatConfiguration>(src.Select(x => x.Adapt<StatConfiguration>()).ToArray()));
}
private static void CacheChangePatchConfigs()
{
if (AssetChangesConfig.AGRoomChanges.Value) AGRoomChanges.config.Get();
if (GameManagerConfig.AnyGameFreeSpawn.Value) GameFreeSpawns.config.Get();
if (GameManagerConfig.StaticGameTeamConfig.Value) TeamConfigurator.config.Get();
if (GameManagerConfig.StaticGameConfig.Value) GameConfigurator.config.Get();
}
}