/// <summary> /// Activate autopilot /// </summary> internal virtual bool Activate() { if (distanceToTarget == 0) { ScreenMessages.PostScreenMessage(Localizer.Format("#LOC_BV_Warning_NoRoute", 5f)).color = Color.yellow; return(false); } BonVoyageModule module = vessel.FindPartModuleImplementing <BonVoyageModule>(); if (module != null) { distanceTravelled = 0; lastTimeUpdated = 0; active = true; module.active = active; module.targetLatitude = targetLatitude; module.targetLongitude = targetLongitude; module.distanceToTarget = distanceToTarget; module.distanceTravelled = distanceTravelled; module.pathEncoded = PathUtils.EncodePath(path); module.requiredPower = requiredPower; BonVoyage.Instance.AutopilotActivated(true); ScreenMessages.PostScreenMessage(Localizer.Format("#LOC_BV_BonVoyage"), 5f); } return(active); }
// [KSPEvent(guiActive = true, guiName = "Toggle utilities")] // public void ToggleUtils() // { // showUtils = !showUtils; // Events["CalculateSolar"].active = showUtils; // Events["CalculateOther"].active = showUtils; //// Events["CalculateAverageSpeed"].active = showUtils; // Events["CalculatePowerRequirement"].active = showUtils; // // //Clean up previous builds // Events["CalculateSolar"].guiActive = true; // Events["CalculateOther"].guiActive = true; // if (Events["FindPath"] != null) // { // Events["FindPath"].guiActive = false; // Events["FindPath"].active = false; // } // if (Events["PickTest"] != null) // { // Events["PickTest"].guiActive = false; // Events["PickTest"].active = false; // } // } private void FindPath() { distanceToTarget = 0; PathFinder finder = new PathFinder( this.vessel.latitude, this.vessel.longitude, targetLatitude, targetLongitude, this.vessel.mainBody ); finder.FindPath(); distanceToTarget = finder.GetDistance(); if (distanceToTarget > 0) { pathEncoded = PathUtils.EncodePath(finder.path); BonVoyage.Instance.UpdateWayPoints(); // wayPoints = PathUtils.DecodePath (pathEncoded, this.vessel.mainBody); } else { ScreenMessages.PostScreenMessage("No path found, try some other location!"); } }