Beispiel #1
0
        public void Update()
        {
            // The first time an existing save game is loaded with Kerbalism installed,
            // MM will to any existing vessels add Nitrogen with the correct capacities as set in default.cfg but they will have zero amounts,
            // this is not the case for any newly created vessels in the editor.
            if (configured)
            {
                if (state == State.enabled && Features.Pressure)
                {
                    Lib.FillResource(part, "Nitrogen");
                }
                else
                {
                    Lib.EmptyResource(part, "Nitrogen");
                }
                configured = false;
            }

            // update ui
            string status_str = string.Empty;

            switch (state)
            {
            case State.enabled:
                if (Math.Truncate(Math.Abs((perctDeployed + ResourceBalance.precision) - 1.0) * 100000) / 100000 > ResourceBalance.precision)
                {
                    // No inflatable can be enabled been pressurizing
                    status_str = Localizer.Format("#KERBALISM_Habitat_pressurizing");
                }
                else
                {
                    status_str = Localizer.Format("#KERBALISM_Generic_ENABLED");
                }
                Set_pressurized(true);
                break;

            case State.disabled:
                status_str = Localizer.Format("#KERBALISM_Generic_DISABLED");
                Set_pressurized(false);
                break;

            case State.pressurizing:
                status_str  = Get_inflate_string().Length == 0 ? Localizer.Format("#KERBALISM_Habitat_pressurizing") : Localizer.Format("#KERBALISM_Habitat_inflating");
                status_str += string.Format("{0:p2}", perctDeployed);
                Set_pressurized(false);
                break;

            case State.depressurizing:
                status_str  = Get_inflate_string().Length == 0 ? Localizer.Format("#KERBALISM_Habitat_depressurizing") : Localizer.Format("#KERBALISM_Habitat_deflating");
                status_str += string.Format("{0:p2}", perctDeployed);
                Set_pressurized(false);
                break;
            }

            Events["Toggle"].guiName = Lib.StatusToggle("Habitat", status_str);

            // Changing this animation when we expect rotation will not work because
            // Unity disables other animations when playing the inflation animation.
            if (prev_state != State.enabled)
            {
                Set_inflation();
            }
            prev_state = state;
        }