Ejemplo n.º 1
0
        public bool ConsiderSuperconductivity(GridAtmosphereComponent gridAtmosphere, TileAtmosphere tile, bool starting)
        {
            if (!Superconduction)
            {
                return(false);
            }

            if (tile.Air == null || tile.Air.Temperature < (starting
                ? Atmospherics.MinimumTemperatureStartSuperConduction
                : Atmospherics.MinimumTemperatureForSuperconduction))
            {
                return(false);
            }

            return(!(GetHeatCapacity(tile.Air) < Atmospherics.MCellWithRatio) &&
                   ConsiderSuperconductivity(gridAtmosphere, tile));
        }
Ejemplo n.º 2
0
        private AtmosDirection ConductivityDirections(GridAtmosphereComponent gridAtmosphere, TileAtmosphere tile)
        {
            if (tile.Air == null)
            {
                if (tile.ArchivedCycle < gridAtmosphere.UpdateCounter)
                {
                    Archive(tile, gridAtmosphere.UpdateCounter);
                }
                return(AtmosDirection.All);
            }

            // TODO ATMOS check if this is correct
            return(AtmosDirection.All);
        }
Ejemplo n.º 3
0
        public bool ConsiderSuperconductivity(GridAtmosphereComponent gridAtmosphere, TileAtmosphere tile)
        {
            if (tile.ThermalConductivity == 0f || !Superconduction)
            {
                return(false);
            }

            gridAtmosphere.SuperconductivityTiles.Add(tile);
            return(true);
        }
        private void ProcessCell(GridAtmosphereComponent gridAtmosphere, TileAtmosphere tile, int fireCount)
        {
            // Can't process a tile without air
            if (tile.Air == null)
            {
                RemoveActiveTile(gridAtmosphere, tile);
                return;
            }

            if (tile.ArchivedCycle < fireCount)
            {
                Archive(tile, fireCount);
            }

            tile.CurrentCycle = fireCount;
            var adjacentTileLength = 0;

            for (var i = 0; i < Atmospherics.Directions; i++)
            {
                var direction = (AtmosDirection)(1 << i);
                if (tile.AdjacentBits.IsFlagSet(direction))
                {
                    adjacentTileLength++;
                }
            }

            for (var i = 0; i < Atmospherics.Directions; i++)
            {
                var direction = (AtmosDirection)(1 << i);
                if (!tile.AdjacentBits.IsFlagSet(direction))
                {
                    continue;
                }
                var enemyTile = tile.AdjacentTiles[i];

                // If the tile is null or has no air, we don't do anything for it.
                if (enemyTile?.Air == null)
                {
                    continue;
                }
                if (fireCount <= enemyTile.CurrentCycle)
                {
                    continue;
                }
                Archive(enemyTile, fireCount);

                var shouldShareAir = false;

                if (ExcitedGroups && tile.ExcitedGroup != null && enemyTile.ExcitedGroup != null)
                {
                    if (tile.ExcitedGroup != enemyTile.ExcitedGroup)
                    {
                        ExcitedGroupMerge(gridAtmosphere, tile.ExcitedGroup, enemyTile.ExcitedGroup);
                    }

                    shouldShareAir = true;
                }
                else if (tile.Air !.Compare(enemyTile.Air !) != GasMixture.GasCompareResult.NoExchange)
                {
                    if (!enemyTile.Excited)
                    {
                        AddActiveTile(gridAtmosphere, enemyTile);
                    }

                    if (ExcitedGroups)
                    {
                        var excitedGroup = tile.ExcitedGroup;
                        excitedGroup ??= enemyTile.ExcitedGroup;

                        if (excitedGroup == null)
                        {
                            excitedGroup = new ExcitedGroup();
                            gridAtmosphere.ExcitedGroups.Add(excitedGroup);
                        }

                        if (tile.ExcitedGroup == null)
                        {
                            ExcitedGroupAddTile(excitedGroup, tile);
                        }

                        if (enemyTile.ExcitedGroup == null)
                        {
                            ExcitedGroupAddTile(excitedGroup, enemyTile);
                        }
                    }

                    shouldShareAir = true;
                }

                if (shouldShareAir)
                {
                    var difference = Share(tile.Air !, enemyTile.Air !, adjacentTileLength);

                    // Monstermos already handles this, so let's not handle it ourselves.
                    if (!MonstermosEqualization)
                    {
                        if (difference >= 0)
                        {
                            ConsiderPressureDifference(gridAtmosphere, tile, direction, difference);
                        }
                        else
                        {
                            ConsiderPressureDifference(gridAtmosphere, enemyTile, direction.GetOpposite(), -difference);
                        }
                    }

                    LastShareCheck(tile);
                }
            }

            if (tile.Air != null)
            {
                React(tile.Air, tile);
            }

            InvalidateVisuals(tile.GridIndex, tile.GridIndices);

            var remove = true;

            if (tile.Air !.Temperature > Atmospherics.MinimumTemperatureStartSuperConduction)
            {
                if (ConsiderSuperconductivity(gridAtmosphere, tile, true))
                {
                    remove = false;
                }
            }

            if (ExcitedGroups && tile.ExcitedGroup == null && remove)
            {
                RemoveActiveTile(gridAtmosphere, tile);
            }
        }
Ejemplo n.º 5
0
        public void NeighborConductWithSource(GridAtmosphereComponent gridAtmosphere, TileAtmosphere tile, TileAtmosphere other)
        {
            if (tile.Air == null)
            {
                if (other.Tile != null)
                {
                    TemperatureShareOpenToSolid(other, tile);
                }
                else
                {
                    TemperatureShareMutualSolid(other, tile, tile.ThermalConductivity);
                }

                // TODO ATMOS: tile.TemperatureExpose(null, tile.Temperature, gridAtmosphere.GetVolumeForCells(1));
                return;
            }

            if (other.Air != null)
            {
                TemperatureShare(other.Air, tile.Air, Atmospherics.WindowHeatTransferCoefficient);
            }
            else
            {
                TemperatureShareOpenToSolid(tile, other);
            }

            AddActiveTile(gridAtmosphere, tile);
        }
 private void Archive(TileAtmosphere tile, int fireCount)
 {
     tile.Air?.Archive();
     tile.ArchivedCycle       = fireCount;
     tile.TemperatureArchived = tile.Temperature;
 }
Ejemplo n.º 7
0
 public override bool HasHighPressureDelta(TileAtmosphere tile)
 {
     return(false);
 }
 public virtual bool HasHighPressureDelta(TileAtmosphere tile)
 {
     return(_highPressureDelta.Contains(tile));
 }
        protected virtual void Revalidate()
        {
            if (!Owner.TryGetComponent(out IMapGridComponent? mapGrid))
            {
                return;
            }

            foreach (var indices in _invalidatedCoords.ToArray())
            {
                var tile = GetTile(indices);
                AddActiveTile(tile);

                if (tile == null)
                {
                    tile = new TileAtmosphere(this, mapGrid.Grid.Index, indices, new GasMixture(GetVolumeForCells(1))
                    {
                        Temperature = Atmospherics.T20C
                    });
                    Tiles[indices] = tile;
                }

                if (IsSpace(indices))
                {
                    tile.Air = new GasMixture(GetVolumeForCells(1));
                    tile.Air.MarkImmutable();
                    Tiles[indices] = tile;
                }
                else if (IsAirBlocked(indices))
                {
                    tile.Air = null;
                }
                else
                {
                    var obs = GetObstructingComponent(indices);

                    if (obs != null)
                    {
                        if (tile.Air == null && obs.FixVacuum)
                        {
                            FixVacuum(tile.GridIndices);
                        }
                    }

                    tile.Air ??= new GasMixture(GetVolumeForCells(1))
                    {
                        Temperature = Atmospherics.T20C
                    };
                }

                tile.UpdateAdjacent();
                tile.UpdateVisuals();

                for (var i = 0; i < Atmospherics.Directions; i++)
                {
                    var direction    = (AtmosDirection)(1 << i);
                    var otherIndices = indices.Offset(direction.ToDirection());
                    var otherTile    = GetTile(otherIndices);
                    AddActiveTile(otherTile);
                    otherTile?.UpdateAdjacent(direction.GetOpposite());
                }
            }

            _invalidatedCoords.Clear();
        }
 private void ConsiderPressureDifference(GridAtmosphereComponent gridAtmosphere, TileAtmosphere tile, TileAtmosphere other, float difference)
 {
     gridAtmosphere.HighPressureDelta.Add(tile);
     if (difference > tile.PressureDifference)
     {
         tile.PressureDifference = difference;
         tile.PressureDirection  = (tile.GridIndices - other.GridIndices).GetDir().ToAtmosDirection();
     }
 }