From d1b10df5497efba44a28e55f7f466c995c4f9e5f Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Mon, 17 Jan 2022 22:37:21 +0900 Subject: [PATCH] Ensure built vessel has a valid orbit And the orbit driver has a vessel. This fixes the vessel (for a stake, no idea why that was singled out) being ripped out from under EL and thus causing all sorts of things to break. The orbit driver needed its vessel set explicitly because the driver is added before the vessel and thus has nothing to find. --- Source/BuildControl.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Source/BuildControl.cs b/Source/BuildControl.cs index dc60c56d..7f358da7 100644 --- a/Source/BuildControl.cs +++ b/Source/BuildControl.cs @@ -679,6 +679,9 @@ internal void BuildAndLaunchCraft () Box vessel_bounds = GetVesselBox (nship); var rootPart = nship.parts[0].localRoot; + var ro = rootPart.gameObject; + var od = ro.GetComponent () ?? ro.AddComponent (); + od.orbit = new Orbit(builder.vessel.orbit); var shipTransform = rootPart.transform; builder.SetShipTransform (shipTransform, rootPart); builder.PlaceShip (shipTransform, vessel_bounds); @@ -688,6 +691,7 @@ internal void BuildAndLaunchCraft () flag, game, crew); var craftVessel = nship.parts[0].localRoot.GetComponent (); craftVessel.launchedFrom = builder.LaunchedFrom; + od.vessel = craftVessel; FlightGlobals.ForceSetActiveVessel (craftVessel); SetCraftOrbit (craftVessel, OrbitDriver.UpdateMode.IDLE);