public IList <IVesselSection> GetBodyVessels(string body) { List <IVesselSection> vesselList = new List <IVesselSection>(); if (string.IsNullOrEmpty(body)) { return(vesselList); } int l = vessels.Count; for (int i = 0; i < l; i++) { SEP_VesselSection vessel = vessels.At(i); if (vessel == null) { continue; } if (vessel.VesselBody == null) { continue; } if (vessel.VesselBody.bodyName != body) { continue; } vesselList.Add(vessel); } return(vesselList); }
private void getPartTitles() { for (int i = 0; i < requiredParts.Count; i++) { string s = requiredParts.At(i).FirstOrDefault(); AvailablePart aPart = PartLoader.getPartInfoByName(s); if (aPart == null) { continue; } partTitles.Add(aPart.title); } }
internal static string stringConcat(DictionaryValueList <int, List <string> > source) { if (source.Count == 0) { return(""); } string[] result = new string[source.Count]; for (int i = 0; i < source.Count; i++) { List <string> group = source.At(i); if (group.Count == 0) { result[i] = "|"; continue; } string[] s = new string[group.Count]; for (int j = 0; j < group.Count; j++) { s[j] = group[j] + ","; } result[i] = string.Concat(s).TrimEnd(',') + "|"; } return(string.Concat(result).TrimEnd('|')); }
public override void OnSave(ConfigNode node) { try { if (contractLoader.Settings != null) { contractLoader.Settings.Save(); } saveWindow(windowRects[currentScene(HighLogic.LoadedScene)]); ConfigNode scenes = new ConfigNode("Contracts_Window_Parameters"); //Scene settings scenes.AddValue("WindowPosition", stringConcat(windowPos, windowPos.Length)); scenes.AddValue("WindowVisible", stringConcat(windowVisible, windowVisible.Length)); for (int i = missionList.Count - 1; i >= 0; i--) { contractMission m = missionList.At(i); if (m == null) { continue; } ConfigNode missionNode = new ConfigNode("Contracts_Window_Mission"); missionNode.AddValue("MissionName", m.InternalName); missionNode.AddValue("ActiveListID", m.stringConcat(m.ActiveMissionList)); missionNode.AddValue("HiddenListID", m.stringConcat(m.HiddenMissionList)); missionNode.AddValue("VesselIDs", m.vesselConcat(currentMission)); missionNode.AddValue("AscendingSort", m.AscendingOrder); missionNode.AddValue("ShowActiveList", m.ShowActiveMissions); missionNode.AddValue("SortMode", (int)m.OrderMode); scenes.AddNode(missionNode); } node.AddNode(scenes); } catch (Exception e) { DMC_MBE.LogFormatted("Contracts Window Settings Cannot Be Saved: {0}", e); } }
public DMAnomalyObject getAnomaly(int index) { if (anomalies.Count > index) { return(anomalies.At(index)); } return(null); }
public Vessel getVessel(int index) { if (suitableVessels.Count > index) { return(suitableVessels.At(index)); } return(null); }
public static DMAnomalyStorage getAnomalyStorage(int index) { if (anomalies.Count > index) { return(anomalies.At(index)); } return(null); }
public void RefreshPanels() { for (int i = panels.Count - 1; i >= 0; i--) { panels.At(i).RefreshModules(); } }
public static contractContainer getFailedContract(int index, bool warn = false) { if (failedContracts.Count > index) { return(failedContracts.At(index)); } else if (warn) { Debug.Log(string.Format("[Contract Parser] No Failed Contract At Index: [{0}] Found", index)); } return(null); }
private void experimentCheck(double time) { int l = experiments.Count; //if (l > 0) //SEP_Utilities.log("Performing SEP background check on {0} experiments at time: {1:N0}", logLevels.log, l , time); for (int i = 0; i < l; i++) { List <SEP_ExperimentHandler> modules = experiments.At(i); int c = modules.Count; for (int j = 0; j < c; j++) { SEP_ExperimentHandler m = modules[j]; if (m == null) { continue; } if (!m.loaded) { continue; } if (!m.vessel.Landed) { continue; } if (!m.experimentRunning) { continue; } if (m.usingECResource && !m.vessel.loaded) { if (!m.vessel.HasValidContractObjectives(new List <string> { "Generator" })) { continue; } } if (m.vessel.loaded) { if (m.host != null && m.host.Controller != null) { if (m.host.vessel != m.host.Controller.vessel) { continue; } } else { continue; } } double t = m.experimentTime; float calib = m.calibration; if (usingCommNet) { if (m.vessel.Connection != null) { float signal = (float)m.vessel.Connection.SignalStrength - 0.5f; if (signal < 0) { signal /= 2; } float bonus = calib * signal; calib += bonus; } } t /= calib; double length = time - m.lastBackgroundCheck; m.lastBackgroundCheck = time; double days = length / 21600; if (days < t) { double n = days / t; //SEPUtilities.log("Updating SEP Experiment Handler [{0}]: Add {1:P6}", logLevels.warning, m.experimentTitle, n); m.completion += (float)n; } else { m.completion = 1; } float max = m.getMaxCompletion(); if (max <= 0.5f) { if (m.completion >= 0.5f) { m.completion = 0.5f; } } else if (max <= 0.75f) { if (m.completion >= 0.75f) { m.completion = 0.75f; } } else { if (m.completion >= 1f) { m.completion = 1f; } } bool transmitted = false; m.submittedData = m.getSubmittedData(); if (m.canTransmit && m.controllerAutoTransmit && transmissionUpgrade) { transmitted = checkTransmission(m); } else { int level = m.getMaxLevel(false); if (!dataOnboard(m, level)) { m.addData(SEP_Utilities.getScienceData(m, m.getExperimentLevel(level), level)); if (m.vessel.loaded && m.host != null) { m.host.Events["ReviewDataEvent"].active = true; m.host.Events["TransferDataEvent"].active = m.host.hasContainer; m.host.Events["CollectData"].active = true; if (m.host.Controller != null) { m.host.Controller.setCollectEvent(); } } } } if (transmitted) { m.clearData(); } if (m.completion >= max) { m.experimentRunning = false; if (m.vessel.loaded && m.host != null) { int count = m.GetScienceCount(); m.host.Events["ReviewDataEvent"].active = !transmitted && count > 0; m.host.Events["TransferDataEvent"].active = !transmitted && count > 0 && m.host.hasContainer; m.host.Events["CollectData"].active = !transmitted && count > 0; m.host.PauseExperiment(); if (m.host.Controller != null) { m.host.Controller.setCollectEvent(); } } } } } }