use of eidolons.game.battlecraft.ai.elements.actions.sequence.ActionSequence in project Eidolons by IDemiurge.
the class ExplorePartyMaster method checkNewGoal.
public void checkNewGoal(Unit unit) {
DC_ActiveObj active = lastAction.getAction();
if (active.getActionGroup() == ACTION_TYPE_GROUPS.MODE) {
Goal goal = getNewGoal(active, unit.getAI());
if (goal != null) {
master.getGame().getAiManager().setUnit(unit);
List<ActionSequence> sequences = master.getGame().getAiManager().getActionSequenceConstructor().createActionSequencesForGoal(goal, unit.getAI());
if (!sequences.isEmpty()) {
ActionSequence sequence = master.getGame().getAiManager().getPriorityManager().chooseByPriority(sequences);
unit.getAI().setStandingOrders(sequence);
}
}
}
// if (mainHero.getMode()!=null ){
// }
}
use of eidolons.game.battlecraft.ai.elements.actions.sequence.ActionSequence in project Eidolons by IDemiurge.
the class GuardAi method getOrders.
@Override
public ActionSequence getOrders(UnitAI ai) {
if (isEnabled(ai))
return null;
// check mode
Coordinates target = CoordinatesMaster.getRandomAdjacentCoordinate(ai.getUnit().getCoordinates());
List<Action> list = getMaster(ai).getTurnSequenceConstructor().getTurnSequence(FACING_SINGLE.IN_FRONT, ai.getUnit(), target);
return new ActionSequence(GOAL_TYPE.PROTECT, list.toArray(new Action[list.size()]));
}
use of eidolons.game.battlecraft.ai.elements.actions.sequence.ActionSequence in project Eidolons by IDemiurge.
the class WanderAi method getOrders.
@Override
public ActionSequence getOrders(UnitAI ai) {
Coordinates c1 = null;
try {
WanderAi.checkWanderDirectionChange(ai.getGroup(), GOAL_TYPE.WANDER);
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
}
try {
c1 = (getWanderTargetCoordinatesCell(ai, GOAL_TYPE.WANDER));
} catch (Exception e) {
c1 = (CoordinatesMaster.getRandomAdjacentCoordinate(ai.getUnit().getCoordinates()));
main.system.ExceptionMaster.printStackTrace(e);
}
c1 = Positioner.adjustCoordinate(ai.getUnit(), c1, ai.getUnit().getFacing(), getWanderPredicate(ai.getUnit(), ai.getUnit().getFacing(), c1));
Task task = new Task(ai, GOAL_TYPE.WANDER, null);
List<Action> turnSequence = getMaster(ai).getTurnSequenceConstructor().getTurnSequence(ai.getUnit(), c1);
if (ListMaster.isNotEmpty(turnSequence)) {
return new ActionSequence(turnSequence, task, ai);
}
List<Coordinates> c = new ArrayList<>();
c.add(c1);
getMaster(ai).setUnit(ai.getUnit());
// getMaster(ai).getPathBuilder().init(null, null);
// TimeLimitMaster.markTimeForAI(ai);
List<ActionPath> paths = new ArrayList<>();
// getMaster(ai).getPathBuilder().build(c);
Action action = null;
if (paths.isEmpty()) {
if (c.get(0) != null)
action = getMaster(ai).getAtomicAi().getAtomicMove(c.get(0), ai.getUnit());
else
action = getMaster(ai).getAtomicAi().getAtomicActionApproach(ai);
if (action != null)
return new ActionSequence(GOAL_TYPE.WANDER, action);
} else
action = paths.get(0).getActions().get(0);
if (action == null)
return null;
List<ActionSequence> sequences = getMaster(ai).getActionSequenceConstructor().getSequencesFromPaths(paths, task, action);
if (sequences.isEmpty())
return null;
return sequences.get(0);
}
Aggregations