void Start() { // get dialog dialog = gameObject.GetComponentInParent <ExperimentsResultDialog>(); if (dialog == null) { Destroy(gameObject); return; } // prevent rendering dialog.gameObject.SetActive(false); // for each page // - some mod may collect multiple experiments at once while (dialog.pages.Count > 0) { // get page var page = dialog.pages[0]; // get science data ScienceData data = page.pageData; // collect and deduce all info necessary MetaData meta = new MetaData(data, page.host); // record data in the drive Drive drive = DB.Vessel(meta.vessel).drive; if (!meta.is_sample) { drive.Record_File(data.subjectID, data.dataAmount); } else { drive.Record_Sample(data.subjectID, data.dataAmount); } // render experiment inoperable if necessary if (!meta.is_rerunnable) { meta.experiment.SetInoperable(); } // dump the data page.OnDiscardData(data); // inform the user Message.Post ( Lib.BuildString("<b>", Science.Experiment(data.subjectID).fullname, "</b> recorded"), !meta.is_rerunnable ? "The experiment is now inoperable, resetting will require a <b>Scientist</b>" : string.Empty ); } // dismiss the dialog dialog.Dismiss(); }
void Record(MetaData meta, ScienceData data, bool send) { // if amount is zero, warn the user and do nothing else if (data.dataAmount <= double.Epsilon) { Message.Post("There is no more useful data here"); return; } // if this is a sample and we are trying to send it, warn the user and do nothing else if (meta.is_sample && send) { Message.Post("We can't transmit a sample", "Need to be recovered, or analyzed in a lab"); return; } // record data in the drive Drive drive = DB.Vessel(meta.vessel).drive; if (!meta.is_sample) { drive.Record_File(data.subjectID, data.dataAmount); } else { drive.Record_Sample(data.subjectID, data.dataAmount); } // flag for sending if specified if (!meta.is_sample && send) { drive.Send(data.subjectID, true); } // render experiment inoperable if necessary if (!meta.is_rerunnable) { meta.experiment.SetInoperable(); } // dismiss the dialog and popups Dismiss(data); // inform the user Message.Post ( Lib.BuildString("<b>", Science.Experiment(data.subjectID).fullname, "</b> recorded"), !meta.is_rerunnable ? "The experiment is now inoperable, resetting will require a <b>Scientist</b>" : string.Empty ); }
// move all data to another drive public void Move(Drive destination) { // copy files foreach (var p in files) { destination.Record_File(p.Key, p.Value.size); destination.files[p.Key].buff += p.Value.buff; //< move the buffer along with the size } // copy samples foreach (var p in samples) { destination.Record_Sample(p.Key, p.Value.size); } // clear source drive files.Clear(); samples.Clear(); }
public void ReturnData(ScienceData data) { // get drive Drive drive = DB.Vessel(vessel).drive; // if not the preferred drive if (drive.location != part.flightID) { return; } // store the data if (data.baseTransmitValue > float.Epsilon || data.transmitBonus > double.Epsilon) { drive.Record_File(data.subjectID, data.dataAmount); } else { drive.Record_Sample(data.subjectID, data.dataAmount); } }