private void transferToEVA() { if (handler == null) { return; } if (!FlightGlobals.ActiveVessel.isEVA) { handler.clearData(); Inoperable = false; return; } List <ModuleScienceContainer> EVACont = FlightGlobals.ActiveVessel.FindPartModulesImplementing <ModuleScienceContainer>(); if (EVACont.Count <= 0) { return; } if (handler.GetScienceCount() > 0) { if (!EVACont.First().StoreData(new List <IScienceDataContainer> { this }, false)) { handler.clearData(); Inoperable = false; } } if (controller != null) { controller.setCollectEvent(); } }
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(); } } } } } }
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.ElementAt(i).Value; 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.experimentRunning) { continue; } if (m.usingECResource && !m.vessel.loaded) { List <string> generators = FinePrint.ContractDefs.GetModules("Power"); if (!FinePrint.Utilities.VesselUtilities.VesselHasAnyModules(generators, m.vessel)) { 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; t /= m.calibration; 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); float science = m.currentMaxScience(level); if (science > m.submittedData) { bool flag = true; if (m.GetScienceCount() > 0) { ScienceData dat = m.GetData()[0]; ScienceSubject sub = ResearchAndDevelopment.GetSubjectByID(dat.subjectID); if (sub != null) { float d = dat.dataAmount / sub.dataScale; //SEPUtilities.log("Science Data value check: {0:N2} - {1:N2}", logLevels.warning, science, d); if (science <= d) { flag = false; } } else { flag = false; } } if (flag) { 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["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["CollectData"].active = !transmitted && count > 0; m.host.PauseExperiment(); if (m.host.Controller != null) { m.host.Controller.setCollectEvent(); } } } } } }