示例#1
0
        public void ToggleWindow()
        {
            // in flight
            if (Lib.IsFlight())
            {
                // disable for dead eva kerbals
                Vessel v = FlightGlobals.ActiveVessel;
                if (v == null || EVA.IsDead(v))
                {
                    return;
                }

                // check trait
                if (!reconfigure_cs.check(v))
                {
                    Message.Post("Can't reconfigure the component", reconfigure_cs.warning());
                    return;
                }

                // warn the user about potential resource loss
                if (resource_loss())
                {
                    Message.Post(Severity.warning, "Reconfiguring will dump resources in excess of capacity.");
                }
            }

            // open the window
            UI.open(window_body);
        }
示例#2
0
        public void FixedUpdate()
        {
            // do nothing in the editor
            if (Lib.IsEditor())
            {
                return;
            }

            // if enabled
            if (running)
            {
                // if a researcher is not required, or the researcher is present
                if (!researcher_cs || researcher_cs.check(part.protoModuleCrew))
                {
                    // get next sample to analyze
                    string sample_filename = next_sample(vessel);

                    // if there is a sample to analyze
                    if (sample_filename.Length > 0)
                    {
                        // consume EC
                        resource_info ec = ResourceCache.Info(vessel, "ElectricCharge");
                        ec.Consume(ec_rate * Kerbalism.elapsed_s);

                        // if there was ec
                        // - comparing against amount in previous simulation step
                        if (ec.amount > double.Epsilon)
                        {
                            // analyze the sample
                            analyze(vessel, sample_filename, analysis_rate * Kerbalism.elapsed_s);

                            // update status
                            status = Science.experiment(sample_filename).name;
                        }
                        // if there was no ec
                        else
                        {
                            // update status
                            status = "<color=yellow>no electric charge</color>";
                        }
                    }
                    // if there is no sample to analyze
                    else
                    {
                        // update status
                        status = "no samples to analyze";
                    }
                }
                // if a researcher is required, but missing
                else
                {
                    // update status
                    status = Lib.BuildString("<color=yellow>", researcher_cs.warning(), "</color>");
                }
            }
            // if disabled
            else
            {
                // update status
                status = "disabled";
            }
        }
示例#3
0
        public void ToggleWindow()
        {
            // in flight
            if (Lib.IsFlight())
            {
                // disable for dead eva kerbals
                Vessel v = FlightGlobals.ActiveVessel;
                if (v == null || EVA.IsDead(v))
                {
                    return;
                }

                // check trait
                if (!reconfigure_cs.check(v))
                {
                    Message.Post(Localizer.Format("#KERBALISM_Configure_noconfigure"), reconfigure_cs.warning());
                    return;
                }

                // warn the user about potential resource loss
                if (resource_loss())
                {
                    Message.Post(Severity.warning, Localizer.Format("#KERBALISM_Configure_dumpexcess"));
                }
            }

            // open the window
            UI.open(window_body);
        }
示例#4
0
        public void Repair()
        {
            // disable for dead eva kerbals
            Vessel v = FlightGlobals.ActiveVessel;

            if (v == null || EVA.IsDead(v))
            {
                return;
            }

            // check trait
            if (!repair_cs.check(v))
            {
                Message.Post
                (
                    Lib.TextVariant
                    (
                        "I'm not qualified for this",
                        "I will not even know where to start",
                        "I'm afraid I can't do that"
                    ),
                    repair_cs.warning()
                );
                return;
            }

            // flag as not broken
            broken = false;

            // reset times
            last = 0.0;
            next = 0.0;

            // re-enable module
            foreach (PartModule m in modules)
            {
                m.isEnabled = true;
                m.enabled   = true;
            }

            // we need to reconfigure the module here, because if all modules of a type
            // share the broken state, and these modules are part of a configure setup,
            // then repairing will enable all of them, messing up with the configuration
            part.FindModulesImplementing <Configure>().ForEach(k => k.configure());

            // type-specific hacks
            apply(false);

            // notify user
            Message.Post
            (
                Lib.BuildString("<b>", title, "</b> repaired"),
                Lib.TextVariant
                (
                    "A powerkick did the trick",
                    "Duct tape, is there something it can't fix?",
                    "Fully operational again",
                    "We are back in business"
                )
            );
        }