public static void StoreData(this IScienceDataContainer container, IScienceDataContainer experiment, bool dumpDuplicates) { if (container == experiment as IScienceDataContainer) { ScreenMessages.PostScreenMessage("Container is the same as experiment!", 1f, ScreenMessageStyle.UPPER_LEFT); return; } var containerData = container.GetData(); var experimentData = experiment.GetData(); for (var i = 0; i < experimentData.Length; i++) { if (!container.HasData(experimentData[i])) { container.ReturnData(experimentData[i]); if (container.HasData(experimentData[i])) { experiment.DumpData(experimentData[i]); } else { ScreenMessages.PostScreenMessage("Container didnt store the experiment", 1f, ScreenMessageStyle.UPPER_LEFT); } } else if (dumpDuplicates) { experiment.DumpData(experimentData[i]); } } }
private void onTriggeredData(ScienceData data, Vessel vessel, bool aborted) { if (vessel == null) { return; } if (vessel != FlightGlobals.ActiveVessel) { return; } if (data == null) { return; } for (int i = queuedData.Count - 1; i >= 0; i--) { ScienceRelayData d = queuedData[i]; if (d._data.subjectID != data.subjectID) { continue; } if (aborted) { data.triggered = false; return; } if (!finishTransfer(d._target, d._data, d._boost)) { Part host = d._host; List <IScienceDataContainer> containers = host.FindModulesImplementing <IScienceDataContainer>(); IScienceDataContainer hostContainer = null; for (int j = containers.Count - 1; j >= 0; j--) { IScienceDataContainer container = containers[j]; if (container == null) { continue; } PartModule mod = container as PartModule; if (mod.part == null) { continue; } if (mod.part.flightID != data.container) { continue; } hostContainer = container; break; } if (hostContainer != null) { data.triggered = false; hostContainer.ReturnData(data); } } else { ScreenMessages.PostScreenMessage(Localizer.Format("#autoLOC_238419", new string[] { d._target.vesselName, data.dataAmount.ToString("F0"), data.title }), 4, ScreenMessageStyle.UPPER_LEFT); } queuedData.Remove(d); break; } }