using System.Collections.Generic; using System.Reflection; using HarmonyLib; using undead_universal_patch_il2cpp.Core; using undead_universal_patch_il2cpp.Core.Config; namespace undead_universal_patch_il2cpp.Patches.UndeadGameManager; [HarmonyPatch] public class FreeSpawnsPatch_Array { public static List spawns = null; 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) { if (spawns == null) { Util.ConditionalDebug("FreeSpawns was not yet fetched!"); return; } 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 (!spawns.Contains(man.CurrentGameConfiguration.configurationData.Name)) { Util.ConditionalDebug($"Game '{man.CurrentGameConfiguration.configurationData.Name}' is not specified by GameFreeSpawns"); return; } __instance.GameTeamPlayerIndex = GameTeamPlayerIndex.ANY_INDEX; } }