using System; using System.Collections.Generic; using System.Reflection; using HarmonyLib; using undead_universal_patch_il2cpp.Core; using undead_universal_patch_il2cpp.Core.Config; using undead_universal_patch_il2cpp.Core.Content.UndeadGameManager; namespace undead_universal_patch_il2cpp.Patches.UndeadGameManager; [HarmonyPatch] public class FreeSpawnsPatch_Array { public static List config = GameFreeSpawns.config.Get(); static PatchTypesResult patchResult = Util.ConfigPreparePatchTypes( GameManagerConfig.AnyGameFreeSpawn, "FreeSpawns event patch", "GamePlayerSpawnPoint", "Awake" ); public static bool Prepare() => patchResult.Success; public static MethodBase TargetMethod() => patchResult.Method; public static void Postfix(ref GamePlayerSpawnPoint __instance) { Util.ConditionalDebug("Attempting FreeSpawns patch"); GameManager man = NetworkedSingletonMonoBehaviour.instance; if (man.CurrentGameConfiguration == null) { Util.ConditionalDebug("CurrentGameConfiguration was null"); return; } if (man.CurrentGameConfiguration.configurationData == null) { Util.ConditionalDebug("CurrentGameConfiguration.configurationData was null"); return; } if (!config.Contains(man.CurrentGameConfiguration.configurationData.Name)) { Util.ConditionalDebug($"Game '{man.CurrentGameConfiguration.configurationData.Name}' is not specified by GameFreeSpawns"); return; } __instance.GameTeamPlayerIndex = GameTeamPlayerIndex.ANY_INDEX; } }