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);
    }
예제 #2
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;
        }
    }