コード例 #1
0
        public static void BackgroundUpdate(Vessel v, ProtoPartModuleSnapshot m, Experiment exp, Resource_Info ec, double elapsed_s)
        {
            // if experiment is active
            if (Lib.Proto.GetBool(m, "recording"))
            {
                // detect conditions
                // - comparing against amount in previous step
                bool   has_ec       = ec.amount > double.Epsilon;
                bool   has_operator = new CrewSpecs(exp.crew).Check(v);
                string sit          = Science.Situation(v, exp.situations);

                // deduce issues
                string issue = string.Empty;
                if (sit.Length == 0)
                {
                    issue = "invalid situation";
                }
                else if (!has_operator)
                {
                    issue = "no operator";
                }
                else if (!has_ec)
                {
                    issue = "missing <b>EC</b>";
                }
                Lib.Proto.Set(m, "issue", issue);

                // if there are no issues
                if (issue.Length == 0)
                {
                    // generate subject id
                    string subject_id = Science.Generate_Subject(exp.experiment, v.mainBody, sit, Science.Biome(v, sit), Science.Multiplier(v, sit));

                    // record in drive
                    if (exp.transmissible)
                    {
                        DB.Vessel(v).drive.Record_File(subject_id, exp.data_rate * elapsed_s);
                    }
                    else
                    {
                        DB.Vessel(v).drive.Record_Sample(subject_id, exp.data_rate * elapsed_s);
                    }

                    // consume ec
                    ec.Consume(exp.ec_rate * elapsed_s);
                }
            }
        }
コード例 #2
0
        public override void OnStart(StartState state)
        {
            // don't break tutorial scenarios
            if (Lib.DisableScenario(this))
            {
                return;
            }

            // create animator
            deploy_anim = new Animator(part, deploy);

            // set initial animation state
            deploy_anim.Still(recording ? 1.0 : 0.0);

            // parse crew specs
            operator_cs = new CrewSpecs(crew);

            // get experiment title
            exp_name = ResearchAndDevelopment.GetExperiment(experiment).experimentTitle;
        }