private void OnSelectGeoConstructibleCB(GameObject obj)
 {
     if (base.PlayerController != null)
     {
         AgeControlButton component = obj.GetComponent <AgeControlButton>();
         GeoConstructibleLabel.PointOfInterestPair pointOfInterestPair = component.OnActivateDataObject as GeoConstructibleLabel.PointOfInterestPair;
         PointOfInterest pointOfInterest = pointOfInterestPair.PointOfInterest;
         PointOfInterestImprovementDefinition pointOfInterestImprovementDefinition = pointOfInterestPair.PointOfInterestImprovementDefinition;
         OrderQueueConstruction order = new OrderQueueConstruction(this.City.Empire.Index, this.City.GUID, pointOfInterestImprovementDefinition, pointOfInterest.WorldPosition, string.Empty);
         base.PlayerController.PostOrder(order);
     }
 }
    private void DoRazeInfectedCity()
    {
        Construction currentConstructionRaze = this.GetCurrentConstructionRaze();

        if (currentConstructionRaze != null)
        {
            OrderCancelConstruction order = new OrderCancelConstruction(this.City.Empire.Index, this.City.GUID, currentConstructionRaze.GUID);
            Ticket ticket;
            this.playerControllerRepository.ActivePlayerController.PostOrder(order, out ticket, new EventHandler <TicketRaisedEventArgs>(this.OnOrderResponse));
        }
        else
        {
            bool flag = !Amplitude.Unity.Runtime.Runtime.Registry.GetValue <bool>(OvergrownCityPanel.gameplaySettingOvergrownCityImmediateRazePath, true);
            if (flag)
            {
                DepartmentOfIndustry agency = this.City.Empire.GetAgency <DepartmentOfIndustry>();
                IEnumerable <DepartmentOfIndustry.ConstructibleElement> availableConstructibleElementsAsEnumerable = agency.ConstructibleElementDatabase.GetAvailableConstructibleElementsAsEnumerable(new StaticString[0]);
                DepartmentOfIndustry.ConstructibleElement constructibleElement = availableConstructibleElementsAsEnumerable.FirstOrDefault((DepartmentOfIndustry.ConstructibleElement m) => m.Name == OvergrownCityPanel.CityConstructibleActionInfectedRaze);
                OrderQueueConstruction order2 = new OrderQueueConstruction(this.City.Empire.Index, this.City.GUID, constructibleElement, string.Empty);
                Ticket ticket2;
                this.playerControllerRepository.ActivePlayerController.PostOrder(order2, out ticket2, new EventHandler <TicketRaisedEventArgs>(this.OnOrderResponse));
            }
            else
            {
                WorldPosition firstAvailablePositionForArmyCreation = this.GetFirstAvailablePositionForArmyCreation();
                if (this.City.StandardUnits.Count > 0 && firstAvailablePositionForArmyCreation.IsValid)
                {
                    OrderTransferGarrisonToNewArmy order3 = new OrderTransferGarrisonToNewArmy(this.City.Empire.Index, this.City.GUID, (from m in this.City.Units
                                                                                                                                        select m.GUID).ToArray <GameEntityGUID>(), firstAvailablePositionForArmyCreation, StaticString.Empty, false, false, false);
                    Ticket ticket3;
                    this.playerControllerRepository.ActivePlayerController.PostOrder(order3, out ticket3, new EventHandler <TicketRaisedEventArgs>(this.OrderTransferGarrisonToNewArmy_TicketRaised));
                }
                else
                {
                    this.SendOrderDestroyCity();
                }
                this.Hide(true);
            }
        }
    }
Example #3
0
    private void OrderCityBuilding()
    {
        DepartmentOfTheInterior agency  = this.Empire.GetAgency <DepartmentOfTheInterior>();
        DepartmentOfIndustry    agency2 = this.Empire.GetAgency <DepartmentOfIndustry>();

        if (this.CityLocation.IsValid && agency != null)
        {
            City closestCityFromWorldPosition = agency.GetClosestCityFromWorldPosition(this.CityLocation, true);
            if ((closestCityFromWorldPosition != null || closestCityFromWorldPosition.Empire == this.Empire) && agency2.GetConstructionQueue(closestCityFromWorldPosition).PendingConstructions.Count <= 0)
            {
                List <string> list = new List <string>
                {
                    "CityImprovementIndustry0",
                    "CityImprovementDust0",
                    "CityImprovementFood0",
                    "CityImprovementApproval1",
                    "CityImprovementScience0"
                };
                List <DepartmentOfIndustry.ConstructibleElement> list2 = new List <DepartmentOfIndustry.ConstructibleElement>();
                DepartmentOfIndustry.ConstructibleElement        constructibleElement = null;
                foreach (DepartmentOfIndustry.ConstructibleElement constructibleElement2 in agency2.ConstructibleElementDatabase.GetAvailableConstructibleElements(new StaticString[]
                {
                    CityImprovementDefinition.ReadOnlyCategory
                }))
                {
                    if (DepartmentOfTheTreasury.CheckConstructiblePrerequisites(closestCityFromWorldPosition, constructibleElement2, new string[]
                    {
                        ConstructionFlags.Prerequisite
                    }))
                    {
                        if (agency.Cities.Count == 1 && constructibleElement2.ToString().Contains("CityImprovementFIDS"))
                        {
                            constructibleElement = constructibleElement2;
                            break;
                        }
                        if (list.Contains(constructibleElement2.ToString()))
                        {
                            list2.Add(constructibleElement2);
                        }
                    }
                }
                if (constructibleElement == null && list2.Count > 0)
                {
                    using (List <string> .Enumerator enumerator = list.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            string important = enumerator.Current;
                            if (list2.Any((DepartmentOfIndustry.ConstructibleElement item) => item.Name == important))
                            {
                                constructibleElement = list2.First((DepartmentOfIndustry.ConstructibleElement item) => item.Name == important);
                                break;
                            }
                        }
                    }
                }
                if (constructibleElement != null)
                {
                    OrderQueueConstruction order = new OrderQueueConstruction(this.Empire.Index, closestCityFromWorldPosition.GUID, constructibleElement, string.Empty);
                    Ticket ticket;
                    this.Empire.PlayerControllers.AI.PostOrder(order, out ticket, null);
                }
            }
        }
    }
Example #4
0
    private void OnOptionSelect(GameObject obj)
    {
        AgeControlButton component = obj.GetComponent <AgeControlButton>();

        DepartmentOfIndustry.ConstructibleElement constructibleElement = component.OnActivateDataObject as DepartmentOfIndustry.ConstructibleElement;
        Diagnostics.Assert(constructibleElement != null);
        bool flag = false;

        object[] array = constructibleElement.GetType().GetCustomAttributes(typeof(WorldPlacementCursorAttribute), true);
        if (array != null && array.Length > 0)
        {
            flag = true;
        }
        else if (constructibleElement.Tags.Contains(DownloadableContent9.TagColossus))
        {
            flag  = true;
            array = new object[]
            {
                new ColossusWorldPlacementCursorAttribute()
            };
        }
        ICursorService service = Services.GetService <ICursorService>();

        if (flag)
        {
            bool flag2 = true;
            if (flag2)
            {
                if (service != null)
                {
                    service.Backup();
                    WorldPlacementCursorAttribute worldPlacementCursorAttribute = array[0] as WorldPlacementCursorAttribute;
                    Type type = worldPlacementCursorAttribute.Type;
                    service.ChangeCursor(type, new object[]
                    {
                        this.City,
                        constructibleElement
                    });
                }
                return;
            }
            OrderQueueConstruction order = new OrderQueueConstruction(this.City.Empire.Index, this.City.GUID, constructibleElement, string.Empty);
            Ticket ticket;
            this.playerControllerRepository.ActivePlayerController.PostOrder(order, out ticket, new EventHandler <TicketRaisedEventArgs>(this.OnOrderResponse));
        }
        else if (this.keyMappingService.GetKeyUp(KeyAction.ControlBindingsQueueOnAll) || this.keyMappingService.GetKeyUp(KeyAction.ControlBindingsQueueOnTopOfAll))
        {
            DepartmentOfTheInterior agency = this.City.Empire.GetAgency <DepartmentOfTheInterior>();
            List <City>             list   = agency.Cities.ToList <City>();
            for (int i = 0; i < list.Count; i++)
            {
                OrderQueueConstruction order2 = new OrderQueueConstruction(this.City.Empire.Index, list[i].GUID, constructibleElement, string.Empty);
                Ticket ticket2;
                this.playerControllerRepository.ActivePlayerController.PostOrder(order2, out ticket2, new EventHandler <TicketRaisedEventArgs>(this.OnOrderResponse));
            }
        }
        else
        {
            OrderQueueConstruction order3 = new OrderQueueConstruction(this.City.Empire.Index, this.City.GUID, constructibleElement, string.Empty);
            Ticket ticket3;
            this.playerControllerRepository.ActivePlayerController.PostOrder(order3, out ticket3, new EventHandler <TicketRaisedEventArgs>(this.OnOrderResponse));
        }
    }