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(); }
// store a sample on a vessel public static void StoreSample(Vessel v, string subject_id, double amount) { if (!Cache.VesselInfo(v).is_valid) { return; } Drive drive = DB.Vessel(v).drive; drive.record_sample(subject_id, amount); }
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); } }