Пример #1
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);
        }