Example #1
0
 private void OnRightClick(GameObject obj)
 {
     DepartmentOfIndustry.ConstructibleElement constructibleElement = obj.GetComponent <AgeControlButton>().OnActivateDataObject as DepartmentOfIndustry.ConstructibleElement;
     Diagnostics.Assert(constructibleElement != null);
     if (constructibleElement is UnitDesign)
     {
         base.GuiService.GetGuiPanel <UnitDesignModalPanel>().CreateMode = false;
         base.GuiService.GetGuiPanel <UnitDesignModalPanel>().Show(new object[]
         {
             constructibleElement as UnitDesign
         });
     }
 }
Example #2
0
 public ProductionConstruction(DepartmentOfIndustry.ConstructibleElement constructibleElement, global::Empire empire, GuiSorting guiSubCategorySorting, StaticString[] flags)
 {
     this.ConstructibleElement = constructibleElement;
     this.Flags            = flags;
     this.CostInProduction = 0f;
     IConstructionCost[] costs = constructibleElement.Costs;
     for (int i = 0; i < costs.Length; i++)
     {
         if (costs[i].ResourceName == "Production")
         {
             this.CostInProduction += costs[i].GetValue(empire);
         }
     }
     this.subCategorySortValue = guiSubCategorySorting.GetSortValue(this.ConstructibleElement.SubCategory);
 }
 private Construction GetCurrentConstructionRaze()
 {
     if (this.ConstructionQueue.PendingConstructions.Count > 0)
     {
         Construction construction = this.ConstructionQueue.Peek();
         if (construction != null && construction.ConstructibleElement is DepartmentOfIndustry.ConstructibleElement)
         {
             DepartmentOfIndustry.ConstructibleElement constructibleElement = construction.ConstructibleElement as DepartmentOfIndustry.ConstructibleElement;
             if (constructibleElement != null && constructibleElement.Name == OvergrownCityPanel.CityConstructibleActionInfectedRaze)
             {
                 return(construction);
             }
         }
     }
     return(null);
 }
    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 #5
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 #6
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));
        }
    }
    protected override IEnumerator OnShow(params object[] parameters)
    {
        Quest quest = this.context as Quest;

        if (quest == null)
        {
            Diagnostics.LogError("Context must be a quest");
            yield break;
        }
        int        num = 0;
        GuiElement guiElement;

        if (base.GuiService.GuiPanelHelper.TryGetGuiElement(quest.Name, out guiElement))
        {
            QuestGuiElement questGuiElement = guiElement as QuestGuiElement;
            this.ObjectiveLabel.AgeTransform.Height = 0f;
            this.ObjectiveLabel.Text = string.Empty;
            if (!this.progressionOnly)
            {
                this.ObjectiveBackground.TintColor = this.DescriptionColor;
                AgePrimitiveLabel objectiveLabel = this.ObjectiveLabel;
                objectiveLabel.Text += AgeLocalizer.Instance.LocalizeString(questGuiElement.Steps[num].Text);
            }
            if (!this.descriptionOnly)
            {
                this.ObjectiveBackground.TintColor = this.ProgressionColor;
                AgePrimitiveLabel objectiveLabel2 = this.ObjectiveLabel;
                objectiveLabel2.Text += quest.GetProgressionString(quest.QuestDefinition.Steps[num].Name);
                if (this.constructibleProgression && quest.QuestState != QuestState.Failed && quest.QuestState != QuestState.Completed)
                {
                    if (this.departmentOfIndustries == null)
                    {
                        IGameService service = Services.GetService <IGameService>();
                        Diagnostics.Assert(service != null && service.Game != null);
                        global::Game game = service.Game as global::Game;
                        this.departmentOfIndustries = new List <DepartmentOfIndustry>();
                        for (int i = 0; i < game.Empires.Length; i++)
                        {
                            global::Empire empire = game.Empires[i];
                            if (empire is MajorEmpire)
                            {
                                DepartmentOfIndustry agency = empire.GetAgency <DepartmentOfIndustry>();
                                if (agency != null)
                                {
                                    this.departmentOfIndustries.Add(agency);
                                }
                            }
                        }
                    }
                    DepartmentOfIndustry.ConstructibleElement constructibleElement = null;
                    if (!this.departmentOfIndustries[0].ConstructibleElementDatabase.TryGetValue(quest.Name.ToString().Replace("Quest", string.Empty), out constructibleElement))
                    {
                        Diagnostics.LogError("Cannot find ConstructibleElement {0}", new object[]
                        {
                            quest.Name.ToString().Replace("Quest", string.Empty)
                        });
                    }
                    else
                    {
                        List <KeyValuePair <float, City> > list = new List <KeyValuePair <float, City> >();
                        KeyValuePair <float, City>         item = default(KeyValuePair <float, City>);
                        for (int j = 0; j < this.departmentOfIndustries.Count; j++)
                        {
                            City         city;
                            Construction construction = this.departmentOfIndustries[j].GetConstruction(constructibleElement, out city);
                            if (construction != null && city != null)
                            {
                                int   num2;
                                float key;
                                float num3;
                                bool  flag;
                                QueueGuiItem.GetConstructionTurnInfos(city, construction, QueueGuiItem.EmptyList, out num2, out key, out num3, out flag);
                                KeyValuePair <float, City> keyValuePair = new KeyValuePair <float, City>(key, city);
                                list.Add(keyValuePair);
                                if (city.Empire.Bits == quest.EmpireBits)
                                {
                                    item = keyValuePair;
                                }
                            }
                        }
                        list.Sort(new Comparison <KeyValuePair <float, City> >(PanelFeatureQuest.ConstructionInProgressInverseSorter));
                        int num4;
                        if (item.Value != null)
                        {
                            num4 = list.IndexOf(item);
                        }
                        else
                        {
                            num4 = list.Count;
                        }
                        if (this.ObjectiveLabel.Text != string.Empty)
                        {
                            AgePrimitiveLabel objectiveLabel3 = this.ObjectiveLabel;
                            objectiveLabel3.Text += "\n";
                        }
                        this.ObjectiveLabel.Text = string.Concat(new object[]
                        {
                            this.ObjectiveLabel.Text,
                            AgeLocalizer.Instance.LocalizeString("%QuestRank"),
                            num4 + 1,
                            "/",
                            this.departmentOfIndustries.Count
                        });
                    }
                }
            }
            if (!string.IsNullOrEmpty(this.ObjectiveLabel.Text))
            {
                this.ObjectiveLabel.AgeTransform.Width = this.DefaultWidth - this.ObjectiveLabel.AgeTransform.PixelMarginLeft - this.ObjectiveLabel.AgeTransform.PixelMarginRight;
                this.ObjectiveLabel.ComputeText();
                this.ObjectiveGroup.Height = this.ObjectiveLabel.Font.LineHeight * (float)this.ObjectiveLabel.TextLines.Count + this.ObjectiveLabel.AgeTransform.PixelMarginTop + this.ObjectiveLabel.AgeTransform.PixelMarginBottom;
                this.ObjectiveBox.Height   = this.ObjectiveGroup.Height + this.ObjectiveGroup.PixelMarginTop + this.ObjectiveGroup.PixelMarginBottom;
            }
            base.AgeTransform.Height = this.ObjectiveBox.Height;
        }
        yield return(base.OnShow(parameters));

        yield break;
    }
Example #8
0
    public override void ReadXml(XmlReader reader)
    {
        int num = reader.ReadVersionAttribute();

        this.GUID          = reader.GetAttribute <ulong>("GUID");
        this.ArmyPillaging = reader.GetAttribute <ulong>("ArmyPillaging");
        base.ReadXml(reader);
        string text = reader.GetAttribute("PointOfInterestTemplateName");

        reader.ReadStartElement("PointOfInterestDefinition");
        this.PointOfInterestDefinition = new PointOfInterestDefinition();
        if (text == "QuestLocation_SunkenRuin")
        {
            text = "NavalQuestLocation_SunkenRuin";
        }
        IDatabase <PointOfInterestTemplate> database = Databases.GetDatabase <PointOfInterestTemplate>(true);

        this.PointOfInterestDefinition.PointOfInterestTemplateName = text;
        this.PointOfInterestDefinition.PointOfInterestTemplate     = database.GetValue(text);
        this.PointOfInterestDefinition.WorldPosition = reader.ReadElementSerializable <WorldPosition>();
        int attribute = reader.GetAttribute <int>("Count");

        reader.ReadStartElement("Overrides");
        for (int i = 0; i < attribute; i++)
        {
            string attribute2 = reader.GetAttribute("Key");
            string attribute3 = reader.GetAttribute("Value");
            this.PointOfInterestDefinition.Overrides.Add(attribute2, attribute3);
        }
        reader.ReadEndElement("Overrides");
        reader.ReadEndElement("PointOfInterestDefinition");
        this.Interaction.Bits = reader.GetAttribute <int>("Bits");
        int attribute4 = reader.GetAttribute <int>("InteractionLockCount");

        reader.ReadStartElement("Interaction");
        for (int j = 0; j < attribute4; j++)
        {
            int attribute5 = reader.GetAttribute <int>("Key");
            int attribute6 = reader.GetAttribute <int>("ValueCount");
            reader.ReadStartElement("InteractionLock");
            for (int k = 0; k < attribute6; k++)
            {
                string attribute7 = reader.GetAttribute <string>("Key");
                int    attribute8 = reader.GetAttribute <int>("Value");
                reader.ReadStartElement("Value");
                if (!this.Interaction.InteractionLockCount.ContainsKey(attribute5))
                {
                    this.Interaction.InteractionLockCount.Add(attribute5, new Dictionary <string, int>());
                }
                this.Interaction.InteractionLockCount[attribute5].Add(attribute7, attribute8);
                reader.ReadEndElement("Value");
            }
            reader.ReadEndElement("InteractionLock");
        }
        reader.ReadEndElement("Interaction");
        string text2 = reader.ReadElementString("PointOfInterestImprovement");

        if (!string.IsNullOrEmpty(text2))
        {
            IDatabase <DepartmentOfIndustry.ConstructibleElement> database2 = Databases.GetDatabase <DepartmentOfIndustry.ConstructibleElement>(true);
            DepartmentOfIndustry.ConstructibleElement             pointOfInterestImprovement = null;
            if (database2.TryGetValue(text2, out pointOfInterestImprovement))
            {
                this.PointOfInterestImprovement = pointOfInterestImprovement;
                if (this.PointOfInterestImprovement != null)
                {
                    for (int l = 0; l < this.PointOfInterestImprovement.Descriptors.Length; l++)
                    {
                        if (!base.SimulationObject.Tags.Contains(this.PointOfInterestImprovement.Descriptors[l].Name))
                        {
                            base.AddDescriptor(this.PointOfInterestImprovement.Descriptors[l], false);
                        }
                    }
                }
            }
            reader.ReadEndElement("PointOfInterestImprovement");
        }
        if (reader.IsStartElement("AffinityMapping"))
        {
            this.AffinityMapping = reader.ReadElementString("AffinityMapping");
        }
        this.QuestStepsUsedBy.Clear();
        if (reader.IsStartElement("QuestStepsUsedBy"))
        {
            int attribute9 = reader.GetAttribute <int>("QuestStepsCount");
            reader.ReadStartElement("QuestStepsUsedBy");
            for (int m = 0; m < attribute9; m++)
            {
                this.QuestStepsUsedBy.Add(reader.ReadString());
            }
            reader.ReadEndElement("QuestStepsUsedBy");
        }
        if (num < 2 && this.Type == Fortress.Citadel)
        {
            base.RemoveDescriptorByType("CitadelType");
            IDatabase <DepartmentOfIndustry.ConstructibleElement> database3 = Databases.GetDatabase <DepartmentOfIndustry.ConstructibleElement>(true);
            DepartmentOfIndustry.ConstructibleElement             pointOfInterestImprovement2 = null;
            if (database3.TryGetValue(this.PointOfInterestDefinition.PointOfInterestTemplate.Properties["Improvement"], out pointOfInterestImprovement2))
            {
                this.PointOfInterestImprovement = pointOfInterestImprovement2;
                if (this.PointOfInterestImprovement != null)
                {
                    for (int n = 0; n < this.PointOfInterestImprovement.Descriptors.Length; n++)
                    {
                        if (!base.SimulationObject.Tags.Contains(this.PointOfInterestImprovement.Descriptors[n].Name))
                        {
                            base.AddDescriptor(this.PointOfInterestImprovement.Descriptors[n], false);
                        }
                    }
                }
            }
        }
        if (num >= 3)
        {
            this.UntappedDustDeposits = reader.ReadElementString <bool>("UntappedDustDeposits");
        }
        if (num >= 4)
        {
            string text3 = reader.ReadElementString("CreepingNodeImprovement");
            if (!string.IsNullOrEmpty(text3))
            {
                IDatabase <CreepingNodeImprovementDefinition> database4 = Databases.GetDatabase <CreepingNodeImprovementDefinition>(true);
                CreepingNodeImprovementDefinition             creepingNodeImprovement = null;
                if (database4.TryGetValue(text3, out creepingNodeImprovement))
                {
                    this.CreepingNodeImprovement = creepingNodeImprovement;
                    if (Amplitude.Unity.Framework.Application.Preferences.EnableModdingTools && this.CreepingNodeImprovement != null)
                    {
                        for (int num2 = 0; num2 < this.CreepingNodeImprovement.Descriptors.Length; num2++)
                        {
                            if (base.SimulationObject.Tags.Contains(this.CreepingNodeImprovement.Descriptors[num2].Name))
                            {
                                base.RemoveDescriptor(this.CreepingNodeImprovement.Descriptors[num2]);
                            }
                        }
                    }
                }
            }
            this.CreepingNodeGUID = reader.ReadElementString <ulong>("CreepingNodeGUID");
        }
    }