Beispiel #1
0
        /// <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.Empty);

            int targetCount = 0;

            for (var i = 0; i < nodes.Count; i++)
            {
                MetaDataNode node = nodes[i];

                if (node == null)
                {
                    continue;
                }

                for (int j = 0; j < Gas.Count; j++)
                {
                    meanGasMix.Gases[j] += node.GasMix.Gases[j];
                }

                meanGasMix.SetPressure(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.SetPressure(meanGasMix.Pressure / targetCount);
            }

            return(meanGasMix);
        }
Beispiel #2
0
        private GasMix CalcAtmos(GasMix atmos, GasMix gasMix)
        {
            //Used for updating tiles with the averagee Calculated gas
            for (int i = 0; i < Gas.Count; i++)
            {
                atmos.Gases[i] = gasMix.Gases[i];
            }

            atmos.SetPressure(gasMix.Pressure);

            return(atmos);
        }