// analyze a sample static void analyze(Vessel v, string filename, double amount) { // get vessel drive Drive drive = DB.Vessel(v).drive; // get sample Sample sample = drive.samples[filename]; // analyze, and produce data amount = Math.Min(amount, sample.size); bool completed = amount >= sample.size - double.Epsilon; drive.delete_sample(filename, amount); drive.record_file(filename, amount); // if the analysis is completed if (completed) { // inform the user Message.Post ( Lib.BuildString("<color=cyan><b>ANALYSIS COMPLETED</b></color>\nOur laboratory on <b>", v.vesselName, "</b> analyzed <b>", Science.experiment(filename).name, "</b>"), "The results can be transmitted now" ); // record landmark event if (!Lib.Landed(v)) { DB.landmarks.space_analysis = true; } } }
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 file on a vessel public static void StoreFile(Vessel v, string subject_id, double amount) { if (!Cache.VesselInfo(v).is_valid) { return; } Drive drive = DB.Vessel(v).drive; drive.record_file(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); } }