private void ChooseAndMoveAKerbal() { // Debug.Log("KHSAddon:ChooseAndMoveAKerbal"); //Debug.Log("Before moving KerbalGUIManager.ActiveCrew.Count:" + KerbalGUIManager.ActiveCrew.Count); // If CLS is not installed then just bug out if (!CLSClient.CLSInstalled) { Debug.LogWarning("Not moving kerbals as the CLS mod is not installed"); return; } ICLSVessel activeVessel = CLSClient.GetCLS().Vessel; if (activeVessel.Spaces.Count > 0) { List <ICLSSpace> crewedSpaces = new List <ICLSSpace>(activeVessel.Spaces.Count); foreach (ICLSSpace s in activeVessel.Spaces) { if (s.Crew.Count > 0) { crewedSpaces.Add(s); } } // now we have got a list of crewed spaces - pick one at random if (crewedSpaces.Count > 0) { ICLSSpace pickedSpace = crewedSpaces[this.random.Next(crewedSpaces.Count)]; // Now pick one of the crew in that space at random! ICLSKerbal pickedKerbel = pickedSpace.Crew[this.random.Next(pickedSpace.Crew.Count)]; // Move move the kerbal somewhere else MoveKerbal(pickedKerbel); } } //Debug.Log("After moving KerbalGUIManager.ActiveCrew.Count:" + KerbalGUIManager.ActiveCrew.Count); }
public void OnVesselChange(Vessel newVessel) { try { if (newVessel.isEVA && !vessel.isEVA) { // Let's clean up old clsVessel highlighing... if (SettingsManager.CLSInstalled && ShipManifestSettings.EnableCLS && !vessel.isEVA && ManifestController.GetInstance(vessel).SelectedResource == "Crew") { // For some reason, clsVessel.Highlight(false) fails here. no error, just does not turn off highlighting... foreach (ICLSPart iPart in ShipManifestBehaviour.clsVessel.Parts) iPart.Highlight(false); // if we are EVA, then we don't need SM open. if (clsVessel.Parts[0].Part.vessel.isEVA) ManifestUtilities.LogMessage("clsVessel is EVA!! Why?. ", "Info", SettingsManager.VerboseLogging); ManifestUtilities.LogMessage("Setting Old Vessel Highlighting off. ", "Info", SettingsManager.VerboseLogging); } // kill selected resource and its associated highlighting. ManifestController.GetInstance(vessel).SelectedResource = null; ManifestController.GetInstance(vessel).SelectedResourceParts = null; ManifestController.GetInstance(vessel).ShowShipManifest = false; ManifestController.GetInstance(vessel).ShowTransferWindow = false; ManifestUtilities.LogMessage("New Vessel is a Kerbal on EVA. ", "Info", true); } vessel = newVessel; if (SettingsManager.CLSInstalled && ShipManifestSettings.EnableCLS) clsVessel = clsAddon.Vessel; } catch (Exception ex) { ManifestUtilities.LogMessage(string.Format(" in OnVesselChange. Error: {0} \r\n\r\n{1}", ex.Message, ex.StackTrace), "Error", true); } }