private void stabilize(Vessel v) { // At the very first tick we detach what could be possibly detached and restore initial altitude. // At the second and third tick we move vessel up if needed // At the 4-8 ticks we move vessel down to the safe altitude if (vesselsToMoveUp.Contains(v)) { Log.detail("{0}: timer = {1}", v.name, vesselTimer[v.id]); if (vesselTimer [v.id] == stabilizationTimer) { // Detaching what should be detached at the very start of stabilization tryDetachAnchor(v); // If this vessel has anchors (from Hangar), detach them KASAPI.tryDetachPylon(v); // Same with KAS pylons KASAPI.tryDetachHarpoon(v); restoreInitialAltitude(v); } else { Log.detail("{0}: timer = {1}; moving up", v.name, vesselTimer[v.id]); moveUp(v); // Setting up attachment procedure early KASAPI.tryAttachPylon(v); tryAttachAnchor(v); scheduleHarpoonReattachment(v); restoreCEBehavior(v); vesselsToMoveUp.Remove(v); } } else { if (vesselTimer [v.id] > stabilizationTimer - groundingTicks) // next 3(?) ticks after detaching and moving up { Log.detail("{0}: timer = {1}; moving down", v.name, vesselTimer[v.id]); moveDown(v); } } if (drawPoints) { updateLR(v, bounds [v.id]); } v.IgnoreGForces(2); v.SetWorldVelocity(Vector3.zero); v.angularMomentum = Vector3.zero; v.angularVelocity = Vector3.zero; vesselSleep(v); if (vesselTimer [v.id] % 10 == 0) { Log.detail("Stabilizing; v = {0}; radar alt = {1}; timer = {2}", v.name, v.radarAltitude, vesselTimer[v.id]); } }
public void onVesselSwitching(Vessel from, Vessel to) { if (to == null || to.situation != Vessel.Situations.LANDED) // FIXME: Do we need PRELAUNCH here? { return; } string fromString = from != null ? (from.name + "(packed=" + from.packed + ")") : "non-vessel"; Log.info("{0} -> {1}(packed={2})", fromString, to.name, to.packed); this.tryDetachAnchor(to); // If this vessel has anchors (from Hangar), detach them KASAPI.tryDetachPylon(to); // Same with KAS pylons KASAPI.tryDetachHarpoon(to); }