new-horizons/NewHorizons/Patches/PlayerPatches/PlayerSpawnerPatches.cs
2023-03-18 13:30:22 -04:00

27 lines
853 B
C#

using HarmonyLib;
using Logger = NewHorizons.Utility.Logger;
namespace NewHorizons.Patches.PlayerPatches
{
[HarmonyPatch(typeof(PlayerSpawner))]
public static class PlayerSpawnerPatches
{
[HarmonyPrefix]
[HarmonyPatch(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;
}
}
}
}