예제 #1
0
 public string GetPrimaryField()
 {
     return(Lib.BuildString(
                Lib.Bold(Local.Habitat + " " + Local.Habitat_info1),          // "Habitat" + "Volume"
                " : ",
                Lib.HumanReadableVolume(volume > double.Epsilon ? volume : Lib.PartVolume(part))));
 }
예제 #2
0
 public string GetPrimaryField()
 {
     return(Lib.BuildString(
                Lib.Bold(Local.Habitat + " " + Local.Habitat_info1),          // "Habitat" + "Volume"
                " : ",
                Lib.HumanReadableVolume(volume > 0.0 ? volume : Lib.PartBoundsVolume(part)),
                volume > 0.0 ? "" : " (bounds)"));
 }
예제 #3
0
        // analyze a sample
        private static Status Analyze(Vessel v, string filename, double amount)
        {
            Sample sample = null;

            foreach (var d in DB.Vessel(v).drives.Values)
            {
                if (d.samples.ContainsKey(filename))
                {
                    sample = d.samples[filename];
                }
                break;
            }

            var drive = DB.Vessel(v).BestDrive(amount);

            bool completed = sample == null;

            if (sample != null)
            {
                // analyze, and produce dataamount = Math.Min(amount, sample.size);
                completed = amount >= sample.size - double.Epsilon;
                bool recorded = drive.Record_file(filename, amount, false);
                if (recorded)
                {
                    drive.Delete_sample(filename, amount);
                }
                else
                {
                    Message.Post(
                        Lib.Color("red", Lib.BuildString(Localizer.Format("#KERBALISM_Laboratory_Analysis"), " stopped")),
                        "Not enough space on hard drive"
                        );

                    return(Status.NO_STORAGE);
                }
            }

            // if the analysis is completed
            if (completed)
            {
                // inform the user
                Message.Post(Lib.BuildString(Lib.Color("cyan", Localizer.Format("#KERBALISM_Laboratory_Analysis"), true), "\n",
                                             Localizer.Format("#KERBALISM_Laboratory_Analyzed", Lib.Bold(v.vesselName), Lib.Bold(Science.Experiment(filename).name))), localized_results);

                if (PreferencesBasic.Instance.transmitScience)
                {
                    drive.Transmit_file(filename);
                }

                // record landmark event
                if (!Lib.Landed(v))
                {
                    DB.landmarks.space_analysis = true;
                }
            }

            return(Status.RUNNING);
        }
예제 #4
0
        // analyze a sample
        private static Status Analyze(Vessel v, SubjectData subject, double amount)
        {
            Sample sample      = null;
            Drive  sampleDrive = null;

            foreach (var d in Drive.GetDrives(v, true))
            {
                if (d.samples.ContainsKey(subject) && d.samples[subject].analyze)
                {
                    sample      = d.samples[subject];
                    sampleDrive = d;
                    break;
                }
            }

            bool completed = false;

            if (sample != null)
            {
                completed = amount > sample.size;
                amount    = Math.Min(amount, sample.size);
            }

            Drive fileDrive = Drive.FileDrive(v.KerbalismData(), amount);

            if (fileDrive == null)
            {
                return(Status.NO_STORAGE);
            }

            if (sample != null)
            {
                bool recorded = fileDrive.Record_file(subject, amount, false);

                double massRemoved = 0.0;
                if (recorded)
                {
                    massRemoved = sampleDrive.Delete_sample(subject, amount);
                }
                else
                {
                    Message.Post(
                        Lib.Color(Lib.BuildString(Localizer.Format("#KERBALISM_Laboratory_Analysis"), " stopped"), Lib.Kolor.Red),
                        "Not enough space on hard drive"
                        );

                    return(Status.NO_STORAGE);
                }

                // return sample mass to experiment if needed
                if (massRemoved > 0.0)
                {
                    RestoreSampleMass(v, subject, massRemoved);
                }
            }

            // if the analysis is completed
            if (completed)
            {
                if (!PreferencesScience.Instance.analyzeSamples)
                {
                    // only inform the user if auto-analyze is turned off
                    // otherwise we could be spamming "Analysis complete" messages
                    Message.Post(Lib.BuildString(Lib.Color(Localizer.Format("#KERBALISM_Laboratory_Analysis"), Lib.Kolor.Science, true), "\n",
                                                 Localizer.Format("#KERBALISM_Laboratory_Analyzed", Lib.Bold(v.vesselName), Lib.Bold(subject.FullTitle))), localized_results);
                }

                if (PreferencesScience.Instance.transmitScience)
                {
                    fileDrive.Send(subject.Id, true);
                }

                // record landmark event
                if (!Lib.Landed(v))
                {
                    DB.landmarks.space_analysis = true;
                }
            }

            return(Status.RUNNING);
        }
예제 #5
0
        // analyze a sample
        private 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(Lib.Color("cyan", Localizer.Format("#KERBALISM_Laboratory_Analysis"), true), "\n",
                                             Localizer.Format("#KERBALISM_Laboratory_Analyzed", Lib.Bold(v.vesselName), Lib.Bold(Science.Experiment(filename).name))), localized_results);

                // record landmark event
                if (!Lib.Landed(v))
                {
                    DB.landmarks.space_analysis = true;
                }
            }
        }