Example #1
0
        public void MergeGroups(ExcitedGroup other)
        {
            var ourSize   = _tile.Count;
            var otherSize = other._tile.Count;

            if (ourSize > otherSize)
            {
                foreach (var tile in other._tile)
                {
                    tile.ExcitedGroup = this;
                    _tile.Add(tile);
                }
                other._tile.Clear();
                other.Dispose();
                ResetCooldowns();
            }
            else
            {
                foreach (var tile in _tile)
                {
                    tile.ExcitedGroup = other;
                    other._tile.Add(tile);
                }
                _tile.Clear();
                Dispose();
                other.ResetCooldowns();
            }
        }
Example #2
0
        public void ProcessHotspot()
        {
            if (!Hotspot.Valid)
            {
                _gridAtmosphereComponent.RemoveHotspotTile(this);
                return;
            }

            if (!Hotspot.SkippedFirstProcess)
            {
                Hotspot.SkippedFirstProcess = true;
                return;
            }

            ExcitedGroup?.ResetCooldowns();

            if ((Hotspot.Temperature < Atmospherics.FireMinimumTemperatureToExist) || (Hotspot.Volume <= 1f) ||
                Air == null || Air.Gases[(int)Gas.Oxygen] < 0.5f || Air.Gases[(int)Gas.Phoron] < 0.5f)
            {
                Hotspot = new Hotspot();
                UpdateVisuals();
                return;
            }

            PerformHotspotExposure();

            if (Hotspot.Bypassing)
            {
                Hotspot.State = 3;
                _gridAtmosphereComponent.BurnTile(GridIndices);

                if (Air.Temperature > Atmospherics.FireMinimumTemperatureToSpread)
                {
                    var radiatedTemperature = Air.Temperature * Atmospherics.FireSpreadRadiosityScale;
                    foreach (var(_, tile) in _adjacentTiles)
                    {
                        if (!tile.Hotspot.Valid)
                        {
                            tile.HotspotExpose(radiatedTemperature, Atmospherics.CellVolume / 4);
                        }
                    }
                }
            }
            else
            {
                Hotspot.State = Hotspot.Volume > Atmospherics.CellVolume * 0.4f ? 2 : 1;
            }

            if (Hotspot.Temperature > MaxFireTemperatureSustained)
            {
                MaxFireTemperatureSustained = Hotspot.Temperature;
            }

            // TODO ATMOS Maybe destroy location here?
        }
Example #3
0
        private void LastShareCheck()
        {
            var lastShare = Air.LastShare;

            if (lastShare > Atmospherics.MinimumAirToSuspend)
            {
                ExcitedGroup.ResetCooldowns();
            }
            else if (lastShare > Atmospherics.MinimumMolesDeltaToMove)
            {
                ExcitedGroup.DismantleCooldown = 0;
            }
        }
Example #4
0
        public void ProcessCell(int fireCount)
        {
            // Can't process a tile without air
            if (Air == null)
            {
                _gridAtmosphereComponent.RemoveActiveTile(this);
                return;
            }

            if (_archivedCycle < fireCount)
            {
                Archive(fireCount);
            }

            _currentCycle = fireCount;
            var adjacentTileLength = 0;

            foreach (var(_, enemyTile) in _adjacentTiles)
            {
                // If the tile is null or has no air, we don't do anything
                if (enemyTile?.Air == null)
                {
                    continue;
                }
                adjacentTileLength++;
                if (fireCount <= enemyTile._currentCycle)
                {
                    continue;
                }
                enemyTile.Archive(fireCount);

                var shouldShareAir = false;

                if (ExcitedGroup != null && enemyTile.ExcitedGroup != null)
                {
                    if (ExcitedGroup != enemyTile.ExcitedGroup)
                    {
                        ExcitedGroup.MergeGroups(enemyTile.ExcitedGroup);
                    }

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

                    var excitedGroup = ExcitedGroup;
                    excitedGroup ??= enemyTile.ExcitedGroup;

                    if (excitedGroup == null)
                    {
                        excitedGroup = new ExcitedGroup();
                        excitedGroup.Initialize(_gridAtmosphereComponent);
                    }

                    if (ExcitedGroup == null)
                    {
                        excitedGroup.AddTile(this);
                    }

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

                    shouldShareAir = true;
                }

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

                    // Space wind!
                    if (difference > 0)
                    {
                        ConsiderPressureDifference(enemyTile, difference);
                    }
                    else
                    {
                        enemyTile.ConsiderPressureDifference(this, -difference);
                    }

                    LastShareCheck();
                }
            }

            React();
            UpdateVisuals();

            if ((!(Air.Temperature > Atmospherics.MinimumTemperatureStartSuperConduction && ConsiderSuperconductivity(true))) && ExcitedGroup == null)
            {
                _gridAtmosphereComponent.RemoveActiveTile(this);
            }
        }