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