Fix NRE on spawned vessels with physics

This commit is contained in:
Joshua Thome 2023-04-18 21:34:40 -05:00
parent 444bcbf8b7
commit 2f913fc8b0

View File

@ -145,6 +145,7 @@ namespace NewHorizons.Handlers
var hasParentBody = !string.IsNullOrEmpty(system.Config.Vessel?.vesselSpawn?.parentBody); var hasParentBody = !string.IsNullOrEmpty(system.Config.Vessel?.vesselSpawn?.parentBody);
var hasPhysics = system.Config.Vessel?.hasPhysics ?? !hasParentBody; var hasPhysics = system.Config.Vessel?.hasPhysics ?? !hasParentBody;
var planetGO = hasParentBody ? vesselObject.transform.parent.gameObject : null;
if (hasPhysics) if (hasPhysics)
{ {
@ -167,8 +168,6 @@ namespace NewHorizons.Handlers
var attachWarpExitToVessel = system.Config.Vessel?.warpExit?.attachToVessel ?? false; var attachWarpExitToVessel = system.Config.Vessel?.warpExit?.attachToVessel ?? false;
var warpExitParent = vesselWarpController._targetWarpPlatform.transform.parent; var warpExitParent = vesselWarpController._targetWarpPlatform.transform.parent;
var planetGO = hasPhysics ? vesselObject.transform.parent.gameObject : null;
var warpExit = GeneralPropBuilder.MakeFromExisting(vesselWarpController._targetWarpPlatform.gameObject, planetGO, null, system.Config.Vessel?.warpExit, parentOverride: attachWarpExitToVessel ? warpExitParent : null); var warpExit = GeneralPropBuilder.MakeFromExisting(vesselWarpController._targetWarpPlatform.gameObject, planetGO, null, system.Config.Vessel?.warpExit, parentOverride: attachWarpExitToVessel ? warpExitParent : null);
if (attachWarpExitToVessel) if (attachWarpExitToVessel)
{ {