private void StartNextBooster() { if (base.Empire.SimulationObject.Tags.Contains(FactionTrait.FactionTraitReplicants1)) { return; } DepartmentOfScience agency = base.Empire.GetAgency <DepartmentOfScience>(); bool flag = base.Empire.GetAgency <DepartmentOfForeignAffairs>().IsInWarWithSomeone(); bool flag2 = agency.GetTechnologyState("TechnologyDefinitionAllBoosterLevel1") == DepartmentOfScience.ConstructibleElement.State.Researched || agency.GetTechnologyState("TechnologyDefinitionAllBoosterLevel2") == DepartmentOfScience.ConstructibleElement.State.Researched; if (agency.GetResearchPropertyValue("UnlockedTechnologyCount") <= 16f || flag2 || flag) { if (agency.GetResearchPropertyValue("UnlockedTechnologyCount") >= 23f && !flag2) { return; } for (int i = 0; i < this.departmentOfEducation.VaultCount; i++) { BoosterDefinition boosterDefinition = this.departmentOfEducation.VaultItems[i].Constructible as BoosterDefinition; if (boosterDefinition != null && boosterDefinition.Name == "BoosterScience") { OrderBuyoutAndActivateBooster order = new OrderBuyoutAndActivateBooster(base.Empire.Index, boosterDefinition.Name, this.departmentOfEducation.VaultItems[i].GUID, false); Ticket ticket; base.Empire.PlayerControllers.AI.PostOrder(order, out ticket, new EventHandler <TicketRaisedEventArgs>(this.BuyoutAndActivateBooster_TicketRaised)); return; } } } }
private SynchronousJobState SynchronousJob_StartBooster() { int count = this.chosenmessages.Count; OrderBuyoutAndActivateBooster order = new OrderBuyoutAndActivateBooster(base.Empire.Index, this.chosenmessages[count - 1].BoosterDefinition.Name, 0UL, false); Ticket ticket; base.Empire.PlayerControllers.AI.PostOrder(order, out ticket, new EventHandler <TicketRaisedEventArgs>(this.OrderBuyoutAndActivateBooster_TicketRaised)); this.chosenmessages.RemoveAt(count - 1); if (count == 1) { return(SynchronousJobState.Success); } return(SynchronousJobState.Running); }
private void OrderBuyoutAndActivateBooster_TicketRaised(object sender, TicketRaisedEventArgs e) { OrderBuyoutAndActivateBooster orderBuyoutAndActivateBooster = e.Order as OrderBuyoutAndActivateBooster; EvaluableMessage_LavaboostNeeded firstMessage = base.AIEntity.AIPlayer.Blackboard.GetFirstMessage <EvaluableMessage_LavaboostNeeded>(BlackboardLayerID.Empire, (EvaluableMessage_LavaboostNeeded match) => match.EvaluationState == EvaluableMessage.EvaluableMessageState.Pending && match.BoosterDefinition.Name == orderBuyoutAndActivateBooster.BoosterDefinitionName); if (firstMessage != null) { if (e.Result != PostOrderResponse.Processed) { firstMessage.SetFailedToObtain(); return; } firstMessage.SetObtained(); } }
private void PostOrderBuyoutAndActivateBooster(GameEntityGUID targetGUID) { IGameService service = Services.GetService <IGameService>(); if (service != null && service.Game != null) { IPlayerControllerRepositoryService service2 = service.Game.Services.GetService <IPlayerControllerRepositoryService>(); if (service2 != null && service2.ActivePlayerController != null) { OrderBuyoutAndActivateBooster orderBuyoutAndActivateBooster = new OrderBuyoutAndActivateBooster(service2.ActivePlayerController.Empire.Index, this.guiStackedBooster.BoosterDefinition.Name, this.guiStackedBooster.GetFirstAvailableVaultBooster().GUID, false); orderBuyoutAndActivateBooster.TargetGUID = targetGUID; service2.ActivePlayerController.PostOrder(orderBuyoutAndActivateBooster); Services.GetService <IAudioEventService>().Play2DEvent("Gui/Interface/BoosterStockPile"); } } }
private SynchronousJobState SynchronousJob_StartBooster() { SynchronousJobState result; if (this.boosterDefinitionWrappers == null || base.AIEntity == null || base.AIEntity.AIPlayer == null) { result = SynchronousJobState.Failure; } else { DepartmentOfScience agency = base.AIEntity.Empire.GetAgency <DepartmentOfScience>(); bool flag = agency.GetTechnologyState("TechnologyDefinitionAllBoosterLevel1") == DepartmentOfScience.ConstructibleElement.State.Researched || agency.GetTechnologyState("TechnologyDefinitionAllBoosterLevel2") == DepartmentOfScience.ConstructibleElement.State.Researched; for (int i = this.boosterDefinitionWrappers.Count - 1; i >= 0; i--) { CityBoosterNeeds cityBoosterNeeds = null; if (this.boosterDefinitionWrappers[i] != null && base.AIEntity.AIPlayer.Blackboard.TryGetMessage <CityBoosterNeeds>(this.boosterDefinitionWrappers[i].CurrentMessageId, out cityBoosterNeeds) && cityBoosterNeeds.AvailabilityState == CityBoosterNeeds.CityBoosterState.Available) { StaticString x = this.boosterDefinitionWrappers[i].BoosterDefinitionName; if (x == "BoosterIndustry" || x == "FlamesIndustryBooster") { if (this.aiEntityCity.City.SimulationObject.Children.Exists((SimulationObject C) => C.Tags.Contains("BoosterDecreaseCityProduction4"))) { goto IL_275; } } if (agency.GetResearchPropertyValue("UnlockedTechnologyCount") <= 16f || flag || x == "BoosterFood" || x == "BoosterCadavers") { if (cityBoosterNeeds.BoosterGuid.IsValid && this.departmentOfEducation[cityBoosterNeeds.BoosterGuid] != null && this.departmentOfEducation[cityBoosterNeeds.BoosterGuid].Constructible != null) { x = this.departmentOfEducation[cityBoosterNeeds.BoosterGuid].Constructible.Name; } OrderBuyoutAndActivateBooster orderBuyoutAndActivateBooster = new OrderBuyoutAndActivateBooster(base.AIEntity.Empire.Index, x, cityBoosterNeeds.BoosterGuid, false); orderBuyoutAndActivateBooster.TargetGUID = this.aiEntityCity.City.GUID; base.AIEntity.Empire.PlayerControllers.AI.PostOrder(orderBuyoutAndActivateBooster); this.boosterDefinitionWrappers[i].CurrentMessageId = 0UL; cityBoosterNeeds.BoosterGuid = 0UL; cityBoosterNeeds.AvailabilityState = CityBoosterNeeds.CityBoosterState.Success; base.AIEntity.AIPlayer.Blackboard.CancelMessage(cityBoosterNeeds); } } IL_275 :; } result = SynchronousJobState.Success; } return(result); }
protected override State Execute(QuestBehaviour questBehaviour, params object[] parameters) { if (!string.IsNullOrEmpty(this.ResourceName)) { if (!string.IsNullOrEmpty(this.EmpireIndexVarName)) { int num = -1; if (!questBehaviour.TryGetQuestVariableValueByName <int>(this.EmpireIndexVarName, out num)) { Diagnostics.LogError("Cannot retrieve quest variable (varname: '{0}')", new object[] { this.EmpireIndexVarName }); return(State.Failure); } if (num != questBehaviour.Initiator.Index) { return(State.Success); } } if (questBehaviour.Initiator is MajorEmpire && (questBehaviour.Initiator as MajorEmpire).ELCPIsEliminated) { return(State.Success); } if (this.ResourceName.Contains("Booster")) { for (int i = 0; i < this.Amount; i++) { OrderBuyoutAndActivateBooster order = new OrderBuyoutAndActivateBooster(questBehaviour.Initiator.Index, this.ResourceName, 0UL, false); questBehaviour.Initiator.PlayerControllers.Server.PostOrder(order); } } else { Order order2 = new OrderTransferResources(questBehaviour.Initiator.Index, this.ResourceName, (float)this.Amount, 0UL); questBehaviour.Initiator.PlayerControllers.Server.PostOrder(order2); } } return(State.Success); }
void IDiplomaticTermManagement.ApplyEffects() { DiplomaticTermCityExchangeDefinition diplomaticTermCityExchangeDefinition = base.Definition as DiplomaticTermCityExchangeDefinition; Diagnostics.Assert(diplomaticTermCityExchangeDefinition != null); Diagnostics.Assert(base.EmpireWhichProvides != null && base.EmpireWhichReceives != null); DepartmentOfTheInterior agency = base.EmpireWhichProvides.GetAgency <DepartmentOfTheInterior>(); DepartmentOfTheInterior agency2 = base.EmpireWhichReceives.GetAgency <DepartmentOfTheInterior>(); Diagnostics.Assert(agency != null && agency2 != null); City city = null; for (int i = 0; i < agency.Cities.Count; i++) { City city2 = agency.Cities[i]; if (city2.GUID == this.CityGUID) { city = city2; break; } } if (city == null) { Diagnostics.LogError("DiplomaticTermCityExchange.ApplyEffect failed, can't retrieve the city {0} from the empire which provides the term ({1}).", new object[] { this.CityGUID, base.EmpireWhichProvides }); return; } IEventService service = Services.GetService <IEventService>(); if (service == null) { Diagnostics.LogError("Failed to retrieve the event service."); return; } bool flag = base.EmpireWhichReceives.SimulationObject.Tags.Contains("FactionTraitCultists9"); bool flag2 = agency2.Cities.Count >= 1; if (flag && flag2) { IGameService service2 = Services.GetService <IGameService>(); IPlayerControllerRepositoryService service3 = service2.Game.Services.GetService <IPlayerControllerRepositoryService>(); IPlayerControllerRepositoryControl playerControllerRepositoryControl = service3 as IPlayerControllerRepositoryControl; if (playerControllerRepositoryControl != null) { global::PlayerController playerControllerById = playerControllerRepositoryControl.GetPlayerControllerById("server"); if (playerControllerById != null) { float propertyValue = city.GetPropertyValue(SimulationProperties.Population); DepartmentOfScience agency3 = base.EmpireWhichReceives.GetAgency <DepartmentOfScience>(); bool flag3 = agency3 != null && agency3.GetTechnologyState("TechnologyDefinitionCultists12") == DepartmentOfScience.ConstructibleElement.State.Researched; int num = 0; while ((float)num < propertyValue) { OrderBuyoutAndActivateBooster order = new OrderBuyoutAndActivateBooster(base.EmpireWhichReceives.Index, "BoosterIndustry", 0UL, false); playerControllerById.PostOrder(order); if (flag3) { order = new OrderBuyoutAndActivateBooster(base.EmpireWhichReceives.Index, "BoosterScience", 0UL, false); playerControllerById.PostOrder(order); } num++; } OrderDestroyCity order2 = new OrderDestroyCity(city.Empire.Index, city.GUID, true, true, base.EmpireWhichReceives.Index); playerControllerById.PostOrder(order2); EventCityRazed eventToNotify = new EventCityRazed(city.Empire, city.Region, base.EmpireWhichReceives, false); service.Notify(eventToNotify); } } } else { agency.SwapCityOwner(city, base.EmpireWhichReceives); service.Notify(new EventSwapCity(base.EmpireWhichProvides, city, base.EmpireWhichProvides.Index, base.EmpireWhichReceives.Index, false)); service.Notify(new EventSwapCity(base.EmpireWhichReceives, city, base.EmpireWhichProvides.Index, base.EmpireWhichReceives.Index, false)); } }