Exemplo n.º 1
0
        /// <summary>
        /// Refreshes the properties of this ViewModel.
        ///
        /// If partialRefresh is set to true, the ViewModel will try to update only data changes during a pulse.
        /// </summary>
        public void Refresh(bool partialRefresh = false)
        {
            // Get up-to-date datablobs for this entity.
            PositionDB positionDB = _entity.GetDataBlob <PositionDB>();

            UpdateProperties(positionDB);

            SystemBodyInfoDB systemBodyDB = _entity.GetDataBlob <SystemBodyInfoDB>();

            UpdateProperties(systemBodyDB, partialRefresh);

            NameDB nameDB = _entity.GetDataBlob <NameDB>();

            UpdateProperties(nameDB);

            //AtmosphereDB atmosphereDB = _entity.GetDataBlob<AtmosphereDB>();
            //UpdateProperties(atmosphereDB);

            // Check if we're doing a full refresh.
            if (!partialRefresh)
            {
                OrbitDB orbitDB = _entity.GetDataBlob <OrbitDB>();
                UpdateProperties(orbitDB);

                MassVolumeDB massVolumeDB = _entity.GetDataBlob <MassVolumeDB>();
                UpdateProperties(massVolumeDB);
            }
        }
Exemplo n.º 2
0
        private void Planetetup(SystemBodyInfoDB sysBodyInfo)
        {
            //maybe look at proceduraly genning textures? also look at diferentiating an icon (zoomed out) and a textue (zoomed right in)
            switch (sysBodyInfo.BodyType)
            {
            case BodyType.Asteroid:
            {
                ItemTextureName = DEFAULT_PLANET_ICON;
            }
            break;

            case BodyType.Comet:
            {
                ItemTextureName = DEFAULT_PLANET_ICON;
            }
            break;

            case BodyType.DwarfPlanet:
            {
                ItemTextureName = DEFAULT_PLANET_ICON;
            }
            break;

            case BodyType.GasDwarf:
            {
                ItemTextureName = DEFAULT_PLANET_ICON;
            }
            break;

            case BodyType.GasGiant:
            {
                ItemTextureName = DEFAULT_PLANET_ICON;
            }
            break;

            case BodyType.IceGiant:
            {
                ItemTextureName = DEFAULT_PLANET_ICON;
            }
            break;

            case BodyType.Moon:
            {
                ItemTextureName = DEFAULT_PLANET_ICON;
            }
            break;

            case BodyType.Terrestrial:
            {
                ItemTextureName = DEFAULT_PLANET_ICON;
            }
            break;

            default:
            {
                ItemTextureName = DEFAULT_PLANET_ICON;
            }
            break;
            }
        }
Exemplo n.º 3
0
        void Setup(Entity entity)
        {
            _systemBodyInfoDB = entity.GetDataBlob <SystemBodyInfoDB>();
            _bodyType         = _systemBodyInfoDB.BodyType;
            _massVolDB        = entity.GetDataBlob <MassVolumeDB>();

            _rng = new Random(entity.Guid.GetHashCode()); //use entity guid as a seed for psudoRandomness.

            switch (_bodyType)
            {
            case BodyType.Asteroid:
                Asteroid();
                break;

            case BodyType.Terrestrial:
                Terestrial();
                break;

            default:
                Unknown();
                break;
            }

            if (entity.HasDataBlob <AtmosphereDB>())
            {
            }
        }
Exemplo n.º 4
0
        // Sets an entity to earth normal aside from the atmosphere
        private Entity setAtmosphere(AtmosphereDB atmosDB)
        {
            SystemBodyInfoDB earthBodyDB = new SystemBodyInfoDB {
                BodyType = BodyType.Terrestrial, SupportsPopulations = true
            };
            NameDB earthNameDB = new NameDB("Earth");

            earthBodyDB.Gravity         = 1.0;
            earthBodyDB.BaseTemperature = 20.0f;

            Entity resultPlanet = new Entity(_entityManager, new List <BaseDataBlob> {
                earthBodyDB, earthNameDB, atmosDB
            });

            return(resultPlanet);
        }
Exemplo n.º 5
0
        private void UpdateProperties([NotNull] SystemBodyInfoDB systemBodyDB, bool partialRefresh)
        {
            if (systemBodyDB == null)
            {
                throw new ArgumentNullException("systemBodyDB");
            }

            if (!partialRefresh)
            {
                // Full Refresh. Update unchanging variables.
                PlanetType      = systemBodyDB.BodyType.ToString();
                AxialTilt       = systemBodyDB.AxialTilt;
                BaseTemperature = systemBodyDB.BaseTemperature;
                LengthOfDay     = systemBodyDB.LengthOfDay;
                MagneticField   = systemBodyDB.MagneticField;
                Tectonics       = systemBodyDB.Tectonics.ToString();
            }
            // Unused currently. TODO: Review if this should be moved to AtmosphereDB in the game lib.
            // AtmosphericDust = systemBodyDB.AtmosphericDust;
            // RadiationLevel = systemBodyDB.RadiationLevel;
            // SupportsPopulation = systemBodyDB.SupportsPopulation;
            // Minerals = systemBodyDB.Minerals;
        }
Exemplo n.º 6
0
        public void testColonyToxicityCost()
        {
            SystemBodyInfoDB earthBodyDB = new SystemBodyInfoDB {
                BodyType = BodyType.Terrestrial, SupportsPopulations = true
            };
            NameDB earthNameDB = new NameDB("Earth");
            double expectedCost;
            string gasSym;

            Dictionary <string, AtmosphericGasSD> lowToxicGases, highToxicGases, benignGases;
            AtmosphericGasSD oxygenGas;

            lowToxicGases  = new Dictionary <string, AtmosphericGasSD>();
            highToxicGases = new Dictionary <string, AtmosphericGasSD>();
            benignGases    = new Dictionary <string, AtmosphericGasSD>();
            oxygenGas      = new AtmosphericGasSD();

            //Separate all the gases into the lists above
            foreach (KeyValuePair <string, AtmosphericGasSD> kvp in _gasDictionary)
            {
                gasSym = kvp.Key;
                if (gasSym == "H2" || gasSym == "CH4" || gasSym == "NH3" || gasSym == "CO" || gasSym == "NO" || gasSym == "H2S" || gasSym == "NO2" || gasSym == "SO2")
                {
                    lowToxicGases.Add(gasSym, kvp.Value);
                }
                else if (gasSym == "Cl2" || gasSym == "F2" || gasSym == "Br2" || gasSym == "I2")
                {
                    highToxicGases.Add(gasSym, kvp.Value);
                }
                else if (gasSym == "O")
                {
                    oxygenGas = kvp.Value;
                }
                else
                {
                    benignGases.Add(gasSym, kvp.Value);
                }
            }

            // @todo: set up two nested loops - one for list of species, one for list of gases
            // test a large number of different inputs
            AtmosphereDB weirdAtmosphereDB;
            Dictionary <AtmosphericGasSD, float> atmoGasses = new Dictionary <AtmosphericGasSD, float>();

            // Test the "low" toxic gases (colony cost 2.0 minimum
            foreach (KeyValuePair <string, AtmosphericGasSD> kvp in lowToxicGases)
            {
                expectedCost = 2.0;
                gasSym       = kvp.Key;
                atmoGasses.Clear();
                atmoGasses.Add(_gasDictionary[gasSym], 0.1f);
                weirdAtmosphereDB = new AtmosphereDB(1f, true, 71, 1f, 1f, 0.3f, 57.2f, atmoGasses); //TODO what's our greenhouse factor an pressure?
                _weirdatmosPlanet = setAtmosphere(weirdAtmosphereDB);

                Assert.AreEqual(expectedCost, SpeciesProcessor.ColonyCost(_weirdatmosPlanet, _humanSpecies.GetDataBlob <SpeciesDB>()));
            }

            // Test the "high" toxic gases (colony cost 3.0 minimum)
            foreach (KeyValuePair <string, AtmosphericGasSD> kvp in highToxicGases)
            {
                expectedCost = 3.0;
                gasSym       = kvp.Key;
                atmoGasses.Clear();
                atmoGasses.Add(_gasDictionary[gasSym], 0.1f);
                weirdAtmosphereDB = new AtmosphereDB(1f, true, 71, 1f, 1f, 0.3f, 57.2f, atmoGasses); //TODO what's our greenhouse factor an pressure?
                _weirdatmosPlanet = setAtmosphere(weirdAtmosphereDB);

                Assert.AreEqual(expectedCost, SpeciesProcessor.ColonyCost(_weirdatmosPlanet, _humanSpecies.GetDataBlob <SpeciesDB>()));
            }

            // Test the "benign" toxic gases (no affect on colony cost, but no oxygen means 2.0)
            foreach (KeyValuePair <string, AtmosphericGasSD> kvp in lowToxicGases)
            {
                expectedCost = 2.0;
                gasSym       = kvp.Key;
                atmoGasses.Clear();
                atmoGasses.Add(_gasDictionary[gasSym], 0.1f);
                weirdAtmosphereDB = new AtmosphereDB(1f, true, 71, 1f, 1f, 0.3f, 57.2f, atmoGasses); //TODO what's our greenhouse factor an pressure?
                _weirdatmosPlanet = setAtmosphere(weirdAtmosphereDB);

                Assert.AreEqual(expectedCost, SpeciesProcessor.ColonyCost(_weirdatmosPlanet, _humanSpecies.GetDataBlob <SpeciesDB>()));
            }

            // test with atmposheres composed of two toxic gases that have the same colony cost
            foreach (KeyValuePair <string, AtmosphericGasSD> kvp1 in lowToxicGases)
            {
                foreach (KeyValuePair <string, AtmosphericGasSD> kvp2 in lowToxicGases)
                {
                    expectedCost = 2.0;
                    string gasSym1 = kvp1.Key;
                    string gasSym2 = kvp2.Key;
                    if (gasSym1 == gasSym2)
                    {
                        continue;
                    }

                    atmoGasses.Clear();
                    atmoGasses.Add(lowToxicGases[gasSym1], 0.1f);
                    atmoGasses.Add(lowToxicGases[gasSym2], 0.1f);
                    weirdAtmosphereDB = new AtmosphereDB(1f, true, 71, 1f, 1f, 0.3f, 57.2f, atmoGasses); //TODO what's our greenhouse factor an pressure?
                    _weirdatmosPlanet = setAtmosphere(weirdAtmosphereDB);

                    Assert.AreEqual(expectedCost, SpeciesProcessor.ColonyCost(_weirdatmosPlanet, _humanSpecies.GetDataBlob <SpeciesDB>()));
                }
            }

            // test with atmposheres composed of two toxic gases that have the same colony cost
            foreach (KeyValuePair <string, AtmosphericGasSD> kvp1 in highToxicGases)
            {
                foreach (KeyValuePair <string, AtmosphericGasSD> kvp2 in highToxicGases)
                {
                    expectedCost = 3.0;
                    string gasSym1 = kvp1.Key;
                    string gasSym2 = kvp2.Key;
                    if (gasSym1 == gasSym2)
                    {
                        continue;
                    }

                    atmoGasses.Clear();
                    atmoGasses.Add(highToxicGases[gasSym1], 0.1f);
                    atmoGasses.Add(highToxicGases[gasSym2], 0.1f);
                    weirdAtmosphereDB = new AtmosphereDB(1f, true, 71, 1f, 1f, 0.3f, 57.2f, atmoGasses); //TODO what's our greenhouse factor an pressure?
                    _weirdatmosPlanet = setAtmosphere(weirdAtmosphereDB);

                    Assert.AreEqual(expectedCost, SpeciesProcessor.ColonyCost(_weirdatmosPlanet, _humanSpecies.GetDataBlob <SpeciesDB>()));
                }
            }

            // test with atmospheres composed of two toxic gases that have different colony costs

            foreach (KeyValuePair <string, AtmosphericGasSD> kvp1 in lowToxicGases)
            {
                foreach (KeyValuePair <string, AtmosphericGasSD> kvp2 in highToxicGases)
                {
                    expectedCost = 3.0;
                    string gasSym1 = kvp1.Key;
                    string gasSym2 = kvp2.Key;
                    if (gasSym1 == gasSym2)
                    {
                        continue;
                    }

                    atmoGasses.Clear();
                    atmoGasses.Add(lowToxicGases[gasSym1], 0.1f);
                    atmoGasses.Add(highToxicGases[gasSym2], 0.1f);
                    weirdAtmosphereDB = new AtmosphereDB(1f, true, 71, 1f, 1f, 0.3f, 57.2f, atmoGasses); //TODO what's our greenhouse factor an pressure?
                    _weirdatmosPlanet = setAtmosphere(weirdAtmosphereDB);

                    Assert.AreEqual(expectedCost, SpeciesProcessor.ColonyCost(_weirdatmosPlanet, _humanSpecies.GetDataBlob <SpeciesDB>()));
                }
            }


            //Toxic Gasses(CC = 2): Hydrogen(H2), Methane(CH4), Ammonia(NH3), Carbon Monoxide(CO), Nitrogen Monoxide(NO), Hydrogen Sulfide(H2S), Nitrogen Dioxide(NO2), Sulfur Dioxide(SO2)
            //Toxic Gasses(CC = 3): Chlorine(Cl2), Florine(F2), Bromine(Br2), and Iodine(I2)
            //Toxic Gasses at 30% or greater of atm: Oxygen(O2) *


            Assert.AreEqual(1.0, SpeciesProcessor.ColonyCost(_earthPlanet, _humanSpecies.GetDataBlob <SpeciesDB>()));
        }
Exemplo n.º 7
0
 void SetIconFor(SystemBodyInfoDB db)
 {
     BodyType type = db.BodyType;
     float    temp = db.BaseTemperature;
 }