Beispiel #1
0
        public override string Info()
        {
            bool   recording    = Lib.Proto.GetBool(proto, "recording");
            bool   forcedRun    = Lib.Proto.GetBool(proto, "forcedRun");
            double scienceValue = Lib.Proto.GetDouble(proto, "scienceValue");
            string issue        = Lib.Proto.GetString(proto, "issue");

            var state = Experiment.GetState(scienceValue, issue, recording, forcedRun);

            if (state == Experiment.State.WAITING)
            {
                return("waiting...");
            }

            double dataSampled = Lib.Proto.GetDouble(proto, "dataSampled");
            double data_rate   = Lib.Proto.GetDouble(proto, "data_rate");

            var exp             = Science.Experiment(prefab.experiment_id);
            var recordedPercent = Lib.HumanReadablePerc(dataSampled / exp.max_amount);
            var eta             = data_rate < double.Epsilon || Experiment.Done(exp, dataSampled) ? " done" : " " + Lib.HumanReadableCountdown((exp.max_amount - dataSampled) / data_rate);

            return(!recording
                          ? "<color=red>" + Localizer.Format("#KERBALISM_Generic_STOPPED") + " </color>"
                          : issue.Length == 0 ? "<color=cyan>" + Lib.BuildString(recordedPercent, eta) + "</color>"
                          : Lib.BuildString("<color=yellow>", issue.ToLower(), "</color>"));
        }
Beispiel #2
0
        public override string Info()
        {
            var state = Experiment.GetState(experiment.scienceValue, experiment.issue, experiment.recording, experiment.forcedRun);

            if (state == Experiment.State.WAITING)
            {
                return("waiting...");
            }
            var exp             = Science.Experiment(experiment.experiment_id);
            var recordedPercent = Lib.HumanReadablePerc(experiment.dataSampled / exp.max_amount);
            var eta             = experiment.data_rate < double.Epsilon || Experiment.Done(exp, experiment.dataSampled) ? " done" : " " + Lib.HumanReadableCountdown((exp.max_amount - experiment.dataSampled) / experiment.data_rate);

            return(!experiment.recording
                          ? "<color=red>" + Localizer.Format("#KERBALISM_Generic_DISABLED") + " </color>"
                          : experiment.issue.Length == 0 ? "<color=cyan>" + Lib.BuildString(recordedPercent, eta) + "</color>"
                          : Lib.BuildString("<color=yellow>", experiment.issue.ToLower(), "</color>"));
        }
Beispiel #3
0
        public override void Ctrl(bool value)
        {
            bool   recording    = Lib.Proto.GetBool(proto, "recording");
            bool   forcedRun    = Lib.Proto.GetBool(proto, "forcedRun");
            double scienceValue = Lib.Proto.GetDouble(proto, "scienceValue");
            string issue        = Lib.Proto.GetString(proto, "issue");
            var    state        = Experiment.GetState(scienceValue, issue, recording, forcedRun);


            if (state == Experiment.State.WAITING)
            {
                Lib.Proto.Set(proto, "forcedRun", true);
                return;
            }

            if (value)
            {
                // The same experiment must run only once on a vessel
                foreach (var pair in allExperiments)
                {
                    var e = pair.Key;
                    var p = pair.Value;
                    if (e.experiment_id != prefab.experiment_id)
                    {
                        continue;
                    }
                    if (!e.isEnabled || !e.enabled)
                    {
                        continue;
                    }
                    if (e.part.flightID == prefab.part.flightID)
                    {
                        continue;
                    }
                    if (recording)
                    {
                        Experiment.PostMultipleRunsMessage(title, vessel_name);
                        return;
                    }
                }
            }

            Lib.Proto.Set(proto, "recording", value);
        }