public void LoadRegionVillages(Region region) { if (region == null) { return; } GameEntityGUID guid = this.GameEntityRepositoryService.GenerateGUID(); SimulationDescriptor descriptor = null; this.SimulationDescriptorDatabase.TryGetValue("ClassMinorEmpireGarrison", out descriptor); DepartmentOfIndustry agency = base.Empire.GetAgency <DepartmentOfIndustry>(); SimulationDescriptor value = this.SimulationDescriptorDatabase.GetValue("MinorEmpireVillage"); for (int i = 0; i < region.PointOfInterests.Length; i++) { string a; if (region.PointOfInterests[i].PointOfInterestDefinition.TryGetValue("Type", out a) && a == "Village") { guid = this.GameEntityRepositoryService.GenerateGUID(); Village village = new Village(guid) { Empire = (base.Empire as global::Empire) }; village.PointOfInterest = region.PointOfInterests[i]; village.AddDescriptor(descriptor, false); village.AddDescriptor(value, false); this.AddVillage(village); if (agency != null) { agency.AddQueueTo <Village>(village); } } } this.MinorEmpire.GenerateStartingUnits(); }
public override void Initialize(AgentDefinition agentDefinition, AgentGroup parentGroup) { base.Initialize(agentDefinition, parentGroup); City city = base.ContextObject as City; if (city == null) { Diagnostics.LogError("The agent context object is not a city"); return; } Diagnostics.Assert(city.Empire != null); this.departmentOfTheTreasury = city.Empire.GetAgency <DepartmentOfTheTreasury>(); Diagnostics.Assert(this.departmentOfTheTreasury != null); DepartmentOfIndustry agency = city.Empire.GetAgency <DepartmentOfIndustry>(); Diagnostics.Assert(agency != null); this.aiPlayer = (base.ParentGroup.Parent.ContextObject as AIPlayer_MajorEmpire); if (this.aiPlayer == null) { Diagnostics.LogError("The agent context object is not an ai player."); return; } this.constructionQueue = agency.GetConstructionQueue(city); Diagnostics.Assert(this.constructionQueue != null); InfluencedByPersonalityAttribute.LoadFieldAndPropertyValues(city.Empire, this); }
public override void Initialize(AgentDefinition agentDefinition, AgentGroup parentGroup) { base.Initialize(agentDefinition, parentGroup); AIPlayer_MajorEmpire aiPlayer = base.ContextObject as AIPlayer_MajorEmpire; if (aiPlayer == null) { Diagnostics.LogError("The agent context object is not an ai player."); return; } this.empire = aiPlayer.MajorEmpire; if (this.empire == null) { Diagnostics.LogError("Can't retrieve the empire."); return; } Diagnostics.Assert(this.empire != null); this.departmentOfTheInterior = this.empire.GetAgency <DepartmentOfTheInterior>(); Diagnostics.Assert(this.departmentOfTheInterior != null); this.departmentOfTheTreasury = this.empire.GetAgency <DepartmentOfTheTreasury>(); Diagnostics.Assert(this.departmentOfTheTreasury != null); DepartmentOfIndustry agency = this.empire.GetAgency <DepartmentOfIndustry>(); Diagnostics.Assert(agency != null); DepartmentOfIndustry.ConstructibleElement[] availableConstructibleElements = ((IConstructibleElementDatabase)agency).GetAvailableConstructibleElements(new StaticString[] { DistrictImprovementDefinition.ReadOnlyCategory }); Diagnostics.Assert(availableConstructibleElements != null); this.districtImprovement = Array.Find <DepartmentOfIndustry.ConstructibleElement>(availableConstructibleElements, (DepartmentOfIndustry.ConstructibleElement element) => element.Name == aiPlayer.AIData_Faction.DistrictImprovement); Diagnostics.Assert(this.districtImprovement != null && this.districtImprovement.Costs != null); InfluencedByPersonalityAttribute.LoadFieldAndPropertyValues(this.empire, this); }
private float GetWonderProgress(MajorEmpire empire) { DepartmentOfTheInterior agency = empire.GetAgency <DepartmentOfTheInterior>(); DepartmentOfIndustry agency2 = empire.GetAgency <DepartmentOfIndustry>(); float num = 0f; for (int i = 0; i < agency.Cities.Count; i++) { Construction construction = agency2.GetConstructionQueue(agency.Cities[i]).Get((Construction x) => x.ConstructibleElement.SubCategory == "SubCategoryVictory"); if (construction != null) { for (int j = 0; j < construction.CurrentConstructionStock.Length; j++) { if (construction.CurrentConstructionStock[j].PropertyName == "Production") { float stock = construction.CurrentConstructionStock[j].Stock; if (stock > 0f) { float num2 = stock / DepartmentOfTheTreasury.GetProductionCostWithBonus(agency.Cities[i], construction.ConstructibleElement, "Production"); if (num2 > num) { num = num2; } } } } } } return(num); }
//static MethodBase TargetMethod() //{ // // use reflections (with or without AccessTools) to return the MethodInfo of the original method // var type = AccessTools.TypeByName("Amplitude.Mercury.Simulation.DepartmentOfIndustry"); // return AccessTools.Method(type, "GetConstructibleProductionCostForSettlement"); //} static void Postfix(DepartmentOfIndustry __instance, ConstructibleDefinition constructibleDefinition, ref FixedPoint __result) { if (__instance.Empire.IsControlledByHuman) { //log.LogInfo($"Empire: {__instance.Empire.GetDebugName()}, Construction: {constructibleDefinition.Name}, cost: {__result}"); __result /= 2; } }
public void Bind(City city, IGuiPanelHelper helper) { this.Unbind(); this.City = city; this.GuiEmpire = new GuiEmpire(this.City.Empire); DepartmentOfIndustry agency = this.City.Empire.GetAgency <DepartmentOfIndustry>(); this.ConstructionQueue = agency.GetConstructionQueue(this.City); this.guiPanelHelper = helper; IGameService service = Services.GetService <IGameService>(); this.game = (service.Game as global::Game); this.playerControllerRepository = service.Game.Services.GetService <IPlayerControllerRepositoryService>(); this.regionalEffectsService = service.Game.Services.GetService <IRegionalEffectsService>(); this.PanelSpying.Visible = false; this.AgeTransform.Height = this.ModifierPosition.StartHeight; IDownloadableContentService service2 = Services.GetService <IDownloadableContentService>(); if (service2 != null && service2.IsShared(DownloadableContent11.ReadOnlyName)) { this.PanelSpying.Visible = true; this.AgeTransform.Height = this.ModifierPosition.EndHeight; } this.PanelOvergrownCity.Visible = false; if (service2 != null && service2.IsShared(DownloadableContent20.ReadOnlyName) && this.City.IsInfected) { this.PanelSpying.Visible = false; this.PanelOvergrownCity.Visible = true; this.AgeTransform.Height = this.ModifierPosition.EndHeight; 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; } } } } this.infiltrationCostResourceName = DepartmentOfTheTreasury.Resources.InfiltrationCost; ResourceDefinition resourceDefinition; if (Databases.GetDatabase <ResourceDefinition>(false).TryGetValue(DepartmentOfTheTreasury.Resources.InfiltrationCost, out resourceDefinition)) { this.infiltrationCostResourceName = resourceDefinition.GetName(this.playerControllerRepository.ActivePlayerController.Empire); } }
protected override IEnumerator OnLoad() { yield return(base.OnLoad()); Diagnostics.Assert(base.Empire != null); this.departmentOfTheInterior = base.Empire.GetAgency <DepartmentOfTheInterior>(); Diagnostics.Assert(this.departmentOfTheInterior != null); this.departmentOfTheInterior.CitiesCollectionChanged += this.DepartmentOfTheInterior_CitiesCollectionChanged; this.departmentOfTheInterior.AssimilatedFactionsCollectionChanged += this.DepartmentOfTheInterior_AssimilatedFactionsCollectionChanged; this.departmentOfTheInterior.PopulationRepartitionChanged += this.DepartmentOfTheInterior_PopulationRepartitionChanged; this.departmentOfPlanificationAndDevelopment = base.Empire.GetAgency <DepartmentOfPlanificationAndDevelopment>(); Diagnostics.Assert(this.departmentOfPlanificationAndDevelopment != null); this.departmentOfPlanificationAndDevelopment.BoosterCollectionChange += this.DepartmentOfPlanificationAndDevelopment_BoosterCollectionChange; DepartmentOfIndustry departmentOfIndustry = base.Empire.GetAgency <DepartmentOfIndustry>(); Diagnostics.Assert(departmentOfIndustry != null); departmentOfIndustry.AddConstructionChangeEventHandler <CityImprovementDefinition>(new DepartmentOfIndustry.ConstructionChangeEventHandler(this.DepartmentOfIndustry_ConstructionEventHandler)); departmentOfIndustry.AddConstructionChangeEventHandler <DistrictImprovementDefinition>(new DepartmentOfIndustry.ConstructionChangeEventHandler(this.DepartmentOfIndustry_ConstructionEventHandler)); departmentOfIndustry.AddConstructionChangeEventHandler <PointOfInterestImprovementDefinition>(new DepartmentOfIndustry.ConstructionChangeEventHandler(this.DepartmentOfIndustry_ConstructionEventHandler)); IDatabase <ApprovalStatus> approvalStatusDatabase = Databases.GetDatabase <ApprovalStatus>(false); if (this.currentEmpireApprovalStatus == null) { StaticString approvalStatusName = base.Empire.GetDescriptorNameFromType("ApprovalStatus"); if (!StaticString.IsNullOrEmpty(approvalStatusName) && !approvalStatusDatabase.TryGetValue(approvalStatusName, out this.currentEmpireApprovalStatus)) { Diagnostics.LogWarning("We have found an approval status descriptor on the empire, but the approval status database does not contains it."); } } ReadOnlyCollection <City> cities = this.departmentOfTheInterior.Cities; ApprovalStatus cityStatus = null; for (int index = 0; index < cities.Count; index++) { if (!this.approvalStatusByGameEntity.ContainsKey(cities[index].GUID)) { StaticString approvalStatusName2 = cities[index].GetDescriptorNameFromType("ApprovalStatus"); if (!StaticString.IsNullOrEmpty(approvalStatusName2)) { if (!approvalStatusDatabase.TryGetValue(approvalStatusName2, out cityStatus)) { Diagnostics.LogWarning("We have found an approval status descriptor on the empire, but the approval status database does not contains it."); } else { this.approvalStatusByGameEntity.Add(cities[index].GUID, cityStatus); } } } } this.RefreshApprovalStatus(); yield break; }
private bool CheckPointOfInterestImprovementPrerequisites(PointOfInterestImprovementDefinition pointOfInterestImprovementDefinition, ref List <StaticString> failureFlags) { if (this.lastFailureFlags.Contains(ConstructionFlags.Discard)) { return(false); } IWorldPositionningService service = base.Game.Services.GetService <IWorldPositionningService>(); if (service == null) { this.lastFailureFlags.Add(ConstructionFlags.Discard); return(false); } DepartmentOfIndustry agency = this.City.Empire.GetAgency <DepartmentOfIndustry>(); if (agency == null) { this.lastFailureFlags.Add(ConstructionFlags.Discard); return(false); } ConstructionQueue constructionQueue = agency.GetConstructionQueue(this.City); if (constructionQueue == null) { this.lastFailureFlags.Add(ConstructionFlags.Discard); return(false); } int num = constructionQueue.Count(pointOfInterestImprovementDefinition); int num2 = 0; for (int i = 0; i < this.city.Region.PointOfInterests.Length; i++) { PointOfInterest pointOfInterest = this.city.Region.PointOfInterests[i]; if (!(pointOfInterest.PointOfInterestDefinition.PointOfInterestTemplateName != pointOfInterestImprovementDefinition.PointOfInterestTemplateName)) { if (pointOfInterest.PointOfInterestImprovement == null) { int explorationBits = service.GetExplorationBits(pointOfInterest.WorldPosition); if ((explorationBits & this.city.Empire.Bits) != 0) { num2++; } } } } if (num2 <= num) { this.lastFailureFlags.Add(ConstructionFlags.Discard); return(false); } return(true); }
protected override IEnumerator OnInitialize() { this.SimulationDescriptorDatabase = Databases.GetDatabase <SimulationDescriptor>(false); Diagnostics.Assert(this.SimulationDescriptorDatabase != null); this.GameService = Services.GetService <IGameService>(); this.EventService = Services.GetService <IEventService>(); if (this.EventService == null) { Diagnostics.LogError("Failed to retrieve the event service."); } this.EndTurnService = Services.GetService <IEndTurnService>(); if (this.EndTurnService == null) { Diagnostics.LogError("Failed to retrieve the end turn service."); } this.GameEntityRepositoryService = this.GameService.Game.Services.GetService <IGameEntityRepositoryService>(); if (this.GameEntityRepositoryService == null) { Diagnostics.LogError("Failed to retrieve the game entity repository service."); } this.worldPositionningService = this.GameService.Game.Services.GetService <IWorldPositionningService>(); if (this.worldPositionningService == null) { Diagnostics.LogError("Failed to retrieve the world positionning service."); } this.seasonService = this.GameService.Game.Services.GetService <ISeasonService>(); if (this.seasonService == null) { Diagnostics.LogError("Failed to retrieve the season service."); } else { this.seasonService.SeasonChange += this.OnSeasonChange; } DepartmentOfIndustry industry = base.Empire.GetAgency <DepartmentOfIndustry>(); if (!industry.ConstructibleElementDatabase.TryGetValue("DestroyedVillage", out this.destroyedVillagePointOfInterestImprovement)) { Diagnostics.LogError("Failed to retrieve the destroyed village constructible."); yield break; } this.departmentOfDefense = base.Empire.GetAgency <DepartmentOfDefense>(); base.Empire.RegisterPass("GameClientState_Turn_Begin", "ResetExperienceRewardOnUnits", new Agency.Action(this.GameClientState_Turn_Begin_ResetExperienceRewardOnUnits), new string[0]); base.Empire.RegisterPass("GameClientState_Turn_End", "VillageUnitHealthPerTurnGain", new Agency.Action(this.GameClientState_Turn_End_UnitHealthPerTurnGain), new string[0]); base.Empire.RegisterPass("GameClientState_Turn_End", "VillageResetUnitsActionPoints", new Agency.Action(this.GameClientState_Turn_End_UnitHealthPerTurnGain), new string[0]); yield return(base.OnInitialize()); yield break; }
public override IEnumerator Initialize(AIEntity aiEntity) { this.aiEntityCity = (aiEntity as AIEntity_City); this.amasCityLayer = this.aiEntityCity.GetLayer <AILayer_AmasCity>(); yield return(base.Initialize(aiEntity)); base.AIEntity.RegisterPass(AIEntity.Passes.CreateLocalNeeds.ToString(), "LayerPopulation_CreateLocalNeedsPass", new AIEntity.AIAction(this.CreateLocalNeeds), this, new StaticString[] { "LayerAmasCity_CreateLocalNeedsPass", "LayerExtension_CreateLocalNeedsPass" }); base.AIEntity.RegisterPass(AIEntity.Passes.EvaluateNeeds.ToString(), "LayerPopulation_EvaluateNeedsPass", new AIEntity.AIAction(this.EvaluateNeeds), this, new StaticString[] { "LayerExtension_EvaluateNeedsPass" }); base.AIEntity.RegisterPass(AIEntity.Passes.ExecuteNeeds.ToString(), "LayerPopulation_ExecuteNeedsPass", new AIEntity.AIAction(this.ExecuteNeeds), this, new StaticString[] { "LayerExtension_ExecuteNeedsPass" }); this.interpreterContext = new InterpreterContext(this.aiEntityCity.City); for (int index = 0; index < AILayer_Population.PopulationResource.Length; index++) { this.interpreterContext.Register(AILayer_Population.PopulationResource[index], 1); } this.preferedPopulationMessageID = base.AIEntity.AIPlayer.Blackboard.AddMessage(new PreferedPopulationMessage(this.aiEntityCity.City.GUID)); if (!(this.aiEntityCity.AIPlayer is AIPlayer_MajorEmpire)) { AILayer.LogError("The agent context object is not an ai player."); } DepartmentOfIndustry industry = this.Empire.GetAgency <DepartmentOfIndustry>(); DepartmentOfIndustry.ConstructibleElement[] constructibleElements = ((IConstructibleElementDatabase)industry).GetAvailableConstructibleElements(new StaticString[] { DistrictImprovementDefinition.ReadOnlyCategory }); Diagnostics.Assert(constructibleElements != null); this.districtImprovement = Array.Find <DepartmentOfIndustry.ConstructibleElement>(constructibleElements, delegate(DepartmentOfIndustry.ConstructibleElement element) { AIPlayer_MajorEmpire aiPlayer; return(element.Name == aiPlayer.AIData_Faction.DistrictImprovement); }); Diagnostics.Assert(this.districtImprovement != null); IPersonalityAIHelper personalityAIHelper = AIScheduler.Services.GetService <IPersonalityAIHelper>(); this.populationThresholdForSacrifice = personalityAIHelper.GetRegistryValue <float>(this.Empire, "AI/MajorEmpire/AIEntity_City/AILayer_Population/PopulationThresholdForSacrifice", this.populationThresholdForSacrifice); this.approvalThresholdForSacrifice = personalityAIHelper.GetRegistryValue <float>(this.Empire, "AI/MajorEmpire/AIEntity_City/AILayer_Population/ApprovalThresholdForSacrifice", this.approvalThresholdForSacrifice); yield break; }
private void RemoveVillage(Village village) { int num = this.villages.BinarySearch((Village match) => match.GUID.CompareTo(village.GUID)); if (num < 0) { return; } village.Region = null; this.villages.RemoveAt(num); this.GameEntityRepositoryService.Unregister(village); base.Empire.RemoveChild(village); DepartmentOfIndustry agency = base.Empire.GetAgency <DepartmentOfIndustry>(); if (agency != null) { agency.RemoveQueueFrom <Village>(village); } }
private void DoRazeInfectedCity() { Construction currentConstructionRaze = this.GetCurrentConstructionRaze(); if (currentConstructionRaze != null) { OrderCancelConstruction order = new OrderCancelConstruction(this.City.Empire.Index, this.City.GUID, currentConstructionRaze.GUID); Ticket ticket; this.playerControllerRepository.ActivePlayerController.PostOrder(order, out ticket, new EventHandler <TicketRaisedEventArgs>(this.OnOrderResponse)); } else { bool flag = !Amplitude.Unity.Runtime.Runtime.Registry.GetValue <bool>(OvergrownCityPanel.gameplaySettingOvergrownCityImmediateRazePath, true); if (flag) { DepartmentOfIndustry agency = this.City.Empire.GetAgency <DepartmentOfIndustry>(); IEnumerable <DepartmentOfIndustry.ConstructibleElement> availableConstructibleElementsAsEnumerable = agency.ConstructibleElementDatabase.GetAvailableConstructibleElementsAsEnumerable(new StaticString[0]); DepartmentOfIndustry.ConstructibleElement constructibleElement = availableConstructibleElementsAsEnumerable.FirstOrDefault((DepartmentOfIndustry.ConstructibleElement m) => m.Name == OvergrownCityPanel.CityConstructibleActionInfectedRaze); OrderQueueConstruction order2 = new OrderQueueConstruction(this.City.Empire.Index, this.City.GUID, constructibleElement, string.Empty); Ticket ticket2; this.playerControllerRepository.ActivePlayerController.PostOrder(order2, out ticket2, new EventHandler <TicketRaisedEventArgs>(this.OnOrderResponse)); } else { WorldPosition firstAvailablePositionForArmyCreation = this.GetFirstAvailablePositionForArmyCreation(); if (this.City.StandardUnits.Count > 0 && firstAvailablePositionForArmyCreation.IsValid) { OrderTransferGarrisonToNewArmy order3 = new OrderTransferGarrisonToNewArmy(this.City.Empire.Index, this.City.GUID, (from m in this.City.Units select m.GUID).ToArray <GameEntityGUID>(), firstAvailablePositionForArmyCreation, StaticString.Empty, false, false, false); Ticket ticket3; this.playerControllerRepository.ActivePlayerController.PostOrder(order3, out ticket3, new EventHandler <TicketRaisedEventArgs>(this.OrderTransferGarrisonToNewArmy_TicketRaised)); } else { this.SendOrderDestroyCity(); } this.Hide(true); } } }
protected override void OnRelease() { base.OnRelease(); DepartmentOfIndustry agency = base.Empire.GetAgency <DepartmentOfIndustry>(); Diagnostics.Assert(agency != null); agency.RemoveConstructionChangeEventHandler <CityImprovementDefinition>(new DepartmentOfIndustry.ConstructionChangeEventHandler(this.DepartmentOfIndustry_ConstructionEventHandler)); agency.RemoveConstructionChangeEventHandler <DistrictImprovementDefinition>(new DepartmentOfIndustry.ConstructionChangeEventHandler(this.DepartmentOfIndustry_ConstructionEventHandler)); agency.RemoveConstructionChangeEventHandler <PointOfInterestImprovementDefinition>(new DepartmentOfIndustry.ConstructionChangeEventHandler(this.DepartmentOfIndustry_ConstructionEventHandler)); if (this.departmentOfPlanificationAndDevelopment != null) { this.departmentOfPlanificationAndDevelopment.BoosterCollectionChange -= this.DepartmentOfPlanificationAndDevelopment_BoosterCollectionChange; this.departmentOfPlanificationAndDevelopment = null; } if (this.departmentOfTheInterior != null) { this.departmentOfTheInterior.CitiesCollectionChanged -= this.DepartmentOfTheInterior_CitiesCollectionChanged; this.departmentOfTheInterior.AssimilatedFactionsCollectionChanged -= this.DepartmentOfTheInterior_AssimilatedFactionsCollectionChanged; this.departmentOfTheInterior.PopulationRepartitionChanged -= this.DepartmentOfTheInterior_PopulationRepartitionChanged; this.departmentOfTheInterior = null; } this.approvalStatusByClass.Clear(); this.approvalStatusByGameEntity.Clear(); }
public override void RefreshContent() { base.RefreshContent(); this.filter = CityOptionsPanel.OptionCategory.Default; for (int i = 0; i < this.FilterTable.GetChildren().Count; i++) { AgeControlToggle ageControlToggle = this.filterToggles[i]; if (ageControlToggle.State) { this.filter |= this.filtersByToggle[ageControlToggle]; } } DepartmentOfIndustry agency = this.City.Empire.GetAgency <DepartmentOfIndustry>(); IEnumerable <DepartmentOfIndustry.ConstructibleElement> availableConstructibleElementsAsEnumerable = agency.ConstructibleElementDatabase.GetAvailableConstructibleElementsAsEnumerable(new StaticString[0]); this.filteredElement.Clear(); foreach (DepartmentOfIndustry.ConstructibleElement constructibleElement in availableConstructibleElementsAsEnumerable) { CityOptionsPanel.OptionCategory optionCategory = CityOptionsPanel.OptionCategory.Buildings; if (!(constructibleElement.Category == CampConstructibleActionDefinition.ReadOnlyCategory)) { if (constructibleElement.Category == CityImprovementDefinition.ReadOnlyCategory) { optionCategory = CityOptionsPanel.OptionCategory.Buildings; } else if (constructibleElement.Category == CityConstructibleActionDefinition.ReadOnlyCategory) { optionCategory = CityOptionsPanel.OptionCategory.Buildings; } else if (constructibleElement.Category == CityImprovementDefinition.ReadOnlyNationalCategory) { optionCategory = CityOptionsPanel.OptionCategory.Buildings; } else if (constructibleElement.Category == DistrictImprovementDefinition.ReadOnlyCategory) { optionCategory = CityOptionsPanel.OptionCategory.Expand; } else if (constructibleElement.Category == PointOfInterestImprovementDefinition.ReadOnlyCategory) { optionCategory = CityOptionsPanel.OptionCategory.Expand; } else if (constructibleElement.Category == UnitDesign.ReadOnlyCategory) { optionCategory = CityOptionsPanel.OptionCategory.Unit; if (constructibleElement is UnitDesign && (constructibleElement as UnitDesign).Hidden) { continue; } } else if (constructibleElement.Category == BoosterGeneratorDefinition.ReadOnlyCategory) { optionCategory = CityOptionsPanel.OptionCategory.Booster; } else if (constructibleElement.Category == ConstructibleDistrictDefinition.ReadOnlyCategory) { optionCategory = CityOptionsPanel.OptionCategory.Expand; } if ((optionCategory & this.filter) != CityOptionsPanel.OptionCategory.Default) { this.lastFailureFlags.Clear(); agency.GetConstructibleState(this.City, constructibleElement, ref this.lastFailureFlags); DepartmentOfTheTreasury.CheckConstructiblePrerequisites(this.City, constructibleElement, ref this.lastFailureFlags, new string[] { ConstructionFlags.Disable, ConstructionFlags.Discard }); if (!this.lastFailureFlags.Contains(ConstructionFlags.Discard)) { if (!this.lastFailureFlags.Contains(ConstructionFlags.Disable) && !this.AuthorizeExpand && optionCategory == CityOptionsPanel.OptionCategory.Expand) { this.lastFailureFlags.Add(ConstructionFlags.Disable); } if (this.City.IsInfected) { Diagnostics.Assert(this.City.LastNonInfectedOwner != null); if (StaticString.IsNullOrEmpty(constructibleElement.SubCategory) || !constructibleElement.SubCategory.Equals(DepartmentOfTheInterior.InfectionAllowedSubcategory)) { continue; } if (constructibleElement is CityConstructibleActionDefinition) { CityConstructibleActionDefinition cityConstructibleActionDefinition = constructibleElement as CityConstructibleActionDefinition; if (cityConstructibleActionDefinition.Action.Name == "IntegrateFaction" && (string.IsNullOrEmpty(cityConstructibleActionDefinition.InfectedAffinityConstraint) || !cityConstructibleActionDefinition.InfectedAffinityConstraint.Equals(this.city.LastNonInfectedOwner.Faction.Affinity.Name) || this.City.LastNonInfectedOwner.Faction.GetIntegrationDescriptorsCount() <= 0 || this.departmentOfPlanificationAndDevelopment.HasIntegratedFaction(this.City.LastNonInfectedOwner.Faction))) { continue; } } } if (constructibleElement is CityConstructibleActionDefinition && (constructibleElement as CityConstructibleActionDefinition).Action.Name == "PurgeTheLand") { bool flag = false; PointOfInterest[] pointOfInterests = this.City.Region.PointOfInterests; for (int j = 0; j < pointOfInterests.Length; j++) { if (pointOfInterests[j].CreepingNodeGUID != GameEntityGUID.Zero) { IGameEntity gameEntity = null; if (this.gameEntityRepositoryService.TryGetValue(pointOfInterests[j].CreepingNodeGUID, out gameEntity)) { CreepingNode creepingNode = gameEntity as CreepingNode; if (creepingNode != null && creepingNode.Empire.Index != this.City.Empire.Index && !this.departmentOfForeignAffairs.IsFriend(creepingNode.Empire)) { flag = true; break; } } } } if (!flag) { continue; } } if (constructibleElement is PointOfInterestImprovementDefinition) { this.CheckPointOfInterestImprovementPrerequisites((PointOfInterestImprovementDefinition)constructibleElement, ref this.lastFailureFlags); if (this.lastFailureFlags.Contains(ConstructionFlags.Discard)) { continue; } } this.filteredElement.Add(new CityOptionsPanel.ProductionConstruction(constructibleElement, this.playerControllerRepository.ActivePlayerController.Empire as global::Empire, this.guiSubCategorySorting, this.lastFailureFlags.ToArray())); } } } } this.filteredElement.Sort(); this.OptionsTable.Height = this.optionsTableMinHeight; this.OptionsTable.ReserveChildren(this.filteredElement.Count, this.ConstructibleItemPrefab, "Option"); this.OptionsTable.RefreshChildrenIList <CityOptionsPanel.ProductionConstruction>(this.filteredElement, this.constructibleItemRefreshDelegate, true, false); this.OptionsTable.ArrangeChildren(); this.OptionsScrollview.OnPositionRecomputed(); this.OptionsTable.Enable = (!this.IsOtherEmpire && this.interactionsAllowed); }
public bool IsPositionValidForDevice(Amplitude.Unity.Game.Empire empire, WorldPosition position) { if (!position.IsValid) { return(false); } if (this.WorldPositionningService.IsWaterTile(position)) { return(false); } if (this.GetDeviceAtPosition(position) != null) { return(false); } if (this.IsAreaVolcanoformed(position)) { return(false); } if (this.WorldPositionningService != null) { if (!this.WorldPositionningService.IsConstructible(position, WorldPositionning.PreventsDistrictTypeExtensionConstruction, 0) && !this.pillarService.IsPositionOccupiedByAPillar(position)) { return(false); } Region region = this.WorldPositionningService.GetRegion(position); if (region.KaijuEmpire != null && region.Kaiju != null) { KaijuGarrison kaijuGarrison = region.Kaiju.KaijuGarrison; if (kaijuGarrison.WorldPosition == position) { return(false); } } if (region != null && region.City != null && region.City.Empire.Index != empire.Index) { for (int i = 0; i < region.City.Districts.Count; i++) { if (region.City.Districts[i].Type != DistrictType.Exploitation && region.City.Districts[i].WorldPosition == position) { return(false); } } DepartmentOfIndustry agency = region.City.Empire.GetAgency <DepartmentOfIndustry>(); ConstructionQueue constructionQueue = agency.GetConstructionQueue(region.City); if (constructionQueue != null) { for (int j = 0; j < constructionQueue.PendingConstructions.Count; j++) { if (constructionQueue.PendingConstructions[j].WorldPosition == position) { if (constructionQueue.PendingConstructions[j].ConstructibleElement is DistrictImprovementDefinition) { return(false); } if (constructionQueue.PendingConstructions[j].ConstructibleElement is UnitDesign && (constructionQueue.PendingConstructions[j].ConstructibleElement as UnitDesign).Tags.Contains(DownloadableContent9.TagSolitary)) { return(false); } } } } } } return(true); }
public void Bind(City city) { if (this.City != null) { this.Unbind(); } this.City = city; this.Empire = this.City.Empire; this.Empire.Refreshed += this.Simulation_Refreshed; this.IsOtherEmpire = (this.playerControllerRepository.ActivePlayerController.Empire != this.Empire); DepartmentOfIndustry agency = this.Empire.GetAgency <DepartmentOfIndustry>(); this.ConstructionQueue = agency.GetConstructionQueue(this.City); base.GuiService.GetGuiPanel <QueueDragPanel>().Bind(this.City); base.GuiService.GetGuiPanel <QueueDragPanel>().CancelDrag(); if (this.ConstructionQueue != null) { this.constructions = this.ConstructionQueue.PendingConstructions; this.ConstructionQueue.CollectionChanged += this.ConstructionQueue_CollectionChanged; } else { this.constructions = new List <Construction>().AsReadOnly(); } GuiElement guiElement = null; for (int i = 0; i < this.typesFIDS.Count; i++) { base.GuiService.GuiPanelHelper.TryGetGuiElement(this.typesFIDS[i], out guiElement, this.City.Empire.Faction.Name); if (guiElement != null) { ExtendedGuiElement extendedGuiElement = (ExtendedGuiElement)guiElement; if (i < this.TotalValuesTable.GetChildren().Count) { AgeTransform ageTransform = this.TotalValuesTable.GetChildren()[i]; for (int j = 0; j < ageTransform.GetChildren().Count; j++) { AgeTooltip component = ageTransform.GetComponent <AgeTooltip>(); if (component != null) { component.Class = "Simple"; component.Content = extendedGuiElement.Description; } AgeTransform ageTransform2 = ageTransform.GetChildren()[j]; if (ageTransform2.name == "1Symbol") { Texture2D image; if (base.GuiService.GuiPanelHelper.TryGetTextureFromIcon(guiElement, global::GuiPanel.IconSize.Small, out image)) { ageTransform2.GetComponent <AgePrimitiveImage>().Image = image; ageTransform2.GetComponent <AgePrimitiveImage>().TintColor = extendedGuiElement.Color; } break; } } } } SimulationPropertyTooltipData simulationPropertyTooltipData = this.valuesFIDS[i].AgeTransform.AgeTooltip.ClientData as SimulationPropertyTooltipData; if (simulationPropertyTooltipData != null) { simulationPropertyTooltipData.Context = this.City; } } this.GuiEmpire = new GuiEmpire(this.City.Empire); if (this.GuiEmpire != null) { this.OwnerFactionIconSmall.TintColor = this.GuiEmpire.Color; this.OwnerFactionIconSmall.Image = this.GuiEmpire.GuiFaction.GetImageTexture(global::GuiPanel.IconSize.LogoLarge, true); } this.GuiPreviousEmpire = new GuiEmpire(this.City.LastNonInfectedOwner); if (this.GuiPreviousEmpire != null) { this.IntegratedFactionIconLarge.Image = this.GuiPreviousEmpire.GuiFaction.GetImageTexture(global::GuiPanel.IconSize.LogoLarge, true); this.LastOwnerCityFactionTitle.Text = this.GuiPreviousEmpire.Empire.Faction.LocalizedName; } this.IntegratedFactionIconTooltip.Class = "Descriptor"; this.IntegratedFactionIconTooltip.ClientData = this.City.Empire; this.IntegratedTraitTitle.AgeTransform.AgeTooltip.Class = "Descriptor"; this.IntegratedTraitTitle.AgeTransform.AgeTooltip.ClientData = this.City.Empire; Faction faction = this.City.LastNonInfectedOwner.Faction; if (faction != null) { List <string> list = new List <string>(); foreach (SimulationDescriptor simulationDescriptor in faction.GetIntegrationDescriptors()) { this.IntegratedFactionIconTooltip.Content = simulationDescriptor.Name; this.IntegratedTraitTitle.AgeTransform.AgeTooltip.Content = simulationDescriptor.Name; if (base.GuiService.GuiPanelHelper.TryGetGuiElement(simulationDescriptor.Name, out guiElement)) { this.IntegratedTraitTitle.Text = "\\7765\\ " + AgeLocalizer.Instance.LocalizeString(guiElement.Title); } } } if (faction.Affinity.Name == this.City.Empire.Faction.Affinity.Name) { this.IntegratedTraitTitle.Text = "%OCPanelIntegratedFactionSameAffinityTitle"; this.IntegratedTraitTitle.AgeTransform.AgeTooltip.Class = string.Empty; this.IntegratedTraitTitle.AgeTransform.AgeTooltip.ClientData = null; this.IntegratedTraitTitle.AgeTransform.AgeTooltip.Content = "%OCPanelIntegratedFactionSameAffinityTooltip"; this.IntegratedFactionIconTooltip.Class = string.Empty; this.IntegratedFactionIconTooltip.ClientData = null; this.IntegratedFactionIconTooltip.Content = "%OCPanelIntegratedFactionSameAffinityTooltip"; } bool enable = false; this.ActionToogle.AgeTransform.Enable = enable; this.ActionToogle.AgeTransform.Alpha = ((!this.ActionToogle.AgeTransform.Enable) ? 0.5f : 1f); this.ModifierSector.GetComponent <AgePrimitiveSector>().MaxAngle = 0f; this.ModifierSector.Reset(); }
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; }
private void OrderCityBuilding() { DepartmentOfTheInterior agency = this.Empire.GetAgency <DepartmentOfTheInterior>(); DepartmentOfIndustry agency2 = this.Empire.GetAgency <DepartmentOfIndustry>(); if (this.CityLocation.IsValid && agency != null) { City closestCityFromWorldPosition = agency.GetClosestCityFromWorldPosition(this.CityLocation, true); if ((closestCityFromWorldPosition != null || closestCityFromWorldPosition.Empire == this.Empire) && agency2.GetConstructionQueue(closestCityFromWorldPosition).PendingConstructions.Count <= 0) { List <string> list = new List <string> { "CityImprovementIndustry0", "CityImprovementDust0", "CityImprovementFood0", "CityImprovementApproval1", "CityImprovementScience0" }; List <DepartmentOfIndustry.ConstructibleElement> list2 = new List <DepartmentOfIndustry.ConstructibleElement>(); DepartmentOfIndustry.ConstructibleElement constructibleElement = null; foreach (DepartmentOfIndustry.ConstructibleElement constructibleElement2 in agency2.ConstructibleElementDatabase.GetAvailableConstructibleElements(new StaticString[] { CityImprovementDefinition.ReadOnlyCategory })) { if (DepartmentOfTheTreasury.CheckConstructiblePrerequisites(closestCityFromWorldPosition, constructibleElement2, new string[] { ConstructionFlags.Prerequisite })) { if (agency.Cities.Count == 1 && constructibleElement2.ToString().Contains("CityImprovementFIDS")) { constructibleElement = constructibleElement2; break; } if (list.Contains(constructibleElement2.ToString())) { list2.Add(constructibleElement2); } } } if (constructibleElement == null && list2.Count > 0) { using (List <string> .Enumerator enumerator = list.GetEnumerator()) { while (enumerator.MoveNext()) { string important = enumerator.Current; if (list2.Any((DepartmentOfIndustry.ConstructibleElement item) => item.Name == important)) { constructibleElement = list2.First((DepartmentOfIndustry.ConstructibleElement item) => item.Name == important); break; } } } } if (constructibleElement != null) { OrderQueueConstruction order = new OrderQueueConstruction(this.Empire.Index, closestCityFromWorldPosition.GUID, constructibleElement, string.Empty); Ticket ticket; this.Empire.PlayerControllers.AI.PostOrder(order, out ticket, null); } } } }
protected override IEnumerator OnShow(params object[] parameters) { Quest quest = this.context as Quest; if (quest == null) { Diagnostics.LogError("Context must be a quest"); yield break; } int num = 0; GuiElement guiElement; if (base.GuiService.GuiPanelHelper.TryGetGuiElement(quest.Name, out guiElement)) { QuestGuiElement questGuiElement = guiElement as QuestGuiElement; this.ObjectiveLabel.AgeTransform.Height = 0f; this.ObjectiveLabel.Text = string.Empty; if (!this.progressionOnly) { this.ObjectiveBackground.TintColor = this.DescriptionColor; AgePrimitiveLabel objectiveLabel = this.ObjectiveLabel; objectiveLabel.Text += AgeLocalizer.Instance.LocalizeString(questGuiElement.Steps[num].Text); } if (!this.descriptionOnly) { this.ObjectiveBackground.TintColor = this.ProgressionColor; AgePrimitiveLabel objectiveLabel2 = this.ObjectiveLabel; objectiveLabel2.Text += quest.GetProgressionString(quest.QuestDefinition.Steps[num].Name); if (this.constructibleProgression && quest.QuestState != QuestState.Failed && quest.QuestState != QuestState.Completed) { if (this.departmentOfIndustries == null) { IGameService service = Services.GetService <IGameService>(); Diagnostics.Assert(service != null && service.Game != null); global::Game game = service.Game as global::Game; this.departmentOfIndustries = new List <DepartmentOfIndustry>(); for (int i = 0; i < game.Empires.Length; i++) { global::Empire empire = game.Empires[i]; if (empire is MajorEmpire) { DepartmentOfIndustry agency = empire.GetAgency <DepartmentOfIndustry>(); if (agency != null) { this.departmentOfIndustries.Add(agency); } } } } DepartmentOfIndustry.ConstructibleElement constructibleElement = null; if (!this.departmentOfIndustries[0].ConstructibleElementDatabase.TryGetValue(quest.Name.ToString().Replace("Quest", string.Empty), out constructibleElement)) { Diagnostics.LogError("Cannot find ConstructibleElement {0}", new object[] { quest.Name.ToString().Replace("Quest", string.Empty) }); } else { List <KeyValuePair <float, City> > list = new List <KeyValuePair <float, City> >(); KeyValuePair <float, City> item = default(KeyValuePair <float, City>); for (int j = 0; j < this.departmentOfIndustries.Count; j++) { City city; Construction construction = this.departmentOfIndustries[j].GetConstruction(constructibleElement, out city); if (construction != null && city != null) { int num2; float key; float num3; bool flag; QueueGuiItem.GetConstructionTurnInfos(city, construction, QueueGuiItem.EmptyList, out num2, out key, out num3, out flag); KeyValuePair <float, City> keyValuePair = new KeyValuePair <float, City>(key, city); list.Add(keyValuePair); if (city.Empire.Bits == quest.EmpireBits) { item = keyValuePair; } } } list.Sort(new Comparison <KeyValuePair <float, City> >(PanelFeatureQuest.ConstructionInProgressInverseSorter)); int num4; if (item.Value != null) { num4 = list.IndexOf(item); } else { num4 = list.Count; } if (this.ObjectiveLabel.Text != string.Empty) { AgePrimitiveLabel objectiveLabel3 = this.ObjectiveLabel; objectiveLabel3.Text += "\n"; } this.ObjectiveLabel.Text = string.Concat(new object[] { this.ObjectiveLabel.Text, AgeLocalizer.Instance.LocalizeString("%QuestRank"), num4 + 1, "/", this.departmentOfIndustries.Count }); } } } if (!string.IsNullOrEmpty(this.ObjectiveLabel.Text)) { this.ObjectiveLabel.AgeTransform.Width = this.DefaultWidth - this.ObjectiveLabel.AgeTransform.PixelMarginLeft - this.ObjectiveLabel.AgeTransform.PixelMarginRight; this.ObjectiveLabel.ComputeText(); this.ObjectiveGroup.Height = this.ObjectiveLabel.Font.LineHeight * (float)this.ObjectiveLabel.TextLines.Count + this.ObjectiveLabel.AgeTransform.PixelMarginTop + this.ObjectiveLabel.AgeTransform.PixelMarginBottom; this.ObjectiveBox.Height = this.ObjectiveGroup.Height + this.ObjectiveGroup.PixelMarginTop + this.ObjectiveGroup.PixelMarginBottom; } base.AgeTransform.Height = this.ObjectiveBox.Height; } yield return(base.OnShow(parameters)); yield break; }
public override void RefreshContent() { base.RefreshContent(); this.validPointsOfInterest.Clear(); this.validImprovements.Clear(); if (this.City != null && this.City.BesiegingEmpire == null && base.Empire == this.City.Empire && !this.City.IsInfected) { DepartmentOfIndustry agency = this.City.Empire.GetAgency <DepartmentOfIndustry>(); DepartmentOfTheInterior agency2 = this.City.Empire.GetAgency <DepartmentOfTheInterior>(); DepartmentOfTheTreasury agency3 = this.City.Empire.GetAgency <DepartmentOfTheTreasury>(); ConstructibleElement[] availableConstructibleElements = agency.ConstructibleElementDatabase.GetAvailableConstructibleElements(new StaticString[0]); ConstructibleElement[] array = availableConstructibleElements; List <StaticString> list = new List <StaticString>(); for (int i = 0; i < this.City.Region.PointOfInterests.Length; i++) { PointOfInterest pointOfInterest = this.City.Region.PointOfInterests[i]; if (pointOfInterest.PointOfInterestImprovement == null && pointOfInterest.CreepingNodeImprovement == null && (base.WorldPositionningService.GetExplorationBits(pointOfInterest.WorldPosition) & this.City.Empire.Bits) > 0) { List <PointOfInterestImprovementDefinition> list2 = new List <PointOfInterestImprovementDefinition>(); List <ConstructibleDistrictDefinition> list3 = new List <ConstructibleDistrictDefinition>(); for (int j = 0; j < array.Length; j++) { if (array[j] is PointOfInterestImprovementDefinition) { PointOfInterestImprovementDefinition pointOfInterestImprovementDefinition = array[j] as PointOfInterestImprovementDefinition; if (pointOfInterestImprovementDefinition.PointOfInterestTemplateName == pointOfInterest.PointOfInterestDefinition.PointOfInterestTemplateName) { list.Clear(); DepartmentOfTheTreasury.CheckConstructiblePrerequisites(this.City, pointOfInterestImprovementDefinition, ref list, new string[] { ConstructionFlags.Prerequisite }); if (!list.Contains(ConstructionFlags.Discard) && agency3.CheckConstructibleInstantCosts(this.City, pointOfInterestImprovementDefinition)) { list2.Add(agency2.GetBestImprovementDefinition(this.City, pointOfInterest, pointOfInterestImprovementDefinition, list)); } } } else if (array[j] is ConstructibleDistrictDefinition) { ConstructibleDistrictDefinition constructibleDistrictDefinition = array[j] as ConstructibleDistrictDefinition; if (constructibleDistrictDefinition != null) { list3.Add(constructibleDistrictDefinition); } } } if (list2.Count > 0) { ConstructionQueue constructionQueue = agency.GetConstructionQueue(this.City); bool flag = false; for (int k = 0; k < list2.Count; k++) { for (int l = 0; l < constructionQueue.Length; l++) { Construction construction = constructionQueue.PeekAt(l); if (construction.ConstructibleElement == list2[k] && construction.WorldPosition == pointOfInterest.WorldPosition) { flag = true; break; } } } if (!flag) { for (int m = 0; m < list3.Count; m++) { for (int n = 0; n < constructionQueue.Length; n++) { Construction construction2 = constructionQueue.PeekAt(n); if (construction2.ConstructibleElement == list3[m] && construction2.WorldPosition == pointOfInterest.WorldPosition) { flag = true; break; } } } } if (!flag) { for (int num = 0; num < list2.Count; num++) { this.validPointsOfInterest.Add(pointOfInterest); this.validImprovements.Add(list2[num]); } } } } } } this.LabelsTable.ReserveChildren(this.validPointsOfInterest.Count, this.LabelPrefab, "ConstructibleLabel"); this.LabelsTable.RefreshChildrenIList <PointOfInterest>(this.validPointsOfInterest, new AgeTransform.RefreshTableItem <PointOfInterest>(this.RefreshPointOfInterest), true, false); this.LabelsTable.Enable = this.interactionsAllowed; this.UnbindAndHideLabels(this.validPointsOfInterest.Count); }