public Task <CreateOfferResponseDto> Handle(CreateOfferRequestDto request, CancellationToken cancellationToken) { //TODO: add request validtion var calculatePriceRequest = new CalculatePriceRequestDto() { PolicyHolderAge = AgeUtils.CalculateAgeFromPesel(request.PolicyHolder.Pesel), PolicyStartDate = request.PolicyFrom, ProductCode = request.ProductCode, SelectedCovers = request.SelectedCovers }; var calculatePriceResponse = pricingApiFacade.CalculatePrice(calculatePriceRequest); var offer = new Offer(request, calculatePriceResponse); dbContext.Offer.Add(offer); dbContext.SaveChanges(); var response = new CreateOfferResponseDto() { OfferNumber = offer.OfferNumber, OfferValidityEnd = offer.ValidTo, TotalPrice = offer.TotalPrice }; return(Task.FromResult(response)); }
public static bool HexaKeyToColor(string hexaKey, out Color color) { bool result = true; color = Color.white; bool flag = true; for (int i = 1; i < 7; i++) { if (AgeUtils.ValidHex.IndexOf(hexaKey[i]) < 0) { flag = false; break; } } if (flag) { color.r = (AgeUtils.ComputeHexa(hexaKey[1]) * 16f + AgeUtils.ComputeHexa(hexaKey[2])) / 255f; color.g = (AgeUtils.ComputeHexa(hexaKey[3]) * 16f + AgeUtils.ComputeHexa(hexaKey[4])) / 255f; color.b = (AgeUtils.ComputeHexa(hexaKey[5]) * 16f + AgeUtils.ComputeHexa(hexaKey[6])) / 255f; } else { result = false; } return(result); }
private void WriteFullDescription() { this.QuestDescriptionScrollView.ResetUp(); if (this.questGuiElement == null) { this.QuestDescription.Text = this.Quest.QuestDefinition.Name; return; } if (this.QuestDescription.Text != this.questGuiElement.Description) { this.QuestDescription.AgeTransform.Height = 0f; this.QuestDescription.Text = QuestStepItem.ComputeLocalizedQuestText(this.questGuiElement.Description, this.Quest.LocalizationVariables); if (NotificationPanelBase.FirstOpening) { this.temp.Length = 0; AgeUtils.CleanLine(this.QuestDescription.Text, ref this.temp); AgeModifierTypewriter component = this.QuestDescription.GetComponent <AgeModifierTypewriter>(); component.Duration = 0.02f * (float)this.temp.Length; component.StartAnimation(); } else { AgeModifierTypewriter component2 = this.QuestDescription.GetComponent <AgeModifierTypewriter>(); component2.Reset(); this.QuestDescription.CurrentLine = -1; this.QuestDescription.CurrentCharInLine = -1; } } }
public static string FormatInstantCost(Empire empire, float cost, StaticString resourceName, bool monochromatic = false, int decimals = 1) { DepartmentOfTheTreasury agency = empire.GetAgency <DepartmentOfTheTreasury>(); float num; if (!agency.TryGetResourceStockValue(empire.SimulationObject, resourceName, out num, false)) { Diagnostics.Log("Can't get resource stock value {0} on simulation object {1}.", new object[] { resourceName, empire.SimulationObject.Name }); } StringBuilder stringBuilder = new StringBuilder(); bool flag = false; if (!monochromatic && num < cost) { AgeUtils.ColorToHexaKey(Color.red, ref stringBuilder, false); flag = true; } stringBuilder.Append(GuiFormater.FormatGui(cost, false, decimals == 0, false, decimals)); if (!monochromatic && flag) { stringBuilder.Append("#REVERT#"); } stringBuilder.Append(" "); stringBuilder.Append(Services.GetService <IGuiService>().FormatSymbol(resourceName)); return(stringBuilder.ToString()); }
public void RefreshContent(City city, CityOptionsPanel.ProductionConstruction constructibleElementDefinition, int index, GameObject client) { IGuiPanelHelper guiPanelHelper = Services.GetService <global::IGuiService>().GuiPanelHelper; Diagnostics.Assert(guiPanelHelper != null, "Unable to access GuiPanelHelper"); UnitDesign unitDesign = constructibleElementDefinition.ConstructibleElement as UnitDesign; GuiElement guiElement2; if (unitDesign != null) { this.ConstructibleName.Text = GuiUnitDesign.GetTruncatedTitle(unitDesign, this.ConstructibleName); this.ConstructibleImage.Image = null; GuiElement guiElement; Texture2D image; if (guiPanelHelper.TryGetGuiElement(unitDesign.UnitBodyDefinitionReference, out guiElement) && guiPanelHelper.TryGetTextureFromIcon(guiElement, global::GuiPanel.IconSize.Small, out image)) { this.ConstructibleImage.Image = image; } } else if (guiPanelHelper.TryGetGuiElement(constructibleElementDefinition.ConstructibleElement.Name, out guiElement2)) { AgeUtils.TruncateString(AgeLocalizer.Instance.LocalizeString(guiElement2.Title), this.ConstructibleName, out this.temp, '.'); this.ConstructibleName.Text = this.temp; Texture2D image2; if (guiPanelHelper.TryGetTextureFromIcon(guiElement2, global::GuiPanel.IconSize.Small, out image2)) { this.ConstructibleImage.Image = image2; } else { this.ConstructibleImage.Image = null; } } else { this.ConstructibleName.Text = string.Empty; this.ConstructibleImage.Image = null; } if (this.AgeTransform.AgeTooltip != null) { this.AgeTransform.AgeTooltip.Class = constructibleElementDefinition.ConstructibleElement.TooltipClass; this.AgeTransform.AgeTooltip.Content = constructibleElementDefinition.ConstructibleElement.Name; if (constructibleElementDefinition.ConstructibleElement is BoosterGeneratorDefinition) { this.AgeTransform.AgeTooltip.ClientData = new BoosterGeneratorTooltipData(city.Empire, city, constructibleElementDefinition.ConstructibleElement); } else { this.AgeTransform.AgeTooltip.ClientData = new ConstructibleTooltipData(city.Empire, city, constructibleElementDefinition.ConstructibleElement); } } this.ConstructibleButton.OnActivateMethod = "OnOptionSelect"; this.ConstructibleButton.OnActivateObject = client; this.ConstructibleButton.OnActivateDataObject = constructibleElementDefinition.ConstructibleElement; this.ConstructibleButton.OnMiddleClickMethod = "OnRightClick"; this.ConstructibleButton.OnMiddleClickObject = client; this.ConstructibleButton.OnRightClickMethod = "OnRightClick"; this.ConstructibleButton.OnRightClickObject = client; this.AgeTransform.Enable = (constructibleElementDefinition.Flags.Length == 0); }
private void RefreshOtherEmpiresDropList() { global::Game game = base.Game as global::Game; Diagnostics.Assert(game != null); List <DiplomaticRelation> list = (from relation in this.DepartmentOfForeignAffairs.DiplomaticRelations where relation.OwnerEmpireIndex == this.Empire.Index select relation).ToList <DiplomaticRelation>(); list.RemoveAll((DiplomaticRelation diplomaticRelation) => diplomaticRelation.State == null || diplomaticRelation.State.Name == DiplomaticRelationState.Names.Unknown || diplomaticRelation.State.Name == DiplomaticRelationState.Names.Dead); this.otherEmpires = (from relation in list select game.Empires[relation.OtherEmpireIndex]).ToArray <global::Empire>(); List <string> list2 = new List <string>(); List <string> list3 = new List <string>(); for (int i = 0; i < this.otherEmpires.Length; i++) { string text; AgeUtils.ColorToHexaKey(this.otherEmpires[i].Color, out text); string text2 = string.Concat(new string[] { text, this.otherEmpires[i].LocalizedName, " - ", this.otherEmpires[i].Faction.LocalizedName, "#REVERT#" }); list2.Add(text2); list3.Add((!this.otherEmpires[i].IsControlledByAI) ? (text2 + "\n" + AgeLocalizer.Instance.LocalizeString("%CompetitorEmpireTypeHumanDescription")) : (text2 + "\n" + AgeLocalizer.Instance.LocalizeString("%CompetitorEmpireTypeComputerDescription"))); } this.TheirEmpireNameDropList.ItemTable = list2.ToArray(); this.TheirEmpireNameDropList.TooltipTable = list3.ToArray(); }
public float ComputeTextWidth(string text, bool forcedCaps = false, bool makeClean = false) { float num = 0f; this.CreateCharMap(false); if (makeClean) { AgeUtils.CleanLine(text, ref AgePrimitiveLabel.CleanLine); text = AgePrimitiveLabel.CleanLine.ToString(); } for (int i = 0; i < text.Length; i++) { char charCode = text[i]; if (forcedCaps) { charCode = AgeFont.RaiseChar(charCode); } AgeFont.Character character = null; if (this.TryGetCharacter(charCode, this.fontSize, out character)) { num += character.Advance; if (this.HasKerningInfo && i + 1 < text.Length) { char c = text[i + 1]; if (forcedCaps && c >= 'a' && c <= 'z') { c = (char)((int)c + -32); } num += this.GetKerningOffset(text[i], c); } } } return(num); }
public static string Colorize(Empire empire, string name) { string str; AgeUtils.ColorToHexaKey(empire.Color, out str); return(str + name + "#REVERT#"); }
public static void TruncateString(string src, int maxChars, out string dest, char truncateChar) { dest = src; AgeUtils.CleanLine(dest, ref AgeUtils.line); while (AgeUtils.line.Length > maxChars && AgeUtils.line.Length > 1) { dest = dest.Substring(0, dest.Length - 2) + truncateChar; AgeUtils.CleanLine(dest, ref AgeUtils.line); } }
public static void TruncateString(string src, AgePrimitiveLabel label, out string dest, char truncateChar) { float width = label.AgeTransform.Width; if (width == 0f) { width = label.AgeTransform.Width; } AgeUtils.TruncateString(src, label.Font, width, out dest, truncateChar, label.ForceCaps); }
public static void TruncateString(string src, AgeFont font, float maxWidth, out string dest, char truncateChar, bool forcedCaps = false) { dest = src; AgeUtils.CleanLine(dest, ref AgeUtils.line); float num = font.ComputeTextWidth(AgeUtils.line.ToString(), forcedCaps, false); while (num > maxWidth && AgeUtils.line.Length > 1) { dest = dest.Substring(0, dest.Length - 2) + truncateChar; AgeUtils.CleanLine(dest, ref AgeUtils.line); num = font.ComputeTextWidth(AgeUtils.line.ToString(), forcedCaps, false); } }
public static void TruncateStringWithSuffix(string src, string suffix, AgePrimitiveLabel label, float maxWidth, out string dest, char truncateChar, bool forcedCaps = false) { dest = src; AgeUtils.CleanLine(dest + suffix, ref AgeUtils.line); float num = label.Font.ComputeTextWidth(AgeUtils.line.ToString(), forcedCaps, false); while (num > maxWidth && AgeUtils.line.Length > 1) { dest = dest.Substring(0, dest.Length - 2) + truncateChar; AgeUtils.CleanLine(dest + suffix, ref AgeUtils.line); num = label.Font.ComputeTextWidth(AgeUtils.line.ToString(), forcedCaps, false); } dest += suffix; }
private void UpdateButtonsAvailability() { if (this.DepartmentOfScience.HaveResearchedAtLeastOneTradeTechnology() || base.Empire.SimulationObject.Tags.Contains(global::Empire.TagEmpireEliminated)) { this.MarketplaceToggle.AgeTransform.Enable = true; this.MarketplaceToggle.AgeTransform.AgeTooltip.Content = AgeLocalizer.Instance.LocalizeString("%MarketplaceScreenShortcutDescription"); } else { this.MarketplaceToggle.AgeTransform.Enable = false; string text = string.Empty; IGuiPanelHelper guiPanelHelper = Services.GetService <global::IGuiService>().GuiPanelHelper; Diagnostics.Assert(guiPanelHelper != null, "Unable to access GuiPanelHelper"); for (int i = 1; i < this.DepartmentOfScience.TechnologiesToUnlockMarketplace.Length; i++) { GuiElement guiElement; if (guiPanelHelper.TryGetGuiElement(this.DepartmentOfScience.TechnologiesToUnlockMarketplace[i], out guiElement)) { text = text + "\n - " + AgeLocalizer.Instance.LocalizeString(guiElement.Title); } } this.MarketplaceToggle.AgeTransform.AgeTooltip.Content = string.Format(AgeLocalizer.Instance.LocalizeString("%MarketplaceScreenShortcutDisabledDescription"), text); } bool isActivated = TutorialManager.IsActivated; this.EmpireToggle.AgeTransform.Enable = (!isActivated || this.DepartmentOfScience.GetTechnologyState("TechnologyDefinitionTutorialUnlockEmpire") == DepartmentOfScience.ConstructibleElement.State.Researched); this.ResearchToggle.AgeTransform.Enable = (!isActivated || this.DepartmentOfScience.GetTechnologyState("TechnologyDefinitionTutorialUnlockResearch") == DepartmentOfScience.ConstructibleElement.State.Researched); this.QuestToggle.AgeTransform.Enable = (!isActivated || this.DepartmentOfScience.GetTechnologyState("TechnologyDefinitionTutorialUnlockQuest") == DepartmentOfScience.ConstructibleElement.State.Researched); this.CityListToggle.AgeTransform.Enable = !isActivated; this.AcademyToggle.AgeTransform.Enable = (!isActivated || this.DepartmentOfScience.GetTechnologyState("TechnologyDefinitionTutorialUnlockAcademy") == DepartmentOfScience.ConstructibleElement.State.Researched); this.MilitaryToggle.AgeTransform.Enable = (!isActivated || this.DepartmentOfScience.GetTechnologyState("TechnologyDefinitionTutorialUnlockMilitary") == DepartmentOfScience.ConstructibleElement.State.Researched); this.DiplomacyToggle.AgeTransform.Enable = !isActivated; this.EspionageplaceToggle.AgeTransform.Visible = false; IDownloadableContentService service = Services.GetService <IDownloadableContentService>(); if (service != null && service.IsShared(DownloadableContent11.ReadOnlyName)) { this.EspionageplaceToggle.AgeTransform.Visible = true; this.EspionageplaceToggle.AgeTransform.Enable = !isActivated; } if (this.EspionageplaceToggle.AgeTransform.Visible) { this.ControlTable.HorizontalSpacing = this.WideSpacing * AgeUtils.CurrentUpscaleFactor(); return; } this.ControlTable.HorizontalSpacing = this.StandardSpacing * AgeUtils.CurrentUpscaleFactor(); }
private void RefreshForceShiftingButton() { if (this.ForceShiftButton == null || this.Garrison == null || this.Garrison.Empire == null) { return; } this.ForceShiftButton.Visible = false; this.ForceShiftButton.Enable = false; if (this.IsOtherEmpire || !this.interactionsAllowed) { return; } DepartmentOfScience agency = this.Garrison.Empire.GetAgency <DepartmentOfScience>(); if (agency == null || agency.GetTechnologyState("TechnologyDefinitionOrbUnlock17WinterShifters") != DepartmentOfScience.ConstructibleElement.State.Researched) { return; } if (this.selectedUnits.Count > 0) { List <Unit> list = new List <Unit>(this.selectedUnits); list.RemoveAll((Unit match) => !match.IsShifter() || !match.IsInCurrentSeasonForm()); if (list.Count > 0) { ConstructionCost[] unitForceShiftingCost = this.DepartmentOfTheTreasury.GetUnitForceShiftingCost(list); AgeUtils.CleanLine(GuiFormater.FormatCost(this.garrison.Empire, unitForceShiftingCost, false, 1, null), ref this.monochromaticFormat); this.ForceShiftButtonPriceLabel.Text = GuiFormater.FormatCost(this.garrison.Empire, unitForceShiftingCost, false, 0, null); this.ForceShiftButton.Visible = true; if (this.DepartmentOfTheTreasury.CanAfford(unitForceShiftingCost)) { if (!this.garrison.IsInEncounter) { this.ForceShiftButton.AgeTooltip.Content = AgeLocalizer.Instance.LocalizeString("%ForceShiftTabOKFormat").Replace("$Value", this.monochromaticFormat.ToString()); this.ForceShiftButton.Enable = true; } else { this.ForceShiftButton.AgeTooltip.Content = AgeLocalizer.Instance.LocalizeString("%ArmyLockedInBattleDescription"); } } else { this.ForceShiftButton.AgeTooltip.Content = AgeLocalizer.Instance.LocalizeString("%ForceShiftTabCannotAffordDescription") + " : " + this.monochromaticFormat; } } } }
public static string FormatCost(Empire empire, IConstructionCost[] costs, bool monochromatic = false, int decimals = 1, SimulationObject context = null) { DepartmentOfTheTreasury agency = empire.GetAgency <DepartmentOfTheTreasury>(); if (context == null) { context = empire.SimulationObject; } StringBuilder stringBuilder = new StringBuilder(); if (costs != null) { bool flag = false; for (int i = 0; i < costs.Length; i++) { float value = costs[i].GetValue(empire); if (stringBuilder.Length > 0) { stringBuilder.Append(" "); } float num; if (!agency.TryGetResourceStockValue(context, costs[i].ResourceName, out num, false)) { Diagnostics.Log("Can't get resource stock value {0} on simulation object {1}.", new object[] { costs[i].ResourceName, empire.SimulationObject.Name }); } if (!monochromatic && (costs[i].Instant || costs[i].InstantOnCompletion) && num < value) { AgeUtils.ColorToHexaKey(Color.red, ref stringBuilder, false); flag = true; } stringBuilder.Append(GuiFormater.FormatGui(value, false, decimals == 0, false, decimals)); if (!monochromatic && flag) { stringBuilder.Append("#REVERT#"); flag = false; } stringBuilder.Append(" "); stringBuilder.Append(Services.GetService <IGuiService>().FormatSymbol(costs[i].ResourceName)); } } return(stringBuilder.ToString()); }
public static void TruncateStringWithSubst(string srcKey, string match, string subst, AgePrimitiveLabel label, float maxWidth, out string dest, char truncateChar) { dest = subst; AgeLocalizer.Instance.LocalizeString(srcKey, out AgeUtils.lineString); AgeUtils.lineString = AgeUtils.lineString.Replace(match, dest); AgeUtils.CleanLine(AgeUtils.lineString, ref AgeUtils.line); float num = label.Font.ComputeTextWidth(AgeUtils.line.ToString(), label.ForceCaps, false); while (num > maxWidth && dest.Length > 1) { dest = dest.Substring(0, dest.Length - 2) + truncateChar; AgeLocalizer.Instance.LocalizeString(srcKey, out AgeUtils.lineString); AgeUtils.lineString = AgeUtils.lineString.Replace(match, dest); AgeUtils.CleanLine(AgeUtils.lineString, ref AgeUtils.line); num = label.Font.ComputeTextWidth(AgeUtils.line.ToString(), label.ForceCaps, false); } dest = AgeUtils.lineString; }
private bool CanSellUnitsAndExplain() { this.SellButtonPriceLabel.AgeTransform.Visible = false; if (this.IsOtherEmpire || !this.DepartmentOfScience.CanTradeUnits(false)) { return(false); } if (this.selectedUnits.Count == 0) { this.SellButton.AgeTooltip.Content = "%ArmyEmptySelectionDescription"; return(false); } this.SellComputeCandidates(); if (this.salableUnits.Count == 0) { this.SellButton.AgeTooltip.Content = "%SellTabNoCandidateDescription"; return(false); } if (ELCPUtilities.UseELCPUnitSelling && this.Garrison is Army) { IWorldPositionningService service = base.GameService.Game.Services.GetService <IWorldPositionningService>(); Army army = this.Garrison as Army; Region region = service.GetRegion(army.WorldPosition); if (region == null || region.Owner != army.Empire) { this.SellButton.AgeTooltip.Content = "%SellTabNotInOwnRegionDescription"; return(false); } } float num = this.TotalSellPriceOfSalableUnits(); string text = GuiFormater.FormatStock(num, DepartmentOfTheTreasury.Resources.EmpireMoney, 0, true); string formattedLine = GuiFormater.FormatInstantCost(this.Garrison.Empire, num, DepartmentOfTheTreasury.Resources.EmpireMoney, true, 1); this.SellButtonPriceLabel.Text = text; this.SellButtonPriceLabel.AgeTransform.Visible = true; AgeUtils.CleanLine(formattedLine, ref this.monochromaticFormat); if (!this.Garrison.IsInEncounter) { this.SellButton.AgeTooltip.Content = string.Format(AgeLocalizer.Instance.LocalizeString("%SellTabOKDescription"), this.monochromaticFormat); return(true); } this.SellButton.AgeTooltip.Content = AgeLocalizer.Instance.LocalizeString("%ArmyLockedInBattleDescription"); return(false); }
protected void DisplayPrice() { ConstructionCost[] costs = new ConstructionCost[] { new ConstructionCost(DepartmentOfTheTreasury.Resources.EmpireMoney, this.Price, true, false) }; string text = GuiFormater.FormatCost(this.empire, costs, false, 1, null); this.PriceLabel.Text = text; AgeTooltip ageTooltip = this.PriceLabel.AgeTransform.AgeTooltip; if (ageTooltip != null) { string formattedLine = AgeLocalizer.Instance.LocalizeString("%MarketplaceTradablePriceDescription").Replace("$TradableName", this.LocalizedName).Replace("$Price", text); StringBuilder stringBuilder = new StringBuilder(); AgeUtils.CleanLine(formattedLine, ref stringBuilder); ageTooltip.Content = stringBuilder.ToString(); } }
public static string FormatStockCost(Empire empire, ConstructionResourceStock[] stockCosts, bool monochromatic = false, int decimals = 1) { DepartmentOfTheTreasury agency = empire.GetAgency <DepartmentOfTheTreasury>(); StringBuilder stringBuilder = new StringBuilder(); if (stockCosts != null) { bool flag = false; for (int i = 0; i < stockCosts.Length; i++) { float stock = stockCosts[i].Stock; if (stringBuilder.Length > 0) { stringBuilder.Append(" "); } float num; if (!agency.TryGetResourceStockValue(empire.SimulationObject, stockCosts[i].PropertyName, out num, false)) { Diagnostics.Log("Can't get resource stock value {0} on simulation object {1}.", new object[] { stockCosts[i].PropertyName, empire.SimulationObject.Name }); } if (!monochromatic) { AgeUtils.ColorToHexaKey(Color.red, ref stringBuilder, false); flag = true; } stringBuilder.Append(GuiFormater.FormatGui(stock, false, decimals == 0, false, decimals)); if (!monochromatic && flag) { stringBuilder.Append("#REVERT#"); flag = false; } stringBuilder.Append(" "); stringBuilder.Append(Services.GetService <IGuiService>().FormatSymbol(stockCosts[i].PropertyName)); } } return(stringBuilder.ToString()); }
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; }
private bool CanHealUnitsAndExplain() { this.HealButton.Visible = false; if (this.IsOtherEmpire) { return(false); } if (this.selectedUnits.Count > 0) { List <Unit> list = new List <Unit>(this.selectedUnits); list.RemoveAll((Unit match) => !match.CheckUnitAbility(UnitAbility.UnitAbilityInstantHeal, -1)); list.RemoveAll((Unit match) => !match.IsWounded()); if (list.Count > 0) { ConstructionCost[] unitHealCost = this.DepartmentOfTheTreasury.GetUnitHealCost(list); AgeUtils.CleanLine(GuiFormater.FormatCost(this.garrison.Empire, unitHealCost, false, 1, null), ref this.monochromaticFormat); this.HealButtonPriceLabel.Text = GuiFormater.FormatCost(this.garrison.Empire, unitHealCost, false, 0, null); this.HealButton.Visible = true; if (list.Exists((Unit unit) => !unit.HasEnoughActionPointLeft(1))) { this.HealButton.AgeTooltip.Content = AgeLocalizer.Instance.LocalizeString("%HealTabNoActionPointDescription"); } else if (this.DepartmentOfTheTreasury.CanAfford(unitHealCost)) { if (!this.garrison.IsInEncounter) { this.HealButton.AgeTooltip.Content = AgeLocalizer.Instance.LocalizeString("%HealTabOKFormat").Replace("$Value", this.monochromaticFormat.ToString()); return(true); } this.HealButton.AgeTooltip.Content = AgeLocalizer.Instance.LocalizeString("%ArmyLockedInBattleDescription"); } else { this.HealButton.AgeTooltip.Content = AgeLocalizer.Instance.LocalizeString("%HealTabCannotAffordDescription") + " : " + this.monochromaticFormat; } } } return(false); }
public static void CleanLine(string formattedLine, ref StringBuilder cleanLine) { cleanLine.Length = 0; cleanLine.EnsureCapacity(formattedLine.Length); for (int i = 0; i < formattedLine.Length; i++) { if (formattedLine[i] == '#' && i < formattedLine.Length - 8 + 1 && formattedLine[i + 8 - 1] == '#') { i += 7; } else if (formattedLine[i] == '\\') { int num = formattedLine.IndexOf('\\', i + 1); if (num != -1 && num > i + 1) { char c = AgeUtils.ParseCharCode(formattedLine, i, num); if (c > '\0') { cleanLine.Append(c); i += num - i; } else { cleanLine.Append(formattedLine[i]); } } else { cleanLine.Append(formattedLine[i]); } } else { cleanLine.Append(formattedLine[i]); } } }
protected override IEnumerator OnLoad() { yield return(base.OnLoadGame()); base.UseRefreshLoop = true; this.workerTypes = new List <StaticString>(); this.workerTypes.Add(SimulationProperties.FoodPopulation); this.workerTypes.Add(SimulationProperties.IndustryPopulation); this.workerTypes.Add(SimulationProperties.SciencePopulation); this.workerTypes.Add(SimulationProperties.DustPopulation); this.workerTypes.Add(SimulationProperties.CityPointPopulation); this.prodPerPopFIDSTypes = new List <StaticString>(); this.prodPerPopFIDSTypes.Add(SimulationProperties.BaseFoodPerPopulation); this.prodPerPopFIDSTypes.Add(SimulationProperties.BaseIndustryPerPopulation); this.prodPerPopFIDSTypes.Add(SimulationProperties.BaseSciencePerPopulation); this.prodPerPopFIDSTypes.Add(SimulationProperties.BaseDustPerPopulation); this.prodPerPopFIDSTypes.Add(SimulationProperties.BaseCityPointPerPopulation); this.workedFIDSTypes = new List <StaticString>(); this.workedFIDSTypes.Add(SimulationProperties.WorkedFood); this.workedFIDSTypes.Add(SimulationProperties.WorkedIndustry); this.workedFIDSTypes.Add(SimulationProperties.WorkedScience); this.workedFIDSTypes.Add(SimulationProperties.WorkedDust); this.workedFIDSTypes.Add(SimulationProperties.WorkedCityPoint); this.cityTileFIDSTypes = new List <StaticString>(); this.cityTileFIDSTypes.Add(SimulationProperties.DistrictFoodNet); this.cityTileFIDSTypes.Add(SimulationProperties.DistrictIndustryNet); this.cityTileFIDSTypes.Add(SimulationProperties.DistrictScienceNet); this.cityTileFIDSTypes.Add(SimulationProperties.DistrictDustNet); this.cityTileFIDSTypes.Add(SimulationProperties.DistrictCityPointNet); this.totalFIDSTypes = new List <StaticString>(); this.totalFIDSTypes.Add(SimulationProperties.NetCityGrowth); this.totalFIDSTypes.Add(SimulationProperties.NetCityProduction); this.totalFIDSTypes.Add(SimulationProperties.NetCityResearch); this.totalFIDSTypes.Add(SimulationProperties.NetCityMoney); this.totalFIDSTypes.Add(SimulationProperties.NetCityEmpirePoint); for (int i = 0; i < this.prodPerPopFIDSTypes.Count; i++) { GuiElement guiElement; base.GuiService.GuiPanelHelper.TryGetGuiElement(this.prodPerPopFIDSTypes[i], out guiElement); if (guiElement != null) { ExtendedGuiElement extendedGuiElement = (ExtendedGuiElement)guiElement; if (i < this.FidsSymbols.Length && i < this.ProdPerPopFIDSValues.Length && i < this.ModifierFIDSValues.Length && i < this.CityTileFIDSValues.Length && i < this.TotalFIDSValues.Length && extendedGuiElement != null) { Texture2D image; if (base.GuiService.GuiPanelHelper.TryGetTextureFromIcon(guiElement, global::GuiPanel.IconSize.Small, out image)) { this.FidsSymbols[i].Image = image; this.FidsSymbols[i].TintColor = extendedGuiElement.Color; } this.ProdPerPopFIDSValues[i].TintColor = extendedGuiElement.Color; this.CityTileFIDSValues[i].TintColor = extendedGuiElement.Color; this.ModifierFIDSValues[i].TintColor = extendedGuiElement.Color; this.TotalFIDSValues[i].TintColor = extendedGuiElement.Color; } } } if (this.WorkersGroups.Length != 0) { AgeTransform workersTable = this.WorkersGroups[0].WorkersTable; AgeTransform component = this.WorkersGroups[0].WorkerSymbolPrefab.GetComponent <AgeTransform>(); this.childWidth = component.Width * AgeUtils.CurrentUpscaleFactor(); this.childHeight = component.Height * AgeUtils.CurrentUpscaleFactor(); this.workersPerLine = Mathf.RoundToInt((workersTable.Width - workersTable.HorizontalMargin) / (this.childWidth + workersTable.HorizontalSpacing)); } string[] array = new string[this.prodPerPopFIDSTypes.Count]; array[0] = string.Format("{0},{1},{2},!{3}", new object[] { SimulationProperties.CityFood, SimulationProperties.CityGrowth, SimulationProperties.NetCityGrowth, SimulationProperties.CityGrowthUpkeep }); array[1] = string.Format("{0},{1},{2},!{3}", new object[] { SimulationProperties.CityIndustry, SimulationProperties.CityProduction, SimulationProperties.NetCityProduction, SimulationProperties.CityProductionUpkeep }); array[2] = string.Format("{0},{1},{2},!{3}", new object[] { SimulationProperties.CityScience, SimulationProperties.CityResearch, SimulationProperties.NetCityResearch, SimulationProperties.CityResearchUpkeep }); array[3] = string.Format("{0},{1},{2},!{3}", new object[] { SimulationProperties.CityDust, SimulationProperties.CityMoney, SimulationProperties.NetCityMoney, SimulationProperties.TotalCityMoneyUpkeep }); array[4] = string.Format("{0},{1},{2}", SimulationProperties.CityCityPoint, SimulationProperties.CityEmpirePoint, SimulationProperties.NetCityEmpirePoint); string[] array2 = new string[this.prodPerPopFIDSTypes.Count]; array2[0] = string.Format("%ModifierCategory{0}Title", SimulationProperties.CityFood); array2[1] = string.Format("%ModifierCategory{0}Title", SimulationProperties.CityIndustry); array2[2] = string.Format("%ModifierCategory{0}Title", SimulationProperties.CityScience); array2[3] = string.Format("%ModifierCategory{0}Title", SimulationProperties.CityDust); array2[4] = string.Format("%ModifierCategory{0}Title", SimulationProperties.CityCityPoint); string[] array3 = new string[this.prodPerPopFIDSTypes.Count]; array3[0] = string.Format("{0},{1}", SimulationProperties.DistrictFood, SimulationProperties.DistrictFoodNet); array3[1] = string.Format("{0},{1}", SimulationProperties.DistrictIndustry, SimulationProperties.DistrictIndustryNet); array3[2] = string.Format("{0},{1}", SimulationProperties.DistrictScience, SimulationProperties.DistrictScienceNet); array3[3] = string.Format("{0},{1}", SimulationProperties.DistrictDust, SimulationProperties.DistrictDustNet); array3[4] = string.Format("{0},{1}", SimulationProperties.DistrictCityPoint, SimulationProperties.DistrictCityPointNet); int num = 0; while (num < this.prodPerPopFIDSTypes.Count && !(this.ProdPerPopFIDSValues[num].AgeTransform.AgeTooltip == null)) { this.ProdPerPopFIDSValues[num].AgeTransform.AgeTooltip.Class = "FIDS"; this.ProdPerPopFIDSValues[num].AgeTransform.AgeTooltip.Content = this.prodPerPopFIDSTypes[num]; this.ProdPerPopFIDSValues[num].AgeTransform.AgeTooltip.ClientData = new SimulationPropertyTooltipData(this.prodPerPopFIDSTypes[num], this.prodPerPopFIDSTypes[num], this.City); this.CityTileFIDSValues[num].AgeTransform.AgeTooltip.Class = "FIDS"; this.CityTileFIDSValues[num].AgeTransform.AgeTooltip.Content = this.cityTileFIDSTypes[num]; this.CityTileFIDSValues[num].AgeTransform.AgeTooltip.ClientData = new SimulationPropertyTooltipData(this.cityTileFIDSTypes[num], array3[num], this.City); this.ModifierFIDSValues[num].AgeTransform.AgeTooltip.Class = "FIDS"; this.ModifierFIDSValues[num].AgeTransform.AgeTooltip.Content = array2[num]; this.ModifierFIDSValues[num].AgeTransform.AgeTooltip.ClientData = new SimulationPropertyTooltipData(array2[num], array[num], this.City); this.TotalFIDSValues[num].AgeTransform.AgeTooltip.Class = "FIDS"; this.TotalFIDSValues[num].AgeTransform.AgeTooltip.Content = this.totalFIDSTypes[num]; this.TotalFIDSValues[num].AgeTransform.AgeTooltip.ClientData = new SimulationPropertyTooltipData(this.totalFIDSTypes[num], GuiSimulation.Instance.FIMSTooltipTotal[num], this.City); num++; } yield break; }
public override void RefreshContent() { if (this.City == null) { return; } base.RefreshContent(); float num = 0f; WorkersDragPanel guiPanel = base.GuiService.GetGuiPanel <WorkersDragPanel>(); for (int i = 0; i < this.workerTypes.Count; i++) { int num2 = Mathf.FloorToInt(this.City.GetPropertyValue(this.workerTypes[i])); if (guiPanel.DragInProgress && guiPanel.DragMoved && this.workerTypes[i] == guiPanel.StartingWorkerType) { num2 -= guiPanel.NumberOfWorkers; } if (i < this.WorkersGroups.Length) { this.WorkersGroups[i].RefreshContent(this.City, num2, this.workerTypes[i], guiPanel); this.WorkersGroups[i].GetComponent <AgeTransform>().Enable = (this.interactionsAllowed && !this.IsOtherEmpire); } int num3 = num2 / this.workersPerLine; if (num3 * this.workersPerLine != num2) { num3++; } if (num3 < 1) { num3 = 1; } if (i < this.WorkersGroups.Length && this.WorkersGroups[i] != null) { AgeTransform workersTable = this.WorkersGroups[i].WorkersTable; float num4 = workersTable.VerticalMargin + (float)num3 * (this.childHeight + workersTable.VerticalSpacing); if (num4 > num) { num = num4; } } } for (int j = 0; j < this.prodPerPopFIDSTypes.Count; j++) { float num5 = 0f; if (j < this.ProdPerPopFIDSValues.Length) { float propertyValue = this.City.GetPropertyValue(this.prodPerPopFIDSTypes[j]); this.ProdPerPopFIDSValues[j].Text = GuiFormater.FormatGui(propertyValue, false, false, false, 0); } float propertyValue2 = this.City.GetPropertyValue(this.workedFIDSTypes[j]); if (j < this.CityTileFIDSValues.Length) { float propertyValue3 = this.City.GetPropertyValue(this.cityTileFIDSTypes[j]); this.CityTileFIDSValues[j].Text = GuiFormater.FormatGui(propertyValue3, false, false, false, 0); } if (j < this.TotalFIDSValues.Length) { num5 = this.City.GetPropertyValue(this.totalFIDSTypes[j]); if (this.City.SimulationObject.Tags.Contains(City.MimicsCity) && this.TotalFIDSValues[j].AgeTransform.AgeTooltip.ClientData != null && this.TotalFIDSValues[j].AgeTransform.AgeTooltip.ClientData is SimulationPropertyTooltipData) { SimulationPropertyTooltipData simulationPropertyTooltipData = this.TotalFIDSValues[j].AgeTransform.AgeTooltip.ClientData as SimulationPropertyTooltipData; if (simulationPropertyTooltipData.Title == SimulationProperties.NetCityProduction) { num5 = 0f; } else if (simulationPropertyTooltipData.Title == SimulationProperties.NetCityGrowth) { num5 = this.City.GetPropertyValue("AlmostNetCityGrowth"); } } this.TotalFIDSValues[j].Text = GuiFormater.FormatGui(num5, false, false, false, 0); } if (j < this.ModifierFIDSValues.Length) { float num6 = num5 - propertyValue2; if (Mathf.RoundToInt(num6) != 0) { this.ModifierFIDSValues[j].Text = GuiFormater.FormatGui(num6, false, false, true, 0); } else { this.ModifierFIDSValues[j].Text = string.Empty; } } } this.WorkerGroupsTable.Height = num; this.WorkersTitle.Height = num; for (int k = 0; k < this.WorkersGroups.Length; k++) { this.WorkersGroups[k].WorkersTable.Height = num; this.WorkersGroups[k].ActiveHighlight.Height = num; this.WorkersGroups[k].GetComponent <AgeTransform>().Height = num; } base.AgeTransform.Height = this.TopMargin * AgeUtils.CurrentUpscaleFactor() + num + this.WorkerGroupsTable.PixelMarginBottom; bool flag = DepartmentOfTheInterior.CanBuyoutPopulation(this.City); bool flag2 = this.City.Empire.SimulationObject.Tags.Contains(FactionTrait.FactionTraitReplicants1); bool flag3 = this.City.Empire.SimulationObject.Tags.Contains(FactionTrait.FactionTraitMimics2); int rowIndex; Func <WorkersGroup, bool> < > 9__0; int rowIndex2; for (rowIndex = 0; rowIndex < this.FoodColumnCells.Length; rowIndex = rowIndex2 + 1) { bool flag4 = false; if (this.IsOtherEmpire) { IEnumerable <WorkersGroup> workersGroups = this.WorkersGroups; Func <WorkersGroup, bool> predicate; if ((predicate = < > 9__0) == null) { predicate = (< > 9__0 = ((WorkersGroup cell) => cell.GetComponent <AgeTransform>() == this.FoodColumnCells[rowIndex])); } flag4 = workersGroups.Any(predicate); } this.FoodColumnCells[rowIndex].Enable = (!flag && this.interactionsAllowed && !flag4); this.ScienceColumnCells[rowIndex].Enable = (!flag2 && this.interactionsAllowed && !flag4); this.IndustryColumnCells[rowIndex].Enable = (!flag3 && this.interactionsAllowed && !flag4); rowIndex2 = rowIndex; } if (this.BoostersTable == null) { bool highDefinition = AgeUtils.HighDefinition; AgeUtils.HighDefinition = false; this.BoostersTable = base.AgeTransform.InstanciateChild(this.BoostersEnumerator.BoostersTable.transform, "WorkerPanelBoostersTable1"); this.BoostersTable.TableArrangement = false; this.BoostersTable2 = base.AgeTransform.InstanciateChild(this.BoostersEnumerator.BoostersTable.transform, "WorkerPanelBoostersTable2"); this.BoostersTable2.TableArrangement = false; AgeUtils.HighDefinition = highDefinition; } this.stackedBoosters.Clear(); this.stackedBoosters2.Clear(); float num7 = 0f; bool flag5 = false; bool flag6 = false; bool flag7 = false; bool flag8 = false; float num8 = AgeUtils.HighDefinition ? 3f : 2f; if (!this.IsOtherEmpire) { foreach (string text in new List <string> { "BoosterFood", "BoosterCadavers", "BoosterIndustry", "FlamesIndustryBooster", "BoosterScience" }) { BoosterDefinition boosterDefinition2; if (this.database.TryGetValue(text, out boosterDefinition2)) { GuiStackedBooster item = new GuiStackedBooster(boosterDefinition2); this.stackedBoosters.Add(item); if (!this.ParentIsCityListScreen && (text == "BoosterCadavers" || text == "FlamesIndustryBooster")) { this.stackedBoosters2.Add(item); } } } bool flag9 = false; this.vaultBoosters = this.departmentOfEducation.GetVaultItems <BoosterDefinition>(); for (int l = 0; l < this.vaultBoosters.Count; l++) { BoosterDefinition boosterDefinition = this.vaultBoosters[l].Constructible as BoosterDefinition; if (boosterDefinition != null) { flag9 = true; if (boosterDefinition.Name == "BoosterFood") { flag5 = true; } else if (boosterDefinition.Name == "BoosterIndustry") { flag6 = true; } else if (boosterDefinition.Name == "BoosterCadavers") { flag7 = true; } else if (boosterDefinition.Name == "FlamesIndustryBooster") { flag8 = true; } this.stackedBoosters.Find((GuiStackedBooster booster) => booster.BoosterDefinition.RewardType == boosterDefinition.RewardType).AddVaultBooster(this.vaultBoosters[l]); } } if (!flag9) { this.stackedBoosters.Clear(); this.stackedBoosters2.Clear(); } else { num7 = this.FidsGroups[0].Height; if (!this.ParentIsCityListScreen) { if (!flag6) { GuiStackedBooster item2 = this.stackedBoosters.Find((GuiStackedBooster booster) => booster.BoosterDefinition.Name == "BoosterIndustry"); this.stackedBoosters.Remove(item2); } else { GuiStackedBooster item3 = this.stackedBoosters.Find((GuiStackedBooster booster) => booster.BoosterDefinition.Name == "FlamesIndustryBooster"); this.stackedBoosters.Remove(item3); } if (!flag5) { GuiStackedBooster item4 = this.stackedBoosters.Find((GuiStackedBooster booster) => booster.BoosterDefinition.Name == "BoosterFood"); this.stackedBoosters.Remove(item4); } else { GuiStackedBooster item5 = this.stackedBoosters.Find((GuiStackedBooster booster) => booster.BoosterDefinition.Name == "BoosterCadavers"); this.stackedBoosters.Remove(item5); } if (!flag6 && !flag5) { this.stackedBoosters2.Clear(); } } else { if (flag8 && !flag6) { GuiStackedBooster item6 = this.stackedBoosters.Find((GuiStackedBooster booster) => booster.BoosterDefinition.Name == "BoosterIndustry"); this.stackedBoosters.Remove(item6); } else if (!flag8) { GuiStackedBooster item7 = this.stackedBoosters.Find((GuiStackedBooster booster) => booster.BoosterDefinition.Name == "FlamesIndustryBooster"); this.stackedBoosters.Remove(item7); } if (!flag5 && flag7) { GuiStackedBooster item8 = this.stackedBoosters.Find((GuiStackedBooster booster) => booster.BoosterDefinition.Name == "BoosterFood"); this.stackedBoosters.Remove(item8); } else if (!flag7) { GuiStackedBooster item9 = this.stackedBoosters.Find((GuiStackedBooster booster) => booster.BoosterDefinition.Name == "BoosterCadavers"); this.stackedBoosters.Remove(item9); } } } } this.BoostersTable2.ReserveChildren(this.stackedBoosters2.Count, this.BoostersEnumerator.BoosterStockPrefab, "Item2"); this.BoostersTable2.RefreshChildrenIList <GuiStackedBooster>(this.stackedBoosters2, this.refreshDelegate, true, true); this.BoostersTable.ReserveChildren(this.stackedBoosters.Count, this.BoostersEnumerator.BoosterStockPrefab, "Item"); this.BoostersTable.RefreshChildrenIList <GuiStackedBooster>(this.stackedBoosters, this.refreshDelegate, true, true); this.BoostersTable.PixelMarginTop = base.AgeTransform.Height; this.BoostersTable2.PixelMarginTop = base.AgeTransform.Height + this.FidsGroups[0].Height + num8; float num9 = 0f; foreach (BoosterStock boosterStock in this.BoostersTable.GetChildren <BoosterStock>(true)) { float num10 = num8; if (this.ParentIsCityListScreen && ((flag5 && flag7 && (boosterStock.GuiStackedBooster.BoosterDefinition.Name == "BoosterFood" || boosterStock.GuiStackedBooster.BoosterDefinition.Name == "BoosterCadavers")) || (flag6 && flag8 && (boosterStock.GuiStackedBooster.BoosterDefinition.Name == "BoosterIndustry" || boosterStock.GuiStackedBooster.BoosterDefinition.Name == "FlamesIndustryBooster")))) { boosterStock.AgeTransform.Width = this.FidsGroups[0].Width / 2f - 1f; if (boosterStock.GuiStackedBooster.BoosterDefinition.Name == "BoosterFood" || boosterStock.GuiStackedBooster.BoosterDefinition.Name == "BoosterIndustry") { num10 = 2f; } } else { boosterStock.AgeTransform.Width = this.FidsGroups[0].Width; } if (boosterStock.GuiStackedBooster.Quantity == 0 || (flag && (num9 == 0f || boosterStock.GuiStackedBooster.BoosterDefinition.Name == "BoosterCadavers")) || (flag2 && boosterStock.GuiStackedBooster.BoosterDefinition.Name == "BoosterScience")) { boosterStock.AgeTransform.Enable = false; boosterStock.AgeTransform.Visible = false; } else { num7 = boosterStock.AgeTransform.Height; boosterStock.AgeTransform.Enable = this.interactionsAllowed; boosterStock.AgeTransform.Visible = true; boosterStock.QuickActivation = true; boosterStock.Guid = this.City.GUID; boosterStock.QuantityLabel.AgeTransform.AttachTop = true; boosterStock.QuantityLabel.AgeTransform.AttachRight = true; boosterStock.QuantityLabel.AgeTransform.PixelMarginLeft = 0f; boosterStock.QuantityLabel.Alignement = AgeTextAnchor.AscendMiddleRight; if (!this.ParentIsCityListScreen) { boosterStock.IconImage.AgeTransform.PixelMarginLeft = num8 * 2.5f; boosterStock.QuantityLabel.AgeTransform.PixelMarginRight = num8 * 2f; } else { boosterStock.IconImage.AgeTransform.PixelMarginLeft = ((boosterStock.AgeTransform.Width == this.FidsGroups[0].Width) ? (boosterStock.AgeTransform.Width / 3f) : (boosterStock.AgeTransform.Width / 5f)); boosterStock.QuantityLabel.AgeTransform.PixelMarginRight = ((boosterStock.AgeTransform.Width == this.FidsGroups[0].Width) ? (boosterStock.AgeTransform.Width / 3f) : (boosterStock.AgeTransform.Width / 5f)); } } boosterStock.AgeTransform.X = num9; boosterStock.AgeTransform.AttachRight = false; boosterStock.AgeTransform.AttachLeft = true; num9 += boosterStock.AgeTransform.Width + num10; } if (this.BoostersTable2.GetChildren <BoosterStock>(true).Count > 0) { bool flag10 = false; num9 = 0f; foreach (BoosterStock boosterStock2 in this.BoostersTable2.GetChildren <BoosterStock>(true)) { boosterStock2.AgeTransform.Width = this.FidsGroups[0].Width; if (boosterStock2.GuiStackedBooster.Quantity == 0 || (num9 == 0f && !flag5) || (num9 > 0f && !flag6) || (flag && num9 == 0f)) { boosterStock2.AgeTransform.Enable = false; boosterStock2.AgeTransform.Visible = false; } else { flag10 = true; boosterStock2.AgeTransform.Enable = this.interactionsAllowed; boosterStock2.AgeTransform.Visible = true; boosterStock2.QuickActivation = true; boosterStock2.Guid = this.City.GUID; boosterStock2.IconImage.AgeTransform.PixelMarginLeft = num8 * 2.5f; boosterStock2.QuantityLabel.AgeTransform.AttachTop = true; boosterStock2.QuantityLabel.AgeTransform.AttachRight = true; boosterStock2.QuantityLabel.AgeTransform.PixelMarginLeft = 0f; boosterStock2.QuantityLabel.AgeTransform.PixelMarginRight = num8 * 2f; boosterStock2.QuantityLabel.Alignement = AgeTextAnchor.AscendMiddleRight; } boosterStock2.AgeTransform.X = num9; boosterStock2.AgeTransform.AttachRight = false; boosterStock2.AgeTransform.AttachLeft = true; num9 += this.FidsGroups[0].Width + this.BoostersTable2.HorizontalSpacing; } num7 += (flag10 ? (this.FidsGroups[0].Height + num8) : 0f); } base.AgeTransform.Height += num7; this.AgeModifierPosition.EndHeight = base.AgeTransform.Height; foreach (AgeTransform ageTransform in base.AgeTransform.GetChildren()) { if (ageTransform.name.Contains("CityTile") || ageTransform.name.Contains("Total") || ageTransform.name.Contains("Modifiers")) { ageTransform.PixelMarginBottom = this.OriginalMargins[ageTransform.name] * (AgeUtils.HighDefinition ? 1.5f : 1f) + num7; } } }
private void RefreshCurrentResearch() { DepartmentOfScience agency = base.Empire.GetAgency <DepartmentOfScience>(); DepartmentOfTheTreasury agency2 = base.Empire.GetAgency <DepartmentOfTheTreasury>(); Construction construction = agency.ResearchQueue.Peek(); IDownloadableContentService service = Services.GetService <IDownloadableContentService>(); if (service != null && service.IsShared(DownloadableContent11.ReadOnlyName) && base.Empire.SimulationObject.Tags.Contains(FactionTrait.FactionTraitReplicants1)) { this.ResearchBuyoutButton.AgeTransform.Visible = true; this.ResearchBuyoutLabel.AgeTransform.Visible = true; this.CurrentResearchTitle.AgeTransform.Visible = false; this.EmpireResearchPanel.Enable = true; this.EmpireResearchPanel.AgeTooltip.Class = string.Empty; this.EmpireResearchPanel.AgeTooltip.Content = string.Empty; this.EmpireResearchPanel.AgeTooltip.ClientData = null; ConstructibleElement technology = null; if (this.departmentOfScience.ResearchQueue.Peek() != null) { technology = this.departmentOfScience.ResearchQueue.Peek().ConstructibleElement; } float buyOutTechnologyCost = this.departmentOfScience.GetBuyOutTechnologyCost(technology); float num = -buyOutTechnologyCost; string newValue = GuiFormater.FormatInstantCost(base.Empire, buyOutTechnologyCost, DepartmentOfTheTreasury.Resources.EmpireMoney, true, 0); string content; if (construction != null) { this.ResearchBuyoutLabel.AgeTransform.Alpha = 1f; TechnologyDefinition technologyDefinition = construction.ConstructibleElement as TechnologyDefinition; if (technologyDefinition != null) { AgeUtils.TruncateString(AgeLocalizer.Instance.LocalizeString(DepartmentOfScience.GetTechnologyTitle(technologyDefinition)), this.ResearchBuyoutLabel, out this.format, '.'); DepartmentOfScience.BuildTechnologyTooltip(technologyDefinition, base.Empire, this.ResearchBuyoutLabel.AgeTransform.AgeTooltip, MultipleConstructibleTooltipData.TechnologyState.Normal); } if (agency2.IsTransferOfResourcePossible(base.Empire, DepartmentOfTheTreasury.Resources.TechnologiesBuyOut, ref num) && this.interactionsAllowed) { this.ResearchBuyoutButton.AgeTransform.Enable = true; this.ResearchBuyoutButton.AgeTransform.Alpha = 1f; this.ResearchBuyoutLabel.Text = this.format; content = AgeLocalizer.Instance.LocalizeString("%ResearchBuyoutAvailableFormat").Replace("$Cost", newValue); } else { this.ResearchBuyoutButton.AgeTransform.Enable = false; this.ResearchBuyoutButton.AgeTransform.Alpha = 0.5f; this.ResearchBuyoutLabel.Text = this.format; content = AgeLocalizer.Instance.LocalizeString("%ResearchBuyoutUnavailableFormat").Replace("$Cost", newValue); } } else { this.ResearchBuyoutButton.AgeTransform.Enable = false; this.ResearchBuyoutButton.AgeTransform.Alpha = 0.5f; this.ResearchBuyoutLabel.Text = "%ResearchNoneTitle"; this.ResearchBuyoutLabel.AgeTransform.Alpha = 0.5f; content = AgeLocalizer.Instance.LocalizeString("%ResearchBuyoutNoSelection"); this.ResearchBuyoutLabel.AgeTransform.AgeTooltip.Class = string.Empty; this.ResearchBuyoutLabel.AgeTransform.AgeTooltip.Content = "%ResearchNoneDescription"; this.ResearchBuyoutLabel.AgeTransform.AgeTooltip.ClientData = null; } if (this.ResearchBuyoutButton.AgeTransform.AgeTooltip != null) { this.ResearchBuyoutButton.AgeTransform.AgeTooltip.Content = content; return; } } else { this.ResearchBuyoutButton.AgeTransform.Visible = false; this.ResearchBuyoutLabel.AgeTransform.Visible = false; this.CurrentResearchTitle.AgeTransform.Visible = true; if (construction != null) { this.EmpireResearchPanel.Enable = true; int num2 = agency2.ComputeConstructionRemainingTurn(base.Empire, construction); if (num2 == 2147483647) { this.format = string.Format("$Tech ({0})", GuiFormater.Infinite.ToString()); } else { this.format = string.Format("$Tech ({0})", QueueGuiItem.FormatNumberOfTurns(num2)); } TechnologyDefinition technologyDefinition2 = construction.ConstructibleElement as TechnologyDefinition; if (technologyDefinition2 != null) { AgeUtils.TruncateStringWithSubst(this.format, "$Tech", AgeLocalizer.Instance.LocalizeString(DepartmentOfScience.GetTechnologyTitle(technologyDefinition2)), this.CurrentResearchTitle, out this.format, '.'); this.CurrentResearchTitle.Text = this.format; DepartmentOfScience.BuildTechnologyTooltip(technologyDefinition2, base.Empire, this.EmpireResearchPanel.AgeTooltip, MultipleConstructibleTooltipData.TechnologyState.Normal); } } else { this.EmpireResearchPanel.Enable = false; AgeUtils.TruncateString(AgeLocalizer.Instance.LocalizeString("%ResearchNoneTitle"), this.CurrentResearchTitle, out this.format, '.'); this.CurrentResearchTitle.Text = this.format; this.EmpireResearchPanel.AgeTooltip.Class = string.Empty; this.EmpireResearchPanel.AgeTooltip.Content = "%ResearchNoneDescription"; this.EmpireResearchPanel.AgeTooltip.ClientData = null; } this.CurrentResearchTitle.Text = this.format; } }
public static void GetCostAndTurn(Amplitude.Unity.Gui.IGuiService guiService, DepartmentOfTheTreasury departmentOfTheTreasury, SimulationObjectWrapper context, out string costString, out int turn) { turn = 0; StringBuilder stringBuilder = new StringBuilder(); if (PanelFeatureCost.costByResource.Count > 0) { bool flag = false; IDatabase <ResourceDefinition> database = Databases.GetDatabase <ResourceDefinition>(false); foreach (KeyValuePair <StaticString, PanelFeatureCost.CostResume> keyValuePair in PanelFeatureCost.costByResource) { if (keyValuePair.Key == SimulationProperties.Population) { stringBuilder.Append(GuiFormater.FormatGui(keyValuePair.Value.Cost, false, true, false, 1)); stringBuilder.Append(guiService.FormatSymbol(keyValuePair.Key)); } else if (keyValuePair.Key == DepartmentOfTheTreasury.Resources.FreeBorough) { stringBuilder.Append(GuiFormater.FormatGui(keyValuePair.Value.Cost, false, true, false, 1)); stringBuilder.Append(guiService.FormatSymbol(keyValuePair.Key)); float num; if (!departmentOfTheTreasury.TryGetResourceStockValue(context.SimulationObject, DepartmentOfTheTreasury.Resources.QueuedFreeBorough, out num, true)) { Diagnostics.Log("Can't get resource stock value {0} on simulation object {1}.", new object[] { DepartmentOfTheTreasury.Resources.QueuedFreeBorough, context.SimulationObject.Name }); } else { stringBuilder.Append(string.Format(AgeLocalizer.Instance.LocalizeString("%CityFreeBoroughsLeft"), num)); } } else { float cost = keyValuePair.Value.Cost; StaticString key = keyValuePair.Key; ResourceDefinition resourceDefinition; if (!database.TryGetValue(key, out resourceDefinition)) { Diagnostics.LogError("Invalid resource name. The resource {0} does not exist in the resource database.", new object[] { key }); } else { string value = guiService.FormatSymbol(resourceDefinition.GetName(departmentOfTheTreasury.Empire)); if (!string.IsNullOrEmpty(value)) { global::Empire empire = null; if (context is City) { empire = (context as City).Empire; } else if (context is global::Empire) { empire = (context as global::Empire); } if (empire.SimulationObject.Tags.Contains(FactionTrait.FactionTraitMimics2) && key == DepartmentOfTheTreasury.Resources.Production) { ResourceDefinition resourceDefinition2; if (!database.TryGetValue(SimulationProperties.CityGrowth, out resourceDefinition2)) { Diagnostics.LogError("Invalid resource name. The resource {0} does not exist in the resource database.", new object[] { key }); continue; } value = guiService.FormatSymbol(resourceDefinition2.GetName(departmentOfTheTreasury.Empire)); if (string.IsNullOrEmpty(value)) { continue; } } float num2; if (!departmentOfTheTreasury.TryGetResourceStockValue(context.SimulationObject, key, out num2, true)) { num2 = 0f; } if (keyValuePair.Value.Instant && num2 < cost) { AgeUtils.ColorToHexaKey(Color.red, ref stringBuilder, false); flag = true; } stringBuilder.Append(GuiFormater.FormatGui(cost, false, true, false, 1)); stringBuilder.Append(value); if (flag) { stringBuilder.Append("#REVERT#"); flag = false; } if (!keyValuePair.Value.Instant) { float num3; if (!departmentOfTheTreasury.TryGetNetResourceValue(context.SimulationObject, key, out num3, true)) { num3 = 0f; } if (cost > num2) { if (num3 <= 0f) { turn = int.MaxValue; } else { int num4 = Mathf.CeilToInt((cost - num2) / num3); if (num4 > turn) { turn = num4; } } } } stringBuilder.Append(" "); } } } } } costString = stringBuilder.ToString(); if (string.IsNullOrEmpty(costString)) { costString = "-"; } }
protected override IEnumerator OnShow(params object[] parameters) { this.CostValue.Text = string.Empty; this.TurnValue.Text = string.Empty + GuiFormater.Infinite; ICostFeatureProvider provider = this.context as ICostFeatureProvider; if (provider != null && provider.Constructible != null && provider.Empire != null) { DepartmentOfTheTreasury departmentOfTheTreasury = provider.Empire.GetAgency <DepartmentOfTheTreasury>(); SimulationObjectWrapper context = (provider.Context == null) ? provider.Empire : provider.Context; string costString; int turn; PanelFeatureCost.ComputeCostAndTurn(base.GuiService, provider.Constructible, departmentOfTheTreasury, context, out costString, out turn); this.CostValue.AgeTransform.PixelMarginRight = 0f; if (this.DisplayTurnCost) { this.CostValue.AgeTransform.PixelMarginRight = base.AgeTransform.Width - this.TurnValue.AgeTransform.X - 20f * AgeUtils.CurrentUpscaleFactor(); } this.CostValue.AgeTransform.ComputeExtents(Rect.MinMaxRect(0f, 0f, 0f, 0f)); this.CostValue.Text = costString; this.CostTitle.Text = "%FeatureCostTitle"; if (provider.Constructible is KaijuTechnologyDefinition) { KaijuTechnologyDefinition kaijuTechnologyDefinition = provider.Constructible as KaijuTechnologyDefinition; IGameService gameService = Services.GetService <IGameService>(); IKaijuTechsService kaijuTechsService = gameService.Game.Services.GetService <IKaijuTechsService>(); if (kaijuTechsService.GetTechnologyState(kaijuTechnologyDefinition, provider.Empire) == DepartmentOfScience.ConstructibleElement.State.Researched) { this.CostTitle.Text = "%FeatureAlreadyUnlockedTitle"; costString = " "; } } this.CostValue.Text = costString; if (this.CostValue.AgeTransform.PixelMarginTop == this.CostTitle.AgeTransform.PixelMarginTop) { float pixelMargin = 2f * this.CostTitle.AgeTransform.PixelMarginLeft + this.CostTitle.Font.ComputeTextWidth(AgeLocalizer.Instance.LocalizeString(this.CostTitle.Text), this.CostTitle.ForceCaps, false); this.CostValue.AgeTransform.PixelMarginLeft = pixelMargin; } if (provider.Context == null) { this.TurnValue.Text = string.Empty; this.TurnIcon.AgeTransform.Visible = false; } else { this.TurnIcon.AgeTransform.Visible = true; if (turn == 2147483647) { this.TurnValue.Text = string.Empty + GuiFormater.Infinite; } else { turn = Mathf.Max(1, turn); this.TurnValue.Text = turn.ToString(); } } } yield return(base.OnShow(parameters)); this.CostValue.AgeTransform.Height = this.CostValue.Font.LineHeight * (float)this.CostValue.TextLines.Count; base.AgeTransform.Height = this.CostValue.Font.LineHeight * (float)this.CostValue.TextLines.Count + this.CostValue.AgeTransform.PixelMarginTop + this.CostValue.AgeTransform.PixelMarginBottom; base.AgeTransform.Visible = !string.IsNullOrEmpty(this.CostValue.Text); if (!this.DisplayTurnCost) { this.TurnIcon.AgeTransform.Visible = false; this.TurnValue.AgeTransform.Visible = false; } yield break; }
private void RefreshButtons() { if (this.SelectedTradableLine != null && this.SelectedTradableLine.Tradable != null && this.SelectedTradableLine.Tradable.Quantity > 0f) { this.QuantityTextField.AgeTransform.Enable = true; this.QuantityMinusButton.AgeTransform.Enable = (this.CurrentQuantity > 1); if (this.CurrentQuantity >= Mathf.FloorToInt(this.SelectedTradableLine.Tradable.Quantity)) { this.QuantityPlusButton.AgeTransform.Enable = false; this.QuantityPlusButton.AgeTransform.AgeTooltip.Content = "%MarketplaceBuyQuantityPlusTradableQuantityReachedDescription"; } else if (this.CurrentQuantity >= 10) { this.QuantityPlusButton.AgeTransform.Enable = false; this.QuantityPlusButton.AgeTransform.AgeTooltip.Content = string.Format(AgeLocalizer.Instance.LocalizeString("%MarketplaceBuyQuantityPlusHardLimitReachedDescription"), 10); } else { this.QuantityPlusButton.AgeTransform.Enable = true; this.QuantityPlusButton.AgeTransform.AgeTooltip.Content = "%MarketplaceBuyQuantityPlusDescription"; } string formattedPrice = this.GetFormattedPrice(this.SelectedTradableLine.Tradable, this.CurrentQuantity); this.BuyButtonPriceLabel.Text = formattedPrice; if (this.SelectedTradableLine.Tradable.Quantity >= (float)this.CurrentQuantity && this.CanAfford(this.SelectedTradableLine.Tradable, this.CurrentQuantity)) { this.BuyButton.AgeTransform.Enable = this.interactionsAllowed; AgeTooltip ageTooltip = this.BuyButton.AgeTransform.AgeTooltip; if (ageTooltip != null) { string formattedLine = AgeLocalizer.Instance.LocalizeString("%MarketplaceBuyDescription").Replace("$Quantity", this.CurrentQuantity.ToString()).Replace("$TradableName", this.SelectedTradableLine.LocalizedName).Replace("$Price", formattedPrice); StringBuilder stringBuilder = new StringBuilder(); AgeUtils.CleanLine(formattedLine, ref stringBuilder); ageTooltip.Content = stringBuilder.ToString(); if (this.SelectedTradableLine.Tradable is TradableUnit) { ITradeManagementService service = base.Game.Services.GetService <ITradeManagementService>(); UnitDesign unitDesign; if (service != null && service.TryRetrieveUnitDesign((this.SelectedTradableLine.Tradable as TradableUnit).Barcode, out unitDesign) && unitDesign.Tags.Contains(DownloadableContent9.TagColossus)) { float propertyValue = base.Empire.GetPropertyValue(SimulationProperties.MaximumNumberOfColossi); float propertyValue2 = base.Empire.GetPropertyValue(SimulationProperties.NumberOfColossi); if (propertyValue - propertyValue2 < 1f) { formattedLine = AgeLocalizer.Instance.LocalizeString("%MarketplaceCannotBuyColossusDescription").Replace("$ColossiCap", propertyValue.ToString()); stringBuilder = new StringBuilder(); AgeUtils.CleanLine(formattedLine, ref stringBuilder); this.BuyButton.AgeTransform.Enable = false; ageTooltip.Content = stringBuilder.ToString(); } } } } } else { this.BuyButton.AgeTransform.Enable = false; AgeTooltip ageTooltip2 = this.BuyButton.AgeTransform.AgeTooltip; if (ageTooltip2 != null) { string formattedLine2 = AgeLocalizer.Instance.LocalizeString("%MarketplaceCannotBuyDescription").Replace("$Quantity", this.CurrentQuantity.ToString()).Replace("$TradableName", this.SelectedTradableLine.LocalizedName); StringBuilder stringBuilder2 = new StringBuilder(); AgeUtils.CleanLine(formattedLine2, ref stringBuilder2); ageTooltip2.Content = stringBuilder2.ToString(); } } } else { this.QuantityTextField.AgeTransform.Enable = false; this.QuantityMinusButton.AgeTransform.Enable = false; this.QuantityPlusButton.AgeTransform.Enable = false; this.BuyButton.AgeTransform.Enable = false; this.BuyButtonPriceLabel.Text = string.Empty; AgeTooltip ageTooltip3 = this.BuyButton.AgeTransform.AgeTooltip; if (ageTooltip3 != null) { ageTooltip3.Content = null; } } }
public override void RefreshContent() { base.RefreshContent(); base.Empire.Refresh(false); DepartmentOfScience agency = base.Empire.GetAgency <DepartmentOfScience>(); DepartmentOfTheTreasury agency2 = base.Empire.GetAgency <DepartmentOfTheTreasury>(); this.ComputeCurrentEraNumber(); this.CurrentEraNumber.Text = AgeUtils.ToRoman(this.currentEraNumber); this.ResearchErasTable.RefreshChildrenIList <ResearchEraFrame.TechnologyEra>(this.eras, this.refreshEraDelegate, true, false); Construction construction = agency.ResearchQueue.Peek(); bool flag = construction != null; float quantity; if (flag) { quantity = DepartmentOfTheTreasury.GetProductionCostWithBonus(base.Empire.SimulationObject, construction.ConstructibleElement, DepartmentOfTheTreasury.Resources.EmpireResearch); } else { quantity = agency.GetResearchPropertyValue(SimulationProperties.TechnologyCost); } this.TechnologyCostValue.Text = GuiFormater.FormatQuantity(quantity, SimulationProperties.EmpireResearch, 1); float quantity2; agency2.TryGetNetResourceValue(base.Empire.SimulationObject, DepartmentOfTheTreasury.Resources.EmpireResearch, out quantity2, false); this.EmpireOutputValue.Text = GuiFormater.FormatQuantity(quantity2, SimulationProperties.EmpireResearch, 0); if (flag) { float num = agency2.ComputeConstructionProgress(base.Empire, construction); this.ResearchProgress.Text = Mathf.RoundToInt(num * 100f).ToString() + "%"; int num2 = agency2.ComputeConstructionRemainingTurn(base.Empire, construction); num2 = Mathf.Max(num2, 1); if (num2 == 2147483647) { this.ResearchTurns.Text = GuiFormater.Infinite.ToString(); } else { this.ResearchTurns.Text = num2.ToString(); } TechnologyDefinition technologyDefinition = construction.ConstructibleElement as TechnologyDefinition; if (technologyDefinition != null) { this.TechnologyName.Text = DepartmentOfScience.GetTechnologyTitle(technologyDefinition); this.TechnologyImage.Image = DepartmentOfScience.GetTechnologyImage(technologyDefinition, GuiPanel.IconSize.Small); } DepartmentOfScience.BuildTechnologyTooltip(technologyDefinition, base.Empire, this.TechnologyName.AgeTransform.AgeTooltip, MultipleConstructibleTooltipData.TechnologyState.Normal); } else { this.TechnologyName.Text = "%ResearchNoneTitle"; this.TechnologyImage.Image = null; this.ResearchProgress.Text = "%ResearchVoidSymbol"; this.ResearchTurns.Text = "%ResearchVoidSymbol"; if (this.TechnologyName.AgeTransform.AgeTooltip != null) { this.TechnologyName.AgeTransform.AgeTooltip.Class = string.Empty; this.TechnologyName.AgeTransform.AgeTooltip.Content = string.Empty; this.TechnologyName.AgeTransform.AgeTooltip.ClientData = null; } if (this.TechnologyImage.AgeTransform.AgeTooltip != null) { this.TechnologyImage.AgeTransform.AgeTooltip.Class = string.Empty; this.TechnologyImage.AgeTransform.AgeTooltip.Content = string.Empty; this.TechnologyImage.AgeTransform.AgeTooltip.ClientData = null; } } IDownloadableContentService service = Services.GetService <IDownloadableContentService>(); if (service != null && service.IsShared(DownloadableContent11.ReadOnlyName) && base.Empire.SimulationObject.Tags.Contains(FactionTrait.FactionTraitReplicants1)) { this.TechnologyStatsGroup.Visible = false; this.ResearchBuyoutButton.AgeTransform.Visible = true; this.ResearchCompletionGroup.Visible = false; this.RefreshBuyout(this.ResearchBuyoutButton); return; } this.TechnologyStatsGroup.Visible = true; this.ResearchBuyoutButton.AgeTransform.Visible = false; this.ResearchCompletionGroup.Visible = true; }
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; }