public override void Update() { if (_target == null) { return; } if (FlightGlobals.ActiveVessel.Landed) { FlightGlobals.ActiveVessel.Landed = false; } if (FlightGlobals.ActiveVessel.Splashed) { FlightGlobals.ActiveVessel.Splashed = false; } foreach (var part in FlightGlobals.ActiveVessel.parts.ToArray().Where(part => part.Modules.OfType <LaunchClamp>().Any())) { part.Die(); } FlightGlobals.ActiveVessel.GoOnRails(); var diff = _target.getTruePositionAtUT(Planetarium.GetUniversalTime()) - FlightGlobals.ActiveVessel.orbit.getTruePositionAtUT(Planetarium.GetUniversalTime()); Krakensbane.Teleport(diff); FlightGlobals.ActiveVessel.SetPosition(_target.getPositionAtUT(Planetarium.GetUniversalTime() + _leadTime)); FlightGlobals.ActiveVessel.orbit.IndirectSet(_target, Planetarium.GetUniversalTime() + _leadTime); FlightGlobals.ActiveVessel.GoOffRails(); _target = null; }
public override void Update() { if (_landing) { if (FlightGlobals.ActiveVessel.LandedOrSplashed) { _landing = false; } else { var accel = FlightGlobals.ActiveVessel.srf_velocity * -0.5 + FlightGlobals.ActiveVessel.upAxis * -0.5; FlightGlobals.ActiveVessel.ChangeWorldVelocity(accel); } } if (_toLandAt != null) { double raisedAlt; if (UnitParser.Parse(FindField <TextBox, string>("altitude"), "m", out raisedAlt) == false) { ErrorPopup.Error("Altitude was not a number"); _toLandAt = null; return; } var alt = FlightGlobals.ActiveVessel.mainBody.pqsController.GetSurfaceHeight( QuaternionD.AngleAxis(_toLandAt.Longitude, Vector3d.down) * QuaternionD.AngleAxis(_toLandAt.Latitude, Vector3d.forward) * Vector3d.right) - FlightGlobals.ActiveVessel.mainBody.pqsController.radius; alt = Math.Max(alt, 0); // Underwater! var diff = FlightGlobals.ActiveVessel.mainBody.GetWorldSurfacePosition(_toLandAt.Latitude, _toLandAt.Longitude, alt + raisedAlt) - FlightGlobals.ActiveVessel.GetWorldPos3D(); if (FlightGlobals.ActiveVessel.Landed) { FlightGlobals.ActiveVessel.Landed = false; } else if (FlightGlobals.ActiveVessel.Splashed) { FlightGlobals.ActiveVessel.Splashed = false; } foreach (var part in FlightGlobals.ActiveVessel.parts.ToArray().Where(part => part.Modules.OfType <LaunchClamp>().Any())) { part.Die(); } Krakensbane.Teleport(diff); FlightGlobals.ActiveVessel.ChangeWorldVelocity(-FlightGlobals.ActiveVessel.obt_velocity); //var up = (FlightGlobals.ActiveVessel.CoM - FlightGlobals.ActiveVessel.mainBody.position).normalized; //var forward = Vector3.Cross(up, Vector3.down); //var targetRot = Quaternion.LookRotation(forward, up); _toLandAt = null; _landing = true; } base.Update(); }