Esempio n. 1
0
 protected override bool TryComputeArmyMissionParameter()
 {
     this.besiegers = null;
     if (this.City.BesiegingEmpire != null)
     {
         this.besiegers = DepartmentOfTheInterior.GetBesiegers(this.City);
         if (this.besiegers.Length == 0)
         {
             return(false);
         }
         float    num      = 0f;
         float    num2     = 0f;
         Garrison defender = this.besiegers[0];
         this.intelligenceAiHelper.EstimateMPInBattleground(this.City, defender, ref num, ref num2);
         if (num > num2)
         {
             return(this.AskForArmy(true));
         }
         float propertyValue  = this.City.GetPropertyValue(SimulationProperties.CityDefensePoint);
         float besiegingPower = DepartmentOfTheInterior.GetBesiegingPower(this.City, true);
         if (propertyValue <= besiegingPower)
         {
             return(this.AskForArmy(true));
         }
     }
     else
     {
         if (base.AIDataArmyGUID.IsValid)
         {
             return(this.DisbandArmy());
         }
         base.Completion = AICommanderMission.AICommanderMissionCompletion.Success;
     }
     return(false);
 }
    protected override int GetNeededAvailabilityTime()
    {
        float num           = -DepartmentOfTheInterior.GetBesiegingPower(this.RegionWithCityToFree.City, true);
        float propertyValue = this.RegionWithCityToFree.City.GetPropertyValue(SimulationProperties.CityDefensePoint);

        return((int)Math.Floor((double)(propertyValue / num)));
    }
    protected override State Execute(AIBehaviorTree aiBehaviorTree, params object[] parameters)
    {
        Army army;

        if (base.GetArmyUnlessLocked(aiBehaviorTree, "$Army", out army) > AIArmyMission.AIArmyMissionErrorCode.None)
        {
            return(State.Failure);
        }
        if (!aiBehaviorTree.Variables.ContainsKey(this.CityUnderSiege))
        {
            aiBehaviorTree.LogError("city not set", new object[0]);
            return(State.Failure);
        }
        City city = aiBehaviorTree.Variables[this.CityUnderSiege] as City;

        if (city == null)
        {
            aiBehaviorTree.ErrorCode = 8;
            return(State.Failure);
        }
        if (city.BesiegingEmpire != null)
        {
            float propertyValue  = city.GetPropertyValue(SimulationProperties.CityDefensePoint);
            float besiegingPower = DepartmentOfTheInterior.GetBesiegingPower(city, true);
            if (propertyValue <= besiegingPower)
            {
                if (this.Inverted)
                {
                    return(State.Failure);
                }
                return(State.Success);
            }
        }
        if (this.Inverted)
        {
            return(State.Success);
        }
        return(State.Failure);
    }
Esempio n. 4
0
    public void RefreshContent()
    {
        if (this.City == null)
        {
            return;
        }
        if (this.City.Empire == null)
        {
            return;
        }
        if (this.GuiEmpire.Index != this.City.Empire.Index)
        {
            if (this.guiEmpire == null)
            {
                this.Unbind();
                return;
            }
            this.GuiEmpire = new GuiEmpire(this.City.Empire);
            DepartmentOfIndustry agency = this.City.Empire.GetAgency <DepartmentOfIndustry>();
            this.ConstructionQueue = agency.GetConstructionQueue(this.City);
        }
        if (this.GuiEmpire != null)
        {
            this.FactionBackground.TintColor = this.GuiEmpire.Color;
            this.PopulationSymbol.TintColor  = this.GuiEmpire.Color;
            this.FactionSymbol.TintColor     = this.GuiEmpire.Color;
            this.PinLine.TintColor           = this.GuiEmpire.Color;
            this.PopulationNumber.Text       = GuiFormater.FormatGui(this.City.GetPropertyValue(SimulationProperties.Population), false, false, false, 1);
            this.FactionSymbol.Image         = this.GuiEmpire.GuiFaction.GetImageTexture(global::GuiPanel.IconSize.LogoSmall, true);
        }
        string content = "%CityCurrentConstructionDescription";

        if (this.City.IsInfected)
        {
            this.PanelSpying.Visible        = false;
            this.PanelOvergrownCity.Visible = true;
            this.AgeTransform.Height        = this.ModifierPosition.EndHeight;
            if (this.GuiPreviousEmpire == null)
            {
                this.GuiPreviousEmpire = new GuiEmpire(this.City.LastNonInfectedOwner);
            }
            if (this.GuiPreviousEmpire != null)
            {
                this.PreviousEmpireFactionIcon.TintColor     = this.GuiPreviousEmpire.Color;
                this.PreviousEmpireFactionIcon.Image         = this.GuiPreviousEmpire.GuiFaction.GetImageTexture(global::GuiPanel.IconSize.LogoSmall, true);
                this.PreviousEmpireFactionTooltip.Class      = "Descriptor";
                this.PreviousEmpireFactionTooltip.ClientData = this.GuiEmpire.Empire;
                Faction faction = this.GuiPreviousEmpire.Empire.Faction;
                if (faction != null)
                {
                    new List <string>();
                    foreach (SimulationDescriptor simulationDescriptor in faction.GetIntegrationDescriptors())
                    {
                        this.PreviousEmpireFactionTooltip.Content = simulationDescriptor.Name;
                    }
                }
            }
            if (this.ConstructionQueue.PendingConstructions.Count > 0)
            {
                Construction construction = this.ConstructionQueue.Peek();
                if (construction.ConstructibleElement.SubCategory == "SubCategoryAssimilation" && construction.ConstructibleElement.Name != "CityConstructibleActionInfectedRaze")
                {
                    content = "%IntegratingFactionUnderConstructionDescription";
                }
            }
        }
        this.ConstructionGroup.AgeTooltip.Content = content;
        this.RefreshCityName();
        DepartmentOfIntelligence agency2 = this.playerControllerRepository.ActivePlayerController.Empire.GetAgency <DepartmentOfIntelligence>();
        bool flag = this.playerControllerRepository.ActivePlayerController.Empire.SimulationObject.Tags.Contains(global::Empire.TagEmpireEliminated);

        if (flag && ELCPUtilities.SpectatorSpyFocus >= 0)
        {
            agency2 = this.game.Empires[ELCPUtilities.SpectatorSpyFocus].GetAgency <DepartmentOfIntelligence>();
        }
        Unit hero = null;

        InfiltrationProcessus.InfiltrationState infiltrationState = InfiltrationProcessus.InfiltrationState.None;
        bool flag2 = false;

        if (this.playerControllerRepository != null)
        {
            if (this.City.Empire == this.playerControllerRepository.ActivePlayerController.Empire)
            {
                flag2 = true;
            }
            else if (this.PanelSpying.Visible && agency2 != null && agency2.TryGetSpyOnGarrison(this.City, out hero, out infiltrationState) && infiltrationState == InfiltrationProcessus.InfiltrationState.Infiltrated)
            {
                flag2 = true;
            }
            else if (flag)
            {
                flag2 = true;
            }
        }
        if (!flag2)
        {
            if (this.City.Empire == null)
            {
                this.CompetitorTitle.Text = string.Empty;
            }
            else
            {
                DiplomaticRelation diplomaticRelation = this.playerControllerRepository.ActivePlayerController.Empire.GetAgency <DepartmentOfForeignAffairs>().GetDiplomaticRelation(this.City.Empire);
                Diagnostics.Assert(diplomaticRelation != null);
                if (diplomaticRelation.State != null && diplomaticRelation.State.Name == DiplomaticRelationState.Names.Alliance)
                {
                    AgeUtils.TruncateString(AgeLocalizer.Instance.LocalizeString("%CityLabelAlliedTitle"), this.CompetitorTitle, out this.temp, '.');
                    this.CompetitorTitle.Text = this.temp;
                }
                else if (diplomaticRelation.State != null && diplomaticRelation.State.Name == DiplomaticRelationState.Names.Peace)
                {
                    AgeUtils.TruncateString(AgeLocalizer.Instance.LocalizeString("%CityLabelFriendlyTitle"), this.CompetitorTitle, out this.temp, '.');
                    this.CompetitorTitle.Text = this.temp;
                }
                else
                {
                    AgeUtils.TruncateString(AgeLocalizer.Instance.LocalizeString("%CityLabelEnemyTitle"), this.CompetitorTitle, out this.temp, '.');
                    this.CompetitorTitle.Text = this.temp;
                }
            }
        }
        this.SelectionButton.AgeTransform.Enable = flag2;
        this.PlayerSpecificGroup.Visible         = flag2;
        this.CompetitorSpecificGroup.Visible     = !flag2;
        float propertyValue  = this.City.GetPropertyValue(SimulationProperties.CityDefensePoint);
        float propertyValue2 = this.City.GetPropertyValue(SimulationProperties.MaximumCityDefensePoint);
        float propertyValue3 = this.City.GetPropertyValue(SimulationProperties.CityDefensePointRecoveryPerTurn);
        float propertyValue4 = this.City.GetPropertyValue(SimulationProperties.Ownership);

        Diagnostics.Assert(this.UnitNumber != null);
        Diagnostics.Assert(this.City.StandardUnits != null);
        int num = (this.City.Militia == null) ? 0 : this.City.Militia.StandardUnits.Count;

        this.UnitNumber.Text    = GuiFormater.FormatGui(this.City.StandardUnits.Count + num);
        this.DefenseNumber.Text = GuiFormater.FormatStock(propertyValue, SimulationProperties.CityDefensePoint, 0, true);
        float propertyValue5 = this.City.GetPropertyValue(SimulationProperties.DefensivePower);

        this.DefenseGroup.AgeTooltip.Content = AgeLocalizer.Instance.LocalizeString("%CityDefenseDescription");
        this.DefenseIcon.Image = AgeManager.Instance.FindDynamicTexture("fortificationCityLabel", false);
        if (propertyValue5 > 0f)
        {
            this.DefenseGroup.AgeTooltip.Content = AgeLocalizer.Instance.LocalizeString("%CityDefenseWithDefensivePowerDescription").Replace("$DefensivePowerValue", GuiFormater.FormatGui(propertyValue5, false, true, false, 1));
            this.DefenseIcon.Image = AgeManager.Instance.FindDynamicTexture("retaliationCityLabel", false);
        }
        this.DefenseGroup.AgeTooltip.Content = this.DefenseGroup.AgeTooltip.Content.Replace("$CityDefenseValue", GuiFormater.FormatGui(propertyValue, false, true, false, 1));
        if (propertyValue4 < 1f && !this.City.IsInfected)
        {
            this.OwnershipPercentage.AgeTransform.Visible = true;
            this.OwnershipPercentage.Text = GuiFormater.FormatGui(propertyValue4, true, false, false, 1);
        }
        else
        {
            this.OwnershipPercentage.AgeTransform.Visible = false;
        }
        if (this.City.BesiegingEmpire != null || this.City.BesiegingSeafaringArmies.Count != 0 || this.City.IsUnderEarthquake)
        {
            float num2 = DepartmentOfTheInterior.GetBesiegingPower(this.City, true);
            num2 += DepartmentOfTheInterior.GetCityPointEarthquakeDamage(this.City);
            this.DefenseTendency.Text = "(" + GuiFormater.FormatGui(-num2, false, true, true, 1) + ")";
        }
        else if (propertyValue < propertyValue2)
        {
            this.DefenseTendency.Text = "(" + GuiFormater.FormatGui(propertyValue3, false, true, true, 1) + ")";
        }
        else
        {
            this.DefenseTendency.Text = string.Empty;
        }
        if (flag2)
        {
            Construction construction2 = null;
            if (this.ConstructionQueue != null)
            {
                construction2 = this.ConstructionQueue.Peek();
            }
            if (this.City.IsInfected && construction2 == null)
            {
                this.PlayerSpecificGroup.Visible = false;
            }
            if (construction2 != null)
            {
                IImageFeatureProvider imageFeatureProvider = construction2.ConstructibleElement as IImageFeatureProvider;
                GuiElement            guiElement;
                if (imageFeatureProvider != null)
                {
                    Texture2D image;
                    if (imageFeatureProvider.TryGetTextureFromIcon(global::GuiPanel.IconSize.Small, out image))
                    {
                        this.ConstructionImage.Image = image;
                    }
                }
                else if (this.guiPanelHelper.TryGetGuiElement(construction2.ConstructibleElement.Name, out guiElement))
                {
                    Texture2D image2;
                    if (this.guiPanelHelper.TryGetTextureFromIcon(guiElement, global::GuiPanel.IconSize.Small, out image2))
                    {
                        this.ConstructionImage.Image = image2;
                    }
                }
                else
                {
                    this.ConstructionImage.Image = null;
                }
                CityLabel.emptyList.Clear();
                int   b;
                float num3;
                float num4;
                bool  flag3;
                QueueGuiItem.GetConstructionTurnInfos(this.City, construction2, CityLabel.emptyList, out b, out num3, out num4, out flag3);
                int numberOfTurn = Mathf.Max(1, b);
                this.ConstructionTurns.Text = QueueGuiItem.FormatNumberOfTurns(numberOfTurn);
            }
            else
            {
                this.ConstructionImage.Image = this.NoConstructionTexture;
                this.ConstructionTurns.Text  = "%EmptyConstructionTitle";
            }
        }
        if (this.PanelSpying.Visible && this.playerControllerRepository != null && agency2 != null)
        {
            float value = this.City.GetPropertyValue(SimulationProperties.CityAntiSpy) * 0.01f;
            this.AntiSpyValue.Text                    = GuiFormater.FormatGui(value, true, true, false, 0);
            this.HeroGroup.Visible                    = false;
            this.SpyingEffectsGroup.Visible           = false;
            this.AssignSpyButton.AgeTransform.Visible = false;
            if (this.City.Empire != this.playerControllerRepository.ActivePlayerController.Empire)
            {
                if (infiltrationState != InfiltrationProcessus.InfiltrationState.None)
                {
                    this.HeroGroup.Visible = true;
                    this.HeroCard.Bind(hero, this.playerControllerRepository.ActivePlayerController.Empire as global::Empire, null);
                    this.HeroCard.RefreshContent(false, false);
                    if (this.HeroCard.GuiHero != null)
                    {
                        AgeTooltip ageTooltip = this.HeroCard.HeroPortrait.AgeTransform.AgeTooltip;
                        if (ageTooltip != null)
                        {
                            ageTooltip.Class      = "Unit";
                            ageTooltip.ClientData = this.HeroCard.GuiHero;
                            ageTooltip.Content    = this.HeroCard.GuiHero.Title;
                        }
                    }
                    if (infiltrationState == InfiltrationProcessus.InfiltrationState.Infiltrated)
                    {
                        this.InfiltrationTurnSymbol.AgeTransform.Visible = false;
                        this.InfiltrationTurnValue.AgeTransform.Visible  = false;
                        this.HeroCard.AgeTransform.Alpha = 1f;
                        this.SpyingEffectsGroup.Visible  = true;
                    }
                    else
                    {
                        this.HeroCard.AgeTransform.Alpha = 0.75f;
                        this.InfiltrationTurnSymbol.AgeTransform.Visible = true;
                        this.InfiltrationTurnValue.AgeTransform.Visible  = true;
                        int value2 = DepartmentOfIntelligence.InfiltrationRemainingTurns(hero);
                        this.InfiltrationTurnValue.Text = GuiFormater.FormatGui(value2);
                    }
                }
                else if (!flag)
                {
                    this.AssignSpyButton.AgeTransform.Visible = true;
                    float value3 = 0f;
                    this.failures.Clear();
                    bool flag4 = agency2.CanBeInfiltrate(this.City, out value3, this.failures);
                    bool flag5 = agency2.Empire.GetAgency <DepartmentOfEducation>().Heroes.Count < 1;
                    if (flag5)
                    {
                        flag4 = false;
                    }
                    this.AssignSpyButton.AgeTransform.Enable = flag4;
                    global::IGuiService service = Services.GetService <global::IGuiService>();
                    string str = string.Empty;
                    if (this.failures.Contains(DepartmentOfIntelligence.InfiltrationTargetFailureNotAffordable))
                    {
                        str = "#c52222#";
                    }
                    string arg    = str + GuiFormater.FormatGui(value3, false, true, false, 0) + service.FormatSymbol(this.infiltrationCostResourceName);
                    string format = AgeLocalizer.Instance.LocalizeString("%EspionageLabelAssignSpyTitle");
                    this.AssignTitle.Text = string.Format(format, arg);
                    AgeTooltip ageTooltip2 = this.AssignSpyButton.AgeTransform.AgeTooltip;
                    if (ageTooltip2)
                    {
                        if (flag4)
                        {
                            ageTooltip2.Content = "%EspionageLabelAssignSpyDescription";
                        }
                        else if (flag5)
                        {
                            ageTooltip2.Content = "%EspionageLabelAssignSpyNoHeroesDescription";
                        }
                        else if (this.failures.Contains(DepartmentOfIntelligence.InfiltrationTargetFailureNotVisible))
                        {
                            ageTooltip2.Content = "%EspionageLabelAssignSpyNoVisibilityDescription";
                        }
                        else if (this.failures.Contains(DepartmentOfIntelligence.InfiltrationTargetFailureSiege))
                        {
                            ageTooltip2.Content = "%EspionageLabelAssignSpyUnderSiegeDescription";
                        }
                        else if (this.failures.Contains(DepartmentOfIntelligence.InfiltrationTargetFailureNotAffordable))
                        {
                            ageTooltip2.Content = "%EspionageLabelAssignSpyNotAffordableDescription";
                        }
                        else if (this.failures.Contains(DepartmentOfIntelligence.InfiltrationTargetFailureAlreadyInfiltrated))
                        {
                            ageTooltip2.Content = "%EspionageLabelAssignSpyAlreadyInfiltratedDescription";
                        }
                        else if (this.failures.Contains(DepartmentOfIntelligence.InfiltrationTargetFailureCityInfected))
                        {
                            ageTooltip2.Content = "%EspionageLabelAssignSpyCityInfectedDescription";
                        }
                    }
                }
            }
        }
        bool         flag6 = false;
        List <Kaiju> list  = new List <Kaiju>();

        foreach (RegionalEffect regionalEffect in this.city.GetRegionalEffects())
        {
            IRegionalEffectsProviderGameEntity regionalEffectsProviderGameEntity = null;
            if (this.regionalEffectsService.TryGetEffectOwner(regionalEffect.GUID, out regionalEffectsProviderGameEntity) && regionalEffectsProviderGameEntity.GetRegionalEffectsProviderContext().SimulationObject.Tags.Contains("ClassKaiju"))
            {
                flag6 = true;
                if (regionalEffectsProviderGameEntity is Kaiju)
                {
                    Kaiju item = regionalEffectsProviderGameEntity as Kaiju;
                    if (!list.Contains(item))
                    {
                        list.Add(item);
                    }
                }
            }
        }
        if (flag6)
        {
            AgeTransform ageTransform = this.KaijuIcon.AgeTransform;
            ageTransform.Visible = true;
            ageTransform.Enable  = true;
            this.PopulationGroup.PercentBottom = 100f - (ageTransform.Height + ageTransform.PixelMarginBottom) / ageTransform.GetParent().Height * 100f;
            KaijuInfluenceInCityTooltipData clientData = new KaijuInfluenceInCityTooltipData(this.City, list);
            this.KaijuIcon.AgeTransform.AgeTooltip.Content    = "%CityKaijuAffectedDescription";
            this.KaijuIcon.AgeTransform.AgeTooltip.Class      = "Kaijus";
            this.KaijuIcon.AgeTransform.AgeTooltip.ClientData = clientData;
            return;
        }
        this.KaijuIcon.AgeTransform.Visible = false;
        this.KaijuIcon.AgeTransform.Enable  = false;
        this.PopulationGroup.PercentBottom  = 100f;
    }