protected override Amplitude.Unity.Game.Orders.Order SellOne(Empire empire, AuctionItem_GameEntity item, ref List <AuctionInstruction> instructions) { Unit unit = item.GameEntity as Unit; string parentName = string.Empty; if (unit.Garrison is City) { parentName = (unit.Garrison as City).LocalizedName; } else if (unit.Garrison is Army) { parentName = (unit.Garrison as Army).LocalizedName; } DepartmentOfScience agency = empire.GetAgency <DepartmentOfScience>(); if (agency != null && agency.GetTechnologyState(TechnologyDefinition.Names.MarketplaceMercenaries) == DepartmentOfScience.ConstructibleElement.State.Researched) { instructions.Add(new AuctionInstruction(AuctionInstruction.AuctionType.Unit, AuctionInstruction.AuctionAction.Sell, unit.UnitDesign.LocalizedName, 1, parentName)); } else { instructions.Add(new AuctionInstruction(AuctionInstruction.AuctionType.Unit, AuctionInstruction.AuctionAction.Destroy, unit.UnitDesign.LocalizedName, 1, parentName)); } return(new OrderSelloutTradableUnits(empire.Index, new GameEntityGUID[] { item.ItemGuid })); }
private void OnVisibityRefreshed(object sender, VisibilityRefreshedEventArgs args) { MajorEmpire majorEmpire = args.Empire as MajorEmpire; if (majorEmpire == null) { return; } DepartmentOfScience agency = majorEmpire.GetAgency <DepartmentOfScience>(); for (int i = 0; i < this.majorEmpires.Length; i++) { global::Empire empire = this.majorEmpires[i]; if (majorEmpire.Index != empire.Index) { WorldPosition worldPosition = this.CheckMetting(majorEmpire, empire); if (worldPosition != WorldPosition.Invalid) { WorldPosition worldPosition2 = this.CheckMetting(empire, majorEmpire); if (worldPosition2 != WorldPosition.Invalid) { this.OnEmpireSymetricDiscovery(majorEmpire, empire, worldPosition, worldPosition2); } else if (agency.GetTechnologyState(this.technologyDefinitionDrakkenVisionDuringFirstTurn) == DepartmentOfScience.ConstructibleElement.State.Researched) { this.OnEmpireAsymetricDiscovery(majorEmpire, empire, worldPosition); } } } } }
private void OnSelectOrbUnlockCB(GameObject obj) { if (this.empire == null) { Diagnostics.LogError("Empire is null"); return; } DepartmentOfScience agency = this.empire.GetAgency <DepartmentOfScience>(); DepartmentOfScience.ConstructibleElement.State technologyState = agency.GetTechnologyState(this.TechnologyDefinition); ConstructionQueue constructionQueueForTech = agency.GetConstructionQueueForTech(this.TechnologyDefinition); if (technologyState == DepartmentOfScience.ConstructibleElement.State.Available && agency.OrbUnlockQueue.Length < 2) { this.AgeTransform.Enable = false; if (agency.OrbUnlockQueue.Length > 0) { Construction construction = constructionQueueForTech.Peek(); this.CancelResearch(construction); } this.QueueResearch(); this.selectionClient.SendMessage("OnSelectTechnology", this.AgeTransform, SendMessageOptions.RequireReceiver); } else if (technologyState == DepartmentOfScience.ConstructibleElement.State.InProgress || technologyState == DepartmentOfScience.ConstructibleElement.State.Queued) { this.AgeTransform.Enable = false; Construction construction2 = constructionQueueForTech.Get(this.TechnologyDefinition); this.CancelResearch(construction2); this.selectionClient.SendMessage("OnSelectTechnology", this.AgeTransform, SendMessageOptions.RequireReceiver); } }
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 static float UtilityFunc_EmpireLuxury(SeasonEffect aiEvaluableElement, InterpreterContext context, float aiParameterValue, AIHeuristicAnalyser.Context debugContext) { global::Empire empire = context.Get("Empire") as global::Empire; Diagnostics.Assert(empire != null); DepartmentOfScience agency = empire.GetAgency <DepartmentOfScience>(); DepartmentOfTheInterior agency2 = empire.GetAgency <DepartmentOfTheInterior>(); float num; float num2; AILayer_Altar.GetResourceUnitMarketPrice(empire, out num, out num2); float b = 0f; if (agency.GetTechnologyState(TechnologyDefinition.Names.MarketplaceResources) == DepartmentOfScience.ConstructibleElement.State.Researched) { float propertyValue = empire.GetPropertyValue(SimulationProperties.NetEmpireMoney); b = num2 / Mathf.Max(propertyValue, 1f); } float technologyUnlockedCount = agency.GetTechnologyUnlockedCount(); float a = (float)agency2.Cities.Count; float a2 = technologyUnlockedCount / (15f * Mathf.Max(a, 1f)); float num3 = Mathf.Max(a2, b); return(aiParameterValue * num3); }
public void OnForceShiftCB(GameObject obj) { if (this.Garrison != null) { DepartmentOfScience agency = this.Garrison.Empire.GetAgency <DepartmentOfScience>(); if (agency == null || agency.GetTechnologyState("TechnologyDefinitionOrbUnlock17WinterShifters") != DepartmentOfScience.ConstructibleElement.State.Researched) { return; } List <Unit> list = new List <Unit>(this.selectedUnits); list.RemoveAll((Unit unit) => !unit.IsShifter() || !unit.IsInCurrentSeasonForm()); if (list.Count > 0) { OrderForceShiftUnits order = new OrderForceShiftUnits(this.Garrison.Empire.Index, list.ToArray()); IPlayerControllerRepositoryService service = base.Game.Services.GetService <IPlayerControllerRepositoryService>(); Ticket ticket; service.ActivePlayerController.PostOrder(order, out ticket, new EventHandler <TicketRaisedEventArgs>(this.OnOrderResponse)); EventForceShift eventToNotify = new EventForceShift(this.Garrison.Empire, list.Count, true); IEventService service2 = Services.GetService <IEventService>(); if (service2 != null) { service2.Notify(eventToNotify); } } } }
private bool ArmyCanConvert(Army army, List <StaticString> failureFlags = null) { if (army.Empire == null || army.Empire.Faction == null) { if (failureFlags != null) { failureFlags.Add(ArmyAction.NoCanDoWhileHidden); } return(false); } DepartmentOfScience agency = army.Empire.GetAgency <DepartmentOfScience>(); bool flag = army.Empire.SimulationObject.Tags.Contains("FactionTraitCultists14"); bool flag2 = agency.GetTechnologyState("TechnologyDefinitionCultists5") == DepartmentOfScience.ConstructibleElement.State.Researched; if (!flag && !flag2) { if (failureFlags != null) { failureFlags.Add(ArmyAction.NoCanDoWhileHidden); } return(false); } if (army.IsInEncounter) { if (failureFlags != null) { failureFlags.Add(ArmyAction.NoCanDoWhileLockedInBattle); } return(false); } if (!flag2 && flag) { if (!army.Units.Any((Unit unit) => !unit.SimulationObject.Tags.Contains("UnitFactionTypeMinorFaction") && !unit.SimulationObject.Tags.Contains(TradableUnit.ReadOnlyMercenary))) { if (failureFlags != null) { failureFlags.Add(ArmyAction_Convert.NoCanDoWhileMinorUnitsOnly); } return(false); } } DepartmentOfTheInterior agency2 = army.Empire.GetAgency <DepartmentOfTheInterior>(); if (agency2 != null && agency2.MainCity == null && agency2.Cities.Count < 1) { if (failureFlags != null) { failureFlags.Add(ArmyAction_Convert.NoCanDoWhileMainCityIsNotSettled); } return(false); } return(true); }
private void RefreshVFXEffects(bool endlessDay, bool dustDeposits) { string text = base.PointOfInterest.Type; if (text != null && (text == "NavalQuestLocation" || text == "QuestLocation")) { bool flag = (base.PlayerControllerRepositoryService.ActivePlayerController.Empire.Bits & base.PointOfInterest.Interaction.Bits) != 0; int num = this.NumberOfSetBits(base.PointOfInterest.Interaction.Bits); string text2 = string.Empty; if (flag) { text2 = "Searched"; } else if (num == 0) { text2 = "Blank"; } else { text2 = "Other"; } if (base.PointOfInterest.UntappedDustDeposits && dustDeposits) { text2 += "_DustDeposit"; } else if (this.sensibleToEndlessDay && endlessDay) { text2 += "_EndlessDay"; } this.interpreterContext.Register("Interaction", text2); this.DestroyPointOfInterestIcon(); this.CreatePointOfInterestIcon(); this.CreateOrRegeneratePointOfInterestFXTypeIFN(); if (flag && this.interactionBitsBound) { DepartmentOfScience agency = base.PlayerControllerRepositoryService.ActivePlayerController.Empire.GetAgency <DepartmentOfScience>(); Diagnostics.Assert(agency != null); if (StaticString.IsNullOrEmpty(agency.ArcheologyTechnologyDefinitionName)) { base.PointOfInterest.Interaction.PointOfInterestInteractionChange -= this.Interaction_PointOfInterestInteractionChange; this.interactionBitsBound = false; } else if (agency.GetTechnologyState(agency.ArcheologyTechnologyDefinitionName) == DepartmentOfScience.ConstructibleElement.State.Researched) { base.PointOfInterest.Interaction.PointOfInterestInteractionChange -= this.Interaction_PointOfInterestInteractionChange; this.interactionBitsBound = false; } } base.UpdatePointOfInterestVisibility(); } }
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; } } } }
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); }
private void OnOrderResponse(object sender, TicketRaisedEventArgs args) { this.AgeTransform.Enable = true; DepartmentOfScience agency = this.empire.GetAgency <DepartmentOfScience>(); DepartmentOfScience.ConstructibleElement.State technologyState = agency.GetTechnologyState(this.TechnologyDefinition); if (this.TechnologyDefinition.HasTechnologyFlag(DepartmentOfScience.ConstructibleElement.TechnologyFlag.KaijuUnlock)) { IGameService service = Services.GetService <IGameService>(); if (service == null || service.Game == null) { Diagnostics.LogError("GameService or GameService.Game is null"); return; } IKaijuTechsService service2 = service.Game.Services.GetService <IKaijuTechsService>(); technologyState = service2.GetTechnologyState(this.TechnologyDefinition, this.empire); } this.Refresh(this.empire, technologyState); }
private void OnSelectTechnologyCB(GameObject obj) { if (this.empire == null) { Diagnostics.LogError("Empire is null"); return; } DepartmentOfScience agency = this.empire.GetAgency <DepartmentOfScience>(); DepartmentOfScience.ConstructibleElement.State technologyState = agency.GetTechnologyState(this.TechnologyDefinition); ConstructionQueue constructionQueueForTech = agency.GetConstructionQueueForTech(this.TechnologyDefinition); if (technologyState == DepartmentOfScience.ConstructibleElement.State.Available) { this.AgeTransform.Enable = false; if (Amplitude.Unity.Framework.Application.Preferences.EnableModdingTools && Input.GetKey(KeyCode.G)) { this.ForceUnlockTechnology(); } else { this.QueueResearch(); } this.selectionClient.SendMessage("OnSelectTechnology", this.AgeTransform, SendMessageOptions.RequireReceiver); return; } if (technologyState == DepartmentOfScience.ConstructibleElement.State.InProgress || technologyState == DepartmentOfScience.ConstructibleElement.State.Queued) { this.AgeTransform.Enable = false; Construction construction = constructionQueueForTech.Get(this.TechnologyDefinition); this.CancelResearch(construction); if (Amplitude.Unity.Framework.Application.Preferences.EnableModdingTools && Input.GetKey(KeyCode.G)) { this.ForceUnlockTechnology(); } this.selectionClient.SendMessage("OnSelectTechnology", this.AgeTransform, SendMessageOptions.RequireReceiver); } }
private bool CanPathToRegion(Region region) { foreach (Region region2 in this.worldPositionningService.GetNeighbourRegions(region, false, false)) { if (region2.Owner != null && region2.Owner.Index == base.AIEntity.Empire.Index) { return(true); } } PathfindingContext pathfindingContext; if (this.PathingOrigin is Army) { pathfindingContext = (this.PathingOrigin as Army).GenerateContext(); } else { pathfindingContext = new PathfindingContext(GameEntityGUID.Zero, base.AIEntity.Empire, PathfindingMovementCapacity.Ground); pathfindingContext.AddMovementCapacity(PathfindingMovementCapacity.FrozenWater); pathfindingContext.RefreshProperties(1f, 100f, false, false, 100f, 100f); DepartmentOfScience agency = base.AIEntity.Empire.GetAgency <DepartmentOfScience>(); DepartmentOfScience.ConstructibleElement technology; if (agency.TechnologyDatabase.TryGetValue("TechnologyDefinitionShip", out technology) && agency.GetTechnologyState(technology) == DepartmentOfScience.ConstructibleElement.State.Researched) { pathfindingContext.AddMovementCapacity(PathfindingMovementCapacity.Water); } } WorldPosition[] worldPositions = region.WorldPositions; int j = 0; while (j < worldPositions.Length) { WorldPosition worldPosition = worldPositions[j]; if (!this.worldPositionningService.IsWaterTile(worldPosition) && !this.worldPositionningService.HasRidge(worldPosition) && this.pathfindingService.IsTileStopable(worldPosition, pathfindingContext, (PathfindingFlags)0, null)) { if (this.pathfindingService.FindPath(pathfindingContext, (this.PathingOrigin as IWorldPositionable).WorldPosition, worldPosition, PathfindingManager.RequestMode.Default, null, PathfindingFlags.IgnoreArmies | PathfindingFlags.IgnoreEncounterAreas | PathfindingFlags.IgnoreFogOfWar | PathfindingFlags.IgnorePOI | PathfindingFlags.IgnoreSieges | PathfindingFlags.IgnoreTerraformDevices | PathfindingFlags.IgnoreKaijuGarrisons, null) == null) { if (Amplitude.Unity.Framework.Application.Preferences.EnableModdingTools) { Diagnostics.Log("ELCP {0}/{1} AILayer_Colonization:CanPathToRegion FAILED! from {3} to {2}/{5} with {4}", new object[] { base.AIEntity.Empire, this.PathingOrigin.LocalizedName, worldPosition, (this.PathingOrigin as IWorldPositionable).WorldPosition, pathfindingContext.MovementCapacities, region.LocalizedName }); } return(false); } return(true); } else { j++; } } return(false); }
public override IEnumerator Ignite(IGameEntity gameEntity, Amplitude.Unity.Framework.IServiceProvider serviceProvider) { yield return(base.Ignite(gameEntity, serviceProvider)); string text = base.PointOfInterest.Type; if (text != null) { if (WorldPointOfInterest_QuestLocation.< > f__switch$map24 == null) { WorldPointOfInterest_QuestLocation.< > f__switch$map24 = new Dictionary <string, int>(2) { { "NavalQuestLocation", 0 }, { "QuestLocation", 0 } }; } int num; if (WorldPointOfInterest_QuestLocation.< > f__switch$map24.TryGetValue(text, out num)) { if (num == 0) { int bits = base.PointOfInterest.Interaction.Bits & base.PlayerControllerRepositoryService.ActivePlayerController.Empire.Bits; if (bits == 0) { base.PointOfInterest.Interaction.PointOfInterestInteractionChange += this.Interaction_PointOfInterestInteractionChange; this.interactionBitsBound = true; } if (bits == base.PlayerControllerRepositoryService.ActivePlayerController.Empire.Bits) { DepartmentOfScience departmentOfScience = base.PlayerControllerRepositoryService.ActivePlayerController.Empire.GetAgency <DepartmentOfScience>(); Diagnostics.Assert(departmentOfScience != null); if (!StaticString.IsNullOrEmpty(departmentOfScience.ArcheologyTechnologyDefinitionName)) { DepartmentOfScience.ConstructibleElement.State state = departmentOfScience.GetTechnologyState(departmentOfScience.ArcheologyTechnologyDefinitionName); if (state != DepartmentOfScience.ConstructibleElement.State.Researched) { base.PointOfInterest.Interaction.PointOfInterestInteractionChange += this.Interaction_PointOfInterestInteractionChange; this.interactionBitsBound = true; } } } StaticString questLocationType = base.PointOfInterest.SimulationObject.GetDescriptorNameFromType("QuestLocationType"); if (questLocationType == "QuestLocationTypeTemple") { this.sensibleToEndlessDay = true; DownloadableContent8.EndlessDay.ActivationChange += this.EndlessDay_ActivationChange; SeasonManager.DustDepositsToggle += this.DustDepositsToggle; } if (base.PointOfInterest is IWorldEntityMappingOverride) { ((IWorldEntityMappingOverride)base.PointOfInterest).TryResolve(out this.interpreterContext); } if (this.interpreterContext == null) { this.interpreterContext = new InterpreterContext(base.PointOfInterest); } this.RefreshVFXEffects(); } } } yield break; }
private void RefreshVisibility() { Diagnostics.Assert(this.majorEmpires != null); for (int i = 0; i < this.majorEmpires.Length; i++) { Diagnostics.Assert(this.empireExplorationBits != null && this.empireVibilityBits != null && this.lastEmpireExplorationBits != null); Diagnostics.Assert(this.empireDetectionBits != null); this.lastEmpireExplorationBits[i] = this.empireExplorationBits[i]; this.empireExplorationBits[i] = this.majorEmpires[i].Bits; this.empireVibilityBits[i] = this.majorEmpires[i].Bits; this.empireDetectionBits[i] = this.majorEmpires[i].Bits; DepartmentOfForeignAffairs agency = this.majorEmpires[i].GetAgency <DepartmentOfForeignAffairs>(); for (int j = 0; j < this.majorEmpires.Length; j++) { if (j != i) { bool flag = false; bool flag2 = false; bool flag3 = false; DepartmentOfScience agency2 = this.majorEmpires[j].GetAgency <DepartmentOfScience>(); Diagnostics.Assert(agency2 != null); if (agency2.GetTechnologyState(this.technologyDefinitionDrakkenEndQuestReward) == DepartmentOfScience.ConstructibleElement.State.Researched) { flag2 = true; flag3 = true; } else if (agency2.GetTechnologyState(this.technologyDefinitionDrakkenVisionDuringFirstTurn) == DepartmentOfScience.ConstructibleElement.State.Researched && base.Game.Turn == 0) { flag2 = true; flag = true; flag3 = true; } DiplomaticRelation diplomaticRelation = agency.GetDiplomaticRelation(this.majorEmpires[j]); if (diplomaticRelation != null) { flag |= (diplomaticRelation.HasActiveAbility(DiplomaticAbilityDefinition.MapExchange) || (ELCPUtilities.SpectatorMode && this.majorEmpires[j].ELCPIsEliminated)); flag2 |= diplomaticRelation.HasActiveAbility(DiplomaticAbilityDefinition.VisionExchange); } if (this.EnableDetection) { StaticString tag = this.stealVisionFromEmpireTags[i]; if (this.majorEmpires[j].SimulationObject.Tags.Contains(tag)) { flag2 = true; flag3 = true; } } if (flag2) { this.empireVibilityBits[i] |= this.majorEmpires[j].Bits; } if (flag) { this.empireExplorationBits[i] |= this.majorEmpires[j].Bits; } if (flag3) { this.empireDetectionBits[i] |= this.majorEmpires[j].Bits; } if (flag2 || flag || flag3) { if ((this.NeedRefreshBits & this.majorEmpires[j].Bits) != 0) { this.NeedRefreshBits |= 1 << i; } if ((this.NeedRefreshBits & this.majorEmpires[i].Bits) != 0) { this.NeedRefreshBits |= 1 << j; } } } } } for (int k = 0; k < this.majorEmpires.Length; k++) { MajorEmpire majorEmpire = this.majorEmpires[k]; Diagnostics.Assert(this.empireExplorationBits != null && this.lastEmpireExplorationBits != null); if (this.lastEmpireExplorationBits[k] != this.empireExplorationBits[k]) { Diagnostics.Assert(this.explorationMap != null && this.explorationMap.Data != null); for (int l = 0; l < this.explorationMap.Data.Length; l++) { if ((this.explorationMap.Data[l] & (short)majorEmpire.Bits) != 0) { short[] data = this.explorationMap.Data; int num = l; int num2 = num; data[num2] |= (short)this.empireExplorationBits[k]; } } } } short num3 = Convert.ToInt16(~this.NeedRefreshBits); for (int m = 0; m < this.publicVisibilityMap.Data.Length; m++) { short[] data2 = this.publicVisibilityMap.Data; int num4 = m; int num5 = num4; data2[num5] &= num3; short[] data3 = this.privateVisibilityMap.Data; int num6 = m; int num7 = num6; data3[num7] &= num3; if (this.EnableDetection) { short[] data4 = this.publicDetectionMap.Data; int num8 = m; int num9 = num8; data4[num9] &= num3; short[] data5 = this.privateDetectionMap.Data; int num10 = m; int num11 = num10; data5[num11] &= num3; } } for (int n = 0; n < this.gameEntities.Count; n++) { this.RefreshLineOfSight(this.gameEntities[n], this.NeedRefreshBits); } for (int num12 = 0; num12 < this.visibilityProviders.Count; num12++) { this.RefreshLineOfSight(this.visibilityProviders[num12], this.NeedRefreshBits); } this.NeedRefreshBits = 0; }
private WorldPosition CheckMetting(global::Empire empireA, global::Empire empireB) { Diagnostics.Assert(empireA != null && empireB != null); if (empireA.Index == empireB.Index) { return(WorldPosition.Invalid); } DepartmentOfForeignAffairs agency = empireA.GetAgency <DepartmentOfForeignAffairs>(); Diagnostics.Assert(agency != null); DiplomaticRelation diplomaticRelation = agency.GetDiplomaticRelation(empireB); if (diplomaticRelation == null || diplomaticRelation.State == null || diplomaticRelation.State.Name != DiplomaticRelationState.Names.Unknown) { return(WorldPosition.Invalid); } DepartmentOfDefense agency2 = empireB.GetAgency <DepartmentOfDefense>(); DepartmentOfTheInterior agency3 = empireB.GetAgency <DepartmentOfTheInterior>(); DepartmentOfScience agency4 = empireA.GetAgency <DepartmentOfScience>(); Diagnostics.Assert(agency4 != null); if (agency2 != null && agency3 != null && agency4.GetTechnologyState(this.technologyDefinitionDrakkenVisionDuringFirstTurn) == DepartmentOfScience.ConstructibleElement.State.Researched) { WorldPosition worldPosition = WorldPosition.Invalid; if (agency3.Cities.Count > 0) { worldPosition = agency3.Cities[0].WorldPosition; } else if (agency2.Armies.Count > 0) { worldPosition = agency2.Armies[0].WorldPosition; } if (worldPosition != WorldPosition.Invalid) { return(worldPosition); } } if (agency2 != null) { ReadOnlyCollection <Army> armies = agency2.Armies; for (int i = 0; i < armies.Count; i++) { Army army = armies[i]; if (!army.IsPrivateers) { if (this.visibilityService.IsWorldPositionVisibleFor(army.WorldPosition, empireA)) { if (!army.IsCamouflaged || this.visibilityService.IsWorldPositionDetectedFor(army.WorldPosition, empireA)) { return(army.WorldPosition); } } } } } if (agency3 != null) { ReadOnlyCollection <City> cities = agency3.Cities; for (int j = 0; j < cities.Count; j++) { ReadOnlyCollection <District> districts = cities[j].Districts; for (int k = 0; k < districts.Count; k++) { if (this.visibilityService.IsWorldPositionVisibleFor(districts[k].WorldPosition, empireA)) { return(districts[k].WorldPosition); } } } } if (agency3 != null) { MajorEmpire majorEmpire = empireB as MajorEmpire; if (majorEmpire != null) { for (int l = 0; l < majorEmpire.ConvertedVillages.Count; l++) { if (this.visibilityService.IsWorldPositionVisibleFor(majorEmpire.ConvertedVillages[l].WorldPosition, empireA)) { return(majorEmpire.ConvertedVillages[l].WorldPosition); } } } } if (agency3 != null) { for (int m = 0; m < agency3.OccupiedFortresses.Count; m++) { if (this.visibilityService.IsWorldPositionVisibleFor(agency3.OccupiedFortresses[m].WorldPosition, empireA)) { return(agency3.OccupiedFortresses[m].WorldPosition); } } } if (agency3 != null) { for (int n = 0; n < agency3.Camps.Count; n++) { if (this.visibilityService.IsWorldPositionVisibleFor(agency3.Camps[n].WorldPosition, empireA)) { return(agency3.Camps[n].WorldPosition); } } } if (agency3 != null) { for (int num = 0; num < agency3.TamedKaijuGarrisons.Count; num++) { if (this.visibilityService.IsWorldPositionVisibleFor(agency3.TamedKaijuGarrisons[num].WorldPosition, empireA)) { return(agency3.TamedKaijuGarrisons[num].WorldPosition); } } } return(WorldPosition.Invalid); }
public void SetupTechnology(global::Empire empire, TechnologyDefinition technologyDefinition, GameObject client) { this.empire = empire; this.TechnologyDefinition = technologyDefinition; this.selectionClient = client; if (this.TagsList == null) { this.TagsList = new List <string>(); } else { this.TagsList.Clear(); } if (this.empire == null) { return; } this.BuildTags(); if (technologyDefinition.HasTechnologyFlag(DepartmentOfScience.ConstructibleElement.TechnologyFlag.Quest)) { this.EraLabel.Text = string.Empty; AgePrimitiveLabel eraLabel = this.EraLabel; eraLabel.Text += (char)this.QuestCharNumber; } else if (technologyDefinition.HasTechnologyFlag(DepartmentOfScience.ConstructibleElement.TechnologyFlag.Medal)) { this.EraLabel.Text = string.Empty; AgePrimitiveLabel eraLabel2 = this.EraLabel; eraLabel2.Text += (char)this.MedalCharNumber; } else if (technologyDefinition.HasTechnologyFlag(DepartmentOfScience.ConstructibleElement.TechnologyFlag.Affinity)) { this.EraLabel.Text = string.Empty; AgePrimitiveLabel eraLabel3 = this.EraLabel; eraLabel3.Text += GuiEmpire.GetFactionSymbolString(this.empire, this.empire); } else if (technologyDefinition.HasTechnologyFlag(DepartmentOfScience.ConstructibleElement.TechnologyFlag.OrbUnlock)) { this.EraLabel.Text = string.Empty; } else if (technologyDefinition.HasTechnologyFlag(DepartmentOfScience.ConstructibleElement.TechnologyFlag.KaijuUnlock)) { this.EraLabel.Text = string.Empty; } else { int technologyEraNumber = DepartmentOfScience.GetTechnologyEraNumber(technologyDefinition); if (technologyEraNumber > 0) { this.EraLabel.Text = AgeUtils.ToRoman(technologyEraNumber); } else { this.EraLabel.Text = "-"; } } this.GlowImage.AgeTransform.Visible = false; IDownloadableContentService service = Services.GetService <IDownloadableContentService>(); if (service != null && service.IsShared(DownloadableContent9.ReadOnlyName) && technologyDefinition.HasTechnologyFlag(DepartmentOfScience.ConstructibleElement.TechnologyFlag.Unique)) { this.GlowImage.AgeTransform.Visible = true; } if (this.UnlockImage != null) { this.UnlockImage.Image = DepartmentOfScience.GetTechnologyImage(technologyDefinition, global::GuiPanel.IconSize.Small); } this.CategoryIcon.Image = DepartmentOfScience.GetCategoryIcon(technologyDefinition, global::GuiPanel.IconSize.Small); this.CategoryFullIcon.Image = this.CategoryIcon.Image; if (this.SubCategoryIcon.Image != null) { this.CategoryIcon.AgeTransform.PixelOffsetLeft = -this.CategoryIcon.AgeTransform.Width; this.CategoryFullIcon.AgeTransform.PixelOffsetLeft = -this.CategoryFullIcon.AgeTransform.Width; } else { this.CategoryIcon.AgeTransform.PixelOffsetLeft = -(0.5f * this.CategoryIcon.AgeTransform.Width); this.CategoryFullIcon.AgeTransform.PixelOffsetLeft = -(0.5f * this.CategoryFullIcon.AgeTransform.Width); } this.SubCategoryIcon.Image = DepartmentOfScience.GetSubCategoryIcon(technologyDefinition, global::GuiPanel.IconSize.Small); this.SubCategoryFullIcon.Image = this.SubCategoryIcon.Image; DepartmentOfScience.BuildTechnologyTooltip(technologyDefinition, this.empire, this.AgeTransform.AgeTooltip, MultipleConstructibleTooltipData.TechnologyState.Normal); this.InProgressSector.TintColor = this.InProgressColor; this.MarkupGroup.Visible = false; DepartmentOfScience agency = empire.GetAgency <DepartmentOfScience>(); DepartmentOfScience.ConstructibleElement.State technologyState = agency.GetTechnologyState(technologyDefinition); this.Refresh(empire, technologyState); }
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)); } }
protected override void EvaluateNeeds(StaticString context, StaticString pass) { base.EvaluateNeeds(context, pass); if (!this.CanUseAltar()) { return; } if (!this.seasonService.IsAlive || this.seasonService.Target == null) { return; } Season winterSeason = this.seasonService.Target.GetWinterSeason(); if (this.seasonService.Target.IsCurrentSeason(winterSeason)) { return; } global::Game game = Services.GetService <IGameService>().Game as global::Game; List <SeasonEffect> candidateEffectsForSeasonType = this.seasonService.Target.GetCandidateEffectsForSeasonType(Season.ReadOnlyWinter); Diagnostics.Assert(this.elementEvaluator != null); this.decisions.Clear(); this.RegisterInterpreterContextData(); if (Amplitude.Unity.Framework.Application.Preferences.EnableModdingTools) { EvaluationData <SeasonEffect, InterpreterContext> evaluationData = new EvaluationData <SeasonEffect, InterpreterContext>(); this.elementEvaluator.Evaluate(candidateEffectsForSeasonType, ref this.decisions, evaluationData); evaluationData.Turn = game.Turn; this.SeasonEffectsEvaluationDataHistoric.Add(evaluationData); } else { this.elementEvaluator.Evaluate(candidateEffectsForSeasonType, ref this.decisions, null); } if (this.decisions.Count <= 0) { return; } int num = 0; int num2 = 0; for (int i = 0; i < candidateEffectsForSeasonType.Count; i++) { SeasonEffect seasonEffect = candidateEffectsForSeasonType[i]; int seasonEffectDisplayedScoreForEmpire = this.seasonService.Target.GetSeasonEffectDisplayedScoreForEmpire(base.AIEntity.Empire, seasonEffect); if (seasonEffectDisplayedScoreForEmpire > num) { num = seasonEffectDisplayedScoreForEmpire; num2 = 1; } else if (seasonEffectDisplayedScoreForEmpire == num) { num2++; } } DecisionResult decisionResult = this.decisions[0]; float score = decisionResult.Score; float score2 = this.decisions[this.decisions.Count - 1].Score; float num3 = score - score2; num3 = Mathf.Clamp01(num3 / this.maximumGainFromXml); SeasonEffect seasonEffect2 = decisionResult.Element as SeasonEffect; Diagnostics.Assert(seasonEffect2 != null); int seasonEffectScore = this.seasonService.Target.GetSeasonEffectScore(seasonEffect2); if (seasonEffectScore == num && num2 == 1) { return; } int neededVoteCount = num - seasonEffectScore + 1; List <EvaluableMessage_VoteForSeasonEffect> list = new List <EvaluableMessage_VoteForSeasonEffect>(base.AIEntity.AIPlayer.Blackboard.GetMessages <EvaluableMessage_VoteForSeasonEffect>(BlackboardLayerID.Empire, (EvaluableMessage_VoteForSeasonEffect message) => message.EvaluationState != EvaluableMessage.EvaluableMessageState.Obtained && message.EvaluationState != EvaluableMessage.EvaluableMessageState.Cancel)); EvaluableMessage_VoteForSeasonEffect evaluableMessage_VoteForSeasonEffect; if (list.Count == 0) { evaluableMessage_VoteForSeasonEffect = new EvaluableMessage_VoteForSeasonEffect(seasonEffect2.SeasonEffectDefinition.Name, 1, AILayer_AccountManager.OrbAccountName); base.AIEntity.AIPlayer.Blackboard.AddMessage(evaluableMessage_VoteForSeasonEffect); } else { evaluableMessage_VoteForSeasonEffect = list[0]; if (seasonEffect2.SeasonEffectDefinition.Name != evaluableMessage_VoteForSeasonEffect.SeasonEffectReference) { Diagnostics.Log("AI don't want to vote for the season effect {0} anymore. AI now wants season effect {1}.", new object[] { evaluableMessage_VoteForSeasonEffect.SeasonEffectReference, seasonEffect2.SeasonEffectDefinition.Name }); evaluableMessage_VoteForSeasonEffect.Cancel(); evaluableMessage_VoteForSeasonEffect = new EvaluableMessage_VoteForSeasonEffect(seasonEffect2.SeasonEffectDefinition.Name, 1, AILayer_AccountManager.OrbAccountName); base.AIEntity.AIPlayer.Blackboard.AddMessage(evaluableMessage_VoteForSeasonEffect); } } float num4 = this.seasonService.Target.ComputePrayerOrbCost(base.AIEntity.Empire); float num5 = 10f * base.AIEntity.Empire.GetPropertyValue(SimulationProperties.GameSpeedMultiplier); int num6 = this.seasonService.Target.GetExactSeasonStartTurn(winterSeason) - game.Turn; float num7 = Mathf.Clamp01((num5 - (float)num6) / num5); float num8 = num3 * (0.5f + num7 / 2f); num8 = Mathf.Clamp01(num8); int num9 = this.ComputeWantedNumberOfOrbs(neededVoteCount); DepartmentOfScience agency = base.AIEntity.Empire.GetAgency <DepartmentOfScience>(); float num10 = 0f; float num11 = 0f; for (int j = 0; j < this.orbUnlockDefinitions.Length; j++) { TechnologyDefinition technologyDefinition = this.orbUnlockDefinitions[j]; if (DepartmentOfTheTreasury.CheckConstructiblePrerequisites(base.AIEntity.Empire, technologyDefinition, new string[] { ConstructionFlags.Prerequisite })) { DepartmentOfScience.ConstructibleElement.State technologyState = agency.GetTechnologyState(technologyDefinition); if (technologyState != DepartmentOfScience.ConstructibleElement.State.Researched && technologyState != DepartmentOfScience.ConstructibleElement.State.NotAvailable) { num11 += 1f; } else if (technologyState == DepartmentOfScience.ConstructibleElement.State.Researched) { num10 += 1f; } } } float num12 = num11 / (num11 + num10); num12 = Mathf.Min(1f, Mathf.Max(0f, 2f * num12 - 0.6f)); if (Amplitude.Unity.Framework.Application.Preferences.EnableModdingTools) { Diagnostics.Log("[ELCP: AILayer_Altar] {0} has reasearched {1} of {2} Orb Techs", new object[] { base.AIEntity.Empire, num10, num11 + num10 }); Diagnostics.Log("... Season Effect Voting score altered from {0} to {1}", new object[] { num8, num8 * num12 }); } evaluableMessage_VoteForSeasonEffect.VoteCount = num9; evaluableMessage_VoteForSeasonEffect.Refresh(0.5f, num8 * num12, (float)num9 * num4, int.MaxValue); }