public void SetTileOverlay(GridId gridIndex, MapIndices indices, GasData[] gasData, int fireState = 0, float fireTemperature = 0f) { if (!_overlay.TryGetValue(gridIndex, out var _)) { _overlay[gridIndex] = new Dictionary <MapIndices, GasOverlayData>(); } _overlay[gridIndex][indices] = new GasOverlayData(fireState, fireTemperature, gasData); _queue.Add(GetData(gridIndex, indices)); }
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); }
public GasTileOverlayData(GridId gridIndex, MapIndices gridIndices, GasOverlayData data) { GridIndex = gridIndex; GridIndices = gridIndices; Data = data; }