public void SetContent(SpellDefinition spellDefinition, Empire empire, GameObject client, bool isInTargetingPhase, bool thereAlreadyIsASpellCasted, Encounter encounter) { if (empire == null) { return; } this.SpellDefinition = spellDefinition; this.Empire = empire; this.client = client; this.ShowIcon(); this.AgeTransform.AgeTooltip.Content = this.SpellDefinition.Name; this.AgeTransform.AgeTooltip.Class = "Spell"; this.AgeTransform.AgeTooltip.ClientData = new SpellDefinitionTooltipData(this.Empire, this.Empire, this.SpellDefinition, encounter); bool enable; if (!isInTargetingPhase) { enable = false; } else if (thereAlreadyIsASpellCasted) { enable = false; } else { DepartmentOfTheTreasury agency = this.Empire.GetAgency <DepartmentOfTheTreasury>(); ConstructionResourceStock[] array; enable = (!ELCPUtilities.SpellUsage_HasSpellBeenUsed(encounter.GUID, empire.Index, spellDefinition.Name) && agency.GetInstantConstructionResourceCostForBuyout(empire, spellDefinition, out array)); } this.AgeTransform.Enable = enable; }
protected override State Execute(AIBehaviorTree aiBehaviorTree, params object[] parameters) { Army army; if (base.GetArmyUnlessLocked(aiBehaviorTree, "$Army", out army) > AIArmyMission.AIArmyMissionErrorCode.None) { return(State.Failure); } global::Empire empire = aiBehaviorTree.AICommander.Empire; if (empire == null || !(empire is MajorEmpire)) { aiBehaviorTree.ErrorCode = 10; return(State.Failure); } if (!army.Empire.SimulationObject.Tags.Contains("FactionTraitAffinityStrategic") || !army.Empire.SimulationObject.Tags.Contains("BoosterTeleport") || army.HasSeafaringUnits() || army.GetPropertyValue(SimulationProperties.Movement) < 0.1f || army.IsSolitary || !ELCPUtilities.CheckCooldownPrerequisites(army)) { return(State.Failure); } if (string.IsNullOrEmpty(this.TargetVarName)) { return(State.Failure); } IGameEntity gameEntity = aiBehaviorTree.Variables[this.TargetVarName] as IGameEntity; if (!(gameEntity is City)) { return(State.Failure); } if (ELCPUtilities.CanTeleportToCity(gameEntity as City, army, this.worldPositionningService.GetRegion(army.WorldPosition), this.worldPositionningService, null)) { return(State.Success); } return(State.Failure); }
public static bool TryGetFirstNodeOfType <T>(BehaviourTreeNodeController controller, out T Node) { foreach (BehaviourTreeNode behaviourTreeNode in controller.Children) { if (behaviourTreeNode is T) { Node = (T)((object)behaviourTreeNode); return(true); } if (behaviourTreeNode is BehaviourTreeNodeController) { T t = default(T); if (ELCPUtilities.TryGetFirstNodeOfType <T>(behaviourTreeNode as BehaviourTreeNodeController, out t)) { Node = t; return(true); } } if (behaviourTreeNode is QuestBehaviourTreeNode_Decorator_InteractWith) { foreach (QuestBehaviourTreeNode_ConditionCheck questBehaviourTreeNode_ConditionCheck in (behaviourTreeNode as QuestBehaviourTreeNode_Decorator_InteractWith).ConditionChecks) { if (questBehaviourTreeNode_ConditionCheck is T) { Node = (T)((object)questBehaviourTreeNode_ConditionCheck); return(true); } } } } Node = default(T); return(false); }
private bool IsKaijuValidForTame(Army army, Kaiju kaiju, ref List <StaticString> failureFlags, bool checkNearbyKaijus = true) { if (army == null || kaiju == null) { failureFlags.Add(ArmyAction.NoCanDoWhileHidden); return(false); } if (checkNearbyKaijus && !this.IsKaijuNearby(kaiju, army)) { failureFlags.Add(ArmyAction.NoCanDoWhileHidden); return(false); } if (kaiju.IsTamed()) { failureFlags.Add(ArmyAction.NoCanDoWhileHidden); return(false); } if (kaiju.IsStunned()) { failureFlags.Add(ArmyAction.NoCanDoWhileHidden); return(false); } if (ELCPUtilities.UseELCPSymbiosisBuffs && !ELCPUtilities.CanELCPTameKaiju(kaiju, this.TameCost, army.Empire)) { failureFlags.Add(ArmyAction.NoCanDoWhileCannotAffordCosts); return(false); } return(true); }
protected override void OnGameLobbyJoinRequested(object sender, SteamGameLobbyJoinRequestedEventArgs e) { base.OnGameLobbyJoinRequested(sender, e); if (new Steamworks.SteamID(e.Message.m_steamIDLobby).IsValid) { ELCPUtilities.SteamMatchMaking_TryConnectingToLobby(e.Message.m_steamIDLobby); } }
public static void SetupELCPSettings() { Diagnostics.Log("Setting up ELCP settings ..."); ELCPUtilities.ELCPVerboseMode = false; Diagnostics.Log("ELCP Vebosemode is {0}", new object[] { ELCPUtilities.ELCPVerboseMode }); ISessionService service = Services.GetService <ISessionService>(); Diagnostics.Assert(service != null); ELCPUtilities.AddGlobalTags(service); ELCPUtilities.ELCPShackleAI = ELCPUtilities.SetupELCPOption <bool>("ShackleAI", service, false); ELCPUtilities.UseELCPPeacePointRulseset = ELCPUtilities.SetupELCPOption <bool>("PeacePointRulseset", service, true); ELCPUtilities.UseELCPFortificationPointRuleset = (ELCPUtilities.SetupELCPOption <string>("FortificationRules", service, "Vanilla") == "ELCP"); ELCPUtilities.UseELCPCityFoundingRuleset = ELCPUtilities.SetupELCPOption <bool>("WeakerCityFoundings", service, true); ELCPUtilities.UseELCPStockpileRulseset = (ELCPUtilities.SetupELCPOption <string>("StockpileRules", service, "Vanilla") == "ELCP"); ELCPUtilities.UseELCPBlackspotRuleset = ELCPUtilities.SetupELCPOption <bool>("BlackspotRules", service, true); ELCPUtilities.UseELCPPeacefulCreepingNodes = ELCPUtilities.SetupELCPOption <bool>("PeacefulBlooms", service, true); ELCPUtilities.FOWUpdateFrames = ELCPUtilities.SetupELCPOption <ushort>("FOWUpdateSpeed", service, 1); if (service.Session.SessionMode == SessionMode.Single) { ELCPUtilities.UseXumukMPBattleRules = false; ELCPUtilities.SpectatorMode = false; } else { ELCPUtilities.UseXumukMPBattleRules = (ELCPUtilities.SetupELCPOption <string>("XumukMPBattleRules", service, "Vanilla") == "Xumuk"); ELCPUtilities.SpectatorMode = ELCPUtilities.SetupELCPOption <bool>("SpectatorMode", service, false); } string text = ELCPUtilities.SetupELCPOption <string>("ArmySpeedScaleFactor", service, "Vanilla"); double elcparmySpeedScaleFactor = 1.0; if (text == "Vanilla" || !double.TryParse(text, out elcparmySpeedScaleFactor)) { ELCPUtilities.ELCPArmySpeedScaleFactor = 1.0; } else { ELCPUtilities.ELCPArmySpeedScaleFactor = elcparmySpeedScaleFactor; } ELCPUtilities.UseELCPSymbiosisBuffs = ELCPUtilities.SetupELCPRegistrySetting <bool>("ELCP/UseELCPSymbiosisBuffs", true); ELCPUtilities.UseELCPUnitSelling = ELCPUtilities.SetupELCPRegistrySetting <bool>("ELCP/UnitSellingInOwnedTerritoryOnly", false); ELCPUtilities.GeomancyRadius = ELCPUtilities.SetupELCPRegistrySetting <int>("ELCP/GeomancyRadius", 1); ELCPUtilities.GeomancyDuration = ELCPUtilities.SetupELCPRegistrySetting <int>("ELCP/GeomancyDuration", 1); ELCPUtilities.SpectatorSpyFocus = -1; }
protected override State Execute(AIBehaviorTree aiBehaviorTree, params object[] parameters) { Army army; if (base.GetArmyUnlessLocked(aiBehaviorTree, "$Army", out army) != AIArmyMission.AIArmyMissionErrorCode.None) { return(State.Failure); } ArmyAction armyAction = null; IDatabase <ArmyAction> database = Databases.GetDatabase <ArmyAction>(false); if (database == null || !database.TryGetValue(this.ArmyActionReadOnlyName, out armyAction)) { return(State.Failure); } bool flag = false; ArmyAction_TameUnstunnedKaiju armyAction_TameUnstunnedKaiju = armyAction as ArmyAction_TameUnstunnedKaiju; if (ELCPUtilities.UseELCPSymbiosisBuffs && armyAction_TameUnstunnedKaiju != null && this.TargetVarName != string.Empty) { Kaiju kaiju = (aiBehaviorTree.Variables[this.TargetVarName] as IGameEntity) as Kaiju; if (kaiju != null) { flag = ELCPUtilities.CanELCPTameKaiju(kaiju, armyAction_TameUnstunnedKaiju.TameCost, army.Empire); } } else { flag = armyAction.CanAfford(army.Empire); } if (flag) { if (aiBehaviorTree.Variables.ContainsKey(this.Output_ArmyActionVarName)) { aiBehaviorTree.Variables[this.Output_ArmyActionVarName] = this.ArmyActionReadOnlyName; } else { aiBehaviorTree.Variables.Add(this.Output_ArmyActionVarName, this.ArmyActionReadOnlyName); } return(State.Success); } aiBehaviorTree.ErrorCode = 38; return(State.Failure); }
public static bool TryGetNodeOfType <T>(BehaviourTreeNodeController controller, out T Node, ref int startvalue, int position = 1) { if (position >= 1 && startvalue < position) { foreach (BehaviourTreeNode behaviourTreeNode in controller.Children) { if (behaviourTreeNode is T) { startvalue++; if (startvalue == position) { Node = (T)((object)behaviourTreeNode); return(true); } } if (behaviourTreeNode is BehaviourTreeNodeController) { T t = default(T); if (ELCPUtilities.TryGetNodeOfType <T>(behaviourTreeNode as BehaviourTreeNodeController, out t, ref startvalue, position)) { Node = t; return(true); } } if (behaviourTreeNode is QuestBehaviourTreeNode_Decorator_InteractWith) { foreach (QuestBehaviourTreeNode_ConditionCheck questBehaviourTreeNode_ConditionCheck in (behaviourTreeNode as QuestBehaviourTreeNode_Decorator_InteractWith).ConditionChecks) { if (questBehaviourTreeNode_ConditionCheck is T) { startvalue++; if (startvalue == position) { Node = (T)((object)questBehaviourTreeNode_ConditionCheck); return(true); } } } } } } Node = default(T); return(false); }
protected override IEnumerator OnShow(params object[] parameters) { SpellDefinitionTooltipData spellDefinitionTooltipData = null; if (this.context is SpellDefinitionTooltipData) { spellDefinitionTooltipData = (this.context as SpellDefinitionTooltipData); } this.Title.Text = string.Empty; if (spellDefinitionTooltipData != null) { if (!this.IsInTargeting(spellDefinitionTooltipData)) { this.Title.Text = AgeLocalizer.Instance.LocalizeString("%SpellWaitForTargetingPhase"); } else if (ELCPUtilities.SpellUsage_HasSpellBeenUsed(spellDefinitionTooltipData.Encounter.GUID, spellDefinitionTooltipData.Empire.Index, spellDefinitionTooltipData.SpellDefinition.Name)) { this.Title.Text = AgeLocalizer.Instance.LocalizeString("%SpellActive"); } else { bool flag = false; if (this.IsSpellAlreadyCasted(spellDefinitionTooltipData, ref flag)) { if (flag) { this.Title.Text = AgeLocalizer.Instance.LocalizeString("%SpellActive"); } else { this.Title.Text = AgeLocalizer.Instance.LocalizeString("%SpellWaitForEndOfCurrentSpell"); } } else { this.Title.Text = AgeLocalizer.Instance.LocalizeString("%SpellClickToCast"); } } } yield return(base.OnShow(parameters)); yield break; }
public override void Begin(params object[] parameters) { base.Begin(parameters); this.viewService = Services.GetService <Amplitude.Unity.View.IViewService>(); if (this.viewService != null) { this.viewService.PostViewChange(typeof(OutGameView), parameters); } if (AgeLocalizer.Instance != null) { this.SetRichPresenceStatus(); } else { this.guiService = Services.GetService <Amplitude.Unity.Gui.IGuiService>(); Diagnostics.Assert(this.guiService != null); this.guiService.GuiSceneStateChange += this.IGuiService_GuiSceneStateChange; } if (parameters.Length == 1 && parameters[0] is ulong && new Steamworks.SteamID((ulong)parameters[0]).IsValid) { ELCPUtilities.SteamMatchMaking_TryConnectingToLobby((ulong)parameters[0]); } }
public override bool IsMissionFinished(bool forceStop) { if (!this.aiDataRepository.IsGUIDValid(base.ForceArmyGUID)) { return(true); } Army army = null; bool flag = false; Comparison <PointOfInterest> < > 9__0; for (int i = 0; i < this.pointOfInterests.Count; i++) { if (ELCPUtilities.CanSearch(base.Empire, this.pointOfInterests[0], this.questManagementService, this.questRepositoryService) && this.departmentOfForeignAffairs.CanMoveOn(this.pointOfInterests[0].Region.Index, false)) { return(false); } this.pointOfInterests.RemoveAt(i); if (!flag) { if (!this.gameEntityRepositoryService.TryGetValue <Army>(base.ForceArmyGUID, out army)) { return(true); } flag = true; } List <PointOfInterest> list = this.pointOfInterests; Comparison <PointOfInterest> comparison; if ((comparison = < > 9__0) == null) { comparison = (< > 9__0 = ((PointOfInterest left, PointOfInterest right) => this.worldPositionningService.GetDistance(left.WorldPosition, army.WorldPosition).CompareTo(this.worldPositionningService.GetDistance(right.WorldPosition, army.WorldPosition)))); } list.Sort(comparison); i--; } return(true); }
protected override State Execute(AIBehaviorTree aiBehaviorTree, params object[] parameters) { Army army; if (base.GetArmyUnlessLocked(aiBehaviorTree, "$Army", out army) != AIArmyMission.AIArmyMissionErrorCode.None) { return(State.Failure); } if (this.currentTicket != null) { if (!this.currentTicket.Raised) { return(State.Running); } bool flag = this.currentTicket.PostOrderResponse == PostOrderResponse.PreprocessHasFailed || this.currentTicket.PostOrderResponse == PostOrderResponse.AuthenticationHasFailed; this.currentTicket = null; if (flag) { aiBehaviorTree.ErrorCode = 1; return(State.Failure); } return(State.Success); } else { if (!aiBehaviorTree.Variables.ContainsKey(this.DestinationVarName)) { aiBehaviorTree.LogError("{0} not set", new object[] { this.DestinationVarName }); return(State.Failure); } City city = (City)aiBehaviorTree.Variables[this.DestinationVarName]; ArmyAction armyAction = null; if (city != null) { if (!ELCPUtilities.CanTeleportToCity(city, army, this.worldPositionningService.GetRegion(army.WorldPosition), this.worldPositionningService, this.encounterRepositoryService)) { return(State.Failure); } List <ArmyAction> list = new List <ArmyAction>(new List <ArmyAction>(Databases.GetDatabase <ArmyAction>(false).GetValues()).FindAll((ArmyAction match) => match is ArmyAction_Teleport)); List <StaticString> list2 = new List <StaticString>(); for (int i = 0; i < list.Count; i++) { if (list[i].CanExecute(army, ref list2, new object[0])) { armyAction = list[i]; break; } } if (armyAction != null) { armyAction.Execute(army, aiBehaviorTree.AICommander.Empire.PlayerControllers.AI, out this.currentTicket, null, new object[] { city }); return(State.Running); } } Diagnostics.LogError("ELCP: AIBehaviorTreeNode_Action_TeleportToCity failed for {0}/{1} {5} -> {6}, {2} {3} {4}", new object[] { army.LocalizedName, army.Empire, army.GetPropertyBaseValue(SimulationProperties.Movement), city != null, armyAction != null, army.WorldPosition, (city != null) ? city.WorldPosition.ToString() : "null" }); return(State.Failure); } }
protected override void RefreshObjectives(StaticString context, StaticString pass) { base.RefreshObjectives(context, pass); base.GatherObjectives(AICommanderMissionDefinition.AICommanderCategory.Pacification.ToString(), false, ref this.globalObjectiveMessages); base.ValidateMessages(ref this.globalObjectiveMessages); base.GatherObjectives(AICommanderMissionDefinition.AICommanderCategory.Colonization.ToString(), ref this.colonizationObjectives); this.colonizationObjectives.Sort((GlobalObjectiveMessage left, GlobalObjectiveMessage right) => - 1 * left.LocalPriority.CompareTo(right.LocalPriority)); List <int> list = new List <int>(); for (int l = 0; l < this.colonizationObjectives.Count; l++) { int regionIndex = this.colonizationObjectives[l].RegionIndex; list.Add(this.colonizationObjectives[l].RegionIndex); if (this.globalObjectiveMessages.Find((GlobalObjectiveMessage match) => match.RegionIndex == regionIndex) == null && AILayer_Pacification.RegionContainsHostileArmies(base.AIEntity.Empire, regionIndex)) { GlobalObjectiveMessage item = base.GenerateObjective(regionIndex); this.globalObjectiveMessages.Add(item); } } for (int j = 0; j < this.departmentOfTheInterior.Cities.Count; j++) { int regionIndex = this.departmentOfTheInterior.Cities[j].Region.Index; list.AddOnce(this.departmentOfTheInterior.Cities[j].Region.Index); if (this.globalObjectiveMessages.Find((GlobalObjectiveMessage match) => match.RegionIndex == regionIndex) == null && AILayer_Pacification.RegionContainsHostileArmies(base.AIEntity.Empire, regionIndex)) { GlobalObjectiveMessage item2 = base.GenerateObjective(regionIndex); this.globalObjectiveMessages.Add(item2); } } this.ComputeObjectivePriority(); if (this.questManagementService.IsQuestRunningForEmpire("VictoryQuest-Chapter2", base.AIEntity.Empire)) { QuestBehaviour questBehaviour = this.questRepositoryService.GetQuestBehaviour("VictoryQuest-Chapter2", base.AIEntity.Empire.Index); QuestBehaviourTreeNode_Action_SpawnArmy questBehaviourTreeNode_Action_SpawnArmy; if (questBehaviour != null && ELCPUtilities.TryGetFirstNodeOfType <QuestBehaviourTreeNode_Action_SpawnArmy>(questBehaviour.Root as BehaviourTreeNodeController, out questBehaviourTreeNode_Action_SpawnArmy)) { Region region = this.worldPositionningService.GetRegion(questBehaviourTreeNode_Action_SpawnArmy.SpawnLocations[0]); int regionIndex = region.Index; GlobalObjectiveMessage globalObjectiveMessage = this.globalObjectiveMessages.Find((GlobalObjectiveMessage match) => match.RegionIndex == regionIndex); list.AddOnce(regionIndex); if (globalObjectiveMessage == null && AILayer_Pacification.RegionContainsHostileArmies(base.AIEntity.Empire, regionIndex) && (region.City == null || region.City.Empire == base.AIEntity.Empire)) { globalObjectiveMessage = base.GenerateObjective(regionIndex); this.globalObjectiveMessages.Add(globalObjectiveMessage); } if (globalObjectiveMessage != null) { globalObjectiveMessage.GlobalPriority.Value = 1f; globalObjectiveMessage.LocalPriority.Value = 1f; } } } float value = 0.9f; if (this.departmentOfForeignAffairs.IsInWarWithSomeone()) { value = 0.7f; } int i; Predicate <GlobalObjectiveMessage> < > 9__4; int i2; for (i = 0; i < this.QuestBTPacifications.Count; i = i2 + 1) { if (!this.questManagementService.IsQuestRunningForEmpire(this.QuestBTPacifications[i].questName, base.AIEntity.Empire)) { this.QuestBTPacifications.RemoveAt(i); i2 = i; i = i2 - 1; } else if (!list.Contains(this.QuestBTPacifications[i].regionIndex)) { Region region2 = this.worldPositionningService.GetRegion(this.QuestBTPacifications[i].regionIndex); if (region2.Owner == null || !(region2.Owner is MajorEmpire)) { list.AddOnce(this.QuestBTPacifications[i].regionIndex); if (this.CanPathToObjective(region2)) { List <GlobalObjectiveMessage> globalObjectiveMessages = this.globalObjectiveMessages; Predicate <GlobalObjectiveMessage> match2; if ((match2 = < > 9__4) == null) { match2 = (< > 9__4 = ((GlobalObjectiveMessage match) => match.RegionIndex == this.QuestBTPacifications[i].regionIndex)); } GlobalObjectiveMessage globalObjectiveMessage2 = globalObjectiveMessages.Find(match2); if (globalObjectiveMessage2 != null) { globalObjectiveMessage2.GlobalPriority.Value = value; globalObjectiveMessage2.LocalPriority.Value = value; } else if (AILayer_Pacification.RegionContainsHostileArmies(base.AIEntity.Empire, this.QuestBTPacifications[i].regionIndex)) { globalObjectiveMessage2 = base.GenerateObjective(this.QuestBTPacifications[i].regionIndex); this.globalObjectiveMessages.Add(globalObjectiveMessage2); globalObjectiveMessage2.GlobalPriority.Value = value; globalObjectiveMessage2.LocalPriority.Value = value; } } } } i2 = i; } for (int k = 0; k < this.globalObjectiveMessages.Count; k++) { if ((this.globalObjectiveMessages[k].State == BlackboardMessage.StateValue.Message_None || this.globalObjectiveMessages[k].State == BlackboardMessage.StateValue.Message_InProgress) && !list.Contains(this.globalObjectiveMessages[k].RegionIndex)) { base.AIEntity.AIPlayer.Blackboard.CancelMessage(this.globalObjectiveMessages[k]); this.CancelObjective(this.globalObjectiveMessages[k]); this.globalObjectiveMessages.RemoveAt(k); k--; } } }
protected override State Execute(AIBehaviorTree aiBehaviorTree, params object[] parameters) { Army army2; base.GetArmyUnlessLocked(aiBehaviorTree, "$Army", out army2); IGameService service = Services.GetService <IGameService>(); Diagnostics.Assert(service != null); IGameEntityRepositoryService service2 = service.Game.Services.GetService <IGameEntityRepositoryService>(); State result; if (this.orderTicket != null) { if (!this.orderTicket.Raised) { result = State.Running; } else { OrderInteractWith orderInteractWith = this.orderTicket.Order as OrderInteractWith; IGameEntity gameEntity = null; if (this.orderTicket.PostOrderResponse != PostOrderResponse.Processed) { if (service2.TryGetValue(orderInteractWith.TargetGUID, out gameEntity)) { PointOfInterest pointOfInterest; if (gameEntity is Village) { pointOfInterest = (gameEntity as Village).PointOfInterest; } else { pointOfInterest = (gameEntity as PointOfInterest); } if (pointOfInterest != null) { IQuestRepositoryService service3 = service.Game.Services.GetService <IQuestRepositoryService>(); foreach (QuestMarker questMarker in service.Game.Services.GetService <IQuestManagementService>().GetMarkersByBoundTargetGUID(pointOfInterest.GUID)) { Quest quest; if (service3.TryGetValue(questMarker.QuestGUID, out quest) && quest.QuestDefinition.Name == "GlobalQuestCoop#0004" && quest.EmpireBits == army2.Empire.Bits && questMarker.IsVisibleFor(army2.Empire)) { this.orderTicket = null; QuestBehaviour questBehaviour = service3.GetQuestBehaviour(quest.Name, army2.Empire.Index); if (questBehaviour != null) { if (quest.QuestDefinition.Variables.First((QuestVariableDefinition p) => p.VarName == "$NameOfStrategicResourceToGather1") != null) { QuestBehaviourTreeNode_ConditionCheck_HasResourceAmount questBehaviourTreeNode_ConditionCheck_HasResourceAmount; if (!ELCPUtilities.TryGetFirstNodeOfType <QuestBehaviourTreeNode_ConditionCheck_HasResourceAmount>(questBehaviour.Root as BehaviourTreeNodeController, out questBehaviourTreeNode_ConditionCheck_HasResourceAmount)) { break; } string resourceName = questBehaviourTreeNode_ConditionCheck_HasResourceAmount.ResourceName; int wantedAmount = questBehaviourTreeNode_ConditionCheck_HasResourceAmount.WantedAmount; DepartmentOfTheTreasury agency = army2.Empire.GetAgency <DepartmentOfTheTreasury>(); if (agency == null) { break; } float num; if (agency != null && agency.TryGetResourceStockValue(army2.Empire.SimulationObject, resourceName, out num, false) && num >= (float)wantedAmount) { return(State.Running); } break; } } } } if ((pointOfInterest.Interaction.Bits & aiBehaviorTree.AICommander.Empire.Bits) != aiBehaviorTree.AICommander.Empire.Bits) { pointOfInterest.Interaction.Bits |= 1 << orderInteractWith.EmpireIndex; } } } aiBehaviorTree.ErrorCode = 30; this.orderTicket = null; result = State.Failure; } else { if (this.orderTicket.PostOrderResponse == PostOrderResponse.Processed && service2.TryGetValue(orderInteractWith.TargetGUID, out gameEntity) && gameEntity is PointOfInterest && orderInteractWith.Tags.Contains("Talk") && orderInteractWith.QuestRewards == null) { PointOfInterest pointOfInterest2 = gameEntity as PointOfInterest; Diagnostics.Log("ELCP: Empire {0} AIBehaviorTreeNode_Action_SearchInRuin parley order without quest reward: {1} ", new object[] { aiBehaviorTree.AICommander.Empire.ToString(), pointOfInterest2.WorldPosition }); if (pointOfInterest2 != null) { pointOfInterest2.Interaction.Bits |= 1 << orderInteractWith.EmpireIndex; } } this.orderTicket = null; result = State.Success; } } } else { Army army; if (base.GetArmyUnlessLocked(aiBehaviorTree, "$Army", out army) > AIArmyMission.AIArmyMissionErrorCode.None) { result = State.Failure; } else { if (!aiBehaviorTree.Variables.ContainsKey(this.TargetVarName)) { aiBehaviorTree.LogError("${0} not set", new object[] { this.TargetVarName }); return(State.Failure); } IGameEntity gameEntity2 = aiBehaviorTree.Variables[this.TargetVarName] as IGameEntity; if (!(gameEntity2 is IWorldPositionable) || (!(gameEntity2 is PointOfInterest) && !(gameEntity2 is Village))) { aiBehaviorTree.ErrorCode = 10; return(State.Failure); } if (gameEntity2 is Village) { Village village = gameEntity2 as Village; Diagnostics.Log("ELCP {0} {1} AIBehaviorTreeNode_Action_SearchInRuin village {2} {3}", new object[] { aiBehaviorTree.AICommander.Empire, army.LocalizedName, village.WorldPosition, this.QuestVillage }); PointOfInterest pointOfInterest3 = village.PointOfInterest; if (pointOfInterest3 == null) { return(State.Failure); } if (!this.QuestVillage) { if (village.HasBeenConverted || village.HasBeenPacified || village.IsInEncounter || village.PointOfInterest.PointOfInterestImprovement == null) { return(State.Failure); } if (!aiBehaviorTree.AICommander.Empire.GetAgency <DepartmentOfScience>().CanParley()) { return(State.Failure); } if (pointOfInterest3.SimulationObject.Tags.Contains(Village.DissentedVillage)) { return(State.Failure); } if ((pointOfInterest3.Interaction.Bits & army.Empire.Bits) != 0) { Diagnostics.Log("fail"); return(State.Failure); } QuestMarker questMarker2; if (service.Game.Services.GetService <IQuestManagementService>().TryGetMarkerByGUID(pointOfInterest3.GUID, out questMarker2)) { Diagnostics.Log("ELCP: Empire {0} AIBehaviorTreeNode_Action_SearchInRuin Questmarker active", new object[] { aiBehaviorTree.AICommander.Empire.ToString() }); return(State.Failure); } } } Diagnostics.Assert(AIScheduler.Services != null); if (service.Game.Services.GetService <IWorldPositionningService>().GetDistance(army.WorldPosition, (gameEntity2 as IWorldPositionable).WorldPosition) != 1) { aiBehaviorTree.ErrorCode = 12; result = State.Failure; } else { IEncounterRepositoryService service4 = service.Game.Services.GetService <IEncounterRepositoryService>(); if (service4 != null) { IEnumerable <Encounter> enumerable = service4; if (enumerable != null && enumerable.Any((Encounter encounter) => encounter.IsGarrisonInEncounter(army.GUID, false))) { return(State.Running); } } if (gameEntity2 is Village) { Diagnostics.Log("ELCP {0} {1} AIBehaviorTreeNode_Action_SearchInRuin2 village", new object[] { aiBehaviorTree.AICommander.Empire, army.LocalizedName }); PointOfInterest pointOfInterest4 = (gameEntity2 as Village).PointOfInterest; OrderInteractWith orderInteractWith2 = new OrderInteractWith(army.Empire.Index, army.GUID, "ArmyActionParley"); orderInteractWith2.WorldPosition = army.WorldPosition; orderInteractWith2.Tags.AddTag("Talk"); orderInteractWith2.TargetGUID = pointOfInterest4.GUID; orderInteractWith2.ArmyActionName = "ArmyActionParley"; orderInteractWith2.NumberOfActionPointsToSpend = 0f; aiBehaviorTree.AICommander.Empire.PlayerControllers.AI.PostOrder(orderInteractWith2, out this.orderTicket, null); } else { if (Amplitude.Unity.Framework.Application.Preferences.EnableModdingTools) { Diagnostics.Log("~~~~~ ELCP: {0}/{1} ArmyActionSearch at {2}, {3} {4} ~~~~~", new object[] { army.LocalizedName, army.Empire, (gameEntity2 as PointOfInterest).WorldPosition, ((gameEntity2 as PointOfInterest).Interaction.Bits & army.Empire.Bits) == army.Empire.Bits, (gameEntity2 as PointOfInterest).UntappedDustDeposits }); } OrderInteractWith orderInteractWith3 = new OrderInteractWith(army.Empire.Index, army.GUID, "ArmyActionSearch"); orderInteractWith3.WorldPosition = army.WorldPosition; orderInteractWith3.Tags.AddTag("Interact"); orderInteractWith3.TargetGUID = gameEntity2.GUID; aiBehaviorTree.AICommander.Empire.PlayerControllers.AI.PostOrder(orderInteractWith3, out this.orderTicket, null); } result = State.Running; } } } return(result); }
private static void SteamMatchMaking_SteamLobbyDataUpdate(object sender, SteamLobbyDataUpdateEventArgs e) { PleaseWaitPanel.Instance.Hide(false); Diagnostics.Log("ELCP: LobbyDataUpdate, success? {0}, lobby {1}, expected {2}", new object[] { e.Message.m_bSuccess, e.Message.m_ulSteamIDLobby, ELCPUtilities.LobbyID }); if (e.Message.m_bSuccess == 0 || ELCPUtilities.LobbyID != e.Message.m_ulSteamIDLobby) { return; } ISteamMatchMakingService service = Services.GetService <ISteamMatchMakingService>(); Steamworks.SteamID steamID = new Steamworks.SteamID(ELCPUtilities.LobbyID); MenuJoinGameScreen.LobbyDescription lobbyDescription = new MenuJoinGameScreen.LobbyDescription(service, steamID); Diagnostics.Log("[Lobby] Flags: {0}, Lobby valid? {1}", new object[] { lobbyDescription.Flags, lobbyDescription.IsValid }); service.SteamLobbyDataUpdate -= ELCPUtilities.SteamMatchMaking_SteamLobbyDataUpdate; ELCPUtilities.LobbyID = 0UL; if (!lobbyDescription.IsValid) { return; } IRuntimeModuleSubscriptionService service2 = Services.GetService <IRuntimeModuleSubscriptionService>(); if (service == null || service2 == null || !steamID.IsValid) { return; } string[] array = new string[0]; string[] array2 = new string[0]; RuntimeModuleConfigurationState runtimeModuleListState = service2.GetRuntimeModuleListState(lobbyDescription.RuntimeConfiguration, out array, out array2); Diagnostics.Log("ELCP runtimeModuleConfigurationState {0} missingWorkshopItems {1} missingNonWorkshopItems {2} RuntimeConfiguration {3}", new object[] { runtimeModuleListState + 1, array.Length, array2.Length, (lobbyDescription.RuntimeConfiguration == null) ? -1 : lobbyDescription.RuntimeConfiguration.Length }); switch (runtimeModuleListState + 1) { case RuntimeModuleConfigurationState.Yellow: Services.GetService <IRuntimeService>().Runtime.FiniteStateMachine.PostStateChange(typeof(RuntimeState_Lobby), new object[] { steamID }); return; case RuntimeModuleConfigurationState.Red: ELCPUtilities.SelectedLobby = lobbyDescription; if (array.Length != 0) { string text = AgeLocalizer.Instance.LocalizeString("%ConfirmDownloadModsBeforeActivation"); MessagePanel.Instance.Show(text.Replace("$NumberOfMods", array.Length.ToString()), "%Confirmation", MessagePanelButtons.OkCancel, new MessagePanel.EventHandler(ELCPUtilities.SteamMatchMaking_OnConfirmOpenActivationPanel), MessagePanelType.IMPORTANT, new MessagePanelButton[0]); return; } ELCPUtilities.SteamMatchMaking_OnConfirmOpenActivationPanel(Amplitude.Unity.Gui.GuiScreen.CurrentScreen, new MessagePanelResultEventArgs(MessagePanelResult.Ok)); return; case (RuntimeModuleConfigurationState)3: ELCPUtilities.SelectedLobby = lobbyDescription; ELCPUtilities.SteamMatchMaking_OnConfirmOpenActivationPanel(Amplitude.Unity.Gui.GuiScreen.CurrentScreen, new MessagePanelResultEventArgs(MessagePanelResult.Ok)); return; default: return; } }
private static void SteamMatchMaking_CallbackRequestLobbyList(object sender, SteamMatchMakingRequestLobbyListEventArgs e) { PleaseWaitPanel.Instance.Hide(false); Diagnostics.Log("ELCP: Request Lobby List : " + e.Message.m_nLobbiesMatching + " result(s)."); ISteamMatchMakingService service = Services.GetService <ISteamMatchMakingService>(); Steamworks.SteamID steamID = new Steamworks.SteamID(ELCPUtilities.LobbyID); Diagnostics.Log("ELCP: looking for lobby: " + steamID.AccountID); int num = 0; while ((long)num < (long)((ulong)e.Message.m_nLobbiesMatching)) { Steamworks.SteamID lobbyByIndex = service.SteamMatchMaking.GetLobbyByIndex(num); Diagnostics.Log(string.Concat(new object[] { "ELCP: lobbybyindex: ", lobbyByIndex.AccountID, " ", lobbyByIndex.IsValid.ToString() })); if (lobbyByIndex.IsValid && steamID.AccountID == lobbyByIndex.AccountID) { MenuJoinGameScreen.LobbyDescription lobbyDescription = new MenuJoinGameScreen.LobbyDescription(service, lobbyByIndex); Diagnostics.Log("[Lobby] Flags: {0}, Lobby valid? {1}", new object[] { lobbyDescription.Flags, lobbyDescription.IsValid }); if (!lobbyDescription.IsValid) { break; } IRuntimeModuleSubscriptionService service2 = Services.GetService <IRuntimeModuleSubscriptionService>(); if (service == null || service2 == null || !steamID.IsValid) { break; } string[] array = new string[0]; string[] array2 = new string[0]; RuntimeModuleConfigurationState runtimeModuleListState = service2.GetRuntimeModuleListState(lobbyDescription.RuntimeConfiguration, out array, out array2); Diagnostics.Log("ELCP runtimeModuleConfigurationState {0} missingWorkshopItems {1} missingNonWorkshopItems {2} RuntimeConfiguration {3}", new object[] { runtimeModuleListState + 1, array.Length, array2.Length, (lobbyDescription.RuntimeConfiguration == null) ? -1 : lobbyDescription.RuntimeConfiguration.Length }); switch (runtimeModuleListState + 1) { case RuntimeModuleConfigurationState.Yellow: Services.GetService <IRuntimeService>().Runtime.FiniteStateMachine.PostStateChange(typeof(RuntimeState_Lobby), new object[] { steamID }); goto IL_28B; case RuntimeModuleConfigurationState.Red: ELCPUtilities.SelectedLobby = lobbyDescription; if (array.Length != 0) { string text = AgeLocalizer.Instance.LocalizeString("%ConfirmDownloadModsBeforeActivation"); MessagePanel.Instance.Show(text.Replace("$NumberOfMods", array.Length.ToString()), "%Confirmation", MessagePanelButtons.OkCancel, new MessagePanel.EventHandler(ELCPUtilities.SteamMatchMaking_OnConfirmOpenActivationPanel), MessagePanelType.IMPORTANT, new MessagePanelButton[0]); goto IL_28B; } ELCPUtilities.SteamMatchMaking_OnConfirmOpenActivationPanel(Amplitude.Unity.Gui.GuiScreen.CurrentScreen, new MessagePanelResultEventArgs(MessagePanelResult.Ok)); goto IL_28B; case (RuntimeModuleConfigurationState)3: ELCPUtilities.SelectedLobby = lobbyDescription; ELCPUtilities.SteamMatchMaking_OnConfirmOpenActivationPanel(Amplitude.Unity.Gui.GuiScreen.CurrentScreen, new MessagePanelResultEventArgs(MessagePanelResult.Ok)); goto IL_28B; default: goto IL_28B; } } else { num++; } } IL_28B: service.SteamMatchMakingRequestLobbyList -= ELCPUtilities.SteamMatchMaking_CallbackRequestLobbyList; ELCPUtilities.LobbyID = 0UL; ELCPUtilities.steamAPICall = 0UL; }
private bool CanSearchQuest(Army army, IWorldPositionable item, IQuestManagementService questManagementService, IQuestRepositoryService questRepositoryService) { PointOfInterest pointOfInterest = item as PointOfInterest; if (pointOfInterest == null) { return(false); } if (pointOfInterest.Type != ELCPUtilities.QuestLocation && pointOfInterest.Type != "NavalQuestLocation") { return(false); } if (ELCPUtilities.UseELCPPeacefulCreepingNodes) { if (pointOfInterest.CreepingNodeGUID != GameEntityGUID.Zero && pointOfInterest.Empire != army.Empire) { if (pointOfInterest.Empire == null) { return(false); } if (!(pointOfInterest.Empire is MajorEmpire)) { return(false); } DepartmentOfForeignAffairs agency = army.Empire.GetAgency <DepartmentOfForeignAffairs>(); if (agency == null) { return(false); } if (!agency.IsFriend(pointOfInterest.Empire)) { return(false); } } } else if (pointOfInterest.CreepingNodeImprovement != null && pointOfInterest.Empire.Index != army.Empire.Index) { return(false); } if (!pointOfInterest.Interaction.IsLocked(army.Empire.Index, "ArmyActionSearch")) { foreach (QuestMarker questMarker in questManagementService.GetMarkersByBoundTargetGUID(pointOfInterest.GUID)) { Quest quest; if (questRepositoryService.TryGetValue(questMarker.QuestGUID, out quest)) { QuestBehaviour questBehaviour = questRepositoryService.GetQuestBehaviour(quest.Name, army.Empire.Index); if (questBehaviour != null && quest.EmpireBits == army.Empire.Bits && questMarker.IsVisibleFor(army.Empire)) { string a = quest.QuestDefinition.Name; if (quest.QuestDefinition.Name == AILayer_QuestSolver.ImportantQuestNames.GlobalQuestACursedBountyName && questMarker.IsVisibleInFogOfWar) { if (this.QuestLayer == null) { GameServer gameServer = (Services.GetService <ISessionService>().Session as global::Session).GameServer as GameServer; AIPlayer_MajorEmpire aiplayer_MajorEmpire; if (gameServer.AIScheduler != null && gameServer.AIScheduler.TryGetMajorEmpireAIPlayer(army.Empire as MajorEmpire, out aiplayer_MajorEmpire)) { AIEntity entity = aiplayer_MajorEmpire.GetEntity <AIEntity_Empire>(); if (entity != null) { this.QuestLayer = entity.GetLayer <AILayer_QuestSolver>(); } } } if (this.QuestLayer.SearchACursedBountyRuin) { return(true); } this.CursedBountyPosition = questMarker.WorldPosition; return(false); } else { if (a == "VictoryQuest-Chapter3" && questMarker.IsVisibleInFogOfWar) { return(true); } if (a == "VictoryQuest-Chapter1Alt" || a == "VictoryQuest-Chapter1") { QuestBehaviourTreeNode_ConditionCheck_Prerequisite questBehaviourTreeNode_ConditionCheck_Prerequisite; if (!ELCPUtilities.TryGetFirstNodeOfType <QuestBehaviourTreeNode_ConditionCheck_Prerequisite>(questBehaviour.Root as BehaviourTreeNodeController, out questBehaviourTreeNode_ConditionCheck_Prerequisite)) { return(false); } foreach (QuestBehaviourPrerequisites questBehaviourPrerequisites in questBehaviourTreeNode_ConditionCheck_Prerequisite.Prerequisites) { for (int j = 0; j < questBehaviourPrerequisites.Prerequisites.Length; j++) { InterpreterPrerequisite interpreterPrerequisite = questBehaviourPrerequisites.Prerequisites[j] as InterpreterPrerequisite; if (interpreterPrerequisite != null && !interpreterPrerequisite.Check(army)) { return(false); } } } return(true); } else if (a == "GlobalQuestCoop#0004") { if (quest.QuestDefinition.Variables.First((QuestVariableDefinition p) => p.VarName == "$NameOfStrategicResourceToGather1") != null) { QuestBehaviourTreeNode_ConditionCheck_HasResourceAmount questBehaviourTreeNode_ConditionCheck_HasResourceAmount; if (!ELCPUtilities.TryGetFirstNodeOfType <QuestBehaviourTreeNode_ConditionCheck_HasResourceAmount>(questBehaviour.Root as BehaviourTreeNodeController, out questBehaviourTreeNode_ConditionCheck_HasResourceAmount)) { return(false); } string resourceName = questBehaviourTreeNode_ConditionCheck_HasResourceAmount.ResourceName; int wantedAmount = questBehaviourTreeNode_ConditionCheck_HasResourceAmount.WantedAmount; DepartmentOfTheTreasury agency2 = army.Empire.GetAgency <DepartmentOfTheTreasury>(); float num; if (agency2 != null && agency2.TryGetResourceStockValue(army.Empire.SimulationObject, resourceName, out num, false) && num >= (float)(wantedAmount * 3)) { return(true); } } } } } } } return(false); } return(false); }
protected override State Execute(AIBehaviorTree aiBehaviorTree, params object[] parameters) { if (this.currentTicket != null) { if (!this.currentTicket.Raised) { return(State.Running); } bool flag = this.currentTicket.PostOrderResponse == PostOrderResponse.PreprocessHasFailed || this.currentTicket.PostOrderResponse == PostOrderResponse.AuthenticationHasFailed; this.currentTicket = null; if (flag) { aiBehaviorTree.ErrorCode = 1; return(State.Failure); } if (this.fastTravel) { Army army; if (this.CurrentPathCollection != null && base.GetArmyUnlessLocked(aiBehaviorTree, "$Army", out army) == AIArmyMission.AIArmyMissionErrorCode.None) { PointOfInterest pointOfInterest = this.worldPositionningService.GetPointOfInterest(this.CurrentPathCollection.ExitNode.WorldPosition); IGameService service = Services.GetService <IGameService>(); IQuestManagementService service2 = service.Game.Services.GetService <IQuestManagementService>(); IQuestRepositoryService service3 = service.Game.Services.GetService <IQuestRepositoryService>(); if (pointOfInterest != null && ELCPUtilities.CanSearch(army.Empire, pointOfInterest, service2, service3) && this.worldPositionningService.GetDistance(army.WorldPosition, pointOfInterest.WorldPosition) < 2 && this.pathfindingService.IsTransitionPassable(army.WorldPosition, pointOfInterest.WorldPosition, army, OrderAttack.AttackFlags, null)) { OrderInteractWith orderInteractWith = new OrderInteractWith(army.Empire.Index, army.GUID, "ArmyActionSearch"); orderInteractWith.WorldPosition = army.WorldPosition; orderInteractWith.Tags.AddTag("Interact"); orderInteractWith.TargetGUID = pointOfInterest.GUID; army.Empire.PlayerControllers.AI.PostOrder(orderInteractWith); } } this.fastTravel = false; this.CurrentPathCollection = null; } return(State.Success); } else { Army army2; if (base.GetArmyUnlessLocked(aiBehaviorTree, "$Army", out army2) != AIArmyMission.AIArmyMissionErrorCode.None) { return(State.Failure); } if (!aiBehaviorTree.Variables.ContainsKey(this.DestinationVarName)) { aiBehaviorTree.LogError("{0} not set", new object[] { this.DestinationVarName }); return(State.Failure); } if (this.AllowFastTravel && !(army2 is KaijuArmy) && aiBehaviorTree.AICommander.Empire is MajorEmpire && aiBehaviorTree.AICommander.Empire.SimulationObject.Tags.Contains(FactionTrait.FactionTraitMimics1)) { float propertyValue = army2.GetPropertyValue(SimulationProperties.MaximumNumberOfActionPoints); float propertyValue2 = army2.GetPropertyValue(SimulationProperties.ActionPointsSpent); if (propertyValue > propertyValue2) { return(this.MykaraExecute(aiBehaviorTree, army2)); } if (this.CurrentPathCollection != null) { this.CurrentPathCollection = null; this.WorldPath = null; } } if (army2.GetPropertyValue(SimulationProperties.Movement) < 0.001f) { aiBehaviorTree.ErrorCode = 24; return(State.Failure); } WorldPosition worldPosition = (WorldPosition)aiBehaviorTree.Variables[this.DestinationVarName]; aiBehaviorTree.LastPathfindTargetPosition = worldPosition; if (!worldPosition.IsValid) { aiBehaviorTree.ErrorCode = 3; return(State.Failure); } if (this.WorldPath != null && this.WorldPath.Destination == worldPosition) { return(State.Success); } this.currentFlags = PathfindingFlags.IgnoreFogOfWar; if (!aiBehaviorTree.AICommander.MayUseFrozenTiles()) { this.currentFlags |= PathfindingFlags.IgnoreFrozenWaters; } this.WorldPath = new WorldPath(); if (army2.WorldPosition == worldPosition) { aiBehaviorTree.ErrorCode = 4; return(State.Failure); } int distance = this.worldPositionningService.GetDistance(army2.WorldPosition, worldPosition); bool flag2 = this.pathfindingService.IsTransitionPassable(army2.WorldPosition, worldPosition, army2, (PathfindingFlags)0, null); if (distance == 1 && flag2 && !this.pathfindingService.IsTileStopable(worldPosition, army2, (PathfindingFlags)0, null)) { aiBehaviorTree.ErrorCode = 4; return(State.Failure); } PathfindingContext pathfindingContext = army2.GenerateContext(); pathfindingContext.Greedy = true; PathfindingResult pathfindingResult = this.pathfindingService.FindPath(pathfindingContext, army2.WorldPosition, worldPosition, PathfindingManager.RequestMode.Default, null, this.currentFlags, null); if (pathfindingResult == null && this.IgnoreArmies) { this.currentFlags |= PathfindingFlags.IgnoreArmies; pathfindingResult = this.pathfindingService.FindPath(pathfindingContext, army2.WorldPosition, worldPosition, PathfindingManager.RequestMode.Default, null, this.currentFlags, null); } if (pathfindingResult == null) { aiBehaviorTree.ErrorCode = 3; if (ELCPUtilities.ELCPVerboseMode) { Diagnostics.Log("ELCP {0}/{1} didnt find pathfindingResult to {2} with flags {3}", new object[] { army2.Empire, army2.LocalizedName, worldPosition, this.currentFlags }); } return(State.Failure); } this.WorldPath.Build(pathfindingResult, army2.GetPropertyValue(SimulationProperties.MovementRatio), this.numberOfTurnForWorldPath, false); this.WorldPath = this.ComputeSafePathOpportunity(army2, worldPosition, this.WorldPath); if (!this.WorldPath.IsValid) { aiBehaviorTree.ErrorCode = 3; if (ELCPUtilities.ELCPVerboseMode) { Diagnostics.Log("ELCP {0}/{1} worldpath invalid {2} with flags {3}", new object[] { army2.Empire, army2.LocalizedName, worldPosition, this.currentFlags }); } return(State.Failure); } if (aiBehaviorTree.Variables.ContainsKey(this.Output_PathVarName)) { aiBehaviorTree.Variables[this.Output_PathVarName] = this.WorldPath; } else { aiBehaviorTree.Variables.Add(this.Output_PathVarName, this.WorldPath); } return(State.Success); } }
public override bool IsMissionFinished(bool forceStop) { QuestBehaviourTreeNode_Decorator_TimerEnded questBehaviourTreeNode_Decorator_TimerEnded; if (this.ActiveVictoryQuest == "VictoryQuest-Chapter4" && this.questBehaviour.Quest.GetCurrentStepIndex() > 0 && ELCPUtilities.TryGetFirstNodeOfType <QuestBehaviourTreeNode_Decorator_TimerEnded>(this.questBehaviour.Root as BehaviourTreeNodeController, out questBehaviourTreeNode_Decorator_TimerEnded)) { int num = (int)this.questBehaviour.GetQuestVariableByName(questBehaviourTreeNode_Decorator_TimerEnded.TimerVarName).Object; if (this.game.Turn - num < questBehaviourTreeNode_Decorator_TimerEnded.TurnCountBeforeTimeOut) { return(true); } } foreach (QuestMarker questMarker in this.questManagementService.GetMarkersByBoundTargetGUID(base.SubObjectiveGuid)) { Quest quest; if (this.questRepositoryService.TryGetValue(questMarker.QuestGUID, out quest) && quest.QuestDefinition.Name == this.ActiveVictoryQuest && quest.EmpireBits == base.Empire.Bits && (this.ActiveVictoryQuest != "VictoryQuest-Chapter3" || questMarker.IsVisibleInFogOfWar)) { if (base.Empire.GetAgency <DepartmentOfForeignAffairs>().CanMoveOn(base.RegionIndex, false)) { return(false); } GlobalObjectiveMessage globalObjectiveMessage; return(base.GlobalObjectiveID == 0UL || base.AIPlayer == null || !base.AIPlayer.Blackboard.TryGetMessage <GlobalObjectiveMessage>(base.GlobalObjectiveID, out globalObjectiveMessage) || globalObjectiveMessage.State == BlackboardMessage.StateValue.Message_Canceled || globalObjectiveMessage.State == BlackboardMessage.StateValue.Message_Failed); } } return(true); }
protected override State Execute(AIBehaviorTree aiBehaviorTree, params object[] parameters) { Army army; if (base.GetArmyUnlessLocked(aiBehaviorTree, "$Army", out army) > AIArmyMission.AIArmyMissionErrorCode.None) { return(State.Failure); } global::Empire empire = aiBehaviorTree.AICommander.Empire; if (empire == null) { aiBehaviorTree.ErrorCode = 10; return(State.Failure); } if (this.Teleport) { if (army.Empire.SimulationObject.Tags.Contains("FactionTraitAffinityStrategic") && army.Empire.SimulationObject.Tags.Contains("BoosterTeleport") && !army.IsNaval && ELCPUtilities.CheckCooldownPrerequisites(army)) { if (!army.StandardUnits.Any((Unit unit) => unit.SimulationObject.Tags.Contains(Unit.ReadOnlyColossus))) { goto IL_B7; } } return(State.Failure); } IL_B7: City city = null; District district = this.worldPositionningService.GetDistrict(army.WorldPosition); if (district != null && district.Empire.Index == army.Empire.Index) { if (this.Inverted && district.City.BesiegingEmpire == null) { city = district.City; if (aiBehaviorTree.Variables.ContainsKey(this.Output_TargetVarName)) { aiBehaviorTree.Variables[this.Output_TargetVarName] = city; } else { aiBehaviorTree.Variables.Add(this.Output_TargetVarName, city); } return(State.Success); } if (district.City.BesiegingEmpire != null) { if (this.Teleport || this.Inverted) { return(State.Failure); } city = district.City; if (aiBehaviorTree.Variables.ContainsKey(this.Output_TargetVarName)) { aiBehaviorTree.Variables[this.Output_TargetVarName] = city; } else { aiBehaviorTree.Variables.Add(this.Output_TargetVarName, city); } return(State.Success); } } DepartmentOfTheInterior agency = empire.GetAgency <DepartmentOfTheInterior>(); if (agency == null) { aiBehaviorTree.ErrorCode = 10; return(State.Failure); } int num = int.MaxValue; List <City> list = new List <City>(); using (IEnumerator <City> enumerator = agency.Cities.GetEnumerator()) { while (enumerator.MoveNext()) { City city2 = enumerator.Current; if (city2.BesiegingEmpire != null) { if (!this.Inverted && this.worldPositionningService.GetDistance(army.WorldPosition, city2.WorldPosition) < num && (!this.Teleport || ELCPUtilities.CanTeleportToCity(city2, army, this.worldPositionningService.GetRegion(army.WorldPosition), this.worldPositionningService, null))) { if (this.Teleport && this.encounterRepositoryService.Any((Encounter encounter) => encounter.IsGarrisonInEncounter(city2.GUID, false))) { list.Add(city2); } else { num = this.worldPositionningService.GetDistance(army.WorldPosition, city2.WorldPosition); city = city2; } } } else if (this.Inverted && this.worldPositionningService.GetDistance(army.WorldPosition, city2.WorldPosition) < num) { num = this.worldPositionningService.GetDistance(army.WorldPosition, city2.WorldPosition); city = city2; } } } if (city == null && list.Count > 0) { city = list[0]; } if (city != null) { if (aiBehaviorTree.Variables.ContainsKey(this.Output_TargetVarName)) { aiBehaviorTree.Variables[this.Output_TargetVarName] = city; } else { aiBehaviorTree.Variables.Add(this.Output_TargetVarName, city); } return(State.Success); } return(State.Failure); }