Ejemplo n.º 1
0
 public void UpdateAdjacent()
 {
     foreach (var direction in Cardinal)
     {
         if (!_gridAtmosphereComponent.IsAirBlocked(GridIndices.Offset(direction)))
         {
             _adjacentTiles[direction] = _gridAtmosphereComponent.GetTile(GridIndices.Offset(direction));
         }
     }
 }
Ejemplo n.º 2
0
        private bool TryRefreshTile(GridAtmosphereComponent gam, GasOverlayData oldTile, MapIndices indices, out GasOverlayData overlayData)
        {
            var tile = gam.GetTile(indices);

            if (tile == null)
            {
                overlayData = default;
                return(false);
            }

            var tileData = new List <GasData>();

            for (byte i = 0; i < Atmospherics.TotalNumberOfGases; i++)
            {
                var gas     = _atmosphereSystem.GetGas(i);
                var overlay = _atmosphereSystem.GetOverlay(i);
                if (overlay == null || tile?.Air == null)
                {
                    continue;
                }

                var moles = tile.Air.Gases[i];

                if (moles < gas.GasMolesVisible)
                {
                    continue;
                }

                var data = new GasData(i, (byte)(MathHelper.Clamp01(moles / gas.GasMolesVisibleMax) * 255));
                tileData.Add(data);
            }

            overlayData = new GasOverlayData(tile !.Hotspot.State, tile.Hotspot.Temperature, tileData.Count == 0 ? null : tileData.ToArray());

            if (overlayData.Equals(oldTile))
            {
                return(false);
            }

            return(true);
        }