Exemplo n.º 1
0
        private void CheckAtmos()
        {
            // FIXME I'm just handling the exception here, I'm no atmos nerd so I don't know what's happening.
            // maybe it is just an initialization order problem?
            if (metaNode == null)
            {
                Logger.LogError("Scrubber found metadaNode to be null. Returning with no op.", Category.Atmos);
                return;
            }

            if (SelfSufficient == false)
            {
                var pressureDensity = pipeData.mixAndVolume.Density();

                if (pressureDensity.y > MaxInternalPressure || metaNode.GasMix.Pressure < MMinimumPressure)
                {
                    return;
                }
            }
            else
            {
                if (metaNode.GasMix.Pressure < MMinimumPressure)
                {
                    return;
                }
            }

            if (metaNode.GasMix.Pressure == 0)
            {
                return;
            }

            float available = MMinimumPressure / metaNode.GasMix.Pressure * metaNode.GasMix.Moles;

            if (available < 0)
            {
                return;
            }

            if (MaxTransferMoles < available)
            {
                available = MaxTransferMoles;
            }

            var    gasOnNode = metaNode.GasMix;
            GasMix pipeMix;

            if (SelfSufficient)
            {
                pipeMix = GasMix.NewGasMix(GasMixes.Air);                 //TODO: get some immutable gasmix to avoid GC
            }
            else
            {
                pipeMix = pipeData.mixAndVolume.GetGasMix();
            }

            GasMix.TransferGas(pipeMix, gasOnNode, available);

            metaDataLayer.UpdateSystemsAt(registerTile.LocalPositionServer, SystemType.AtmosSystem);
        }
Exemplo n.º 2
0
 public override void OnSpawnServer(SpawnInfo info)
 {
     metaDataLayer = MatrixManager.AtPoint(registerTile.WorldPositionServer, true).MetaDataLayer;
     metaNode      = metaDataLayer.Get(registerTile.LocalPositionServer, false);
     if (SelfSufficient)
     {
         selfSufficientGas = GasMix.NewGasMix(GasMixes.Air);
     }
     base.OnSpawnServer(info);
 }
Exemplo n.º 3
0
 /// <summary>
 /// Create a new MetaDataNode on the specified local position (within the parent matrix)
 /// </summary>
 /// <param name="position">local position (within the matrix) the node exists on</param>
 public MetaDataNode(Vector3Int position, ReactionManager reactionManager, Matrix matrix)
 {
     PositionMatrix = matrix;
     Position       = position;
     neighborList   = new List <MetaDataNode>(4);
     for (var i = 0; i < neighborList.Capacity; i++)
     {
         neighborList.Add(null);
     }
     GasMix = GasMix.NewGasMix(GasMixes.BaseSpaceMix);
     this.reactionManager = reactionManager;
 }
Exemplo n.º 4
0
        private void CheckAtmos()
        {
            if (SelfSufficient == false)
            {
                var pressureDensity = pipeData.mixAndVolume.Density();

                if (pressureDensity.y > MaxInternalPressure || metaNode.GasMix.Pressure < MMinimumPressure)
                {
                    return;
                }
            }
            else
            {
                if (metaNode.GasMix.Pressure < MMinimumPressure)
                {
                    return;
                }
            }

            if (metaNode.GasMix.Pressure == 0)
            {
                return;
            }

            float available = MMinimumPressure / metaNode.GasMix.Pressure * metaNode.GasMix.Moles;

            if (available < 0)
            {
                return;
            }

            if (MaxTransferMoles < available)
            {
                available = MaxTransferMoles;
            }

            var    gasOnNode = metaNode.GasMix;
            GasMix pipeMix;

            if (SelfSufficient)
            {
                pipeMix = GasMix.NewGasMix(GasMixes.Air);                 //TODO: get some immutable gasmix to avoid GC
            }
            else
            {
                pipeMix = pipeData.mixAndVolume.GetGasMix();
            }

            GasMix.TransferGas(pipeMix, gasOnNode, available);

            metaDataLayer.UpdateSystemsAt(registerTile.LocalPositionServer, SystemType.AtmosSystem);
        }
Exemplo n.º 5
0
        private void CheckAtmos()
        {
            // FIXME I'm just handling the exception here, I'm no atmos nerd so I don't know what's happening.
            // maybe it is just an initialization order problem?
            if (metaNode == null)
            {
                Logger.LogError("Airvent found metadaNode to be null. Returning with no op.", Category.Atmos);
                return;
            }

            //metaNode.GasMix = pipeData.mixAndVolume.EqualiseWithExternal(metaNode.GasMix);
            if (metaNode.GasMix.Pressure > MaxOutletPressure)
            {
                return;
            }

            float molesTransferred;

            if (metaNode.GasMix.Pressure != 0)
            {
                molesTransferred = ((MaxOutletPressure / metaNode.GasMix.Pressure) * metaNode.GasMix.Moles) - metaNode.GasMix.Moles;
                if (MaxTransferMoles < molesTransferred)
                {
                    molesTransferred = MaxTransferMoles;
                }
            }
            else
            {
                molesTransferred = MaxTransferMoles;
            }

            GasMix pipeMix;

            if (SelfSufficient)
            {
                pipeMix = GasMix.NewGasMix(GasMixes.Air);                 //TODO: get some immutable gasmix to avoid GC
                if (molesTransferred > GasMixes.Air.Moles)
                {
                    molesTransferred = GasMixes.Air.Moles;
                }
            }
            else
            {
                pipeMix = pipeData.mixAndVolume.GetGasMix();
                if (molesTransferred > pipeMix.Moles)
                {
                    molesTransferred = pipeMix.Moles;
                }
            }
            GasMix.TransferGas(metaNode.GasMix, pipeMix, molesTransferred);
            metaDataLayer.UpdateSystemsAt(registerTile.LocalPositionServer, SystemType.AtmosSystem);
        }
Exemplo n.º 6
0
        public override void OnSpawnServer(SpawnInfo info)
        {
            metaDataLayer = MatrixManager.AtPoint(registerTile.WorldPositionServer, true).MetaDataLayer;
            metaNode      = metaDataLayer.Get(registerTile.LocalPositionServer, false);
            pipeMix       = selfSufficient ? GasMix.NewGasMix(GasMixes.BaseEmptyMix) : pipeData.GetMixAndVolume.GetGasMix();

            if (TryGetComponent <AcuDevice>(out var device) && device.Controller != null)
            {
                SetOperatingMode(device.Controller.DesiredMode);
            }

            base.OnSpawnServer(info);
        }
Exemplo n.º 7
0
        private void CheckAtmos()
        {
            //metaNode.GasMix = pipeData.mixAndVolume.EqualiseWithExternal(metaNode.GasMix);
            if (metaNode.GasMix.Pressure > MaxOutletPressure)
            {
                return;
            }

            float molesTransferred;

            if (metaNode.GasMix.Pressure != 0)
            {
                molesTransferred = ((MaxOutletPressure / metaNode.GasMix.Pressure) * metaNode.GasMix.Moles) - metaNode.GasMix.Moles;
                if (MaxTransferMoles < molesTransferred)
                {
                    molesTransferred = MaxTransferMoles;
                }
            }
            else
            {
                molesTransferred = MaxTransferMoles;
            }

            GasMix pipeMix;

            if (SelfSufficient)
            {
                pipeMix = GasMix.NewGasMix(GasMixes.Air);                 //TODO: get some immutable gasmix to avoid GC
                if (molesTransferred > GasMixes.Air.Moles)
                {
                    molesTransferred = GasMixes.Air.Moles;
                }
            }
            else
            {
                pipeMix = pipeData.mixAndVolume.GetGasMix();
                if (molesTransferred > pipeMix.Moles)
                {
                    molesTransferred = pipeMix.Moles;
                }
            }
            GasMix.TransferGas(metaNode.GasMix, pipeMix, molesTransferred);
            metaDataLayer.UpdateSystemsAt(registerTile.LocalPositionServer, SystemType.AtmosSystem);
        }