Ejemplo n.º 1
0
		public void FixedUpdate()
		{
			// if part is manned (even in the editor), force enabled
			if (Lib.IsManned(part) && state != State.enabled) state = State.equalizing;

			perctDeployed = Lib.Level(part, "Atmosphere", true);

			// instant pressurization and scrubbing inside breathable atmosphere
			if (!Lib.IsEditor() && Cache.VesselInfo(vessel).breathable)
			{
				var atmo = part.Resources["Atmosphere"];
				var waste = part.Resources["WasteAtmosphere"];
				var moist = part.Resources["MoistAtmosphere"];
				if (Get_inflate_string().Length == 0) // not inflatable
				{
					if ((state == State.equalizing) || (state == State.enabled))
					{
						if (Features.Pressure) atmo.amount = atmo.maxAmount;
					}
				}
				if (Features.Poisoning) waste.amount = 0.0;
				if (Features.Humidity) moist.amount = 0.0;
			}

			// state machine
			switch (state)
			{
				case State.enabled:
					Set_flow(true);
					break;

				case State.disabled:
					Set_flow(false);
					break;

				case State.equalizing:
					Set_flow(true);
					state = Equalize();
					break;

				case State.venting:
					Set_flow(false);
					// Just do Venting when has no gravityRing or when the gravity ring is not spinning.
					if (hasGravityRing && !gravityRing.Is_rotating()) state = Venting();
					else if (!hasGravityRing) state = Venting();
					break;
			}
		}
Ejemplo n.º 2
0
        public void FixedUpdate()
        {
            // if part is manned (even in the editor), force enabled
            if (Lib.IsManned(part) && state != State.enabled)
            {
                Set_flow(true);
                state = State.pressurizing;

                // Equalize run only in Flight mode
                needEqualize = true && Lib.IsFlight();
            }

            perctDeployed = Lib.Level(part, "Atmosphere", true);

            // Only handle crewTransferred & Toggle, this way has less calls in FixedUpdate
            // CrewTransferred Event occur after FixedUpdate, this must be check in crewtransferred
            if (FixIVA)
            {
                if (Get_inflate_string().Length == 0)                 // it is not inflatable (We always going to show and cross those habitats)
                {
                    SetPassable(true);
                    UpdateIVA(true);
                }
                else
                {
                    // Inflatable modules shows IVA and are passable only in 99.9999% deployed
                    SetPassable(Lib.IsManned(part) || Math.Truncate(Math.Abs((perctDeployed + ResourceBalance.precision) - 1.0) * 100000) / 100000 <= ResourceBalance.precision);
                    UpdateIVA(Math.Truncate(Math.Abs((perctDeployed + ResourceBalance.precision) - 1.0) * 100000) / 100000 <= ResourceBalance.precision);
                }
                FixIVA = false;
            }

            // state machine
            switch (state)
            {
            case State.enabled:
                // In case it is losting pressure
                if (perctDeployed < Settings.PressureThreshold)
                {
                    if (Get_inflate_string().Length != 0)                                     // it is inflatable
                    {
                        SetPassable(false || Lib.IsManned(part));                             // Prevent to not lock a Kerbal into a the part
                        UpdateIVA(false);
                    }
                    needEqualize = true;
                    state        = State.pressurizing;
                }
                break;

            case State.disabled:
                break;

            case State.pressurizing:
                state = Pressurizing();
                break;

            case State.depressurizing:
                // Just do Venting when has no gravityRing or when the gravity ring is not spinning.
                if (hasGravityRing && !gravityRing.Is_rotating())
                {
                    state = Depressurizing();
                }
                else if (!hasGravityRing)
                {
                    state = Depressurizing();
                }
                break;
            }
        }