Beispiel #1
0
        private GasInfo[] ParseGasSettings(string settings, float summPressure, float temp)
        {
            string[] gasSets = settings.Split(',');

            List <GasInfo> gasInfos = new List <GasInfo>();

            foreach (var gasSet in gasSets)
            {
                string[] namePart = gasSet.Split('-');
                string   name     = namePart[0];
                float    part     = float.Parse(namePart[1], CultureInfo.InvariantCulture);
                Gas      gas      = AtmosController.GetGasByName(name);
                int      id       = gas.Id;

                gasInfos.Add(new GasInfo(summPressure * part, id, temp));
            }

            return(gasInfos.ToArray());
        }
Beispiel #2
0
        private void CheckAtmos()
        {
            bool ok = true;

            Vector2Int cell;

            if (Holder == null)
            {
                cell = Cell;
            }
            else
            {
                cell = Holder.GetComponent <TileObject>().Cell;
            }

            Gas oxygen = AtmosController.GetGasByName("Oxygen");

            GasInfo[] gasInfos = AtmosController.GetGases(cell.x, cell.y);

            if (gasInfos == null)
            {
                return;
            }

            float summPressure   = 0;
            float oxygenPressure = 0;

            foreach (var gasInfo in gasInfos)
            {
                summPressure += gasInfo.Pressure;
                if (gasInfo.GasId == oxygen.Id)
                {
                    oxygenPressure += gasInfo.Pressure;
                }
            }
            float oxygenPart;

            if (summPressure != 0)
            {
                oxygenPart = oxygenPressure / summPressure;
            }
            else
            {
                oxygenPart = 0;
            }

            if (oxygenPart < _minimumOxygenPart || oxygenPart > _maximumOxygenPart)
            {
                ok = false;
            }

            if (summPressure < _minimumPressure || summPressure > _maximumPressure)
            {
                ok = false;
            }

            //Debug.Log("Oxygen: " + oxygenPart * 100 + "%" + ", pressure: " + summPressure + "kPa");

            _oxygenPart = oxygenPart;
            _pressure   = summPressure;

            if (gasInfos.Length > 0)
            {
                _temperature = gasInfos[0].Temperature;
            }

            _isOk = ok;
        }