This repository has been archived on 2026-05-30. You can view files and clone it, but cannot push or open issues or pull requests.
Files
undead-universal-patch-il2cpp/Patches/GameManager/FreeSpawns.cs

50 lines
1.6 KiB
C#

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<string> 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<GameManager>.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;
}
}