public override void Reset() { this.departmentOfForeignAffairs = base.Empire.GetAgency <DepartmentOfForeignAffairs>(); ISessionService service = Services.GetService <ISessionService>(); this.SharedVictory = service.Session.GetLobbyData <bool>("Shared", true); GameServer gameServer = (service.Session as global::Session).GameServer as GameServer; AIPlayer_MajorEmpire aiplayer_MajorEmpire; if (!(base.EmpireWhichReceives as MajorEmpire).ELCPIsEliminated && gameServer != null && gameServer.AIScheduler != null && gameServer.AIScheduler.TryGetMajorEmpireAIPlayer(base.EmpireWhichReceives as MajorEmpire, out aiplayer_MajorEmpire)) { AIEntity entity = aiplayer_MajorEmpire.GetEntity <AIEntity_Empire>(); if (entity == null) { Diagnostics.LogError("ELCP {0} has no entity for agent of {1}", new object[] { base.EmpireWhichReceives, base.Empire }); } this.otherDiplomacyLayer = entity.GetLayer <AILayer_Diplomacy>(); } base.Reset(); bool enable = base.Enable; }
protected override bool IsMissionCompleted() { if (base.Commander.Empire != null && base.Commander.Empire is MajorEmpire && this.ailayer_QuestSolver == null) { GameServer gameServer = (Services.GetService <ISessionService>().Session as global::Session).GameServer as GameServer; try { AIPlayer_MajorEmpire aiplayer_MajorEmpire; if (gameServer.AIScheduler != null && gameServer.AIScheduler.TryGetMajorEmpireAIPlayer(base.Commander.Empire as MajorEmpire, out aiplayer_MajorEmpire)) { AIEntity entity = aiplayer_MajorEmpire.GetEntity <AIEntity_Empire>(); if (entity != null) { this.ailayer_QuestSolver = entity.GetLayer <AILayer_QuestSolver>(); } } } catch (Exception ex) { Diagnostics.LogError("Exceptions caught: {0}", new object[] { ex }); return(false); } } return(!(base.Commander is AICommander_Victory) && !AILayer_Patrol.IsPatrolValid(base.Commander.Empire, this.RegionTarget, this.ailayer_QuestSolver)); }
public override IEnumerator Load() { yield return(base.Load()); this.departmentOfTheInterior = this.Empire.GetAgency <DepartmentOfTheInterior>(); this.departmentOfForeignAffairs = this.Empire.GetAgency <DepartmentOfForeignAffairs>(); this.departmentOfIndustry = this.Empire.GetAgency <DepartmentOfIndustry>(); this.departmentOfTheTreasury = this.Empire.GetAgency <DepartmentOfTheTreasury>(); this.departmentOfIndustry.GetConstructionQueue(this.aiEntityCity.City).CollectionChanged += this.ConstructionQueue_CollectionChanged; IGameService service = Services.GetService <IGameService>(); this.game = (service.Game as global::Game); GameServer gameServer = (Services.GetService <ISessionService>().Session as global::Session).GameServer as GameServer; AIPlayer_MajorEmpire aiplayer_MajorEmpire; if (gameServer.AIScheduler != null && gameServer.AIScheduler.TryGetMajorEmpireAIPlayer(base.AIEntity.Empire as MajorEmpire, out aiplayer_MajorEmpire)) { AIEntity entity = aiplayer_MajorEmpire.GetEntity <AIEntity_Empire>(); if (entity != null) { this.aILayer_Victory = entity.GetLayer <AILayer_Victory>(); } } this.sciencePhobic = this.Empire.SimulationObject.Tags.Contains(FactionTrait.FactionTraitReplicants1); AILayer_Population.CitiesWithDustFocus[this.Empire.Index] = new List <GameEntityGUID>(); AILayer_Population.CitiesWithScienceFocus[this.Empire.Index] = new List <GameEntityGUID>(); yield break; }
protected override bool TryComputeArmyMissionParameter() { if (this.RegionTarget == null) { base.Completion = AICommanderMission.AICommanderMissionCompletion.Fail; return(false); } base.ArmyMissionParameters.Clear(); if (base.AIDataArmyGUID == GameEntityGUID.Zero) { return(false); } AIData_Army aidata = this.aiDataRepository.GetAIData <AIData_Army>(base.AIDataArmyGUID); if (aidata == null) { return(false); } Diagnostics.Assert(aidata != null); Diagnostics.Assert(aidata.Army != null); List <object> list = new List <object>(); list.Add(this.RegionTarget.Index); list.Add(this.IsWarBased); if (base.Commander.Empire != null && base.Commander.Empire is MajorEmpire) { if (this.ailayer_War == null) { GameServer gameServer = (Services.GetService <ISessionService>().Session as global::Session).GameServer as GameServer; AIPlayer_MajorEmpire aiplayer_MajorEmpire; if (gameServer.AIScheduler != null && gameServer.AIScheduler.TryGetMajorEmpireAIPlayer(base.Commander.Empire as MajorEmpire, out aiplayer_MajorEmpire)) { AIEntity entity = aiplayer_MajorEmpire.GetEntity <AIEntity_Empire>(); if (entity != null) { this.ailayer_War = entity.GetLayer <AILayer_War>(); } } } if (this.ailayer_War != null) { this.ailayer_War.AssignDefensiveArmyToCity(aidata.Army); } } if (this.IsWarBased) { if (base.TryCreateArmyMission("MajorFactionWarRoaming", list)) { return(true); } } else if (base.TryCreateArmyMission("MajorFactionRoaming", list)) { return(true); } return(false); }
public override void Initialize(AICommander commander) { base.Initialize(commander); IGameService service = Services.GetService <IGameService>(); Diagnostics.Assert(service != null); this.game = (service.Game as global::Game); this.worldPositioningService = service.Game.Services.GetService <IWorldPositionningService>(); this.pathfindingService = service.Game.Services.GetService <IPathfindingService>(); this.departmentOfDefense = base.Commander.Empire.GetAgency <DepartmentOfDefense>(); this.departmentOfTheInterior = base.Commander.Empire.GetAgency <DepartmentOfTheInterior>(); this.aiDataRepositoryHelper = AIScheduler.Services.GetService <IAIDataRepositoryAIHelper>(); base.AIDataArmyGUID = commander.ForceArmyGUID; AIData_Army aidata_Army; if (this.aiDataRepositoryHelper.TryGetAIData <AIData_Army>(base.AIDataArmyGUID, out aidata_Army) && aidata_Army.Army is KaijuArmy) { this.Kaiju = (aidata_Army.Army as KaijuArmy).Kaiju; } if (base.Commander.Empire != null && base.Commander.Empire is MajorEmpire) { GameServer gameServer = (Services.GetService <ISessionService>().Session as global::Session).GameServer as GameServer; AIPlayer_MajorEmpire aiplayer_MajorEmpire; if (gameServer.AIScheduler != null && gameServer.AIScheduler.TryGetMajorEmpireAIPlayer(base.Commander.Empire as MajorEmpire, out aiplayer_MajorEmpire)) { AIEntity entity = aiplayer_MajorEmpire.GetEntity <AIEntity_Empire>(); if (entity != null) { this.aILayer_KaijuManagement = entity.GetLayer <AILayer_KaijuManagement>(); this.aILayer_War = entity.GetLayer <AILayer_War>(); } } } IDatabase <GarrisonAction> database = Databases.GetDatabase <GarrisonAction>(false); GarrisonAction garrisonAction = null; if (database == null || !database.TryGetValue("GarrisonActionMigrateKaiju", out garrisonAction)) { Diagnostics.LogError("AICommanderMission_KaijuSupport didnt find GarrisonActionMigrateKaiju"); return; } this.garrisonAction_MigrateKaiju = (garrisonAction as GarrisonAction_MigrateKaiju); }
public override void Initialize(AICommander commander) { base.Initialize(commander); this.departmentOfDefense = base.Commander.Empire.GetAgency <DepartmentOfDefense>(); this.aiDataRepositoryHelper = AIScheduler.Services.GetService <IAIDataRepositoryAIHelper>(); this.colossusCommander = (commander as AICommander_Colossus); base.AIDataArmyGUID = commander.ForceArmyGUID; if (base.Commander.Empire != null && base.Commander.Empire is MajorEmpire) { GameServer gameServer = (Services.GetService <ISessionService>().Session as global::Session).GameServer as GameServer; AIPlayer_MajorEmpire aiplayer_MajorEmpire; if (gameServer.AIScheduler != null && gameServer.AIScheduler.TryGetMajorEmpireAIPlayer(base.Commander.Empire as MajorEmpire, out aiplayer_MajorEmpire)) { AIEntity entity = aiplayer_MajorEmpire.GetEntity <AIEntity_Empire>(); if (entity != null) { this.ailayer_War = entity.GetLayer <AILayer_War>(); } } } }
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) { global::Empire empire = aiBehaviorTree.AICommander.Empire; if (empire == null || !(empire is MajorEmpire)) { aiBehaviorTree.ErrorCode = 10; return(State.Failure); } Army army; if (base.GetArmyUnlessLocked(aiBehaviorTree, "$Army", out army) > AIArmyMission.AIArmyMissionErrorCode.None) { return(State.Failure); } GameServer gameServer = (Services.GetService <ISessionService>().Session as global::Session).GameServer as GameServer; AILayer_ArmyManagement ailayer_ArmyManagement = null; AIPlayer_MajorEmpire aiplayer_MajorEmpire; if (gameServer.AIScheduler != null && gameServer.AIScheduler.TryGetMajorEmpireAIPlayer(empire as MajorEmpire, out aiplayer_MajorEmpire)) { AIEntity entity = aiplayer_MajorEmpire.GetEntity <AIEntity_Empire>(); if (entity != null) { ailayer_ArmyManagement = entity.GetLayer <AILayer_ArmyManagement>(); } } if (ailayer_ArmyManagement == null) { return(State.Failure); } int num = int.MaxValue; Army value = null; AICommander aicommander = null; foreach (AICommander aicommander2 in ailayer_ArmyManagement.AICommanders) { if (aicommander2 is AICommander_WarWithObjective || aicommander2 is AICommander_Victory) { foreach (AICommanderMission aicommanderMission in aicommander2.Missions) { IGameEntity gameEntity = null; if (aicommanderMission.AIDataArmyGUID.IsValid && this.gameEntityRepositoryService.TryGetValue(aicommanderMission.AIDataArmyGUID, out gameEntity) && gameEntity is Army) { Army army2 = gameEntity as Army; int distance = this.worldPositionningService.GetDistance(army.WorldPosition, army2.WorldPosition); if (distance < num) { num = distance; value = army2; aicommander = aicommander2; } } } } } if ((float)num > Mathf.Max(army.GetPropertyValue(SimulationProperties.MaximumMovement) * 1.5f, 6f)) { return(State.Failure); } if (aicommander != null && aicommander is AICommanderWithObjective) { AICommanderWithObjective aicommanderWithObjective = aicommander as AICommanderWithObjective; IWorldPositionable worldPositionable = null; if (aicommanderWithObjective.SubObjectiveGuid.IsValid) { IGameEntity gameEntity2 = null; if (this.gameEntityRepositoryService.TryGetValue(aicommanderWithObjective.SubObjectiveGuid, out gameEntity2) && gameEntity2 is IWorldPositionable) { worldPositionable = (gameEntity2 as IWorldPositionable); } } Region region = this.worldPositionningService.GetRegion(aicommanderWithObjective.RegionIndex); if (region.City != null) { worldPositionable = region.City; } if (worldPositionable == null) { if (aiBehaviorTree.Variables.ContainsKey(this.Output_MainTargetVarName)) { aiBehaviorTree.Variables.Remove(this.Output_MainTargetVarName); } return(State.Failure); } if (aiBehaviorTree.Variables.ContainsKey(this.Output_MainTargetVarName)) { aiBehaviorTree.Variables[this.Output_MainTargetVarName] = worldPositionable; } else { aiBehaviorTree.Variables.Add(this.Output_MainTargetVarName, worldPositionable); } } if (aiBehaviorTree.Variables.ContainsKey(this.Output_TargetVarName)) { aiBehaviorTree.Variables[this.Output_TargetVarName] = value; } else { aiBehaviorTree.Variables.Add(this.Output_TargetVarName, value); } return(State.Success); }
protected override State Execute(QuestBehaviour questBehaviour, params object[] parameters) { if (!this.TryInitializingTargets(questBehaviour, this.ForceUpdate)) { Diagnostics.LogError("ELCP {0} {2} {1} QuestBehaviourTreeNode_Action_SendAICommand TryInitializingTargets failed!", new object[] { questBehaviour.Initiator, this.Type, questBehaviour.Quest.QuestDefinition.Name }); return(State.Success); } if (Amplitude.Unity.Framework.Application.Preferences.EnableModdingTools) { Diagnostics.Log("ELCP {0} QuestBehaviourTreeNode_Action_SendAICommand {2} {1}, Target {3}, RequiredMilitaryPower {4}, Cancel {5}, Region {6}, ForceArmyGUID {7}, {8}, {9}", new object[] { questBehaviour.Initiator, this.Type, questBehaviour.Quest.QuestDefinition.Name, this.TargetEntityGUID, this.RequiredMilitaryPower, this.CancelOrder, this.TargetRegionIndex, this.ForceArmyGUID, this.ResourceName, this.WantedAmount }); } ISessionService service = Services.GetService <ISessionService>(); if (service == null || service.Session == null || !service.Session.IsHosting) { return(State.Success); } GameServer gameServer = (service.Session as global::Session).GameServer as GameServer; AIPlayer_MajorEmpire aiplayer_MajorEmpire; if (gameServer != null && gameServer.AIScheduler != null && gameServer.AIScheduler.TryGetMajorEmpireAIPlayer(questBehaviour.Initiator as MajorEmpire, out aiplayer_MajorEmpire) && aiplayer_MajorEmpire.AIState != AIPlayer.PlayerState.EmpireControlledByHuman) { AIEntity entity = aiplayer_MajorEmpire.GetEntity <AIEntity_Empire>(); if (entity != null) { if (this.Type == QuestBehaviourTreeNode_Action_SendAICommand.CommandType.VisitTarget && this.TargetEntityGUID > 0UL) { if (this.ForceArmyGUID > 0UL) { AILayer_QuestSolver layer = entity.GetLayer <AILayer_QuestSolver>(); if (!this.CancelOrder) { layer.AddQuestSolverOrder(questBehaviour.Quest.QuestDefinition.Name, new GameEntityGUID(this.TargetEntityGUID), new GameEntityGUID(this.ForceArmyGUID)); } else { layer.RemoveQuestSolverOrder(questBehaviour.Quest.QuestDefinition.Name, new GameEntityGUID(this.ForceArmyGUID)); } } else { AILayer_QuestBTController layer2 = entity.GetLayer <AILayer_QuestBTController>(); if (!this.CancelOrder) { if (!string.IsNullOrEmpty(this.ResourceName)) { layer2.AddQuestBTOrder(questBehaviour.Quest.QuestDefinition.Name, new GameEntityGUID(this.TargetEntityGUID), this.RequiredMilitaryPower, this.ResourceName, this.WantedAmount); } else { layer2.AddQuestBTOrder(questBehaviour.Quest.QuestDefinition.Name, new GameEntityGUID(this.TargetEntityGUID), this.RequiredMilitaryPower); } } else { layer2.RemoveQuestBTOrder(questBehaviour.Quest.QuestDefinition.Name, new GameEntityGUID(this.TargetEntityGUID)); } } } else if (this.Type == QuestBehaviourTreeNode_Action_SendAICommand.CommandType.SuspendPacification) { AILayer_Village layer3 = entity.GetLayer <AILayer_Village>(); if (!this.CancelOrder) { layer3.SuspendPacifications(questBehaviour.Quest.QuestDefinition.Name); } else { layer3.ResumePacifications(questBehaviour.Quest.QuestDefinition.Name); } } else if (this.Type == QuestBehaviourTreeNode_Action_SendAICommand.CommandType.PacifyVillage && this.TargetEntityGUID > 0UL) { AILayer_Village layer4 = entity.GetLayer <AILayer_Village>(); if (!this.CancelOrder) { layer4.AddQuestVillageToPrioritize(questBehaviour.Quest.QuestDefinition.Name, this.TargetEntityGUID); } else { layer4.RemoveQuestVillageToPrioritize(questBehaviour.Quest.QuestDefinition.Name, this.TargetEntityGUID); } } else if (this.Type == QuestBehaviourTreeNode_Action_SendAICommand.CommandType.PacifyRegion && this.TargetRegionIndex >= 0) { AILayer_Pacification layer5 = entity.GetLayer <AILayer_Pacification>(); if (!this.CancelOrder) { layer5.AddQuestBTPacification(questBehaviour.Quest.QuestDefinition.Name, this.TargetRegionIndex); } else { layer5.RemoveQuestBTPacification(questBehaviour.Quest.QuestDefinition.Name, this.TargetRegionIndex); } } } } return(State.Success); }
protected override State Execute(AIBehaviorTree aiBehaviorTree, params object[] parameters) { global::Empire empire = aiBehaviorTree.AICommander.Empire; if (empire == null || !(empire is MajorEmpire)) { aiBehaviorTree.ErrorCode = 10; return(State.Failure); } GameServer gameServer = (Services.GetService <ISessionService>().Session as global::Session).GameServer as GameServer; if (this.ailayer_War == null) { try { AIPlayer_MajorEmpire aiplayer_MajorEmpire; if (gameServer.AIScheduler != null && gameServer.AIScheduler.TryGetMajorEmpireAIPlayer(empire as MajorEmpire, out aiplayer_MajorEmpire)) { AIEntity entity = aiplayer_MajorEmpire.GetEntity <AIEntity_Empire>(); if (entity != null) { this.ailayer_War = entity.GetLayer <AILayer_War>(); } } } catch (Exception ex) { Diagnostics.LogError("{0}", new object[] { ex }); } } if (this.ailayer_War == null) { return(State.Failure); } if (this.ailayer_War.warCityDefenseJobs.Count == 0) { return(State.Failure); } Army key; if (base.GetArmyUnlessLocked(aiBehaviorTree, "$Army", out key) > AIArmyMission.AIArmyMissionErrorCode.None) { return(State.Failure); } bool flag = false; City city = null; if (this.ailayer_War.DefensiveArmyAssignations.TryGetValue(key, out city) && city != null) { if (aiBehaviorTree.Variables.ContainsKey(this.Output_TargetVarName)) { aiBehaviorTree.Variables[this.Output_TargetVarName] = city; } else { aiBehaviorTree.Variables.Add(this.Output_TargetVarName, city); } flag = true; } if (!flag) { if (this.Inverted) { return(State.Success); } return(State.Failure); } else { if (this.Inverted) { return(State.Failure); } return(State.Success); } }
protected override State Execute(AIBehaviorTree behaviorTree, params object[] parameters) { Army army; if (base.GetArmyUnlessLocked(behaviorTree, "$Army", out army) != AIArmyMission.AIArmyMissionErrorCode.None) { return(State.Failure); } Empire empire = behaviorTree.AICommander.Empire; if (empire == null || !(empire is MajorEmpire)) { behaviorTree.ErrorCode = 10; return(State.Failure); } if (!behaviorTree.Variables.ContainsKey(this.CityUnderSiege)) { behaviorTree.LogError("city not set", new object[0]); return(State.Failure); } City city = behaviorTree.Variables[this.CityUnderSiege] as City; if (city == null || city.BesiegingEmpire == null) { behaviorTree.ErrorCode = 8; return(State.Failure); } if (this.SiegeLayer == null) { GameServer gameServer = (Services.GetService <ISessionService>().Session as global::Session).GameServer as GameServer; AIPlayer_MajorEmpire aiplayer_MajorEmpire; if (gameServer.AIScheduler != null && gameServer.AIScheduler.TryGetMajorEmpireAIPlayer(empire as MajorEmpire, out aiplayer_MajorEmpire)) { AIEntity entity = aiplayer_MajorEmpire.GetEntity <AIEntity_Empire>(); if (entity != null) { this.SiegeLayer = entity.GetLayer <AILayer_SiegeBreaker>(); } } if (this.SiegeLayer == null) { return(State.Failure); } } if (!this.WaitForSupport) { this.SiegeLayer.UpdateSiegeBreakerArmyAssignation(army, city); return(State.Success); } if (!behaviorTree.Variables.ContainsKey(this.DestinationVarName)) { return(State.Failure); } WorldPosition targetPosition = (WorldPosition)behaviorTree.Variables[this.DestinationVarName]; if (!targetPosition.IsValid) { behaviorTree.ErrorCode = 2; return(State.Failure); } if (this.SiegeLayer.WaitForSupport(army, city, targetPosition)) { return(State.Success); } return(State.Failure); }