new-horizons/NewHorizons/Patches/PlayerSpawnerPatches.cs
2022-10-02 23:15:09 -04:00

26 lines
838 B
C#

using HarmonyLib;
using Logger = NewHorizons.Utility.Logger;
namespace NewHorizons.Patches
{
[HarmonyPatch]
public static class PlayerSpawnerPatches
{
[HarmonyPrefix]
[HarmonyPatch(typeof(PlayerSpawner), nameof(PlayerSpawner.SpawnPlayer))]
public static bool PlayerSpawner_SpawnPlayer(PlayerSpawner __instance)
{
if (Main.Instance.IsWarpingFromVessel || Main.Instance.DidWarpFromVessel)
{
Logger.LogWarning("Abort player spawn. Vessel will handle it.");
return false;
}
else
{
Logger.LogVerbose("Player spawning");
__instance.SetInitialSpawnPoint(Main.SystemDict[Main.Instance.CurrentStarSystem].SpawnPoint);
return true;
}
}
}
}