protected override void OnUpdate() { base.OnUpdate(); if (lastUpdate > UnityEngine.Time.realtimeSinceStartup + 1) { return; } if (targetBody == null || experiment == null) { NE_Helper.log("targetBody or experimentType is null"); return; } lastUpdate = UnityEngine.Time.realtimeSinceStartup; Vessel vessel = FlightGlobals.ActiveVessel; if (vessel != null) { foreach (Part part in vessel.Parts) { ExperimentStorage[] ess = part.GetComponents <ExperimentStorage>(); if (ess.Length > 0) { foreach (ExperimentStorage es in ess) { ScienceData[] data = es.GetData(); foreach (ScienceData datum in data) { if (datum.subjectID.ToLower().Contains(experiment.getId().ToLower() + "@" + targetBody.name.ToLower() + "inspace")) { SetComplete(); return; } } } OMSExperiment e = part.FindModuleImplementing <OMSExperiment>(); if (e != null) { if (e.completed >= this.Root.DateAccepted) { } } } } } SetIncomplete(); }
protected override void OnUpdate() { base.OnUpdate(); if (lastUpdate > UnityEngine.Time.realtimeSinceStartup + 1) { return; } if (targetBody == null || experiment == null) { NE_Helper.log("targetBody or experimentType is null"); return; } lastUpdate = UnityEngine.Time.realtimeSinceStartup; Vessel vessel = FlightGlobals.ActiveVessel; // MKW TODO: cache all the vessel parts which are KEES experiments to avoid iterating over the entire vessel every update if (vessel != null) { for (int idx = 0, count = vessel.Parts.Count; idx < count; idx++) { var part = vessel.Parts[idx]; if (part.name == experiment.name) { OMSExperiment e = part.FindModuleImplementing <OMSExperiment>(); if (e != null) { if (e.completed >= this.Root.DateAccepted) { ScienceData[] data = e.GetData(); for (int dIdx = 0, dCount = data.Length; dIdx < dCount; dIdx++) { if (data[dIdx].subjectID.ToLower().Contains("@" + targetBody.name.ToLower() + "inspace")) { SetComplete(); return; } } } } } } } SetIncomplete(); }