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]); } } }
public bool CanTransfer(ModuleScienceExperiment baseExperiment, IScienceDataContainer moduleScienceContainer) { var currentExperiment = baseExperiment as DMModuleScienceAnimate; if ((currentExperiment as IScienceDataContainer).GetScienceCount() == 0) { Log(currentExperiment.experimentID, ": Experiment has no data skiping transfer. Data found: ", (currentExperiment as IScienceDataContainer).GetScienceCount(), "_", currentExperiment.experimentNumber); return(false); } if (!currentExperiment.IsRerunnable()) { if (!_AutomatedScienceSamplerInstance.craftSettings.transferAllData) { Log(currentExperiment.experimentID, ": Experiment isn't rerunnable and transferAllData is turned off."); return(false); } } if (!_AutomatedScienceSamplerInstance.craftSettings.dumpDuplicates) { foreach (var data in (currentExperiment as IScienceDataContainer).GetData()) { if (moduleScienceContainer.HasData(data)) { Log(currentExperiment.experimentID, ": Target already has experiment and dumping is disabled."); return(false); } } } Log(currentExperiment.experimentID, ": We can transfer the science!"); return(true); }
public virtual bool CanTransfer(ModuleScienceExperimentWrapper <T> baseExperiment, IScienceDataContainer moduleScienceContainer) { Log(baseExperiment.experimentID, ": CanTransfer"); if (moduleScienceContainer == baseExperiment as IScienceDataContainer) {//no point in transfering to the same container Log(baseExperiment.experimentID, ": Experiment is same as Container ", baseExperiment.GetScienceCount()); return(false); } if (baseExperiment.GetScienceCount() == 0) { Log(baseExperiment.experimentID, ": Experiment has no data skiping transfer ", baseExperiment.GetScienceCount()); return(false); } if (!baseExperiment.IsRerunnable()) { if (!_AutomatedScienceSamplerInstance.craftSettings.transferAllData) { Log(baseExperiment.experimentID, ": Experiment isn't rerunnable and transferAllData is turned off."); return(false); } } if (!_AutomatedScienceSamplerInstance.craftSettings.dumpDuplicates) { foreach (var data in baseExperiment.GetData()) { if (moduleScienceContainer.HasData(data)) { Log(baseExperiment.experimentID, ": Target already has experiment and dumping is disabled."); return(false); } } } Log(baseExperiment.experimentID, ": We can transfer the science!"); return(true); }