/// <summary> /// Calculate the average Gas tile if you averaged all the adjacent ones and itself /// </summary> /// <returns>The mean gas mix.</returns> private GasMix CalcMeanGasMix() { meanGasMix.Copy(GasMixes.Space); int targetCount = 0; for (var i = 0; i < nodes.Count; i++) { MetaDataNode node = nodes[i]; if (node.IsSpace) { //Set to 0 if space node.GasMix *= 0; } for (int j = 0; j < Gas.Count; j++) { meanGasMix.Gases[j] += node.GasMix.Gases[j]; } meanGasMix.Pressure += node.GasMix.Pressure; if (!node.IsOccupied) { targetCount++; } else { //Decay if occupied node.GasMix *= 0; } } // Sometime, we calculate the meanGasMix of a tile surrounded by IsOccupied tiles (no atmos) // This condition is to avoid a divide by zero error (or 0 / 0 that gives NaN) if (targetCount != 0) { for (int j = 0; j < Gas.Count; j++) { meanGasMix.Gases[j] /= targetCount; } meanGasMix.Pressure /= targetCount; } return(meanGasMix); }
private GasMix CalcMeanGasMix() { meanGasMix.Copy(GasMixes.Space); int targetCount = 0; for (var i = 0; i < nodes.Count; i++) { MetaDataNode node = nodes[i]; if (node.IsSpace) { node.GasMix *= 1 - factor; } for (int j = 0; j < Gas.Count; j++) { meanGasMix.Gases[j] += node.GasMix.Gases[j]; } meanGasMix.Pressure += node.GasMix.Pressure; if (!node.IsOccupied) { targetCount++; } else { node.GasMix *= 1 - factor; if (node.GasMix.Pressure > AtmosConstants.MinPressureDifference) { updateList.Enqueue(node); } } } for (int j = 0; j < Gas.Count; j++) { meanGasMix.Gases[j] /= targetCount; } meanGasMix.Pressure /= targetCount; return(meanGasMix); }
/// <summary> /// Calculate the average Gas tile if you averaged all the adjacent ones and itself /// </summary> /// <returns>The mean gas mix.</returns> private GasMix CalcMeanGasMix() { meanGasMix.Copy(GasMixes.Space); int targetCount = 0; for (var i = 0; i < nodes.Count; i++) { MetaDataNode node = nodes[i]; if (node.IsSpace) { //Set to 0 if space node.GasMix *= 0; } for (int j = 0; j < Gas.Count; j++) { meanGasMix.Gases[j] += node.GasMix.Gases[j]; } meanGasMix.Pressure += node.GasMix.Pressure; if (!node.IsOccupied) { targetCount++; } else { //Decay if occupied node.GasMix *= 0; } } for (int j = 0; j < Gas.Count; j++) { meanGasMix.Gases[j] /= targetCount; } meanGasMix.Pressure /= targetCount; return(meanGasMix); }