Skip to content

Commit

Permalink
Ensure built vessel has a valid orbit
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
taniwha committed Jan 17, 2022
1 parent e2e4ed1 commit d1b10df
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Source/BuildControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<OrbitDriver> () ?? ro.AddComponent<OrbitDriver> ();
od.orbit = new Orbit(builder.vessel.orbit);
var shipTransform = rootPart.transform;
builder.SetShipTransform (shipTransform, rootPart);
builder.PlaceShip (shipTransform, vessel_bounds);
Expand All @@ -688,6 +691,7 @@ internal void BuildAndLaunchCraft ()
flag, game, crew);
var craftVessel = nship.parts[0].localRoot.GetComponent<Vessel> ();
craftVessel.launchedFrom = builder.LaunchedFrom;
od.vessel = craftVessel;

FlightGlobals.ForceSetActiveVessel (craftVessel);
SetCraftOrbit (craftVessel, OrbitDriver.UpdateMode.IDLE);
Expand Down

0 comments on commit d1b10df

Please sign in to comment.