Exemplo n.º 1
0
 public void ValidateUnitBodyChoice(UnitBodyDefinition unitBody)
 {
     base.GuiService.GetGuiPanel <UnitDesignModalPanel>().CreateMode = true;
     base.GuiService.GetGuiPanel <UnitDesignModalPanel>().Show(new object[]
     {
         unitBody
     });
 }
Exemplo n.º 2
0
 public bool SetUnitBodyAsPioritary(UnitBodyDefinition unitBodyDefinition)
 {
     this.PriorityUnitBodyForReinforcement = unitBodyDefinition;
     this.ReportInstruction(new BattleReinforcementPriorityChangeInstruction(this.ContenderGUID)
     {
         PriorityUnitBodyDefinitionReference = ((unitBodyDefinition == null) ? StaticString.Empty : unitBodyDefinition.Name)
     });
     return(true);
 }
Exemplo n.º 3
0
    public void RefreshContent(global::Empire empire, UnitBodyDefinition unitBody, GameObject client, AgeTransform anchor)
    {
        this.Reset();
        IGuiPanelHelper guiPanelHelper = Services.GetService <global::IGuiService>().GuiPanelHelper;

        Diagnostics.Assert(guiPanelHelper != null, "Unable to access GuiPanelHelper");
        this.UnitBody = unitBody;
        this.GenerateUnit(empire);
        if (this.tooltip != null)
        {
            this.tooltip.Anchor     = anchor;
            this.tooltip.Class      = this.UnitBody.TooltipClass;
            this.tooltip.ClientData = this.temporaryUnit;
            this.tooltip.Content    = this.UnitBody.Name;
        }
        GuiElement guiElement;

        if (guiPanelHelper.TryGetGuiElement(this.UnitBody.Name, out guiElement))
        {
            AgeUtils.TruncateString(AgeLocalizer.Instance.LocalizeString(guiElement.Title), this.UnitName, out this.temp, '.');
            this.UnitName.Text = this.temp;
            Texture2D image;
            if (guiPanelHelper.TryGetTextureFromIcon(guiElement, global::GuiPanel.IconSize.Small, out image))
            {
                this.UnitPortrait.Image = image;
            }
        }
        else
        {
            this.UnitName.Text      = string.Empty;
            this.UnitPortrait.Image = null;
        }
        if (this.PrivateerGroup != null)
        {
            this.PrivateerGroup.Visible = this.IsMercenary(empire, this.GuiUnit);
        }
        this.UnitToggle.State             = false;
        this.UnitToggle.OnSwitchMethod    = "OnUnitBodyToggle";
        this.UnitToggle.OnSwitchObject    = client;
        this.LifeGauge.AgeTransform.Alpha = 0f;
    }
Exemplo n.º 4
0
    protected override void CreateLocalNeeds(StaticString context, StaticString pass)
    {
        base.CreateLocalNeeds(context, pass);
        float propertyValue = this.Empire.GetPropertyValue(SimulationProperties.MinorFactionSlotCount);
        int   count         = this.departmentOfTheInterior.AssimilatedFactions.Count;
        bool  flag          = false;

        if (propertyValue <= (float)count)
        {
            flag = true;
            if (this.game.Turn - 14 <= this.lastAssimilationTurn)
            {
                return;
            }
        }
        List <MinorFaction> list = new List <MinorFaction>();

        this.departmentOfTheInterior.GetAssimilableMinorFactions(ref list);
        if (list.Count == 0)
        {
            return;
        }
        this.UpdateUnitCategories();
        this.FactionToDeassimilate = string.Empty;
        int   num  = -1;
        float num2 = 0f;

        UnitBodyDefinition[] values = this.unitBodyDefinitionDatabase.GetValues();
        int   index = -1;
        float num3  = float.MaxValue;

        for (int i = 0; i < list.Count; i++)
        {
            Faction faction = list[i];
            bool    flag2   = this.departmentOfTheInterior.IsAssimilated(faction);
            float   num4;
            if (this.MinorfactionScores.TryGetValue(faction.Name, out num4))
            {
                float num5 = (float)this.departmentOfTheInterior.GetNumberOfOwnedMinorFactionVillages(list[i], true);
                float num6 = (float)this.departmentOfTheInterior.GetNumberOfOwnedMinorFactionVillages(list[i], false) - num5;
                float num7 = num4 * (num5 + num6 * 0.5f);
                if (flag2)
                {
                    num7 *= 1.7f;
                }
                float num8 = 0f;
                using (IEnumerator <UnitBodyDefinition> enumerator = (from match in values
                                                                      where match.Affinity != null && match.Affinity.Name == faction.Affinity.Name
                                                                      select match).GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        UnitBodyDefinition unitBodyDefinition = enumerator.Current;
                        if (flag2)
                        {
                            int num9 = 0;
                            Func <Construction, bool> < > 9__2;
                            foreach (City gameEntity in this.departmentOfTheInterior.Cities)
                            {
                                ConstructionQueue constructionQueue = this.departmentOfIndustry.GetConstructionQueue(gameEntity);
                                if (constructionQueue != null)
                                {
                                    IEnumerable <Construction> pendingConstructions = constructionQueue.PendingConstructions;
                                    Func <Construction, bool>  selector;
                                    if ((selector = < > 9__2) == null)
                                    {
                                        selector = (< > 9__2 = ((Construction c) => c.ConstructibleElement is UnitDesign && (c.ConstructibleElement as UnitDesign).UnitBodyDefinition == unitBodyDefinition && (c.GetSpecificConstructionStock(DepartmentOfTheTreasury.Resources.Production) > 0f || c.IsBuyout)));
                                    }
                                    int num10 = pendingConstructions.Count(selector);
                                    num9 += num10;
                                }
                            }
                            if (this.departmentOfTheInterior.Cities.Count < num9 * 4)
                            {
                                goto IL_2E5;
                            }
                        }
                        float num11 = this.intelligenceAIHelper.GetAIStrengthBelief(base.AIEntity.Empire.Index, unitBodyDefinition.Name);
                        if (this.UnitTypes[unitBodyDefinition.SubCategory] == 0 || (flag2 && this.UnitTypes[unitBodyDefinition.SubCategory] == 1))
                        {
                            num11 = AILayer.Boost(num11, 0.8f);
                        }
                        num8 = Mathf.Max(num8, num11);
                    }
                }
                float num12 = num7 * num8;
                if (!flag2 && (num < 0 || num12 > num2))
                {
                    num  = i;
                    num2 = num12;
                }
                if (flag2 && num12 < num3)
                {
                    index = i;
                    num3  = num12;
                }
            }
            IL_2E5 :;
        }
        if (num < 0 || num2 < 0.7f)
        {
            return;
        }
        if (flag)
        {
            if (num2 <= num3)
            {
                return;
            }
            this.FactionToDeassimilate = list[index].Name;
        }
        Faction faction2 = list[num];
        EvaluableMessage_Assimilation evaluableMessage_Assimilation = base.AIEntity.AIPlayer.Blackboard.FindFirst <EvaluableMessage_Assimilation>(BlackboardLayerID.Empire, (EvaluableMessage_Assimilation match) => match.EvaluationState == EvaluableMessage.EvaluableMessageState.Pending || match.EvaluationState == EvaluableMessage.EvaluableMessageState.Validate);

        if (evaluableMessage_Assimilation == null)
        {
            evaluableMessage_Assimilation = new EvaluableMessage_Assimilation(AILayer_AccountManager.AssimilationAccountName);
            base.AIEntity.AIPlayer.Blackboard.AddMessage(evaluableMessage_Assimilation);
        }
        evaluableMessage_Assimilation.Refresh(1f, 1f, faction2.Name);
    }
Exemplo n.º 5
0
    public override void RefreshContent()
    {
        base.RefreshContent();
        this.FactionsTable.Height = 0f;
        this.FactionsTable.ReserveChildren(this.guiFactions.Count, this.FactionCardPrefab, "Item");
        this.FactionsTable.RefreshChildrenIList <GuiFaction>(this.guiFactions, this.setupGuiFactionDelegate, true, false);
        this.FactionsTable.ArrangeChildren();
        this.FactionsTableScrollView.OnPositionRecomputed();
        this.ValidateButton.AgeTransform.Enable             = false;
        this.ValidateButton.AgeTransform.AgeTooltip.Content = null;
        this.DestroyFactionButton.AgeTransform.Enable       = false;
        this.ModifyFactionButton.AgeTransform.Enable        = false;
        this.CreateFactionButton.AgeTransform.Enable        = true;
        List <FactionCard> children = this.FactionsTable.GetChildren <FactionCard>(true);

        for (int i = 0; i < children.Count; i++)
        {
            children[i].SelectionToggle.State = (this.SelectedGuiFaction != null && children[i].GuiFaction.Faction.Name == this.SelectedGuiFaction.Faction.Name);
        }
        if (this.SelectedGuiFaction == null)
        {
            this.FactionTitle.AgeTransform.Visible                 = false;
            this.FactionTitleUnderline.AgeTransform.Visible        = false;
            this.FactionAuthor.AgeTransform.Visible                = false;
            this.FactionMoodImage.AgeTransform.Visible             = false;
            this.FactionDescriptionScrollView.AgeTransform.Visible = false;
            this.FactionTraitsScrollView.AgeTransform.Visible      = false;
            this.UnitBodyGroup.Visible = false;
            return;
        }
        this.ValidateButton.AgeTransform.Enable = true;
        if (this.SelectedGuiFaction.IsCustom)
        {
            bool enable = GuiFaction.IsValidCustomFaction(this.SelectedGuiFaction.Faction, null);
            this.ValidateButton.AgeTransform.Enable = enable;
        }
        IDownloadableContentService service = Services.GetService <IDownloadableContentService>();

        if (service != null)
        {
            bool flag;
            if (service.TryCheckAgainstRestrictions(DownloadableContentRestrictionCategory.LobbyFaction, this.SelectedGuiFaction.Faction.Name, out flag) && !flag)
            {
                this.ValidateButton.AgeTransform.Enable             = false;
                this.ValidateButton.AgeTransform.AgeTooltip.Content = "%RestrictedDownloadableContentTitle";
            }
            if (this.SelectedGuiFaction.Faction.Affinity != null && service.TryCheckAgainstRestrictions(DownloadableContentRestrictionCategory.LobbyFactionAffinity, this.SelectedGuiFaction.Faction.Affinity.Name, out flag) && !flag)
            {
                this.ValidateButton.AgeTransform.Enable             = false;
                this.ValidateButton.AgeTransform.AgeTooltip.Content = "%RestrictedDownloadableContentTitle";
            }
            if (this.ValidateButton.AgeTransform.Enable)
            {
                foreach (FactionTrait factionTrait in Faction.EnumerableTraits(this.SelectedGuiFaction.Faction))
                {
                    if (!service.TryCheckAgainstRestrictions(DownloadableContentRestrictionCategory.LobbyFactionTrait, factionTrait.Name, out flag) || !flag)
                    {
                        this.ValidateButton.AgeTransform.Enable             = false;
                        this.ValidateButton.AgeTransform.AgeTooltip.Content = "%RestrictedDownloadableContentTitle";
                        break;
                    }
                }
            }
        }
        this.DestroyFactionButton.AgeTransform.Enable          = this.SelectedGuiFaction.IsCustom;
        this.ModifyFactionButton.AgeTransform.Enable           = this.SelectedGuiFaction.IsCustom;
        this.FactionDescriptionScrollView.AgeTransform.Visible = true;
        this.FactionTitle.AgeTransform.Visible          = true;
        this.FactionTitleUnderline.AgeTransform.Visible = true;
        this.FactionAuthor.AgeTransform.Visible         = true;
        this.FactionTitle.Text  = this.SelectedGuiFaction.Title;
        this.FactionAuthor.Text = string.Empty;
        if (this.SelectedGuiFaction.Faction.Author != "AMPLITUDE Studios")
        {
            this.FactionAuthor.Text = this.SelectedGuiFaction.Faction.Author;
        }
        if (this.diplomaticNegotiationViewport != null)
        {
            this.FactionMoodImage.AgeTransform.Visible = false;
            XmlNamedReference xmlNamedReference = (!this.SelectedGuiFaction.IsRandom) ? this.SelectedGuiFaction.Faction.AffinityMapping : new XmlNamedReference(GuiFaction.FactionRandomMappingName);
            bool flag2 = this.diplomaticNegotiationViewport.AffinityMapping == null || this.diplomaticNegotiationViewport.AffinityMapping != xmlNamedReference;
            this.diplomaticNegotiationViewport.SetApparence(xmlNamedReference);
            if (flag2)
            {
                this.diplomaticNegotiationViewport.TriggerAlternativeIdle(0.1f);
            }
        }
        else
        {
            this.FactionMoodImage.AgeTransform.Visible = true;
            this.FactionMoodImage.Image = this.SelectedGuiFaction.GetImageTexture(GuiPanel.IconSize.NegotiationLarge, false);
            this.FactionDescription.AgeTransform.Height = 0f;
        }
        if (this.SelectedGuiFaction.IsRandom || this.SelectedGuiFaction.Name == "FactionELCPSpectator")
        {
            this.FactionDescription.Text = this.SelectedGuiFaction.Description;
        }
        else
        {
            this.FactionDescription.Text = AgeLocalizer.Instance.LocalizeString("%" + this.SelectedGuiFaction.Faction.Affinity.Name + "VictoryType") + "\n \n" + AgeLocalizer.Instance.LocalizeString(this.SelectedGuiFaction.Description);
        }
        this.FactionDescriptionScrollView.ResetUp();
        if (!this.SelectedGuiFaction.Faction.IsRandom)
        {
            this.FactionTraitsScrollView.AgeTransform.Visible = true;
            this.UnitBodyGroup.Visible           = true;
            this.FactionTraitsContainers.Visible = true;
            List <GuiFactionTrait> list = (from trait in Faction.EnumerableTraits(this.SelectedGuiFaction.Faction)
                                           where !trait.IsHidden && !trait.IsAffinityRelated
                                           select new GuiFactionTrait(trait)).ToList <GuiFactionTrait>();
            list.Sort();
            this.FactionTraitsTable.Height = 0f;
            this.FactionTraitsTable.ReserveChildren(list.Count, this.FactionTraitPrefab, "Item");
            this.FactionTraitsTable.RefreshChildrenIList <GuiFactionTrait>(list, this.setupGuiFactionTraitDelegate, true, false);
            this.FactionTraitsTable.ArrangeChildren();
            this.FactionTraitsScrollView.ResetUp();
            this.factionUnitBodies.Clear();
            for (int j = 0; j < this.unitBodyDefinitions.Count; j++)
            {
                UnitBodyDefinition unitBodyDefinition = this.unitBodyDefinitions[j];
                if (!unitBodyDefinition.Tags.Contains("Hidden"))
                {
                    SimulationDescriptorReference[] simulationDescriptorReferences = unitBodyDefinition.SimulationDescriptorReferences;
                    for (int k = 0; k < simulationDescriptorReferences.Length; k++)
                    {
                        if (simulationDescriptorReferences[k].Name == this.SelectedGuiFaction.Faction.Affinity.Name)
                        {
                            this.factionUnitBodies.Add(unitBodyDefinition);
                        }
                    }
                }
            }
            if (this.currentBody >= this.factionUnitBodies.Count)
            {
                this.currentBody = 0;
            }
            if (this.currentBody >= 0 && this.currentBody < this.factionUnitBodies.Count)
            {
                this.UnitBodyCard.RefreshContent(this.factionUnitBodies[this.currentBody]);
            }
            this.RefreshCurrentBody();
            return;
        }
        this.FactionTraitsScrollView.AgeTransform.Visible = false;
        this.UnitBodyGroup.Visible           = false;
        this.FactionTraitsContainers.Visible = false;
    }
Exemplo n.º 6
0
 private void SetupCurrentBodyBar(AgeTransform tableItem, UnitBodyDefinition unused, int index)
 {
     tableItem.AgePrimitive.TintColor = ((index != this.currentBody) ? this.CurrentBodyColorBase : this.CurrentBodyColorSelected);
     tableItem.Width = this.CurrentBodyGroup.Width / (float)this.factionUnitBodies.Count - this.CurrentBodyGroup.HorizontalSpacing;
 }