public PlanetGridSquare(int x, int y, int fb, int pb, int rb, Building b, bool hab)
 {
     this.x = x;
     this.y = y;
     this.Habitable = hab;
     this.building = b;
     this.foodbonus = fb;
     this.prodbonus = pb;
     this.resbonus = rb;
 }
コード例 #2
0
 public bool AssignBuildingToTileOnColonize(Building b)
 {
     List<PlanetGridSquare> list = new List<PlanetGridSquare>();
     foreach (PlanetGridSquare planetGridSquare in this.TilesList)
     {
         if (planetGridSquare.Habitable && planetGridSquare.building == null)
             list.Add(planetGridSquare);
     }
     if (list.Count > 0)
     {
         int index = (int)RandomMath.RandomBetween(0.0f, (float)list.Count + 0.97f);
         if (index > list.Count - 1)
             index = list.Count - 1;
         PlanetGridSquare planetGridSquare1 = list[index];
         foreach (PlanetGridSquare planetGridSquare2 in this.TilesList)
         {
             if (planetGridSquare2 == planetGridSquare1)
             {
                 planetGridSquare2.building = b;
                 return true;
             }
         }
     }
     else
     {
         list.Clear();
         foreach (PlanetGridSquare planetGridSquare in this.TilesList)
         {
             if (planetGridSquare.building == null)
                 list.Add(planetGridSquare);
         }
         int index = (int)RandomMath.RandomBetween(0.0f, (float)list.Count + 0.97f);
         if (index > list.Count - 1)
             index = list.Count - 1;
         PlanetGridSquare planetGridSquare1 = list[index];
         foreach (PlanetGridSquare planetGridSquare2 in list)
         {
             if (planetGridSquare2 == planetGridSquare1)
             {
                 planetGridSquare2.building = b;
                 planetGridSquare2.Habitable = true;
                 return true;
             }
         }
     }
     return false;
 }
コード例 #3
0
 public bool AssignBuildingToTile(Building b, QueueItem qi)
 {
     List<PlanetGridSquare> list = new List<PlanetGridSquare>();
     if (b.Name == "Biospheres")
         return false;
     foreach (PlanetGridSquare planetGridSquare in this.TilesList)
     {
         bool flag = true;
         foreach (QueueItem queueItem in (List<QueueItem>)this.ConstructionQueue)
         {
             if (queueItem.pgs == planetGridSquare)
             {
                 flag = false;
                 break;
             }
         }
         if (flag && planetGridSquare.Habitable && planetGridSquare.building == null)
             list.Add(planetGridSquare);
     }
     if (list.Count > 0)
     {
         int index = (int)RandomMath.RandomBetween(0.0f, (float)list.Count);
         PlanetGridSquare planetGridSquare1 = list[index];
         foreach (PlanetGridSquare planetGridSquare2 in this.TilesList)
         {
             if (planetGridSquare2 == planetGridSquare1)
             {
                 planetGridSquare2.QItem = qi;
                 qi.pgs = planetGridSquare2;
                 return true;
             }
         }
     }
     else if (b.CanBuildAnywhere)
     {
         PlanetGridSquare planetGridSquare1 = this.TilesList[(int)RandomMath.RandomBetween(0.0f, (float)this.TilesList.Count)];
         foreach (PlanetGridSquare planetGridSquare2 in this.TilesList)
         {
             if (planetGridSquare2 == planetGridSquare1)
             {
                 planetGridSquare2.QItem = qi;
                 qi.pgs = planetGridSquare2;
                 return true;
             }
         }
     }
     return false;
 }
コード例 #4
0
 public bool AssignBuildingToTile(Building b)
 {
     List<PlanetGridSquare> list = new List<PlanetGridSquare>();
     foreach (PlanetGridSquare planetGridSquare in this.TilesList)
     {
         if (planetGridSquare.Habitable && planetGridSquare.building == null)
             list.Add(planetGridSquare);
     }
     if (list.Count > 0)
     {
         int index = (int)RandomMath.RandomBetween(0.0f, (float)list.Count + 0.97f);
         if (index > list.Count - 1)
             index = list.Count - 1;
         PlanetGridSquare planetGridSquare1 = list[index];
         foreach (PlanetGridSquare planetGridSquare2 in this.TilesList)
         {
             if (planetGridSquare2 == planetGridSquare1)
             {
                 planetGridSquare2.building = b;
                 return true;
             }
         }
     }
     else if (b.Name == "Outpost" || !string.IsNullOrEmpty(b.EventTriggerUID))
     {
         list.Clear();
         foreach (PlanetGridSquare planetGridSquare in this.TilesList)
         {
             if (planetGridSquare.building == null)
                 list.Add(planetGridSquare);
         }
         int index = (int)RandomMath.RandomBetween(0.0f, (float)list.Count + 0.97f);
         if (index > list.Count - 1)
             index = list.Count - 1;
         PlanetGridSquare planetGridSquare1 = list[index];
         foreach (PlanetGridSquare planetGridSquare2 in list)
         {
             if (planetGridSquare2 == planetGridSquare1)
             {
                 planetGridSquare2.building = b;
                 planetGridSquare2.Habitable = true;
                 return true;
             }
         }
     }
     else if (b.Name == "Biospheres")
     {
         list.Clear();
         foreach (PlanetGridSquare planetGridSquare in this.TilesList)
         {
             if (planetGridSquare.building == null)
                 list.Add(planetGridSquare);
         }
         int index = (int)RandomMath.RandomBetween(0.0f, (float)list.Count + 0.97f);
         if (index > list.Count - 1)
             index = list.Count - 1;
         PlanetGridSquare planetGridSquare1 = list[index];
         foreach (PlanetGridSquare planetGridSquare2 in list)
         {
             if (planetGridSquare2 == planetGridSquare1)
             {
                 planetGridSquare2.building = b;
                 return true;
             }
         }
     }
     return false;
 }
コード例 #5
0
 public void AssignBuildingToSpecificTile(Building b, PlanetGridSquare pgs)
 {
     if (pgs.building != null)
         this.BuildingList.Remove(pgs.building);
     pgs.building = b;
     this.BuildingList.Add(b);
 }
コード例 #6
0
 public PlanetGridSquare AssignBuildingToRandomTile(Building b)
 {
     List<PlanetGridSquare> list = new List<PlanetGridSquare>();
     foreach (PlanetGridSquare planetGridSquare in this.TilesList)
     {
         if (planetGridSquare.building == null)
             list.Add(planetGridSquare);
     }
     if (list.Count > 0)
     {
         int index = (int)RandomMath.RandomBetween(0.0f, (float)list.Count);
         PlanetGridSquare planetGridSquare1 = list[index];
         foreach (PlanetGridSquare planetGridSquare2 in this.TilesList)
         {
             if (planetGridSquare2 == planetGridSquare1)
             {
                 planetGridSquare2.building = b;
                 this.BuildingList.Add(b);
                 return planetGridSquare2;
             }
         }
     }
     return (PlanetGridSquare)null;
 }
コード例 #7
0
        public bool WeCanAffordThis(Building building, Planet.ColonyType governor)
        {
            if (governor == ColonyType.TradeHub)
                return true;
            if (building == null)
                return false;
            Empire empire = this.Owner;
            float buildingMaintenance = empire.GetTotalBuildingMaintenance();
            float grossTaxes = empire.GrossTaxes;

            if (building.AllowInfantry && !this.BuildingList.Contains(building) &&( this.AllowInfantry || governor == ColonyType.Military))
                return false;

            //this.data.Traits.MaintMod * this.totalBuildingMaintenance
            foreach (QueueItem queueItem in (List<QueueItem>)this.ConstructionQueue)
            {
                if (queueItem.isBuilding)
                    buildingMaintenance += this.Owner.data.Traits.MaintMod * queueItem.Building.Maintenance;
            }
            buildingMaintenance += building.Maintenance + building.Maintenance * this.Owner.data.Traits.MaintMod;
            bool LowPri = buildingMaintenance / grossTaxes < .25f;
            bool MedPri = buildingMaintenance / grossTaxes < .60f;
            bool HighPri = buildingMaintenance / grossTaxes < .80f;
            float maintCost = this.GrossMoneyPT + this.Owner.data.Traits.TaxMod * this.GrossMoneyPT -building.Maintenance- (this.TotalMaintenanceCostsPerTurn + this.TotalMaintenanceCostsPerTurn * this.Owner.data.Traits.MaintMod);
            bool makingMoney = maintCost > 0 && this.Owner.data.TaxRate <.5 && this.Owner.GetAverageNetIncome() >0;// this.TotalMaintenanceCostsPerTurn  < this.GrossMoneyPT;
            int defensiveBuildings = this.BuildingList.Where(combat => combat.Strength > 0 || combat.PlanetaryShieldStrengthAdded >0 ).Count();
               int offensiveBuildings = this.BuildingList.Where(combat => combat.theWeapon !=null).Count();
            SystemCommander SC;
            //float defensiveNeeds =0;
            bool needDefense =false;
            if (this.Owner.GetGSAI().DefensiveCoordinator.DefenseDict.TryGetValue(this.system, out SC))
            {
                //defensiveNeeds = SC.RankImportance * .1f;
                if (makingMoney)
                    needDefense = SC.RankImportance > 10;//(this.BuildingList.Count / (defensiveBuildings + offensiveBuildings+1)) >defensiveNeeds;

            }

            if (!string.IsNullOrEmpty(building.ExcludesPlanetType) && building.ExcludesPlanetType == this.Type)
                return false;
            if (building.Maintenance <= 0.0f)
                return true;
            if (building.PlusTaxPercentage * this.GrossMoneyPT > building.Maintenance * 1.25f
                || building.CreditsPerColonist * (this.Population / 1000f) > building.Maintenance *1.25f

                )
                return true;
            if (building .Name == "Outpost" || building.WinsGame  )
                return true;
            if (building.PlusFoodPerColonist > 0)// && this.Fertility == 0)
            {

                if (this.Fertility == 0|| (this.NetFoodPerTurn >0 && this.FarmerPercentage <.3) &&!this.BuildingList.Contains(building))

                return false;

            }
            if (building.PlusFlatFoodAmount > 0 && this.NetFoodPerTurn > 0 && this.FarmerPercentage < .3 && !this.BuildingList.Contains(building))
                return false;

            bool iftrue = false;
            switch  (governor)
            {
                case ColonyType.Agricultural:
                    #region MyRegion
                    {
                        if (building.AllowShipBuilding && this.GetMaxProductionPotential()>20 )
                        {
                            return true;
                        }
                        if (this.Fertility > 0 && building.MinusFertilityOnBuild > 0 && this.Owner.data.Traits.Cybernetic <=0)
                            return false;
                        if (HighPri)
                        {
                            if (building.PlusFlatFoodAmount > 0
                                || (building.PlusFoodPerColonist > 0 && this.Population > 500f)
                                || building.Name == "Biospheres"
                                || this.developmentLevel > 4
                                || ((building.MaxPopIncrease > 0
                                || building.PlusFlatPopulation > 0 || building.PlusTerraformPoints > 0) && this.Population > this.MaxPopulation * .5f)
                                || building.PlusFlatFoodAmount > 0
                                || building.PlusFlatProductionAmount > 0
                                || (building.StorageAdded > 0 && this.FoodHere == MAX_STORAGE)
                                || (this.Owner.data.Traits.Cybernetic > 0 && (building.PlusProdPerRichness > 0 || building.PlusProdPerColonist > 0 || building.PlusFlatProductionAmount>0))

                                )
                                return true;
                                //iftrue = true;

                        }
                        if (!iftrue && MedPri)
                        {
                            if (

                                ( building.PlusTerraformPoints > 0 && this.Fertility <3)
                                || building.MaxPopIncrease > 0
                                || building.PlusFlatPopulation > 0
                                || this.developmentLevel > 3
                                )
                                return true;
                        }
                        if (LowPri && this.developmentLevel > 4 && makingMoney)
                        {
                            iftrue = true;
                        }
                        break;
                    }
                    #endregion
                case ColonyType.Core:
                    #region MyRegion
                    {
                        if (this.Fertility > 0 && building.MinusFertilityOnBuild > 0 && this.Owner.data.Traits.Cybernetic <= 0)
                            return false;
                        if (HighPri)
                        {

                            if (building.StorageAdded > 0
                                || ((building.PlusTerraformPoints > 0 && this.Fertility < 1) && this.MaxPopulation > 2000)
                                || ((building.MaxPopIncrease > 0 || building.PlusFlatPopulation > 0 ) && this.Population > this.MaxPopulation * .5f)
                                || building.PlusFlatFoodAmount > 0
                                || building.PlusFoodPerColonist > 0
                                || building.PlusFlatProductionAmount > 0
                                || building.PlusProdPerRichness >0
                                || building.PlusProdPerColonist >0
                                || building.PlusFlatResearchAmount>0
                                || building.PlusResearchPerColonist * this.Population / 1000 > building.Maintenance
                                //|| building.Name == "Biospheres"

                                || needDefense &&(defensiveBuildings <1 && building.PlanetaryShieldStrengthAdded>0)
                                || needDefense && (offensiveBuildings <1 && building.Strength >0)
                                || needDefense && (makingMoney && this.developmentLevel >4)
                                || (this.Owner.data.Traits.Cybernetic > 0 && (building.PlusProdPerRichness > 0 || building.PlusProdPerColonist > 0 || building.PlusFlatProductionAmount > 0))
                                )
                                return true;
                        }
                        if (MedPri && this.developmentLevel > 3 &&makingMoney )
                        {
                            if ((building.theWeapon != null || building.Strength > 0) && !needDefense)
                                return false;
                            iftrue = true;
                        }
                        if (!iftrue && LowPri && this.developmentLevel > 4 && makingMoney)
                        {

                            iftrue = true;
                        }
                        break;
                    }
                    #endregion

                case ColonyType.Industrial:
                    #region MyRegion
                    {
                        if (building.AllowShipBuilding && this.GetMaxProductionPotential() > 20)
                        {
                            return true;
                        }
                        if (HighPri)
                        {
                            if (building.PlusFlatProductionAmount > 0
                                || building.PlusProdPerRichness > 0
                                || building.PlusProdPerColonist > 0
                                //|| building.PlusFlatProductionAmount > 0
                                || (this.Fertility < 1f && building.PlusFlatFoodAmount > 0)
                                || building.StorageAdded > 0
                                || (this.Owner.data.Traits.Cybernetic > 0 && (building.PlusProdPerRichness > 0 || building.PlusProdPerColonist > 0 || building.PlusFlatProductionAmount > 0))
                                )
                                return true;
                        }
                        if (MedPri && this.developmentLevel > 2 && makingMoney)
                        {
                            if (building.PlusResearchPerColonist * this.Population/1000 >building.Maintenance
                            ||    ((building.MaxPopIncrease > 0 || building.PlusFlatPopulation > 0 ) && this.Population > this.MaxPopulation * .5f)
                            || (building.PlusTerraformPoints > 0 && this.Fertility < 1 && this.Population > this.MaxPopulation * .5f && this.MaxPopulation >2000)
                               || (building.PlusFlatFoodAmount > 0 && this.NetFoodPerTurn <0)
                                )

                            {
                                iftrue = true;
                            }

                        }
                        if (!iftrue && LowPri && this.developmentLevel > 3 && makingMoney)
                        {
                            if (this.developmentLevel < 3 && (building.theWeapon != null || building.Strength > 0) && !needDefense)
                                return false;
                            iftrue = true;
                        }
                        break;
                    }
                    #endregion
                case ColonyType.Military:
                    #region MyRegion
                    {
                        if (this.Fertility > 0 && building.MinusFertilityOnBuild > 0 && this.Owner.data.Traits.Cybernetic <= 0)
                            return false;
                        if (HighPri)
                        {
                            if (building.isWeapon
                                || building.IsSensor
                                || building.Defense > 0
                                || (this.Fertility < 1f && building.PlusFlatFoodAmount > 0)
                                || (this.MineralRichness < 1f && building.PlusFlatFoodAmount > 0)
                                || building.PlanetaryShieldStrengthAdded > 0
                                || (building.AllowShipBuilding  && this.GrossProductionPerTurn >1)
                                || (building.ShipRepair > 0&& this.GrossProductionPerTurn >1)
                                || building.Strength > 0
                                || (building.AllowInfantry && this.GrossProductionPerTurn >1)
                                || needDefense &&(building.theWeapon !=null || building.Strength >0)
                                || (this.Owner.data.Traits.Cybernetic > 0 && (building.PlusProdPerRichness > 0 || building.PlusProdPerColonist > 0 || building.PlusFlatProductionAmount > 0))
                                )
                                iftrue = true;
                        }
                        if (!iftrue && MedPri)
                        {
                            if (building.PlusFlatProductionAmount > 0
                                || building.PlusProdPerRichness > 0
                                || building.PlusProdPerColonist > 0
                                || building.PlusFlatProductionAmount > 0)
                                iftrue = true;
                        }
                        if (!iftrue && LowPri && this.developmentLevel > 4)
                        {
                            //if(building.Name!= "Biospheres")
                            iftrue = true;

                        }
                        break;
                    }
                    #endregion
                case ColonyType.Research:
                    #region MyRegion
                    {
                        if (building.AllowShipBuilding && this.GetMaxProductionPotential() > 20)
                        {
                            return true;
                        }
                        if (this.Fertility > 0 && building.MinusFertilityOnBuild > 0 && this.Owner.data.Traits.Cybernetic <= 0)
                            return false;
                        if (HighPri)
                        {
                            if (building.PlusFlatResearchAmount > 0
                                || (this.Fertility < 1f && building.PlusFlatFoodAmount > 0)
                                || building.PlusFlatProductionAmount >0
                                || building.PlusResearchPerColonist > 0
                                || (this.Owner.data.Traits.Cybernetic > 0 && (building.PlusFlatProductionAmount > 0 || building.PlusProdPerColonist > 0 ))
                                )
                                return true;

                        }
                        if ( MedPri && this.developmentLevel > 3 && makingMoney)
                        {
                            if (((building.MaxPopIncrease > 0 || building.PlusFlatPopulation > 0) && this.Population > this.MaxPopulation * .5f)
                            || (building.PlusTerraformPoints > 0 && this.Fertility < 1 && this.Population > this.MaxPopulation * .5f && this.MaxPopulation >2000)
                                || (building.PlusFlatFoodAmount > 0 && this.NetFoodPerTurn < 0)
                                )
                                return true;
                        }
                        if ( LowPri && this.developmentLevel > 4 && makingMoney)
                        {
                            if ((building.theWeapon != null || building.Strength > 0) && !needDefense)
                                return false;
                            return true;
                        }
                        break;
                    }
                    #endregion
            }
            return iftrue;
        }
コード例 #8
0
 public bool TryBiosphereBuild(Building b, QueueItem qi)
 {
     List<PlanetGridSquare> list = new List<PlanetGridSquare>();
     foreach (PlanetGridSquare planetGridSquare in this.TilesList)
     {
         if (!planetGridSquare.Habitable && planetGridSquare.building == null && (!planetGridSquare.Biosphere && planetGridSquare.QItem == null))
             list.Add(planetGridSquare);
     }
     if (b.Name == "Biospheres" && list.Count > 0)
     {
         int index = (int)RandomMath.RandomBetween(0.0f, (float)list.Count);
         PlanetGridSquare planetGridSquare1 = list[index];
         foreach (PlanetGridSquare planetGridSquare2 in this.TilesList)
         {
             if (planetGridSquare2 == planetGridSquare1)
             {
                 qi.Building = b;
                 qi.isBuilding = true;
                 qi.Cost = b.Cost;
                 qi.productionTowards = 0.0f;
                 planetGridSquare2.QItem = qi;
                 qi.pgs = planetGridSquare2;
                 qi.NotifyOnEmpty = false;
                 this.ConstructionQueue.Add(qi);
                 return true;
             }
         }
     }
     return false;
 }
コード例 #9
0
        public void AddBuildingToCQ(Building b)
        {
            int count = this.ConstructionQueue.Count;
            QueueItem qi = new QueueItem();
            qi.isBuilding = true;
            qi.Building = b;
            qi.Cost = ResourceManager.GetBuilding(b.Name).Cost;
            qi.productionTowards = 0.0f;
            qi.NotifyOnEmpty = false;
            Building terraformer =ResourceManager.GetBuilding("Terraformer");
            if (this.AssignBuildingToTile(b, qi))
                this.ConstructionQueue.Add(qi);

            else if (this.Owner.GetBDict()[terraformer.Name] && this.Fertility < 1.0 && this.WeCanAffordThis(terraformer, this.colonyType))
            {
                bool flag = true;
                foreach (QueueItem queueItem in (List<QueueItem>)this.ConstructionQueue)
                {
                    if (queueItem.isBuilding && queueItem.Building.Name == terraformer.Name)
                        flag = false;
                }
                foreach (Building building in this.BuildingList)
                {
                    if (building.Name == terraformer.Name)
                        flag = false;
                }
                if (!flag)
                    return;
                this.AddBuildingToCQ(terraformer);
            }
            else
            {
                if (!this.Owner.GetBDict()["Biospheres"])
                    return;
                this.TryBiosphereBuild(ResourceManager.GetBuilding("Biospheres"), qi);
            }
        }
コード例 #10
0
 public void ScrapBuilding(Building b)
 {
     Building building1 = (Building)null;
     foreach (Building building2 in this.BuildingList)
     {
         if (b == building2)
             building1 = building2;
     }
     this.BuildingList.Remove(building1);
     this.ProductionHere += ResourceManager.BuildingsDict[b.Name].Cost / 2f;
     foreach (PlanetGridSquare planetGridSquare in this.TilesList)
     {
         if (planetGridSquare.building != null && planetGridSquare.building == building1)
             planetGridSquare.building = (Building)null;
     }
 }
コード例 #11
0
 public bool GoodBuilding(Building b)
 {
     return true;
 }
コード例 #12
0
 public static Building GetBuilding(string whichBuilding)
 {
     Building newB = new Building()
     {
         PlanetaryShieldStrengthAdded = Ship_Game.ResourceManager.BuildingsDict[whichBuilding].PlanetaryShieldStrengthAdded,
         MinusFertilityOnBuild = Ship_Game.ResourceManager.BuildingsDict[whichBuilding].MinusFertilityOnBuild,
         CombatStrength = Ship_Game.ResourceManager.BuildingsDict[whichBuilding].CombatStrength,
         PlusProdPerRichness = Ship_Game.ResourceManager.BuildingsDict[whichBuilding].PlusProdPerRichness,
         Name = Ship_Game.ResourceManager.BuildingsDict[whichBuilding].Name,
         IsSensor = Ship_Game.ResourceManager.BuildingsDict[whichBuilding].IsSensor,
         IsProjector = Ship_Game.ResourceManager.BuildingsDict[whichBuilding].IsProjector,
         PlusResearchPerColonist = Ship_Game.ResourceManager.BuildingsDict[whichBuilding].PlusResearchPerColonist,
         StorageAdded = Ship_Game.ResourceManager.BuildingsDict[whichBuilding].StorageAdded,
         Unique = Ship_Game.ResourceManager.BuildingsDict[whichBuilding].Unique,
         Icon = Ship_Game.ResourceManager.BuildingsDict[whichBuilding].Icon,
         PlusTaxPercentage = Ship_Game.ResourceManager.BuildingsDict[whichBuilding].PlusTaxPercentage,
         Strength = Ship_Game.ResourceManager.BuildingsDict[whichBuilding].Strength,
         HardAttack = Ship_Game.ResourceManager.BuildingsDict[whichBuilding].HardAttack,
         SoftAttack = Ship_Game.ResourceManager.BuildingsDict[whichBuilding].SoftAttack,
         Defense = Ship_Game.ResourceManager.BuildingsDict[whichBuilding].Defense,
         Maintenance = Ship_Game.ResourceManager.BuildingsDict[whichBuilding].Maintenance,
         AllowInfantry = Ship_Game.ResourceManager.BuildingsDict[whichBuilding].AllowInfantry,
         CanBuildAnywhere = Ship_Game.ResourceManager.BuildingsDict[whichBuilding].CanBuildAnywhere,
         PlusFlatPopulation = Ship_Game.ResourceManager.BuildingsDict[whichBuilding].PlusFlatPopulation,
         Weapon = Ship_Game.ResourceManager.BuildingsDict[whichBuilding].Weapon,
         isWeapon = Ship_Game.ResourceManager.BuildingsDict[whichBuilding].isWeapon,
         PlusTerraformPoints = Ship_Game.ResourceManager.BuildingsDict[whichBuilding].PlusTerraformPoints,
         SensorRange = Ship_Game.ResourceManager.BuildingsDict[whichBuilding].SensorRange,
         ProjectorRange = Ship_Game.ResourceManager.BuildingsDict[whichBuilding].ProjectorRange,
         Category = Ship_Game.ResourceManager.BuildingsDict[whichBuilding].Category
     };
     //comp fix to ensure functionality of vanilla buildings
     if ((newB.Name == "Outpost" || newB.Name =="Capital City") && newB.IsProjector==false && newB.ProjectorRange==0.0f)
     {
         newB.ProjectorRange = Empire.ProjectorRadius;
         newB.IsProjector = true;
     }
     if ((newB.Name == "Outpost" || newB.Name == "Capital City") && newB.IsSensor == false && newB.SensorRange == 0.0f)
     {
         newB.SensorRange = 20000.0f;
         newB.IsSensor = true;
     }
     if (newB.isWeapon)
     {
         newB.theWeapon = Ship_Game.ResourceManager.GetWeapon(newB.Weapon);
     }
     newB.PlusFlatFoodAmount = Ship_Game.ResourceManager.BuildingsDict[whichBuilding].PlusFlatFoodAmount;
     newB.PlusFlatProductionAmount = Ship_Game.ResourceManager.BuildingsDict[whichBuilding].PlusFlatProductionAmount;
     newB.PlusFlatResearchAmount = Ship_Game.ResourceManager.BuildingsDict[whichBuilding].PlusFlatResearchAmount;
     newB.EventTriggerUID = Ship_Game.ResourceManager.BuildingsDict[whichBuilding].EventTriggerUID;
     newB.EventWasTriggered = false;
     newB.NameTranslationIndex = Ship_Game.ResourceManager.BuildingsDict[whichBuilding].NameTranslationIndex;
     newB.DescriptionIndex = Ship_Game.ResourceManager.BuildingsDict[whichBuilding].DescriptionIndex;
     newB.ShortDescriptionIndex = Ship_Game.ResourceManager.BuildingsDict[whichBuilding].ShortDescriptionIndex;
     newB.Unique = Ship_Game.ResourceManager.BuildingsDict[whichBuilding].Unique;
     newB.CreditsPerColonist = Ship_Game.ResourceManager.BuildingsDict[whichBuilding].CreditsPerColonist;
     newB.PlusProdPerColonist = Ship_Game.ResourceManager.BuildingsDict[whichBuilding].PlusProdPerColonist;
     newB.Scrappable = Ship_Game.ResourceManager.BuildingsDict[whichBuilding].Scrappable;
     newB.PlusFoodPerColonist = Ship_Game.ResourceManager.BuildingsDict[whichBuilding].PlusFoodPerColonist;
     newB.WinsGame = Ship_Game.ResourceManager.BuildingsDict[whichBuilding].WinsGame;
     newB.EventOnBuild = Ship_Game.ResourceManager.BuildingsDict[whichBuilding].EventOnBuild;
     newB.NoRandomSpawn = Ship_Game.ResourceManager.BuildingsDict[whichBuilding].NoRandomSpawn;
     newB.Cost = Ship_Game.ResourceManager.BuildingsDict[whichBuilding].Cost * UniverseScreen.GamePaceStatic;
     newB.MaxPopIncrease = Ship_Game.ResourceManager.BuildingsDict[whichBuilding].MaxPopIncrease;
     newB.AllowShipBuilding = Ship_Game.ResourceManager.BuildingsDict[whichBuilding].AllowShipBuilding;
     newB.BuildOnlyOnce = Ship_Game.ResourceManager.BuildingsDict[whichBuilding].BuildOnlyOnce;
     newB.IsCommodity = Ship_Game.ResourceManager.BuildingsDict[whichBuilding].IsCommodity;
     newB.CommodityBonusType = Ship_Game.ResourceManager.BuildingsDict[whichBuilding].CommodityBonusType;
     newB.CommodityBonusAmount = Ship_Game.ResourceManager.BuildingsDict[whichBuilding].CommodityBonusAmount;
     newB.ResourceCreated = Ship_Game.ResourceManager.BuildingsDict[whichBuilding].ResourceCreated;
     newB.ResourceConsumed = Ship_Game.ResourceManager.BuildingsDict[whichBuilding].ResourceConsumed;
     newB.ConsumptionPerTurn = Ship_Game.ResourceManager.BuildingsDict[whichBuilding].ConsumptionPerTurn;
     newB.OutputPerTurn = Ship_Game.ResourceManager.BuildingsDict[whichBuilding].OutputPerTurn;
     newB.CommodityRequired = Ship_Game.ResourceManager.BuildingsDict[whichBuilding].CommodityRequired;
     newB.ShipRepair = Ship_Game.ResourceManager.BuildingsDict[whichBuilding].ShipRepair;
     return newB;
 }
コード例 #13
0
        public override void HandleInput(InputState input)
        {
            this.pFacilities.HandleInputNoReset(this);
            if (HelperFunctions.CheckIntersection(this.RightColony.r, input.CursorPosition))
            {
                ToolTip.CreateTooltip(Localizer.Token(2279), this.ScreenManager);
            }
            if (HelperFunctions.CheckIntersection(this.LeftColony.r, input.CursorPosition))
            {
                ToolTip.CreateTooltip(Localizer.Token(2280), this.ScreenManager);
            }
            if ((input.Right || this.RightColony.HandleInput(input)) && (PlanetScreen.screen.Debug || this.p.Owner == EmpireManager.GetEmpireByName(PlanetScreen.screen.PlayerLoyalty)))
            {

                try
                {
                    this.p.Owner.GetPlanets().thisLock.EnterReadLock();
                    int thisindex = this.p.Owner.GetPlanets().IndexOf(this.p);
                    thisindex = (thisindex >= this.p.Owner.GetPlanets().Count - 1 ? 0 : thisindex + 1);
                    if (this.p.Owner.GetPlanets()[thisindex] != this.p)
                    {
                        this.p = this.p.Owner.GetPlanets()[thisindex];
                        PlanetScreen.screen.workersPanel = new ColonyScreen(this.p, this.ScreenManager, this.eui);
                    }
                    this.p.Owner.GetPlanets().thisLock.ExitReadLock();
                }
                catch
                {

                    System.Diagnostics.Debug.WriteLine("Colony Screen Handle Inpu. Likely null reference.");
                }
                if (input.CurrentMouseState.RightButton != ButtonState.Released || this.previousMouse.RightButton != ButtonState.Released)
                {
                    this.eui.screen.ShipsInCombat.Active = true;
                    this.eui.screen.PlanetsInCombat.Active = true;
                }
                return;
            }
            if ((input.Left || this.LeftColony.HandleInput(input)) && (PlanetScreen.screen.Debug || this.p.Owner == EmpireManager.GetEmpireByName(PlanetScreen.screen.PlayerLoyalty)))
            {
                int thisindex = this.p.Owner.GetPlanets().IndexOf(this.p);
                thisindex = (thisindex <= 0 ? this.p.Owner.GetPlanets().Count - 1 : thisindex - 1);
                if (this.p.Owner.GetPlanets()[thisindex] != this.p)
                {
                    this.p = this.p.Owner.GetPlanets()[thisindex];
                    PlanetScreen.screen.workersPanel = new ColonyScreen(this.p, this.ScreenManager, this.eui);
                }
                if (input.CurrentMouseState.RightButton != ButtonState.Released || this.previousMouse.RightButton != ButtonState.Released)
                {
                    this.eui.screen.ShipsInCombat.Active = true;
                    this.eui.screen.PlanetsInCombat.Active = true;
                }
                return;
            }
            this.p.UpdateIncomes();
            this.HandleDetailInfo(input);
            this.currentMouse = Mouse.GetState();
            Vector2 MousePos = new Vector2((float)this.currentMouse.X, (float)this.currentMouse.Y);
            this.buildSL.HandleInput(input);
            this.buildSL.Update();
            this.build.HandleInput(this);
            if (this.p.Owner != EmpireManager.GetEmpireByName(PlanetScreen.screen.PlayerLoyalty))
            {
                this.HandleDetailInfo(input);
                if (input.CurrentMouseState.RightButton != ButtonState.Released || this.previousMouse.RightButton != ButtonState.Released)
                {
                    this.eui.screen.ShipsInCombat.Active = true;
                    this.eui.screen.PlanetsInCombat.Active = true;
                }
                return;
            }
            if (!HelperFunctions.CheckIntersection(this.launchTroops.Rect, input.CursorPosition))
            {
                this.launchTroops.State = UIButton.PressState.Normal;
            }
            else
            {
                this.launchTroops.State = UIButton.PressState.Hover;
                if (input.InGameSelect)
                {
                    bool play = false;
                    foreach (PlanetGridSquare pgs in this.p.TilesList)
                    {
                        if (pgs.TroopsHere.Count <= 0 || pgs.TroopsHere[0].GetOwner() != EmpireManager.GetEmpireByName(PlanetScreen.screen.PlayerLoyalty))
                        {
                            continue;
                        }

                        play = true;

                        ResourceManager.CreateTroopShipAtPoint((this.p.Owner.data.DefaultTroopShip != null) ? this.p.Owner.data.DefaultTroopShip : this.p.Owner.data.DefaultSmallTransport, this.p.Owner, this.p.Position, pgs.TroopsHere[0]);
                        this.p.TroopsHere.Remove(pgs.TroopsHere[0]);
                        pgs.TroopsHere[0].SetPlanet(null);
                        pgs.TroopsHere.Clear();
                        this.ClickedTroop = true;
                        this.detailInfo = null;
                    }
                    if (play)
                    {

                        AudioManager.PlayCue("sd_troop_takeoff");
                    }
                }
            }
            //fbedard: Click button to send troops
            if (!HelperFunctions.CheckIntersection(this.SendTroops.Rect, input.CursorPosition))
            {
                this.SendTroops.State = UIButton.PressState.Normal;
            }
            else
            {
                this.SendTroops.State = UIButton.PressState.Hover;
                if (input.InGameSelect)
                {
                    this.eui.empire.GetShips().thisLock.EnterReadLock();
                    List<Ship> troopShips = new List<Ship>(this.eui.empire.GetShips()
                        .Where(troop => troop.TroopList.Count > 0
                            && troop.GetAI().State == AIState.AwaitingOrders
                            && troop.fleet == null && !troop.InCombat).OrderBy(distance => Vector2.Distance(distance.Center, this.p.Position)));
                    this.eui.empire.GetShips().thisLock.ExitReadLock();
                    this.eui.empire.GetPlanets().thisLock.EnterReadLock();
                    List<Planet> planetTroops = new List<Planet>(this.eui.empire.GetPlanets()
                        .Where(troops => troops.TroopsHere.Count > 1).OrderBy(distance => Vector2.Distance(distance.Position, this.p.Position))
                        .Where(Name => Name.Name != this.p.Name));
                    this.eui.empire.GetPlanets().thisLock.ExitReadLock();
                    if (troopShips.Count > 0)
                    {
                        AudioManager.PlayCue("echo_affirm");
                        troopShips.First().GetAI().OrderRebase(this.p,true);
                    }
                    else
                        if (planetTroops.Count > 0)
                        {
                            {
                                planetTroops.First().TroopsHere.thisLock.EnterWriteLock();
                                Ship troop = planetTroops.First().TroopsHere.First().Launch();
                                if (troop != null)
                                {
                                    AudioManager.PlayCue("echo_affirm");
                                    troop.GetAI().OrderRebase(this.p,true);
                                }
                                planetTroops.First().TroopsHere.thisLock.ExitWriteLock();
                            }
                        }
                        else
                        {
                            AudioManager.PlayCue("blip_click");
                        }
                }
            }
            if (!HelperFunctions.CheckIntersection(this.edit_name_button, MousePos))
            {
                this.editHoverState = 0;
            }
            else
            {
                this.editHoverState = 1;
                if (this.currentMouse.LeftButton == ButtonState.Pressed && this.previousMouse.LeftButton == ButtonState.Released)
                {
                    this.PlanetName.HandlingInput = true;
                }
            }
            if (!this.PlanetName.HandlingInput)
            {
                GlobalStats.TakingInput = false;
                bool empty = true;
                string text = this.PlanetName.Text;
                int num = 0;
                while (num < text.Length)
                {
                    if (text[num] == ' ')
                    {
                        num++;
                    }
                    else
                    {
                        empty = false;
                        break;
                    }
                }
                if (empty)
                {
                    int ringnum = 1;
                    foreach (SolarSystem.Ring ring in this.p.system.RingList)
                    {
                        if (ring.planet == this.p)
                        {
                            this.PlanetName.Text = string.Concat(this.p.system.Name, " ", NumberToRomanConvertor.NumberToRoman(ringnum));
                        }
                        ringnum++;
                    }
                }
            }
            else
            {
                GlobalStats.TakingInput = true;
                this.PlanetName.HandleTextInput(ref this.PlanetName.Text, input);
            }
            this.GovernorDropdown.HandleInput(input);
            if (this.GovernorDropdown.Options[this.GovernorDropdown.ActiveIndex].@value != (int)this.p.colonyType)
            {
                this.p.colonyType = (Planet.ColonyType)this.GovernorDropdown.Options[this.GovernorDropdown.ActiveIndex].@value;
                if (this.p.colonyType != Planet.ColonyType.Colony)
                {
                    this.p.FoodLocked = true;
                    this.p.ProdLocked = true;
                    this.p.ResLocked = true;
                    this.p.GovernorOn = true;
                }
                else
                {
                    this.p.GovernorOn = false;
                    this.p.FoodLocked = false;
                    this.p.ProdLocked = false;
                    this.p.ResLocked = false;
                }
            }
            this.HandleSlider();
            if (this.p.HasShipyard && this.build.Tabs.Count > 1 && this.build.Tabs[1].Selected)
            {
                if (HelperFunctions.CheckIntersection(this.playerDesignsToggle.r, input.CursorPosition))
                {
                    ToolTip.CreateTooltip(Localizer.Token(2225), this.ScreenManager);
                }
                if (this.playerDesignsToggle.HandleInput(input))
                {
                    AudioManager.PlayCue("sd_ui_accept_alt3");
                    GlobalStats.ShowAllDesigns = !GlobalStats.ShowAllDesigns;
                    if (GlobalStats.ShowAllDesigns)
                    {
                        this.playerDesignsToggle.Active = true;
                    }
                    else
                    {
                        this.playerDesignsToggle.Active = false;
                    }
                    this.Reset = true;
                }
            }
            if (this.p.colonyType != Planet.ColonyType.Colony)
            {
                this.FoodLock.Locked = true;
                this.ProdLock.Locked = true;
                this.ResLock.Locked = true;
            }
            else
            {
                if (!HelperFunctions.CheckIntersection(this.FoodLock.LockRect, MousePos) || this.p.Owner == null || this.p.Owner.data.Traits.Cybernetic != 0)
                {
                    this.FoodLock.Hover = false;
                }
                else
                {
                    if (this.FoodLock.Locked)
                    {
                        this.FoodLock.Hover = false;
                        if (this.currentMouse.LeftButton == ButtonState.Pressed && this.previousMouse.LeftButton == ButtonState.Released)
                        {
                            this.p.FoodLocked = false;
                            this.FoodLock.Locked = false;
                            AudioManager.PlayCue("sd_ui_accept_alt3");
                        }
                    }
                    else
                    {
                        this.FoodLock.Hover = true;
                        if (this.currentMouse.LeftButton == ButtonState.Pressed && this.previousMouse.LeftButton == ButtonState.Released)
                        {
                            this.p.FoodLocked = true;
                            this.FoodLock.Locked = true;
                            AudioManager.PlayCue("sd_ui_accept_alt3");
                        }
                    }
                    ToolTip.CreateTooltip(69, this.ScreenManager);
                }
                if (!HelperFunctions.CheckIntersection(this.ProdLock.LockRect, MousePos))
                {
                    this.ProdLock.Hover = false;
                }
                else
                {
                    if (this.ProdLock.Locked)
                    {
                        this.ProdLock.Hover = false;
                        if (this.currentMouse.LeftButton == ButtonState.Pressed && this.previousMouse.LeftButton == ButtonState.Released)
                        {
                            this.p.ProdLocked = false;
                            this.ProdLock.Locked = false;
                            AudioManager.PlayCue("sd_ui_accept_alt3");
                        }
                    }
                    else
                    {
                        this.ProdLock.Hover = true;
                        if (this.currentMouse.LeftButton == ButtonState.Pressed && this.previousMouse.LeftButton == ButtonState.Released)
                        {
                            this.p.ProdLocked = true;
                            this.ProdLock.Locked = true;
                            AudioManager.PlayCue("sd_ui_accept_alt3");
                        }
                    }
                    ToolTip.CreateTooltip(69, this.ScreenManager);
                }
                if (!HelperFunctions.CheckIntersection(this.ResLock.LockRect, MousePos))
                {
                    this.ResLock.Hover = false;
                }
                else
                {
                    if (this.ResLock.Locked)
                    {
                        this.ResLock.Hover = false;
                        if (this.currentMouse.LeftButton == ButtonState.Pressed && this.previousMouse.LeftButton == ButtonState.Released)
                        {
                            this.p.ResLocked = false;
                            this.ResLock.Locked = false;
                            AudioManager.PlayCue("sd_ui_accept_alt3");
                        }
                    }
                    else
                    {
                        this.ResLock.Hover = true;
                        if (this.currentMouse.LeftButton == ButtonState.Pressed && this.previousMouse.LeftButton == ButtonState.Released)
                        {
                            this.p.ResLocked = true;
                            this.ResLock.Locked = true;
                            AudioManager.PlayCue("sd_ui_accept_alt3");
                        }
                    }
                    ToolTip.CreateTooltip(69, this.ScreenManager);
                }
            }
            this.selector = null;
            this.ClickedTroop = false;
            foreach (PlanetGridSquare pgs in this.p.TilesList)
            {
                if (!HelperFunctions.CheckIntersection(pgs.ClickRect, MousePos))
                {
                    pgs.highlighted = false;
                }
                else
                {
                    if (!pgs.highlighted)
                    {
                        AudioManager.PlayCue("sd_ui_mouseover");
                    }
                    pgs.highlighted = true;
                }
                if (pgs.TroopsHere.Count <= 0 || !HelperFunctions.CheckIntersection(pgs.TroopClickRect, MousePos))
                {
                    continue;
                }
                this.detailInfo = pgs.TroopsHere[0];
                if (input.RightMouseClick && pgs.TroopsHere[0].GetOwner() == EmpireManager.GetEmpireByName(PlanetScreen.screen.PlayerLoyalty))
                {
                    AudioManager.PlayCue("sd_troop_takeoff");
                    ResourceManager.CreateTroopShipAtPoint((this.p.Owner.data.DefaultTroopShip != null) ? this.p.Owner.data.DefaultTroopShip : this.p.Owner.data.DefaultSmallTransport, this.p.Owner, this.p.Position, pgs.TroopsHere[0]);
                    this.p.TroopsHere.Remove(pgs.TroopsHere[0]);
                    pgs.TroopsHere[0].SetPlanet(null);
                    pgs.TroopsHere.Clear();
                    this.ClickedTroop = true;
                    this.detailInfo = null;
                    rmouse = true;
                }
                return;
            }
            if (!this.ClickedTroop)
            {
                foreach (PlanetGridSquare pgs in this.p.TilesList)
                {
                    if (HelperFunctions.CheckIntersection(pgs.ClickRect, input.CursorPosition))
                    {
                        this.detailInfo = pgs;
                        Rectangle bRect = new Rectangle(pgs.ClickRect.X + pgs.ClickRect.Width / 2 - 32, pgs.ClickRect.Y + pgs.ClickRect.Height / 2 - 32, 64, 64);
                        if (pgs.building != null && pgs.building.Scrappable && HelperFunctions.CheckIntersection(bRect, input.CursorPosition) && input.RightMouseClick)
                        {
                            this.toScrap = pgs.building;
                            string message = string.Concat("Do you wish to scrap ", Localizer.Token(pgs.building.NameTranslationIndex), "? Half of the building's construction cost will be recovered to your storage.");
                            MessageBoxScreen messageBox = new MessageBoxScreen(message);
                            messageBox.Accepted += new EventHandler<EventArgs>(this.ScrapAccepted);
                            this.ScreenManager.AddScreen(messageBox);
                            this.ClickedTroop = true;
                            rmouse = true;
                            return;
                        }
                    }
                    if (pgs.TroopsHere.Count <= 0 || !HelperFunctions.CheckIntersection(pgs.TroopClickRect, input.CursorPosition))
                    {
                        continue;
                    }
                    this.detailInfo = pgs.TroopsHere;
                }
            }
            if (!GlobalStats.HardcoreRuleset)
            {
                if (HelperFunctions.CheckIntersection(this.foodDropDown.r, MousePos) && this.currentMouse.LeftButton == ButtonState.Pressed && this.previousMouse.LeftButton == ButtonState.Released)
                {
                    this.foodDropDown.Toggle();
                    Planet planet = this.p;
                    planet.fs = (Planet.GoodState)((int)planet.fs + (int)Planet.GoodState.IMPORT);
                    if (this.p.fs > Planet.GoodState.EXPORT)
                    {
                        this.p.fs = Planet.GoodState.STORE;
                    }
                    AudioManager.PlayCue("sd_ui_accept_alt3");
                }
                if (HelperFunctions.CheckIntersection(this.prodDropDown.r, MousePos) && this.currentMouse.LeftButton == ButtonState.Pressed && this.previousMouse.LeftButton == ButtonState.Released)
                {
                    this.prodDropDown.Toggle();
                    AudioManager.PlayCue("sd_ui_accept_alt3");
                    Planet planet1 = this.p;
                    planet1.ps = (Planet.GoodState)((int)planet1.ps + (int)Planet.GoodState.IMPORT);
                    if (this.p.ps > Planet.GoodState.EXPORT)
                    {
                        this.p.ps = Planet.GoodState.STORE;
                    }
                }
            }
            else
            {
                foreach (ThreeStateButton b in this.ResourceButtons)
                {
                    b.HandleInput(input, this.ScreenManager);
                }
            }
            for (int i = this.QSL.indexAtTop; i < this.QSL.Copied.Count && i < this.QSL.indexAtTop + this.QSL.entriesToDisplay; i++)
            {
                try
                {
                    ScrollList.Entry e = this.QSL.Copied[i];
                    if (!HelperFunctions.CheckIntersection(e.clickRect, MousePos))
                    {
                        e.clickRectHover = 0;
                    }
                    else
                    {
                        this.selector = new Selector(this.ScreenManager, e.clickRect);
                        if (e.clickRectHover == 0)
                        {
                            AudioManager.PlayCue("sd_ui_mouseover");
                        }
                        e.clickRectHover = 1;
                    }
                    if (HelperFunctions.CheckIntersection(e.up, MousePos))
                    {
                        ToolTip.CreateTooltip(63, PlanetScreen.screen.ScreenManager);
                        if (!input.CurrentKeyboardState.IsKeyDown(Keys.RightControl) && !input.CurrentKeyboardState.IsKeyDown(Keys.LeftControl) || this.currentMouse.LeftButton != ButtonState.Pressed || this.previousMouse.LeftButton != ButtonState.Released)
                        {
                            if (this.currentMouse.LeftButton == ButtonState.Pressed && this.previousMouse.LeftButton == ButtonState.Released && i > 0)
                            {
                                object tmp = this.p.ConstructionQueue[i - 1];
                                this.p.ConstructionQueue[i - 1] = this.p.ConstructionQueue[i];
                                this.p.ConstructionQueue[i] = tmp as QueueItem;
                                AudioManager.PlayCue("sd_ui_accept_alt3");
                            }
                        }
                        else if (i > 0)
                        {
                            LinkedList<QueueItem> copied = new LinkedList<QueueItem>();
                            foreach (QueueItem qi in this.p.ConstructionQueue)
                            {
                                copied.AddLast(qi);
                            }
                            copied.Remove(this.p.ConstructionQueue[i]);
                            copied.AddFirst(this.p.ConstructionQueue[i]);
                            this.p.ConstructionQueue.Clear();
                            foreach (QueueItem qi in copied)
                            {
                                this.p.ConstructionQueue.Add(qi);
                            }
                            AudioManager.PlayCue("sd_ui_accept_alt3");
                            break;
                        }
                    }
                    if (HelperFunctions.CheckIntersection(e.down, MousePos))
                    {
                        ToolTip.CreateTooltip(64, PlanetScreen.screen.ScreenManager);
                        if (!input.CurrentKeyboardState.IsKeyDown(Keys.RightControl) && !input.CurrentKeyboardState.IsKeyDown(Keys.LeftControl) || this.currentMouse.LeftButton != ButtonState.Pressed || this.previousMouse.LeftButton != ButtonState.Released)
                        {
                            if (this.currentMouse.LeftButton == ButtonState.Pressed && this.previousMouse.LeftButton == ButtonState.Released && i + 1 < this.QSL.Copied.Count)
                            {
                                object tmp = this.p.ConstructionQueue[i + 1];
                                this.p.ConstructionQueue[i + 1] = this.p.ConstructionQueue[i];
                                this.p.ConstructionQueue[i] = tmp as QueueItem;
                                AudioManager.PlayCue("sd_ui_accept_alt3");
                            }
                        }
                        else if (i + 1 < this.QSL.Copied.Count)
                        {
                            LinkedList<QueueItem> copied = new LinkedList<QueueItem>();
                            foreach (QueueItem qi in this.p.ConstructionQueue)
                            {
                                copied.AddLast(qi);
                            }
                            copied.Remove(this.p.ConstructionQueue[i]);
                            copied.AddLast(this.p.ConstructionQueue[i]);
                            this.p.ConstructionQueue.Clear();
                            foreach (QueueItem qi in copied)
                            {
                                this.p.ConstructionQueue.Add(qi);
                            }
                            AudioManager.PlayCue("sd_ui_accept_alt3");
                            break;
                        }
                    }
                    if (HelperFunctions.CheckIntersection(e.apply, MousePos) && !this.p.RecentCombat && this.p.Crippled_Turns <= 0)
                    {
                        if (!input.CurrentKeyboardState.IsKeyDown(Keys.RightControl) && !input.CurrentKeyboardState.IsKeyDown(Keys.LeftControl) || this.currentMouse.LeftButton != ButtonState.Pressed || this.previousMouse.LeftButton != ButtonState.Released)
                        {
                            if (this.currentMouse.LeftButton == ButtonState.Pressed && this.previousMouse.LeftButton == ButtonState.Released)
                            {

                                if (this.p.ApplyStoredProduction(i))
                                {
                                    AudioManager.PlayCue("sd_ui_accept_alt3");
                                }
                                else
                                {
                                    AudioManager.PlayCue("UI_Misc20");
                                }
                            }
                        }
                        //else if (PlanetScreen.screen.Debug)
                        //{
                        //    this.p.ApplyProductiontoQueue(this.p.ConstructionQueue[i].Cost - this.p.ConstructionQueue[i].productionTowards, i);
                        //}
                        else if (this.p.ProductionHere == 0f)
                        {
                            AudioManager.PlayCue("UI_Misc20");
                        }
                        else
                        {
                            this.p.ApplyAllStoredProduction(i);
                            AudioManager.PlayCue("sd_ui_accept_alt3");
                        }
                    }
                    if (HelperFunctions.CheckIntersection(e.cancel, MousePos) && this.currentMouse.LeftButton == ButtonState.Pressed && this.previousMouse.LeftButton == ButtonState.Released)
                    {
                        Planet productionHere2 = this.p;
                        productionHere2.ProductionHere = productionHere2.ProductionHere + (e.item as QueueItem).productionTowards;
                        if (this.p.ProductionHere > this.p.MAX_STORAGE)
                        {
                            this.p.ProductionHere = this.p.MAX_STORAGE;
                        }
                        QueueItem item = (e.item as QueueItem);
                        if (item.pgs != null)
                        {
                            (e.item as QueueItem).pgs.QItem = null;
                        }
                        if(item.Goal !=null)
                        {
                            if(item.Goal.GoalName=="BuildConstructionShip")
                            {
                                p.Owner.GetGSAI().Goals.Remove(item.Goal);

                            }
                            if(item.Goal.GetFleet() !=null)
                                p.Owner.GetGSAI().Goals.Remove(item.Goal);

                        }
                        this.p.ConstructionQueue.Remove(e.item as QueueItem);
                        AudioManager.PlayCue("sd_ui_accept_alt3");
                    }
                }
                catch
                {
                }
            }
            this.QSL.HandleInput(input, this.p);
            if (this.ActiveBuildingEntry != null)
            {
                foreach (PlanetGridSquare pgs in this.p.TilesList)
                {
                    if (!HelperFunctions.CheckIntersection(pgs.ClickRect, MousePos) || this.currentMouse.LeftButton != ButtonState.Released || this.previousMouse.LeftButton != ButtonState.Pressed)
                    {
                        continue;
                    }
                    if (pgs.Habitable && pgs.building == null && pgs.QItem == null && (this.ActiveBuildingEntry.item as Building).Name != "Biospheres")
                    {
                        QueueItem qi = new QueueItem();
                        //{
                        qi.isBuilding = true;
                        qi.Building = this.ActiveBuildingEntry.item as Building;
                        qi.Cost = ResourceManager.BuildingsDict[qi.Building.Name].Cost * UniverseScreen.GamePaceStatic;
                        qi.productionTowards = 0f;
                        qi.pgs = pgs;
                        //};
                        pgs.QItem = qi;
                        this.p.ConstructionQueue.Add(qi);
                        this.ActiveBuildingEntry = null;
                        break;
                    }
                    else if (pgs.Habitable || pgs.Biosphere || pgs.QItem != null || !(this.ActiveBuildingEntry.item as Building).CanBuildAnywhere)
                    {
                        AudioManager.PlayCue("UI_Misc20");
                        this.ActiveBuildingEntry = null;
                        break;
                    }
                    else
                    {
                        QueueItem qi = new QueueItem();
                        //{
                        qi.isBuilding = true;
                        qi.Building = this.ActiveBuildingEntry.item as Building;
                        qi.Cost = ResourceManager.BuildingsDict[qi.Building.Name].Cost * UniverseScreen.GamePaceStatic;
                        qi.productionTowards = 0f;
                        qi.pgs = pgs;
                        //};
                        pgs.QItem = qi;
                        this.p.ConstructionQueue.Add(qi);
                        this.ActiveBuildingEntry = null;
                        break;
                    }
                }
                if (this.ActiveBuildingEntry != null)
                {
                    foreach (QueueItem qi in this.p.ConstructionQueue)
                    {
                        if (!qi.isBuilding || !(qi.Building.Name == (this.ActiveBuildingEntry.item as Building).Name) || !(this.ActiveBuildingEntry.item as Building).Unique)
                        {
                            continue;
                        }
                        this.ActiveBuildingEntry = null;
                        break;
                    }
                }
                if (this.currentMouse.RightButton == ButtonState.Pressed && this.previousMouse.RightButton == ButtonState.Released)
                {
                    this.ClickedTroop = true;
                    this.ActiveBuildingEntry = null;
                }
                if (this.currentMouse.LeftButton == ButtonState.Released && this.previousMouse.LeftButton == ButtonState.Pressed)
                {
                    this.ClickedTroop = true;
                    this.ActiveBuildingEntry = null;
                }
            }
            for (int i = this.buildSL.indexAtTop; i < this.buildSL.Copied.Count && i < this.buildSL.indexAtTop + this.buildSL.entriesToDisplay; i++)
            {
                ScrollList.Entry e = this.buildSL.Copied[i];
                if (e.item is ModuleHeader)
                {
                    (e.item as ModuleHeader).HandleInput(input, e);
                }
                else if (!HelperFunctions.CheckIntersection(e.clickRect, MousePos))
                {
                    e.clickRectHover = 0;
                }
                else
                {
                    this.selector = new Selector(this.ScreenManager, e.clickRect);
                    if (e.clickRectHover == 0)
                    {
                        AudioManager.PlayCue("sd_ui_mouseover");
                    }
                    e.clickRectHover = 1;
                    if (this.currentMouse.LeftButton == ButtonState.Pressed && this.previousMouse.LeftButton == ButtonState.Pressed && e.item is Building && this.ActiveBuildingEntry == null)
                    {
                        this.ActiveBuildingEntry = e;
                    }
                    if (this.currentMouse.LeftButton == ButtonState.Released && this.previousMouse.LeftButton == ButtonState.Pressed)
                    {
                        if (this.ClickTimer >= this.TimerDelay)
                        {
                            this.ClickTimer = 0f;
                        }
                        else
                        {
                            Rectangle rectangle = e.addRect;
                            if (!HelperFunctions.CheckIntersection(e.addRect, input.CursorPosition))
                            {
                                QueueItem qi = new QueueItem();
                                if (e.item is Ship)
                                {
                                    qi.isShip = true;
                                    qi.sData = (e.item as Ship).GetShipData();
                                    qi.Cost = (e.item as Ship).GetCost(this.p.Owner);
                                    qi.productionTowards = 0f;
                                    this.p.ConstructionQueue.Add(qi);
                                    AudioManager.PlayCue("sd_ui_mouseover");
                                }
                                else if (e.item is Troop)
                                {
                                    qi.isTroop = true;
                                    qi.troop = e.item as Troop;
                                    qi.Cost = (e.item as Troop).GetCost();
                                    qi.productionTowards = 0f;
                                    this.p.ConstructionQueue.Add(qi);
                                    AudioManager.PlayCue("sd_ui_mouseover");
                                }
                                else if (e.item is Building)
                                {
                                    this.p.AddBuildingToCQ(ResourceManager.GetBuilding((e.item as Building).Name));
                                    AudioManager.PlayCue("sd_ui_mouseover");
                                }
                            }
                        }
                    }
                }
                Rectangle rectangle1 = e.addRect;
                if (!HelperFunctions.CheckIntersection(e.addRect, MousePos))
                {
                    e.PlusHover = 0;
                }
                else
                {
                    e.PlusHover = 1;
                    ToolTip.CreateTooltip(51, this.ScreenManager);
                    if (this.currentMouse.LeftButton == ButtonState.Pressed && this.previousMouse.LeftButton == ButtonState.Released)
                    {
                        QueueItem qi = new QueueItem();
                        if (e.item is Building)
                        {
                            this.p.AddBuildingToCQ(ResourceManager.GetBuilding((e.item as Building).Name));
                        }
                        else if (e.item is Ship)
                        {
                            qi.isShip = true;
                            qi.sData = (e.item as Ship).GetShipData();
                            qi.Cost = (e.item as Ship).GetCost(this.p.Owner);
                            qi.productionTowards = 0f;
                            this.p.ConstructionQueue.Add(qi);
                        }
                        else if (e.item is Troop)
                        {
                            qi.isTroop = true;
                            qi.troop = e.item as Troop;
                            qi.Cost = (e.item as Troop).GetCost();
                            qi.productionTowards = 0f;
                            this.p.ConstructionQueue.Add(qi);
                        }
                    }
                }
                Rectangle rectangle2 = e.editRect;
                if (!HelperFunctions.CheckIntersection(e.editRect, MousePos))
                {
                    e.EditHover = 0;
                }
                else
                {
                    e.EditHover = 1;
                    ToolTip.CreateTooltip(52, this.ScreenManager);
                    if (this.currentMouse.LeftButton == ButtonState.Pressed && this.previousMouse.LeftButton == ButtonState.Released)
                    {
                        ShipDesignScreen sdScreen = new ShipDesignScreen(this.eui);
                        this.ScreenManager.AddScreen(sdScreen);
                        sdScreen.ChangeHull((e.item as Ship).GetShipData());
                    }
                }
            }
            this.shipsCanBuildLast = this.p.Owner.ShipsWeCanBuild.Count;
            this.buildingsHereLast = this.p.BuildingList.Count;
            this.buildingsCanBuildLast = this.BuildingsCanBuild.Count;
            if (input.RightMouseClick && !this.ClickedTroop) rmouse = false;
            if (!rmouse && (input.CurrentMouseState.RightButton != ButtonState.Released || this.previousMouse.RightButton != ButtonState.Released))
            {
                this.eui.screen.ShipsInCombat.Active = true;
                this.eui.screen.PlanetsInCombat.Active = true;
            }
            this.previousMouse = this.currentMouse;
        }