Beispiel #1
0
    private void ComputeTameCosts(global::Game game)
    {
        System.Random          random   = new System.Random(World.Seed);
        IDatabase <ArmyAction> database = Databases.GetDatabase <ArmyAction>(false);

        Diagnostics.Assert(database != null);
        Dictionary <string, List <PointOfInterestTemplate> > dictionary = KaijuTechsManager.ComputeLuxuryAbundance(game);

        for (int i = 0; i < database.Count <ArmyAction>(); i++)
        {
            ArmyAction armyAction = database.ElementAt(i);
            if (armyAction is IArmyActionWithKaijuTameCost)
            {
                KaijuTameCost tameCost = (armyAction as IArmyActionWithKaijuTameCost).TameCost;
                for (int j = 0; j < tameCost.CostDefinitions.Length; j++)
                {
                    KaijuTameCost.CostDefinition   costDefinition = tameCost.CostDefinitions[j];
                    List <PointOfInterestTemplate> list           = new List <PointOfInterestTemplate>();
                    list.AddRange(dictionary[costDefinition.LuxuryTier]);
                    PointOfInterestTemplate pointOfInterestTemplate = list[random.Next(list.Count)];
                    string empty = string.Empty;
                    if (pointOfInterestTemplate.Properties.TryGetValue("ResourceName", out empty))
                    {
                        costDefinition.SetResourceName(empty);
                    }
                }
            }
        }
    }
Beispiel #2
0
    public void Bind(Army army, ArmyAction armyAction, GameObject client, int index, IWorldPositionable target, IEnumerable <Unit> unitsSelection)
    {
        IGameService service = Services.GetService <IGameService>();

        if (service == null || service.Game == null || this.Army != null || this.ArmyAction != null)
        {
            this.Unbind();
        }
        this.Army           = army;
        this.ArmyAction     = armyAction;
        this.Client         = client;
        this.Target         = target;
        this.UnitsSelection = unitsSelection;
        this.ActionButton.OnActivateObject = this.Client;
        IGuiPanelHelper guiPanelHelper = Services.GetService <global::IGuiService>().GuiPanelHelper;

        Diagnostics.Assert(guiPanelHelper != null, "Unable to access GuiPanelHelper");
        GuiElement guiElement;

        if (guiPanelHelper.TryGetGuiElement(armyAction.Name, out guiElement))
        {
            this.ActionTitle.Text       = guiElement.Title;
            this.ActionDescription.Text = guiElement.Description;
            Texture2D image;
            if (guiPanelHelper.TryGetTextureFromIcon(guiElement, global::GuiPanel.IconSize.Large, out image))
            {
                this.ActionImage.Image = image;
            }
        }
        this.AgeTransform.AgeTooltip.Anchor = this.AgeTransform;
        this.RefreshCosts();
        this.RefreshCanExecute();
    }
Beispiel #3
0
    public void OnBattleEnd(ArmyAction oponentFormation, int score)
    {
        teamFormer.UpdateUtility(selfFormation, oponentFormation, score);
        int utility = teamFormer.GetUtilityOf(selfFormation, oponentFormation);

        teamFormer.UpdateValues(oponentFormation);
    }
Beispiel #4
0
    void InterpretatePlayerFormation()
    {
        ArmyAction formation = GameController.Get().playerController.GetPlayerFormation();

        foreach (Unit unit in formation.GetUnits())
        {
            int cellDataRelativeX = unit.GetPosition().GetX();
            int cellDataRelativeY = unit.GetPosition().GetY();

            CellData relativeCellData      = BoardData.Get().GetCellDataAt(cellDataRelativeX, cellDataRelativeY);
            Vector3  cellDataWorldPosition = boardBehaviour.GetWorldPositionOfCell(relativeCellData);

            UnitType   AI_unitUnitType = unit.GetUnitData().GetType();
            GameObject AI_unit         = GameController.Get().unitsPool.GetUnitInstance(AI_unitUnitType);

            relativeCellData.SetEmpty(false);

            AI_unit.SetActive(true);

            Soldier  AI_unitSoldier = AI_unit.GetComponent <Soldier>();
            TeamData team           = GameController.Get().GetPlayerTeamData();

            AI_unitSoldier.SetUnitType(AI_unitUnitType);
            team.AddSoldier(AI_unitSoldier);
            AI_unitSoldier.SetTeam(team);
            AI_unitSoldier.SetUnit(new Unit(unit));
            AI_unitSoldier.Start();
            AI_unit.GetComponent <DraggeableUnit>().enabled = false;

            AI_unit.transform.position = new Vector3(cellDataWorldPosition.x, cellDataWorldPosition.y + 0.5f, cellDataWorldPosition.z);
        }
    }
    private float GetNeededActionPointsForTheNeededAction(AIBehaviorTreeNode_Decorator_EvaluateOpportunity.TargetType actionType)
    {
        ArmyAction armyAction = null;

        switch (actionType)
        {
        case AIBehaviorTreeNode_Decorator_EvaluateOpportunity.TargetType.Army:
            this.armyActionDatabase.TryGetValue(ArmyAction_Attack.ReadOnlyName, out armyAction);
            break;

        case AIBehaviorTreeNode_Decorator_EvaluateOpportunity.TargetType.Ruin:
            this.armyActionDatabase.TryGetValue("ArmyActionSearch", out armyAction);
            break;

        case AIBehaviorTreeNode_Decorator_EvaluateOpportunity.TargetType.City:
            this.armyActionDatabase.TryGetValue(ArmyAction_Attack.ReadOnlyName, out armyAction);
            break;

        case AIBehaviorTreeNode_Decorator_EvaluateOpportunity.TargetType.Village:
            this.armyActionDatabase.TryGetValue(ArmyAction_Attack.ReadOnlyName, out armyAction);
            break;

        case AIBehaviorTreeNode_Decorator_EvaluateOpportunity.TargetType.Kaiju:
            this.armyActionDatabase.TryGetValue(ArmyAction_TameKaiju.ReadOnlyName, out armyAction);
            break;
        }
        if (armyAction != null)
        {
            return(armyAction.GetCostInActionPoints());
        }
        return(0f);
    }
Beispiel #6
0
    public static KaijuTameCost GetKaijuTameCost()
    {
        IDatabase <ArmyAction> database   = Databases.GetDatabase <ArmyAction>(false);
        ArmyAction             armyAction = null;

        if (database == null || !database.TryGetValue(ArmyAction_TameUnstunnedKaiju.ReadOnlyName, out armyAction))
        {
            return(null);
        }
        return((armyAction as IArmyActionWithKaijuTameCost).TameCost);
    }
Beispiel #7
0
    public void AddUnitToFormation(Unit u)
    {
        if (playerFormation is null)
        {
            playerFormation = new ArmyAction(AIController.Get().GetMaxUnitsInTeam());
        }

        if (choosenUnitsCount < (playerFormation.GetUnits().Length))
        {
            playerFormation.GetUnits()[choosenUnitsCount] = u;
            ++choosenUnitsCount;
        }
    }
    protected override bool Initialize(AIBehaviorTree aiBehaviorTree)
    {
        IDatabase <ArmyAction> database   = Databases.GetDatabase <ArmyAction>(false);
        ArmyAction             armyAction = null;

        if (database == null || !database.TryGetValue(ArmyAction_SettleKaiju.ReadOnlyName, out armyAction))
        {
            Diagnostics.LogError("AIBehaviorTreeNode_Action_SettleKaiju didnt find " + ArmyAction_SettleKaiju.ReadOnlyName);
        }
        else
        {
            this.armyAction_SettleKaiju = (armyAction as ArmyAction_SettleKaiju);
        }
        return(base.Initialize(aiBehaviorTree));
    }
Beispiel #9
0
 public void DecideFormations()
 {
     selfFormation = possibleActions.GetAt(selfIndex);
     GameController.Get().SetPlayerFormation(possibleActions.GetAt(playerIndex));
     playerIndex++;
     if (playerIndex == possibleActions.GetCount())
     {
         playerIndex = 0;
         selfIndex++;
         GameController.Get().UpdateXmL();
         if (selfIndex == possibleActions.GetCount())
         {
             // GAME OVER
             GameController.Get().OnGameEnds();
         }
     }
 }
Beispiel #10
0
    public static void UpdateTameCosts()
    {
        IDatabase <ArmyAction> database = Databases.GetDatabase <ArmyAction>(false);

        Diagnostics.Assert(database != null);
        int maxEraNumber = DepartmentOfScience.GetMaxEraNumber();

        for (int i = 0; i < database.Count <ArmyAction>(); i++)
        {
            ArmyAction armyAction = database.ElementAt(i);
            if (armyAction is IArmyActionWithKaijuTameCost)
            {
                KaijuTameCost tameCost = (armyAction as IArmyActionWithKaijuTameCost).TameCost;
                tameCost.UpdateActiveCost(maxEraNumber);
            }
        }
    }
    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);
    }
Beispiel #12
0
    protected override bool IsObjectiveValid(GlobalObjectiveMessage objective)
    {
        if (!(objective.ObjectiveType == base.ObjectiveType))
        {
            return(false);
        }
        ArmyAction             armyAction = null;
        IDatabase <ArmyAction> database   = Databases.GetDatabase <ArmyAction>(false);

        if (database == null || !database.TryGetValue("ArmyActionTameKaiju", out armyAction))
        {
            return(false);
        }
        if (!Amplitude.Unity.Runtime.Runtime.Registry.GetValue <bool>("Gameplay/Kaiju/KaijuAutoTameBeforeLoseEncounter", true) && !armyAction.CanAfford(base.AIEntity.Empire))
        {
            return(false);
        }
        Region region = this.worldPositionningService.GetRegion(objective.RegionIndex);
        Kaiju  kaiju  = region.Kaiju;

        return(kaiju != null && this.IsKaijuValidForObjective(kaiju) && !(kaiju.GUID != objective.SubObjectifGUID) && objective.State != BlackboardMessage.StateValue.Message_Canceled);
    }
Beispiel #13
0
    //-----------------------------------------------------------------------------------------------------------------------------------------------
    // FOR AUTOMATIC KNOWLEDGE

    public void SetPlayerFormation(ArmyAction formation) => playerController.SetPlayerFormation(formation);
Beispiel #14
0
 void ChooseFormation() => selfFormation = teamFormer.Play();
    public void Bind(IPlayerControllerRepositoryService playerControllerRepositoryService, Army army, ArmyAction armyAction, AgeTransform anchor, GameObject client, int index, UnitListPanel unitListPanel)
    {
        IGameService service = Services.GetService <IGameService>();

        if (service == null || service.Game == null || this.PlayerControllerRepositoryService != null || this.Army != null || this.ArmyAction != null || this.SeasonService != null)
        {
            this.Unbind();
        }
        this.unitListPanel = unitListPanel;
        this.SeasonService = service.Game.Services.GetService <ISeasonService>();
        if (this.SeasonService != null)
        {
            this.SeasonService.SeasonChange += this.SeasonService_SeasonChange;
        }
        this.CursorService = Services.GetService <ICursorService>();
        this.PlayerControllerRepositoryService = playerControllerRepositoryService;
        this.Army       = army;
        this.ArmyAction = armyAction;
        this.Client     = client;
        this.ActionToggle.AgeTransform.Visible = (armyAction is IArmyActionWithToggle);
        this.ActionButton.AgeTransform.Visible = !(armyAction is IArmyActionWithToggle);
        this.ModifierSector.Reset();
        this.ModifierSector.GetComponent <AgePrimitiveSector>().MaxAngle = 0f;
        this.ActionImage.Image = null;
        this.ModifierSector.Reset();
        IGuiPanelHelper guiPanelHelper = Services.GetService <global::IGuiService>().GuiPanelHelper;

        Diagnostics.Assert(guiPanelHelper != null, "Unable to access GuiPanelHelper");
        GuiElement guiElement;
        Texture2D  image;

        if (guiPanelHelper.TryGetGuiElement(armyAction.Name, out guiElement) && guiPanelHelper.TryGetTextureFromIcon(guiElement, global::GuiPanel.IconSize.Small, out image))
        {
            this.ActionImage.Image = image;
        }
        this.AgeTransform.AgeTooltip.Anchor = anchor;
        if (this.ArmyAction is IArmyActionWithUnitSelection)
        {
            this.unitListPanel.SelectionChange += this.UnitListPanel_SelectionChange;
        }
        this.RefreshCanExecute();
    }
Beispiel #16
0
 public ArmyAction SetPlayerFormation(ArmyAction formation) => playerFormation = formation;
Beispiel #17
0
    protected override State Execute(AIBehaviorTree aiBehaviorTree, params object[] parameters)
    {
        State result;
        Army  army;

        if (this.orderPosted)
        {
            if (this.orderExecuted)
            {
                this.orderExecuted = false;
                this.orderPosted   = false;
                result             = State.Success;
            }
            else
            {
                result = State.Running;
            }
        }
        else if (base.GetArmyUnlessLocked(aiBehaviorTree, "$Army", out army) > AIArmyMission.AIArmyMissionErrorCode.None)
        {
            result = State.Failure;
        }
        else
        {
            bool flag = true;
            for (int i = 0; i < army.StandardUnits.Count; i++)
            {
                if (army.StandardUnits[i].CheckUnitAbility(UnitAbility.ReadonlyResettle, -1))
                {
                    flag = false;
                    break;
                }
            }
            ArmyAction        armyAction = null;
            List <ArmyAction> list       = new List <ArmyAction>();
            if (flag)
            {
                list = new List <ArmyAction>(new List <ArmyAction>(Databases.GetDatabase <ArmyAction>(false).GetValues()).FindAll((ArmyAction match) => match is ArmyAction_Colonization));
            }
            else
            {
                list = new List <ArmyAction>(new List <ArmyAction>(Databases.GetDatabase <ArmyAction>(false).GetValues()).FindAll((ArmyAction match) => match is ArmyAction_Resettle));
            }
            List <StaticString> list2 = new List <StaticString>();
            for (int j = 0; j < list.Count; j++)
            {
                if (list[j].CanExecute(army, ref list2, new object[0]))
                {
                    armyAction = list[j];
                }
            }
            if (armyAction != null)
            {
                this.orderExecuted = false;
                this.orderPosted   = true;
                if (flag)
                {
                    this.CityLocation = army.WorldPosition;
                    this.Empire       = army.Empire;
                    Ticket ticket;
                    armyAction.Execute(army, aiBehaviorTree.AICommander.Empire.PlayerControllers.AI, out ticket, new EventHandler <TicketRaisedEventArgs>(this.ArmyAction_TicketRaised), new object[0]);
                }
                else
                {
                    OrderResettle order = new OrderResettle(army.Empire.Index, army.GUID, armyAction.Name);
                    Ticket        ticket;
                    aiBehaviorTree.AICommander.Empire.PlayerControllers.AI.PostOrder(order, out ticket, new EventHandler <TicketRaisedEventArgs>(this.OrderResettle_TicketRaised));
                }
                result = State.Running;
            }
            else
            {
                aiBehaviorTree.ErrorCode = 22;
                result = State.Failure;
            }
        }
        return(result);
    }
Beispiel #18
0
    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);
        }
    }
Beispiel #19
0
    private void ValidatePath()
    {
        IGuiService        service  = Services.GetService <IGuiService>();
        IAudioEventService service2 = Services.GetService <IAudioEventService>();

        Diagnostics.Assert(service2 != null);
        bool flag = base.SelectedUnits.Length == 0 || base.SelectedUnits.Length == this.Army.StandardUnits.Count || (this.Garrison.UnitsCount == 1 && this.Garrison.Hero != null);

        if (!base.IsTransferable(WorldCursor.HighlightedWorldPosition) && flag)
        {
            global::Empire empire = this.WorldArmy.Army.Empire;
            if (this.battleTarget is Army)
            {
                Army army = this.battleTarget as Army;
                if (army.Empire.Index == this.Army.Empire.Index)
                {
                    int num = Mathf.Max(army.MaximumUnitSlot - army.CurrentUnitSlot, 0);
                    if (this.Army.HasCatspaw || army.HasCatspaw)
                    {
                        QuickWarningPanel.Show("%UnitsTransferImpossibleWithCatsPawArmy");
                    }
                    else if (this.Army.StandardUnits.Count > num)
                    {
                        QuickWarningPanel.Show(string.Format(AgeLocalizer.Instance.LocalizeString("%UnitsTransferNotEnoughSlotsInTargetArmy"), num));
                    }
                    else if (this.Army.GetPropertyValue(SimulationProperties.Movement) <= 0f && base.WorldPositionningService.GetDistance(this.Army.WorldPosition, army.WorldPosition) == 1)
                    {
                        QuickWarningPanel.Show(AgeLocalizer.Instance.LocalizeString("%" + ArmyAction_TransferUnits.NotEnoughMovementToTransfer + "Description"));
                    }
                    else if (this.TemporaryWorldPath != null && this.TemporaryWorldPath.Length > 1 && !this.Army.HasCatspaw && !army.HasCatspaw)
                    {
                        OrderGoToAndMerge order = new OrderGoToAndMerge(empire.Index, this.WorldArmy.Army.GUID, this.battleTarget.GUID, (from unit in base.SelectedUnits
                                                                                                                                         select unit.GUID).ToArray <GameEntityGUID>(), this.TemporaryWorldPath);
                        this.PlayerControllerRepositoryService.ActivePlayerController.PostOrder(order);
                    }
                }
                else
                {
                    DepartmentOfForeignAffairs agency = empire.GetAgency <DepartmentOfForeignAffairs>();
                    Diagnostics.Assert(agency != null);
                    bool flag2 = this.Army.IsNaval == army.IsNaval;
                    if ((agency.CanAttack(this.battleTarget) || this.WorldArmy.Army.IsPrivateers) && flag2)
                    {
                        ArmyAction             armyAction = null;
                        IDatabase <ArmyAction> database   = Databases.GetDatabase <ArmyAction>(false);
                        float cost = 0f;
                        if (database != null && database.TryGetValue(ArmyAction_Attack.ReadOnlyName, out armyAction))
                        {
                            cost = armyAction.GetCostInActionPoints();
                        }
                        if (!this.Army.HasEnoughActionPoint(cost))
                        {
                            QuickWarningPanel.Show(AgeLocalizer.Instance.LocalizeString("%ArmyNotEnoughActionPointsDescription"));
                        }
                        else if (this.TemporaryWorldPath != null && this.TemporaryWorldPath.Length > 1)
                        {
                            OrderGoToAndAttack order2 = new OrderGoToAndAttack(empire.Index, this.WorldArmy.Army.GUID, this.battleTarget.GUID, this.TemporaryWorldPath);
                            this.PlayerControllerRepositoryService.ActivePlayerController.PostOrder(order2);
                        }
                        else
                        {
                            OrderAttack order3 = new OrderAttack(empire.Index, this.WorldArmy.Army.GUID, this.battleTarget.GUID);
                            this.PlayerControllerRepositoryService.ActivePlayerController.PostOrder(order3);
                        }
                        service2.Play2DEvent("Gui/Interface/InGame/OrderAttack");
                    }
                    else if (army.Empire is MajorEmpire && flag2)
                    {
                        global::Empire empire2 = army.Empire;
                        service.GetGuiPanel <WarDeclarationModalPanel>().Show(new object[]
                        {
                            empire2,
                            "AttackTarget"
                        });
                    }
                }
            }
            else
            {
                bool flag3 = false;
                if (this.battleTarget != null)
                {
                    if (this.TemporaryWorldPath != null && this.TemporaryWorldPath.Length > 1)
                    {
                        flag3  = (this.TemporaryWorldPath.ControlPoints.Length == 0);
                        flag3 |= (this.TemporaryWorldPath.ControlPoints.Length == 1 && (int)this.TemporaryWorldPath.ControlPoints[0] == this.TemporaryWorldPath.Length - 1);
                    }
                    else
                    {
                        flag3 = base.PathfindingService.IsTransitionPassable(this.Army.WorldPosition, this.battleTarget.WorldPosition, this.Army, PathfindingFlags.IgnoreArmies | PathfindingFlags.IgnoreOtherEmpireDistrict | PathfindingFlags.IgnoreDiplomacy | PathfindingFlags.IgnorePOI | PathfindingFlags.IgnoreSieges | PathfindingFlags.IgnoreKaijuGarrisons, null);
                    }
                }
                if (flag3 || this.battleTarget is Fortress || this.battleTarget is KaijuGarrison)
                {
                    flag3 = false;
                    bool flag4 = true;
                    if (this.battleTarget is KaijuGarrison)
                    {
                        KaijuGarrison kaijuGarrison        = this.battleTarget as KaijuGarrison;
                        DepartmentOfForeignAffairs agency2 = empire.GetAgency <DepartmentOfForeignAffairs>();
                        Diagnostics.Assert(agency2 != null);
                        if (!agency2.CanAttack(this.battleTarget))
                        {
                            flag4 = false;
                            global::Empire empire3 = kaijuGarrison.Empire;
                            service.GetGuiPanel <WarDeclarationModalPanel>().Show(new object[]
                            {
                                empire3,
                                "AttackTarget"
                            });
                        }
                    }
                    if (flag4)
                    {
                        ArmyActionModalPanel guiPanel = service.GetGuiPanel <ArmyActionModalPanel>();
                        if (guiPanel != null)
                        {
                            WorldPosition destination = (this.TemporaryWorldPath == null || this.TemporaryWorldPath.Length <= 1) ? WorldPosition.Invalid : this.TemporaryWorldPath.Destination;
                            if (guiPanel.CheckForArmyActionsAvailability(this.Army, this.battleTarget, destination).Count > 0)
                            {
                                flag3 = true;
                            }
                        }
                    }
                }
                if (flag3 && this.battleTarget != null && !this.Army.IsPrivateers)
                {
                    MajorEmpire majorEmpire = null;
                    if (this.battleTarget is Garrison)
                    {
                        majorEmpire = ((this.battleTarget as Garrison).Empire as MajorEmpire);
                    }
                    else if (this.battleTarget is District)
                    {
                        majorEmpire = ((this.battleTarget as District).Empire as MajorEmpire);
                    }
                    if (majorEmpire != null && majorEmpire.Index != this.Army.Empire.Index)
                    {
                        flag3 = this.Army.Empire.GetAgency <DepartmentOfForeignAffairs>().IsSymetricallyDiscovered(majorEmpire);
                    }
                }
                if (flag3)
                {
                    WorldPosition worldPosition = (this.TemporaryWorldPath == null || this.TemporaryWorldPath.Length <= 1) ? WorldPosition.Invalid : this.TemporaryWorldPath.Destination;
                    service.Show(typeof(ArmyActionModalPanel), new object[]
                    {
                        this.Army,
                        this.battleTarget,
                        base.SelectedUnits,
                        worldPosition
                    });
                }
                else if (this.TemporaryWorldPath != null && this.TemporaryWorldPath.Destination != WorldPosition.Invalid)
                {
                    OrderGoTo order4 = new OrderGoTo(empire.Index, this.WorldArmy.Army.GUID, this.TemporaryWorldPath.Destination);
                    this.PlayerControllerRepositoryService.ActivePlayerController.PostOrder(order4);
                    service2.Play2DEvent("Gui/Interface/InGame/OrderGoTo");
                }
                else if (WorldCursor.HighlightedWorldPosition != WorldPosition.Invalid)
                {
                    Region region = base.WorldPositionningService.GetRegion(WorldCursor.HighlightedWorldPosition);
                    if (region != null && region.City != null && region.City.Empire != null)
                    {
                        DepartmentOfForeignAffairs agency3 = this.Army.Empire.GetAgency <DepartmentOfForeignAffairs>();
                        Diagnostics.Assert(agency3 != null);
                        if (!agency3.CanMoveOn(WorldCursor.HighlightedWorldPosition, this.WorldArmy.Army.IsPrivateers, this.WorldArmy.Army.IsCamouflaged))
                        {
                            District district = base.WorldPositionningService.GetDistrict(WorldCursor.HighlightedWorldPosition);
                            if ((district == null || district.Type == DistrictType.Exploitation) && region.City.Empire is MajorEmpire)
                            {
                                service.GetGuiPanel <WarDeclarationModalPanel>().Show(new object[]
                                {
                                    region.City.Empire,
                                    "BreakCloseBorder"
                                });
                            }
                        }
                    }
                }
            }
        }
        this.LastHighlightedWorldPosition = WorldPosition.Invalid;
        this.LastUnpathableWorldPosition  = WorldPosition.Invalid;
        this.SelectTarget();
        this.UpdateBattlegroundVisibility();
        if (this.TemporaryWorldPath != null)
        {
            this.PathRendererService.RemovePath(this.TemporaryWorldPath);
            this.TemporaryWorldPath = null;
        }
    }