Esempio n. 1
0
        // 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;
                }
            }
        }
Esempio n. 2
0
        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();
        }
Esempio n. 3
0
        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
            );
        }
Esempio n. 4
0
        // 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();
        }
Esempio n. 5
0
        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);
            }
        }