コード例 #1
0
ファイル: Experiment.cs プロジェクト: sswelm/Kerbalism
        // specifics support
        public Specifics Specs()
        {
            var specs = new Specifics();
            var exp   = Science.Experiment(experiment_id);

            if (exp == null)
            {
                specs.Add(Localizer.Format("#KERBALISM_ExperimentInfo_Unknown"));
                return(specs);
            }

            specs.Add(Lib.BuildString("<b>", exp.name, "</b>"));
            if (!string.IsNullOrEmpty(experiment_desc))
            {
                specs.Add(Lib.BuildString("<i>", experiment_desc, "</i>"));
            }

            specs.Add(string.Empty);
            double expSize = exp.max_amount;

            if (sample_mass < float.Epsilon)
            {
                specs.Add("Data", Lib.HumanReadableDataSize(expSize));
                specs.Add("Data rate", Lib.HumanReadableDataRate(data_rate));
                specs.Add("Duration", Lib.HumanReadableDuration(expSize / data_rate));
            }
            else
            {
                specs.Add("Sample size", Lib.HumanReadableSampleSize(expSize));
                specs.Add("Sample mass", Lib.HumanReadableMass(sample_mass));
                if (!sample_collecting && Math.Abs(sample_reservoir - sample_mass) > double.Epsilon && sample_mass > double.Epsilon)
                {
                    specs.Add("Experiments", "" + Math.Round(sample_reservoir / sample_mass, 0));
                }
                specs.Add("Duration", Lib.HumanReadableDuration(expSize / data_rate));
            }

            List <string> situations = exp.Situations();

            if (situations.Count > 0)
            {
                specs.Add(string.Empty);
                specs.Add("<color=#00ffff>Situations:</color>", string.Empty);
                foreach (string s in situations)
                {
                    specs.Add(Lib.BuildString("• <b>", s, "</b>"));
                }
            }

            specs.Add(string.Empty);
            specs.Add("<color=#00ffff>Needs:</color>");

            specs.Add("EC", Lib.HumanReadableRate(ec_rate));
            foreach (var p in KerbalismProcess.ParseResources(resources))
            {
                specs.Add(p.Key, Lib.HumanReadableRate(p.Value));
            }

            if (crew_prepare.Length > 0)
            {
                var cs = new CrewSpecs(crew_prepare);
                specs.Add("Preparation", cs ? cs.Info() : "none");
            }
            if (crew_operate.Length > 0)
            {
                var cs = new CrewSpecs(crew_operate);
                specs.Add("Operation", cs ? cs.Info() : "unmanned");
            }
            if (crew_reset.Length > 0)
            {
                var cs = new CrewSpecs(crew_reset);
                specs.Add("Reset", cs ? cs.Info() : "none");
            }

            if (!string.IsNullOrEmpty(requires))
            {
                specs.Add(string.Empty);
                specs.Add("<color=#00ffff>Requires:</color>", string.Empty);
                var tokens = Lib.Tokenize(requires, ',');
                foreach (string s in tokens)
                {
                    specs.Add(Lib.BuildString("• <b>", Science.RequirementText(s), "</b>"));
                }
            }

            return(specs);
        }