private bool Breathe(IGasMixContainer node)
    {
        breatheCooldown--;          //not timebased, but tickbased
        if (breatheCooldown > 0)
        {
            return(false);
        }
        // if no internal breathing is possible, get the from the surroundings
        IGasMixContainer container = GetInternalGasMix() ?? node;

        GasMix gasMix       = container.GasMix;
        GasMix breathGasMix = gasMix.RemoveVolume(AtmosConstants.BREATH_VOLUME, true);

        float oxygenUsed = HandleBreathing(breathGasMix);

        if (oxygenUsed > 0)
        {
            breathGasMix.RemoveGas(Gas.Oxygen, oxygenUsed);
            node.GasMix.AddGas(Gas.CarbonDioxide, oxygenUsed);
            registerTile.Matrix.MetaDataLayer.UpdateSystemsAt(registerTile.LocalPositionClient);
        }

        gasMix          += breathGasMix;
        container.GasMix = gasMix;

        return(oxygenUsed > 0);
    }
Example #2
0
        public Tuple <ReagentMix, GasMix> Take(MixAndVolume InmixAndVolume, bool removeVolume = true)
        {
            if (InmixAndVolume.Volume == 0)
            {
                Logger.LogError(" divide by 0 in Take ");
            }

            float Percentage = Volume / InmixAndVolume.Volume;

            var ReturnMix = Mix.Take(Mix.Total * Percentage);

            if (removeVolume)
            {
                gasMix.ChangeVolumeValue(-InmixAndVolume.gasMix.Volume);
                Volume = Volume - InmixAndVolume.Volume;
            }

            var ReturnGasMix = gasMix.RemoveVolume(InmixAndVolume.gasMix.Volume);

            return(new Tuple <ReagentMix, GasMix>(ReturnMix, ReturnGasMix));
        }
Example #3
0
    private bool Breathe(IGasMixContainer node)
    {
        // if no internal breathing is possible, get the from the surroundings
        IGasMixContainer container = GetInternalGasMix() ?? node;

        GasMix gasMix       = container.GasMix;
        GasMix breathGasMix = gasMix.RemoveVolume(AtmosConstants.BREATH_VOLUME, true);

        float oxygenUsed = HandleBreathing(breathGasMix);

        if (oxygenUsed > 0)
        {
            breathGasMix.RemoveGas(Gas.Oxygen, oxygenUsed);
            breathGasMix.AddGas(Gas.CarbonDioxide, oxygenUsed);
        }

        gasMix          += breathGasMix;
        container.GasMix = gasMix;

        return(oxygenUsed > 0);
    }
Example #4
0
        public Tuple <ReagentMix, GasMix> Take(MixAndVolume InmixAndVolume, bool removeVolume = true)
        {
            float Percentage = Volume / InmixAndVolume.Volume;

            var ReturnMix = Mix.Take(Mix.Total * Percentage);

            if (removeVolume)
            {
                gasMix.ChangeVolumeValue(-InmixAndVolume.gasMix.Volume);
                Volume = Volume - InmixAndVolume.Volume;
            }

            var ReturnGasMix = gasMix.RemoveVolume(InmixAndVolume.gasMix.Volume);

            if (gasMix.Gases.Any(x => x < 0))
            {
                Logger.Log("0!!!");
            }

            return(new Tuple <ReagentMix, GasMix>(ReturnMix, ReturnGasMix));
        }