Search in sources :

Example 1 with COMBAT_SCRIPT_FUNCTION

use of eidolons.game.battlecraft.logic.battle.mission.CombatScriptExecutor.COMBAT_SCRIPT_FUNCTION in project Eidolons by IDemiurge.

the class AiScriptExecutor method executeCommand.

private void executeCommand(Unit unit, COMBAT_SCRIPT_FUNCTION function, String arg, boolean free, boolean immediate, String... args) {
    ActionSequence sequence = null;
    GOAL_TYPE goal = getGoalType(function);
    Task task = new Task(true, unit.getAI(), goal, arg);
    UnitAI ai = unit.getAI();
    switch(function) {
        case MOVE_TO:
            // via a path!
            ActionPath path = getPathSequenceConstructor().getOptimalPathSequence(unit.getAI(), new Coordinates(arg.toString()));
            sequence = new ActionSequence(path.getActions(), task, unit.getAI());
            break;
        case TURN_TO:
            // cell id
            sequence = new ActionSequence(getTurnSequenceConstructor().getTurnSequence(FACING_SINGLE.IN_FRONT, unit, new Coordinates(arg.toString())), task, unit.getAI());
            break;
        case ACTION:
            Action action = AiActionFactory.newAction(arg.toString(), ai);
            // new ActionSequence();
            sequence = getActionSequenceConstructor().constructSingleActionSequence(action, new Task(ai, goal, args[0]));
            break;
        case ATTACK:
            break;
        case FREEZE:
            break;
        case UNFREEZE:
            break;
        case ORDER:
            // OrderFactory.getOrder();
            Order a = new Order(arg.toString());
            unit.getAI().setCurrentOrder(a);
            return;
    }
    if (immediate) {
        unit.getAI().setStandingOrders(sequence);
        unit.getAI().setFree(free);
    } else
        sequence.getActions().forEach(// TODO wait?
        action -> getExecutor().execute(action, free));
}
Also used : Order(eidolons.game.battlecraft.ai.advanced.companion.Order) Action(eidolons.game.battlecraft.ai.elements.actions.Action) ScriptExecutor(eidolons.game.battlecraft.logic.meta.scenario.script.ScriptExecutor) ActionSequence(eidolons.game.battlecraft.ai.elements.actions.sequence.ActionSequence) AiHandler(eidolons.game.battlecraft.ai.elements.generic.AiHandler) AiMaster(eidolons.game.battlecraft.ai.elements.generic.AiMaster) FACING_SINGLE(main.content.enums.entity.UnitEnums.FACING_SINGLE) Order(eidolons.game.battlecraft.ai.advanced.companion.Order) COMBAT_SCRIPT_FUNCTION(eidolons.game.battlecraft.logic.battle.mission.CombatScriptExecutor.COMBAT_SCRIPT_FUNCTION) Ref(main.entity.Ref) UnitAI(eidolons.game.battlecraft.ai.UnitAI) DataManager(main.data.DataManager) GOAL_TYPE(main.content.enums.system.AiEnums.GOAL_TYPE) AiActionFactory(eidolons.game.battlecraft.ai.elements.actions.AiActionFactory) Task(eidolons.game.battlecraft.ai.elements.task.Task) Coordinates(main.game.bf.Coordinates) Unit(eidolons.entity.obj.unit.Unit) ActionPath(eidolons.game.battlecraft.ai.tools.path.ActionPath) EnumMaster(main.system.auxiliary.EnumMaster) Task(eidolons.game.battlecraft.ai.elements.task.Task) Action(eidolons.game.battlecraft.ai.elements.actions.Action) ActionSequence(eidolons.game.battlecraft.ai.elements.actions.sequence.ActionSequence) UnitAI(eidolons.game.battlecraft.ai.UnitAI) Coordinates(main.game.bf.Coordinates) GOAL_TYPE(main.content.enums.system.AiEnums.GOAL_TYPE) ActionPath(eidolons.game.battlecraft.ai.tools.path.ActionPath)

Aggregations

Unit (eidolons.entity.obj.unit.Unit)1 UnitAI (eidolons.game.battlecraft.ai.UnitAI)1 Order (eidolons.game.battlecraft.ai.advanced.companion.Order)1 Action (eidolons.game.battlecraft.ai.elements.actions.Action)1 AiActionFactory (eidolons.game.battlecraft.ai.elements.actions.AiActionFactory)1 ActionSequence (eidolons.game.battlecraft.ai.elements.actions.sequence.ActionSequence)1 AiHandler (eidolons.game.battlecraft.ai.elements.generic.AiHandler)1 AiMaster (eidolons.game.battlecraft.ai.elements.generic.AiMaster)1 Task (eidolons.game.battlecraft.ai.elements.task.Task)1 ActionPath (eidolons.game.battlecraft.ai.tools.path.ActionPath)1 COMBAT_SCRIPT_FUNCTION (eidolons.game.battlecraft.logic.battle.mission.CombatScriptExecutor.COMBAT_SCRIPT_FUNCTION)1 ScriptExecutor (eidolons.game.battlecraft.logic.meta.scenario.script.ScriptExecutor)1 FACING_SINGLE (main.content.enums.entity.UnitEnums.FACING_SINGLE)1 GOAL_TYPE (main.content.enums.system.AiEnums.GOAL_TYPE)1 DataManager (main.data.DataManager)1 Ref (main.entity.Ref)1 Coordinates (main.game.bf.Coordinates)1 EnumMaster (main.system.auxiliary.EnumMaster)1