예제 #1
0
        /// <summary>
        /// Use this when adding gass for terrforming.
        /// @note System gen does not use this function, instead it adds gasses directly to the Composition.
        /// </summary>
        /// <param name="gas">The gass to add.</param>
        /// <param name="ammount">The ammount of gass to add in atm. Provide a negative number to remove gas.</param>
        public void AddGas(AtmosphericGas gas, float ammount)
        {
            if (CanModify == false && Constants.GameSettings.TNTerraformingRules == false)
                return; // we dont care!!

            if (_composition.ContainsKey(gas))
            {
                _composition[gas] += ammount;

                if (ammount > 0)
                {
                    if(Constants.GameSettings.TNTerraformingRules == true)
                    {
                        if (gas.HazardOne == true && HazardTwo == false) //This planet has no hazard two gases that will override a hazard one setting.
                        {
                             HazardOne = true;
                        }

                        if (gas.HazardTwo == true) //Override the hazard one setting if set, or set hazard two directly.
                        {
                            HazardOne = false;
                            HazardTwo = true;
                        }
                    }
                    else
                    {
                        if(gas.IsToxic == true)
                        {
                            HazardOne = true;
                        }
                    }
                }

                if (_composition[gas] <= 0)
                {
                    if (Constants.GameSettings.TNTerraformingRules == true)
                    {
                        if (gas.HazardOne == true && HazardTwo == false)
                        {
                            bool hazard = false;
                            foreach (KeyValuePair<AtmosphericGas, float> atmGas in _composition)
                            {
                                /// <summary>
                                /// This planet just got rid of a hazard one gas, so look for another hazard one gas. if one is found the planet is still hazard one.
                                /// This planet is already not hazard two, so don't worry about that.
                                /// </summary>
                                if (atmGas.Key.HazardOne == true)
                                {
                                    hazard = true;
                                    break;
                                }
                            }
                            HazardOne = hazard;
                        }

                        if (gas.HazardTwo == true)
                        {
                            bool hazardOne = false;
                            bool hazardTwo = false;
                            foreach (KeyValuePair<AtmosphericGas, float> atmGas in _composition)
                            {
                                /// <summary>
                                /// This planet just got rid of a hazard two gas, so look for another hazard two gas. also keep an eye out for hazard one gases.
                                /// </summary>
                                if (atmGas.Key.HazardTwo == true)
                                {
                                    hazardTwo = true;
                                    break;
                                }
                                else if (atmGas.Key.HazardOne == true)
                                {
                                    hazardOne = true;
                                }
                            }
                            HazardTwo = hazardTwo;
                            if (HazardTwo == false)
                                HazardOne = hazardOne;
                        }
                    }
                    else
                    {
                        if (gas.IsToxic == true)
                        {
                            bool hazard = false;
                            foreach (KeyValuePair<AtmosphericGas, float> atmGas in _composition)
                            {
                                /// <summary>
                                /// This planet just got rid of a hazard one gas, so look for another hazard one gas. if one is found the planet is still hazard one.
                                /// This planet is already not hazard two, so don't worry about that.
                                /// </summary>
                                if (atmGas.Key.IsToxic == true)
                                {
                                    hazard = true;
                                    break;
                                }
                            }
                            ///<summary>
                            ///Atmosphere uses HazardOne to indicate IsToxic for non-TN rules.
                            ///</summary>
                            HazardOne = hazard;
                        }
                    }
                    _composition.Remove(gas);  // if there is none left, remove it.
                }

            }
            else if (ammount > 0)               // only add new gas if it is actuall adding (i.e. ammount is positive).
            {
                _composition.Add(gas, ammount);

                if (Constants.GameSettings.TNTerraformingRules == true)
                {
                    if (gas.HazardOne == true && HazardTwo == false)
                    {
                        HazardOne = true;
                    }

                    if (gas.HazardTwo == true)
                    {
                        HazardOne = false;
                        HazardTwo = true;
                    }
                }
                else
                {
                    /// <summary>
                    /// As before, HazardOne indicates IsToxic for non-TN terraforming rules.
                    /// </summary>
                    if (gas.IsToxic == true)
                        HazardOne = true;
                }
            }

            UpdateState();                  // update other state to reflect the new gas ammount.
        }
예제 #2
0
        /// <summary>
        /// Constructor for population.
        /// </summary>
        /// <param name="a_oPlanet">Planet this population is on</param>
        /// <param name="a_oFaction">Faction this population belongs to</param>
        /// <param name="CurrentTimeSlice">Tick this population was created</param>
        /// <param name="a_oName">Name of the population</param>
        /// <param name="a_oSpecies">Species that will reside on this population.</param>
        public Population(SystemBody a_oPlanet, Faction a_oFaction, int CurrentTimeSlice, String a_oName = "Earth", Species a_oSpecies = null)
        {
            Id = Guid.NewGuid();
            // initialise minerials:
            m_aiMinerials = new float[Constants.Minerals.NO_OF_MINERIALS];
            for (int i = 0; i < Constants.Minerals.NO_OF_MINERIALS; ++i)
            {
                m_aiMinerials[i] = 0;
            }

            m_aoInstallations = new Installation[Installation.NO_OF_INSTALLATIONS];
            for (int i = 0; i < Installation.NO_OF_INSTALLATIONS; ++i)
            {
                m_aoInstallations[i] = new Installation((Installation.InstallationType)i);
            }

            CivilianPopulation = 0;
            PopulationGrowthRate = 0.1f;
            FuelStockpile = 0;
            MaintenanceSupplies = 0;
            ModifierEconomicProduction = 1.0f;
            ModifierManfacturing = 1.0f;
            ModifierPoliticalStability = 1.0f;
            ModifierProduction = 1.0f;
            ModifierWealthAndTrade = 1.0f;

            Name = a_oName;  // just a default Value!

            Faction = a_oFaction;
            Planet = a_oPlanet;


            if (a_oSpecies == null)
            {
                Species = Faction.Species;
            }
            else
            {
                Species = a_oSpecies;
            }

            SSEntity = StarSystemEntityType.Population;

            Planet.Populations.Add(this); // add us to the list of pops on the planet!
            Planet.Position.System.Populations.Add(this);
            Contact = new SystemContact(Faction, this);
            Contact.Position.System = Planet.Position.System;
            Contact.Position.X = Planet.Position.X;
            Contact.Position.Y = Planet.Position.Y;
            Planet.Position.System.SystemContactList.Add(Contact);

            GovernorPresent = false;
            AdminRating = 0;

            ComponentStockpile = new BindingList<ComponentDefTN>();
            ComponentStockpileCount = new BindingList<float>();
            ComponentStockpileLookup = new Dictionary<Guid, int>();
            MissileStockpile = new Dictionary<OrdnanceDefTN, float>();

            _OrbitalTerraformModules = 0.0f;

            PoliticalPopStatus = PoliticalStatus.Imperial;

            for (int InstallationIterator = 0; InstallationIterator < (int)Installation.InstallationType.InstallationCount; InstallationIterator++)
            {
                Installations[InstallationIterator].Number = 0.0f;
            }

            FuelStockpile = 0.0f;
            MaintenanceSupplies = 0.0f;
            EMSignature = 0;
            ThermalSignature = 0;
            ModifierEconomicProduction = 1.0f;
            ModifierManfacturing = 1.0f;
            ModifierProduction = 1.0f;
            ModifierWealthAndTrade = 1.0f;
            ModifierPoliticalStability = 1.0f;

            ConstructionBuildQueue = new BindingList<ConstructionBuildQueueItem>();
            MissileBuildQueue = new BindingList<MissileBuildQueueItem>();
            FighterBuildQueue = new BindingList<FighterBuildQueueItem>();

            IsRefining = false;

            ShipyardTasks = new Dictionary<Installation.ShipyardInformation.ShipyardTask, Installation.ShipyardInformation>();

            ThermalDetection = new BindingList<int>();
            EMDetection = new BindingList<int>();
            ActiveDetection = new BindingList<int>();

            for (int loop = 0; loop < Constants.Faction.FactionMax; loop++)
            {
                ThermalDetection.Add(CurrentTimeSlice);
                EMDetection.Add(CurrentTimeSlice);
                ActiveDetection.Add(CurrentTimeSlice);
            }

            ShipsTargetting = new BindingList<ShipTN>();
            MissilesInFlight = new BindingList<OrdnanceGroupTN>();

            _SensorUpdateAck = 0;

            /// <summary>
            /// Terraforming Section:
            /// </summary>
            _GasAddSubtract = false;
            _GasAmt = 0.0f;
            _GasToAdd = null;
        }