protected void CheckVictoryQuestForEmpire(Empire empire)
    {
        IQuestManagementService service = base.ServiceContainer.GetService <IQuestManagementService>();

        if (service != null)
        {
            service.State.Tags.Clear();
            service.State.Tags.AddTag(VictoryManager.TagVictoryManager);
            service.State.Tags.AddTag(VictoryManager.TagVictoryManagerOnBeginTurn);
            service.State.Tags.AddTag(QuestDefinition.TagExclusive);
            service.State.WorldPosition = WorldPosition.Invalid;
            service.State.Empire        = empire;
            service.State.Targets.Clear();
            service.State.AddTargets("$(Empire)", empire);
            service.State.AddTargets("$(Empires)", (from emp in base.Game.Empires
                                                    where emp is MajorEmpire
                                                    select emp).ToArray <Empire>());
            QuestDefinition    questDefinition;
            QuestVariable[]    questVariables;
            QuestInstruction[] pendingInstructions;
            QuestReward[]      questRewards;
            Dictionary <Region, List <string> > regionQuestLocalizationVariableDefinitionLocalizationKey;
            if (service.TryTrigger(out questDefinition, out questVariables, out pendingInstructions, out questRewards, out regionQuestLocalizationVariableDefinitionLocalizationKey))
            {
                service.Trigger(empire, questDefinition, questVariables, pendingInstructions, questRewards, regionQuestLocalizationVariableDefinitionLocalizationKey, null, true);
            }
        }
    }
    private void FilterPointOfInterests(Army army, ref bool available)
    {
        IGameService service = Services.GetService <IGameService>();

        if (service == null)
        {
            return;
        }
        global::Game x = service.Game as global::Game;

        if (x == null)
        {
            return;
        }
        IQuestManagementService service2 = service.Game.Services.GetService <IQuestManagementService>();

        Diagnostics.Assert(service2 != null);
        IQuestRepositoryService service3 = service.Game.Services.GetService <IQuestRepositoryService>();

        Diagnostics.Assert(service2 != null);
        available = false;
        for (int i = base.PointsOfInterest.Count - 1; i >= 0; i--)
        {
            if (!this.CanSearch(army, base.PointsOfInterest[i], service2, service3, ref available))
            {
                base.PointsOfInterest.RemoveAt(i);
            }
        }
    }
    protected override State Execute(QuestBehaviour questBehaviour, EventTerraformDeviceEntityCreated e, params object[] parameters)
    {
        global::Game game = Services.GetService <IGameService>().Game as global::Game;

        if (this.DevicePositionVarName == string.Empty)
        {
            return(State.Success);
        }
        IEnumerable <WorldPosition> source;

        if (this.DevicePositionVarName != null && questBehaviour.TryGetQuestVariableValueByName <WorldPosition>(this.DevicePositionVarName, out source))
        {
            this.DevicePositions = source.ToArray <WorldPosition>();
        }
        if (this.DevicePositions != null && this.DevicePositions[0] == e.TerraformDevice.WorldPosition)
        {
            IQuestManagementService service = game.Services.GetService <IQuestManagementService>();
            if (service != null)
            {
                this.EntityGUID = e.TerraformDevice.GUID;
                QuestVariable questVariable = new QuestVariable(this.Output_EntityVarName, e.TerraformDevice);
                service.State.AddGlobalVariable(questBehaviour.Initiator.Index, questVariable);
            }
            return(State.Success);
        }
        return(State.Running);
    }
    private void UpdateShowLocationButton()
    {
        IQuestManagementService service = base.Game.Services.GetService <IQuestManagementService>();

        Diagnostics.Assert(service != null);
        List <QuestMarker> list = service.GetMarkersByQuestGUID(this.Quest.GUID).ToList <QuestMarker>();

        list.RemoveAll((QuestMarker match) => !match.IsVisibleFor(this.empire));
        this.questLocations = list;
        this.ShowLocationButton.AgeTransform.Visible = (list.Count > 0);
    }
 internal void OnBeginTurn()
 {
     if (base.Game.Turn > this.TurnWhenLastBegun || base.Game.Turn == 0)
     {
         this.TurnWhenLastBegun = base.Game.Turn;
         IQuestManagementService service = base.ServiceContainer.GetService <IQuestManagementService>();
         if (service != null)
         {
             service.State.Tags.Clear();
             service.State.Tags.AddTag(VictoryManager.TagVictoryManager);
             service.State.Tags.AddTag(VictoryManager.TagVictoryManagerOnBeginTurn);
             service.State.Tags.AddTag(QuestDefinition.TagExclusive);
             service.State.WorldPosition = WorldPosition.Invalid;
             for (int i = 0; i < base.Game.Empires.Length; i++)
             {
                 if (!(base.Game.Empires[i] is MajorEmpire))
                 {
                     return;
                 }
                 if (base.Game.Turn != 0 || (base.Game.Empires[i] as MajorEmpire).IsSpectator)
                 {
                     Empire empire = base.Game.Empires[i];
                     service.State.Empire = empire;
                     service.State.Targets.Clear();
                     service.State.AddTargets("$(Empire)", empire);
                     service.State.AddTargets("$(Empires)", (from emp in base.Game.Empires
                                                             where emp is MajorEmpire
                                                             select emp).ToArray <Empire>());
                     QuestDefinition    questDefinition;
                     QuestVariable[]    questVariables;
                     QuestInstruction[] pendingInstructions;
                     QuestReward[]      questRewards;
                     Dictionary <Region, List <string> > regionQuestLocalizationVariableDefinitionLocalizationKey;
                     if (service.TryTrigger(out questDefinition, out questVariables, out pendingInstructions, out questRewards, out regionQuestLocalizationVariableDefinitionLocalizationKey))
                     {
                         service.Trigger(empire, questDefinition, questVariables, pendingInstructions, questRewards, regionQuestLocalizationVariableDefinitionLocalizationKey, null, true);
                     }
                 }
             }
             return;
         }
     }
     else
     {
         Diagnostics.Log("Skipping interaction because quests have already been triggered (turn: {0}, last checked: {1}).", new object[]
         {
             base.Game.Turn,
             this.TurnWhenLastBegun
         });
     }
 }
    private List <IWorldPositionable> Execute_GetRuins(AIBehaviorTree aiBehaviorTree, Army army, IGameService gameService, List <IWorldPositionable> unfilteredTargetList)
    {
        IQuestManagementService   questManagementService = gameService.Game.Services.GetService <IQuestManagementService>();
        IQuestRepositoryService   questRepositoryService = gameService.Game.Services.GetService <IQuestRepositoryService>();
        List <IWorldPositionable> list = new List <IWorldPositionable>();

        list = unfilteredTargetList.FindAll((IWorldPositionable match) => this.CanSearch(army, match, questManagementService, questRepositoryService));
        if (army.Empire is MajorEmpire && !army.HasCatspaw && aiBehaviorTree.AICommander.AIPlayer.AIState != AIPlayer.PlayerState.EmpireControlledByHuman)
        {
            this.CursedBountyPosition = WorldPosition.Invalid;
            list.AddRange(unfilteredTargetList.FindAll((IWorldPositionable match) => this.CanSearchQuest(army, match, questManagementService, questRepositoryService)));
            if (this.CursedBountyPosition.IsValid)
            {
                list.RemoveAll((IWorldPositionable match) => match.WorldPosition == this.CursedBountyPosition);
            }
        }
        return(list);
    }
    protected override bool Initialize(QuestBehaviour questBehaviour)
    {
        IGameService service = Services.GetService <IGameService>();
        global::Game game    = service.Game as global::Game;

        if (service == null || service.Game == null || !(service.Game is global::Game))
        {
            Diagnostics.LogError("Unable to retrieve the game service.");
            return(false);
        }
        IGameEntityRepositoryService service2 = service.Game.Services.GetService <IGameEntityRepositoryService>();

        if (service2 == null)
        {
            Diagnostics.LogError("Unable to retrieve the game entity repository service.");
            return(false);
        }
        IEnumerable <WorldPosition> source;

        if (this.DevicePositions == null && questBehaviour.TryGetQuestVariableValueByName <WorldPosition>(this.DevicePositionVarName, out source))
        {
            this.DevicePositions = source.ToArray <WorldPosition>();
        }
        if (this.EntityGUID == 0UL)
        {
            this.EntityGUID = service2.GenerateGUID();
        }
        QuestVariable questVariable = questBehaviour.GetQuestVariableByName(this.Output_EntityVarName);

        if (questVariable == null)
        {
            questVariable = new QuestVariable(this.Output_EntityVarName);
            questBehaviour.QuestVariables.Add(questVariable);
            IQuestManagementService service3 = game.Services.GetService <IQuestManagementService>();
            if (service3 != null)
            {
                QuestVariable questVariable2 = new QuestVariable(this.Output_EntityVarName, this.EntityGUID);
                service3.State.AddGlobalVariable(questBehaviour.Initiator.Index, questVariable2);
            }
        }
        questVariable.Object = this.EntityGUID;
        return(base.Initialize(questBehaviour));
    }
    private bool CanSearch(Army army, IWorldPositionable item, IQuestManagementService questManagementService, IQuestRepositoryService questRepositoryService)
    {
        if (army.HasCatspaw)
        {
            return(false);
        }
        PointOfInterest pointOfInterest = item as PointOfInterest;

        if (pointOfInterest == null)
        {
            return(false);
        }
        if (pointOfInterest.Type != ELCPUtilities.QuestLocation && pointOfInterest.Type != "NavalQuestLocation")
        {
            return(false);
        }
        if (pointOfInterest.Interaction.IsLocked(army.Empire.Index, "ArmyActionSearch"))
        {
            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.CreepingNodeGUID != GameEntityGUID.Zero && pointOfInterest.Empire != army.Empire)
        {
            return(false);
        }
        if ((pointOfInterest.Interaction.Bits & army.Empire.Bits) == army.Empire.Bits && !SimulationGlobal.GlobalTagsContains(SeasonManager.RuinDustDepositsTag))
        {
            return(false);
        }
        if (SimulationGlobal.GlobalTagsContains(SeasonManager.RuinDustDepositsTag) && !pointOfInterest.UntappedDustDeposits && (pointOfInterest.Interaction.Bits & army.Empire.Bits) == army.Empire.Bits)
        {
            return(false);
        }
        if ((pointOfInterest.Interaction.Bits & army.Empire.Bits) != 0)
        {
            using (IEnumerator <QuestMarker> enumerator = questManagementService.GetMarkersByBoundTargetGUID(pointOfInterest.GUID).GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    Quest quest;
                    if (questRepositoryService.TryGetValue(enumerator.Current.QuestGUID, out quest) && quest.EmpireBits == army.Empire.Bits)
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
        return(true);
    }
    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);
    }
 public override bool Execute(Quest quest)
 {
     Diagnostics.Assert(quest != null);
     if (this.StepNumber >= 0 && this.StepNumber < quest.StepStates.Length)
     {
         quest.StepStates[this.StepNumber] = this.State;
         QuestState state = this.State;
         if (state != QuestState.InProgress)
         {
             if (state != QuestState.Completed || quest.QuestRewards == null)
             {
                 return(true);
             }
             IGameService service = Services.GetService <IGameService>();
             if (service == null || service.Game.Services.GetService <IGameEntityRepositoryService>() == null || service.Game.Services.GetService <IPlayerControllerRepositoryService>() == null)
             {
                 return(true);
             }
             IQuestManagementService service2 = service.Game.Services.GetService <IQuestManagementService>();
             if (service2 == null)
             {
                 return(true);
             }
             List <QuestReward> list = new List <QuestReward>(quest.QuestRewards);
             list.RemoveAll((QuestReward reward) => reward.JustForShow);
             if (quest.QuestDefinition.GlobalWinner == GlobalQuestWinner.Participants)
             {
                 List <QuestReward> list2 = (from reward in list
                                             where reward.StepNumber == this.StepNumber && reward.MinimumRank > 0
                                             select reward).ToList <QuestReward>();
                 if (list2.Count > 0)
                 {
                     int num  = 0;
                     int rank = service2.GetGlobalQuestRank(quest, ref num, quest.QuestDefinition.Steps[this.StepNumber].Name) + 1;
                     list2.RemoveAll((QuestReward reward) => reward.MinimumRank >= rank);
                     for (int i = 0; i < list2.Count; i++)
                     {
                         list.Remove(list2[i]);
                     }
                 }
             }
             service2.AddStepRewards(quest.QuestDefinition, this.StepNumber, list, null, quest);
             Dictionary <StaticString, DroppableResource> dictionary = new Dictionary <StaticString, DroppableResource>();
             for (int j = list.Count - 1; j >= 0; j--)
             {
                 QuestReward questReward = list[j];
                 if (!questReward.Hidden && questReward.StepNumber == this.StepNumber && questReward.Droppables != null)
                 {
                     List <IDroppable> list3 = new List <IDroppable>(questReward.Droppables);
                     for (int k = list3.Count - 1; k >= 0; k--)
                     {
                         DroppableResource droppableResource = list3[k] as DroppableResource;
                         if (droppableResource != null)
                         {
                             if (dictionary.ContainsKey(droppableResource.ResourceName))
                             {
                                 dictionary[droppableResource.ResourceName].Quantity += droppableResource.Quantity;
                             }
                             else
                             {
                                 dictionary.Add(droppableResource.ResourceName, new DroppableResource(droppableResource.ResourceName, droppableResource.Quantity));
                             }
                             list3.RemoveAt(k);
                             if (list3.Count == 0 && string.IsNullOrEmpty(questReward.LocalizationKey))
                             {
                                 list.RemoveAt(j);
                                 break;
                             }
                         }
                     }
                     questReward.Droppables = list3.ToArray();
                 }
             }
             List <QuestReward> list4 = list;
             int          stepNumber  = this.StepNumber;
             bool         hidden      = false;
             IDroppable[] array       = dictionary.Select(delegate(KeyValuePair <StaticString, DroppableResource> kvp)
             {
                 KeyValuePair <StaticString, DroppableResource> keyValuePair = kvp;
                 return(keyValuePair.Value);
             }).ToArray <DroppableResource>();
             list4.Add(new QuestReward(stepNumber, hidden, array, string.Empty, false, -1));
             quest.QuestRewards = list.ToArray();
             using (IEnumerator <QuestReward> enumerator = (from reward in quest.QuestRewards
                                                            where reward.StepNumber == this.StepNumber
                                                            select reward).GetEnumerator())
             {
                 while (enumerator.MoveNext())
                 {
                     QuestReward questReward2 = enumerator.Current;
                     if (questReward2.Droppables == null)
                     {
                         Diagnostics.LogWarning("Quest reward has no droppables.");
                     }
                     else
                     {
                         for (int l = 0; l < questReward2.Droppables.Length; l++)
                         {
                             if (questReward2.Droppables[l] != null)
                             {
                                 IDroppableWithRewardAllocation droppableWithRewardAllocation = questReward2.Droppables[l] as IDroppableWithRewardAllocation;
                                 if (droppableWithRewardAllocation != null)
                                 {
                                     for (int m = 0; m < 32; m++)
                                     {
                                         if ((quest.EmpireBits & 1 << m) != 0)
                                         {
                                             try
                                             {
                                                 global::Empire empire = (service.Game as global::Game).Empires[m];
                                                 if (!empire.SimulationObject.Tags.Contains(global::Empire.TagEmpireEliminated))
                                                 {
                                                     droppableWithRewardAllocation.AllocateRewardTo(empire, new object[0]);
                                                 }
                                             }
                                             catch
                                             {
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
                 return(true);
             }
         }
         if (quest.QuestRewards != null)
         {
             IGameService service3 = Services.GetService <IGameService>();
             if (service3 != null)
             {
                 IQuestManagementService service4 = service3.Game.Services.GetService <IQuestManagementService>();
                 if (service4 != null)
                 {
                     global::Empire empire2 = null;
                     for (int n = 0; n < 32; n++)
                     {
                         if ((quest.EmpireBits & 1 << n) != 0)
                         {
                             try
                             {
                                 empire2 = (service3.Game as global::Game).Empires[n];
                                 break;
                             }
                             catch
                             {
                             }
                         }
                     }
                     if (empire2 != null)
                     {
                         bool flag = false;
                         List <QuestReward> list5 = new List <QuestReward>(quest.QuestRewards);
                         foreach (QuestReward questReward3 in from reward in quest.QuestRewards
                                  where reward.StepNumber == this.StepNumber
                                  select reward)
                         {
                             questReward3.Hidden = this.HideRewards;
                             if (questReward3.Droppables != null)
                             {
                                 foreach (IDroppable droppable in questReward3.Droppables)
                                 {
                                     if (droppable != null && droppable is DroppableReferenceTechnology)
                                     {
                                         TechnologyDefinition technologyDefinition = (droppable as DroppableReferenceTechnology).ConstructibleElement as TechnologyDefinition;
                                         if (technologyDefinition != null && empire2.GetAgency <DepartmentOfScience>().GetTechnologyState(technologyDefinition.Name) == DepartmentOfScience.ConstructibleElement.State.Researched)
                                         {
                                             list5.Remove(questReward3);
                                             flag = true;
                                         }
                                     }
                                 }
                             }
                         }
                         if (flag)
                         {
                             foreach (QuestReward item in service4.ComputeRewards(quest, quest.QuestDefinition, this.StepNumber, null))
                             {
                                 if (!list5.Contains(item))
                                 {
                                     list5.Add(item);
                                 }
                             }
                             quest.QuestRewards = list5.ToArray();
                         }
                     }
                 }
             }
         }
         return(true);
     }
     return(false);
 }
Exemple #11
0
    protected override void ShowTooltip(WorldPosition worldPosition)
    {
        if (this.guiTooltipService == null)
        {
            return;
        }
        if (AgeManager.IsMouseCovered)
        {
            return;
        }
        IWorldPositionningService service = base.GameService.Game.Services.GetService <IWorldPositionningService>();

        if (worldPosition.IsValid)
        {
            if (service != null)
            {
                if (service == null)
                {
                    this.guiTooltipService.HideTooltip();
                    return;
                }
                if ((service.GetExplorationBits(worldPosition) & base.EmpireBits) == 0)
                {
                    this.guiTooltipService.HideTooltip();
                    return;
                }
                AgeTransform         cursorTooltipAnchor = this.guiTooltipService.GetCursorTooltipAnchor();
                AgeTooltipAnchorMode anchorMode          = AgeTooltipAnchorMode.FREE;
                global::CursorTarget cursorTarget        = null;
                if (base.CursorTargetService.HighlightedCursorTargets.Count > 0)
                {
                    for (int i = 0; i < base.CursorTargetService.HighlightedCursorTargets.Count; i++)
                    {
                        Diagnostics.Log("Cursortarget {0} at {1} is {2} and has tooltipclass {3}", new object[]
                        {
                            i,
                            worldPosition,
                            base.CursorTargetService.HighlightedCursorTargets[i].GetType(),
                            (base.CursorTargetService.HighlightedCursorTargets[i] as global::CursorTarget).TooltipClass
                        });
                        Diagnostics.Log("Conten: {0}", new object[]
                        {
                            (base.CursorTargetService.HighlightedCursorTargets[i] as global::CursorTarget).TooltipContent
                        });
                        Diagnostics.Log("Context: {0}", new object[]
                        {
                            (base.CursorTargetService.HighlightedCursorTargets[i] as global::CursorTarget).TooltipContext.GetType()
                        });
                        if (cursorTarget == null)
                        {
                            cursorTarget = (base.CursorTargetService.HighlightedCursorTargets[i] as global::CursorTarget);
                        }
                        else if (StaticString.IsNullOrEmpty(cursorTarget.TooltipClass))
                        {
                            cursorTarget = (base.CursorTargetService.HighlightedCursorTargets[i] as global::CursorTarget);
                        }
                    }
                }
                string          text            = string.Format("Worldposition: {0} {1}", worldPosition.Row, worldPosition.Column);
                PointOfInterest pointOfInterest = service.GetPointOfInterest(worldPosition);
                if (pointOfInterest != null)
                {
                    text += "\nhas POI!";
                    IQuestManagementService service2 = base.GameService.Game.Services.GetService <IQuestManagementService>();
                    IQuestRepositoryService service3 = base.GameService.Game.Services.GetService <IQuestRepositoryService>();
                    global::Empire          empire   = base.GameService.Game.Services.GetService <IPlayerControllerRepositoryService>().ActivePlayerController.Empire as global::Empire;
                    if (empire != null)
                    {
                        text += string.Concat(new object[]
                        {
                            "\n",
                            pointOfInterest.Type,
                            ", ",
                            pointOfInterest.Interaction.IsLocked(empire.Index, "ArmyActionSearch").ToString(),
                            ", ",
                            pointOfInterest.Interaction.Bits,
                            ", ",
                            empire.Bits,
                            ", ",
                            (pointOfInterest.Interaction.Bits & empire.Bits) == empire.Bits,
                            ", ",
                            pointOfInterest.UntappedDustDeposits.ToString(),
                            ", ",
                            SimulationGlobal.GlobalTagsContains(SeasonManager.RuinDustDepositsTag).ToString()
                        }).ToString();
                        foreach (QuestMarker questMarker in service2.GetMarkersByBoundTargetGUID(pointOfInterest.GUID))
                        {
                            Quest quest;
                            if (service3.TryGetValue(questMarker.QuestGUID, out quest))
                            {
                                text = text + "\nhas Questmarker for quest" + quest.QuestDefinition.Name;
                                QuestBehaviour questBehaviour = service3.GetQuestBehaviour(quest.Name, empire.Index);
                                if (questBehaviour != null)
                                {
                                    QuestBehaviourTreeNode_ConditionCheck_HasResourceAmount questBehaviourTreeNode_ConditionCheck_HasResourceAmount;
                                    if (quest.QuestDefinition.Variables.First((QuestVariableDefinition p) => p.VarName == "$NameOfStrategicResourceToGather1") != null && this.TryGetFirstNodeOfType <QuestBehaviourTreeNode_ConditionCheck_HasResourceAmount>(questBehaviour.Root as BehaviourTreeNodeController, out questBehaviourTreeNode_ConditionCheck_HasResourceAmount))
                                    {
                                        string resourceName = questBehaviourTreeNode_ConditionCheck_HasResourceAmount.ResourceName;
                                        int    wantedAmount = questBehaviourTreeNode_ConditionCheck_HasResourceAmount.WantedAmount;
                                        text = text + "\nResource: " + resourceName;
                                        text = text + "\nAmount: " + wantedAmount;
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
                if (!(cursorTarget != null) || StaticString.IsNullOrEmpty(cursorTarget.TooltipClass))
                {
                    if (base.TooltipFilters != null)
                    {
                        if (!Array.Exists <StaticString>(base.TooltipFilters, (StaticString match) => match == "Terrain"))
                        {
                            this.guiTooltipService.HideTooltip();
                            return;
                        }
                    }
                    this.guiTooltipService.ShowTooltip(string.Empty, text, worldPosition, cursorTooltipAnchor, anchorMode, 0f, false);
                    return;
                }
                if (base.TooltipFilters == null || Array.Exists <StaticString>(base.TooltipFilters, (StaticString match) => match == cursorTarget.TooltipClass))
                {
                    this.guiTooltipService.ShowTooltip(string.Empty, text, worldPosition, cursorTooltipAnchor, anchorMode, 0f, false);
                    return;
                }
                this.guiTooltipService.HideTooltip();
                return;
            }
        }
        else
        {
            this.guiTooltipService.HideTooltip();
        }
    }
Exemple #12
0
    protected override bool Initialize(QuestBehaviour questBehaviour)
    {
        IGameService service = Services.GetService <IGameService>();

        if (service == null || service.Game == null)
        {
            Diagnostics.LogError("Failed to retrieve the game service.");
            return(false);
        }
        global::Game game = service.Game as global::Game;

        if (game == null)
        {
            Diagnostics.LogError("Failed to cast gameService.Game to Game.");
            return(false);
        }
        this.gameEntityRepositoryService = game.Services.GetService <IGameEntityRepositoryService>();
        if (this.gameEntityRepositoryService == null)
        {
            Diagnostics.LogError("Failed to retrieve the game entity repository service.");
            return(false);
        }
        IEnumerable <WorldPosition> source;

        if (this.SpawnLocations == null && questBehaviour.TryGetQuestVariableValueByName <WorldPosition>(this.SpawnLocationVarName, out source))
        {
            this.SpawnLocations = source.ToArray <WorldPosition>();
        }
        if (!string.IsNullOrEmpty(this.ForbiddenSpawnLocationVarName) && !questBehaviour.QuestVariables.Exists((QuestVariable match) => match.Name == this.ForbiddenSpawnLocationVarName))
        {
            QuestVariable questVariable = new QuestVariable(this.ForbiddenSpawnLocationVarName);
            questVariable.Object = new List <WorldPosition>();
            questBehaviour.QuestVariables.Add(questVariable);
        }
        if (this.ArmyGUID != GameEntityGUID.Zero && !questBehaviour.QuestVariables.Exists((QuestVariable match) => match.Name == this.OutputEnemyArmyGUIDVarName))
        {
            QuestVariable questVariable2 = new QuestVariable(this.OutputEnemyArmyGUIDVarName);
            questVariable2.Object = this.ArmyGUID;
            questBehaviour.QuestVariables.Add(questVariable2);
        }
        if (this.EmpireArmyOwnerIndex == -1)
        {
            if (!string.IsNullOrEmpty(this.EmpireArmyOwnerVarName))
            {
                global::Empire empireArmyOwner;
                if (!questBehaviour.TryGetQuestVariableValueByName <global::Empire>(this.EmpireArmyOwnerVarName, out empireArmyOwner))
                {
                    Diagnostics.LogError("Cannot retrieve quest variable (varname: '{0}')", new object[]
                    {
                        this.EmpireArmyOwnerVarName
                    });
                    return(false);
                }
                this.EmpireArmyOwner = empireArmyOwner;
            }
            if (this.EmpireArmyOwner == null)
            {
                this.EmpireArmyOwner = game.Empires.FirstOrDefault((global::Empire match) => match.Name == "LesserEmpire#0");
                if (this.EmpireArmyOwner == null)
                {
                    Diagnostics.LogError("Failed to retrieve the (lesser) quest empire.");
                    return(false);
                }
            }
            this.EmpireArmyOwnerIndex = this.EmpireArmyOwner.Index;
        }
        else
        {
            this.EmpireArmyOwner = game.Empires[this.EmpireArmyOwnerIndex];
        }
        if (this.ArmyDroplistSuffixVarName != string.Empty && this.ArmyDroplistSuffix == string.Empty)
        {
            string text;
            if (!questBehaviour.TryGetQuestVariableValueByName <string>(this.ArmyDroplistSuffixVarName, out text))
            {
                Diagnostics.LogError("Cannot retrieve quest variable (varname: '{0}', are you sure it is a string?)", new object[]
                {
                    this.ArmyDroplistSuffixVarName
                });
                return(false);
            }
            if (text == string.Empty)
            {
                Diagnostics.LogError("The suffix is an empty string (varname: '{0}')", new object[]
                {
                    this.ArmyDroplistSuffixVarName
                });
                return(false);
            }
            this.ArmyDroplistSuffix = text;
        }
        if (this.ArmyGUID == 0UL && !string.IsNullOrEmpty(this.OutputEnemyArmyGUIDVarName))
        {
            QuestVariable questVariable3 = questBehaviour.GetQuestVariableByName(this.OutputEnemyArmyGUIDVarName);
            if (questVariable3 == null)
            {
                questVariable3 = new QuestVariable(this.OutputEnemyArmyGUIDVarName);
                questBehaviour.QuestVariables.Add(questVariable3);
            }
            this.ArmyGUID         = this.gameEntityRepositoryService.GenerateGUID();
            questVariable3.Object = this.ArmyGUID;
            if (this.OutputEnemyArmyGUIDIsGlobal)
            {
                IQuestManagementService service2 = game.Services.GetService <IQuestManagementService>();
                if (service2 != null)
                {
                    QuestVariable questVariable4 = new QuestVariable(this.OutputEnemyArmyGUIDVarName, this.ArmyGUID);
                    service2.State.AddGlobalVariable(questBehaviour.Initiator.Index, questVariable4);
                }
            }
        }
        return(base.Initialize(questBehaviour));
    }
Exemple #13
0
    private void SelectTarget()
    {
        this.battleTarget = null;
        if (this.LastHighlightedWorldPosition == WorldPosition.Invalid)
        {
            return;
        }
        if (!base.VisibilityService.IsWorldPositionVisibleFor(this.LastHighlightedWorldPosition, this.Army.Empire))
        {
            return;
        }
        Region region = base.WorldPositionningService.GetRegion(this.LastHighlightedWorldPosition);

        if (region == null || this.battleTarget != null)
        {
            return;
        }
        PointOfInterest pointOfInterest = region.PointOfInterests.FirstOrDefault((PointOfInterest match) => match.WorldPosition == this.LastHighlightedWorldPosition);

        if (pointOfInterest != null && (pointOfInterest.Type == Fortress.Citadel || pointOfInterest.Type == Fortress.Facility))
        {
            Fortress fortressAt = region.NavalEmpire.GetAgency <PirateCouncil>().GetFortressAt(pointOfInterest.WorldPosition);
            this.battleTarget = fortressAt;
        }
        if (region != null)
        {
            District district = null;
            if (region.City != null && region.City.Empire != this.Army.Empire)
            {
                district = region.City.Districts.FirstOrDefault((District match) => match.WorldPosition == this.LastHighlightedWorldPosition);
            }
            if (district != null && district.Type != DistrictType.Exploitation)
            {
                this.battleTarget = district;
            }
        }
        if (this.battleTarget == null && region != null && region.City != null && region.City.Camp != null && region.City.Camp.WorldPosition == this.LastHighlightedWorldPosition && region.City.Empire != this.Army.Empire)
        {
            this.battleTarget = region.City.Camp;
        }
        if (this.battleTarget == null)
        {
            Army armyAtPosition = base.WorldPositionningService.GetArmyAtPosition(this.LastHighlightedWorldPosition);
            if (armyAtPosition != null && (!armyAtPosition.IsCamouflaged || base.VisibilityService.IsWorldPositionDetectedFor(this.LastHighlightedWorldPosition, this.Army.Empire)))
            {
                this.battleTarget = armyAtPosition;
            }
        }
        if (region != null && this.battleTarget == null)
        {
            pointOfInterest = region.PointOfInterests.FirstOrDefault((PointOfInterest match) => match.WorldPosition == this.LastHighlightedWorldPosition);
            if (pointOfInterest != null)
            {
                if (pointOfInterest.CreepingNodeGUID != GameEntityGUID.Zero)
                {
                    CreepingNode creepingNode = null;
                    base.GameEntityRepositoryService.TryGetValue <CreepingNode>(pointOfInterest.CreepingNodeGUID, out creepingNode);
                    if (creepingNode != null)
                    {
                        if (creepingNode.Empire.Index != this.Army.Empire.Index)
                        {
                            if (ELCPUtilities.UseELCPPeacefulCreepingNodes)
                            {
                                DepartmentOfForeignAffairs agency = this.Army.Empire.GetAgency <DepartmentOfForeignAffairs>();
                                if (agency != null && agency.IsFriend(creepingNode.Empire))
                                {
                                    if (pointOfInterest.Type == "QuestLocation")
                                    {
                                        this.battleTarget = pointOfInterest;
                                    }
                                    else if (pointOfInterest.Type == "Village")
                                    {
                                        IQuestManagementService   service  = base.GameService.Game.Services.GetService <IQuestManagementService>();
                                        IQuestRepositoryService   service2 = base.GameService.Game.Services.GetService <IQuestRepositoryService>();
                                        IEnumerable <QuestMarker> markersByBoundTargetGUID = service.GetMarkersByBoundTargetGUID(pointOfInterest.GUID);
                                        bool flag = false;
                                        foreach (QuestMarker questMarker in markersByBoundTargetGUID)
                                        {
                                            Quest quest;
                                            if (service2.TryGetValue(questMarker.QuestGUID, out quest) && quest.EmpireBits == this.Army.Empire.Bits)
                                            {
                                                Village villageAt = region.MinorEmpire.GetAgency <BarbarianCouncil>().GetVillageAt(pointOfInterest.WorldPosition);
                                                this.battleTarget = villageAt;
                                                flag = true;
                                                break;
                                            }
                                        }
                                        if (!flag)
                                        {
                                            this.battleTarget = creepingNode;
                                        }
                                    }
                                    else
                                    {
                                        this.battleTarget = creepingNode;
                                    }
                                }
                            }
                            else
                            {
                                this.battleTarget = creepingNode;
                            }
                        }
                        else if (pointOfInterest.Type == "QuestLocation" || pointOfInterest.Type == "NavalQuestLocation")
                        {
                            this.battleTarget = pointOfInterest;
                        }
                    }
                }
                else if (pointOfInterest.Type == "Village")
                {
                    Village villageAt2 = region.MinorEmpire.GetAgency <BarbarianCouncil>().GetVillageAt(pointOfInterest.WorldPosition);
                    this.battleTarget = villageAt2;
                }
                else if (pointOfInterest.Type == "QuestLocation" || pointOfInterest.Type == "NavalQuestLocation")
                {
                    this.battleTarget = pointOfInterest;
                }
            }
        }
        if (region != null && this.battleTarget == null && region.KaijuEmpire != null && region.Kaiju != null)
        {
            KaijuGarrison kaijuGarrison = region.Kaiju.KaijuGarrison;
            if (kaijuGarrison.WorldPosition == this.LastHighlightedWorldPosition)
            {
                this.battleTarget = kaijuGarrison;
            }
        }
        if (this.battleTarget == null)
        {
            TerraformDevice deviceAtPosition = (base.GameService.Game as global::Game).GetService <ITerraformDeviceService>().GetDeviceAtPosition(this.LastHighlightedWorldPosition);
            if (deviceAtPosition != null)
            {
                this.battleTarget = deviceAtPosition;
            }
        }
    }
 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);
     }
 }
Exemple #15
0
    public static bool CanSearch(global::Empire empire, IWorldPositionable item, IQuestManagementService questManagementService)
    {
        PointOfInterest pointOfInterest = item as PointOfInterest;

        if (pointOfInterest == null)
        {
            return(false);
        }
        if (pointOfInterest.Type != ELCPUtilities.QuestLocation && pointOfInterest.Type != "NavalQuestLocation")
        {
            Diagnostics.Log("fail1 {0}", new object[]
            {
                pointOfInterest.Type
            });
            return(false);
        }
        if (pointOfInterest.Interaction.IsLocked(empire.Index, "ArmyActionSearch"))
        {
            Diagnostics.Log("fail2");
            return(false);
        }
        if (ELCPUtilities.UseELCPPeacefulCreepingNodes)
        {
            if (pointOfInterest.CreepingNodeGUID != GameEntityGUID.Zero && pointOfInterest.Empire != empire)
            {
                if (pointOfInterest.Empire == null)
                {
                    return(false);
                }
                if (!(pointOfInterest.Empire is MajorEmpire))
                {
                    return(false);
                }
                DepartmentOfForeignAffairs agency = empire.GetAgency <DepartmentOfForeignAffairs>();
                if (agency == null)
                {
                    return(false);
                }
                if (!agency.IsFriend(pointOfInterest.Empire))
                {
                    return(false);
                }
            }
        }
        else if (pointOfInterest.CreepingNodeGUID != GameEntityGUID.Zero && pointOfInterest.Empire != empire)
        {
            return(false);
        }
        if ((pointOfInterest.Interaction.Bits & empire.Bits) == empire.Bits && !SimulationGlobal.GlobalTagsContains(SeasonManager.RuinDustDepositsTag))
        {
            Diagnostics.Log("fail3");
            return(false);
        }
        if (SimulationGlobal.GlobalTagsContains(SeasonManager.RuinDustDepositsTag) && !pointOfInterest.UntappedDustDeposits && (pointOfInterest.Interaction.Bits & empire.Bits) == empire.Bits)
        {
            Diagnostics.Log("fail4");
            return(false);
        }
        if ((pointOfInterest.Interaction.Bits & empire.Bits) != 0)
        {
            using (IEnumerator <QuestMarker> enumerator = questManagementService.GetMarkersByBoundTargetGUID(pointOfInterest.GUID).GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    if (enumerator.Current.IsVisibleFor(empire))
                    {
                        Diagnostics.Log("fail5");
                        return(false);
                    }
                }
            }
            return(true);
        }
        return(true);
    }
    private bool CanSearch(Army army, PointOfInterest pointOfInterest, IQuestManagementService questManagementService, IQuestRepositoryService questRepositoryService, ref bool available)
    {
        IGameService service = Services.GetService <IGameService>();

        if (service == null)
        {
            return(false);
        }
        global::Game game = service.Game as global::Game;

        if (game == null)
        {
            return(false);
        }
        if (pointOfInterest == null)
        {
            return(false);
        }
        if (pointOfInterest.Type != ELCPUtilities.QuestLocation)
        {
            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.CreepingNodeGUID != GameEntityGUID.Zero && pointOfInterest.Empire != army.Empire)
        {
            return(false);
        }
        bool flag = false;

        foreach (QuestMarker questMarker in questManagementService.GetMarkersByBoundTargetGUID(pointOfInterest.GUID))
        {
            Quest quest;
            if (!questMarker.IgnoreInteraction && questRepositoryService.TryGetValue(questMarker.QuestGUID, out quest) && quest.EmpireBits == army.Empire.Bits)
            {
                if (!quest.QuestDefinition.SkipLockedQuestTarget)
                {
                    available = true;
                    return(true);
                }
                flag = true;
            }
        }
        if (pointOfInterest.UntappedDustDeposits && SimulationGlobal.GlobalTagsContains(SeasonManager.RuinDustDepositsTag))
        {
            return(true);
        }
        if (pointOfInterest.Interaction.IsLocked(army.Empire.Index, this.Name))
        {
            return(false);
        }
        IWorldPositionningService service2 = game.Services.GetService <IWorldPositionningService>();

        if (service2 != null && service2.IsWaterTile(pointOfInterest.WorldPosition))
        {
            return(false);
        }
        global::Empire[] empires = game.Empires;
        for (int i = 0; i < empires.Length; i++)
        {
            using (IEnumerator <Army> enumerator2 = empires[i].GetAgency <DepartmentOfDefense>().Armies.GetEnumerator())
            {
                while (enumerator2.MoveNext())
                {
                    if (enumerator2.Current.WorldPosition == pointOfInterest.WorldPosition)
                    {
                        return(false);
                    }
                }
            }
        }
        if ((pointOfInterest.Interaction.Bits & army.Empire.Bits) == 0)
        {
            return(true);
        }
        available = true;
        if (flag)
        {
            available = true;
            return(true);
        }
        return(false);
    }