/** * Add a new step to the movement path with the given target. * * @param type the type of movement. * @param target the <code>Targetable</code> object that is the target of this * step. For example, the enemy being charged. */ public MovePath addStep(final MoveStepType type, final Targetable target) { return addStep(new MoveStep(this, type, target)); }
/** * Add a new step to the movement path. * * @param type the type of movement. */ public MovePath addStep(final MoveStepType type) { // TODO : detect steps off the map *here*. return addStep(new MoveStep(this, type)); }
public MovePath addStep(MoveStepType type, TreeMap<Integer, Vector<Integer>> targets) { return addStep(new MoveStep(this, type, targets)); }
public MovePath addStep(final MoveStepType type, final int recover, final int mineToLay) { return addStep(new MoveStep(this, type, recover, mineToLay)); }
public MovePath addStep(final MoveStepType type, final boolean noCost) { return addStep(new MoveStep(this, type, noCost)); }
public MovePath addStep(final MoveStepType type, final Minefield mf) { return addStep(new MoveStep(this, type, mf)); }
public MovePath addStep(final MoveStepType type, final Targetable target, final Coords pos) { return addStep(new MoveStep(this, type, target, pos)); }
public MovePath addStep(final MoveStepType type, final boolean noCost, final boolean isManeuver) { return addStep(new MoveStep(this, type, noCost, isManeuver)); }
public MovePath addManeuver(final int manType) { return addStep(new MoveStep(this, MoveStepType.MANEUVER, -1, -1, manType)); }
/** * Changes turn-forwards-opposite-turn sequences into quad lateral shifts. * <p/> * Finds the sequence of three steps that can be transformed, then removes * all three and replaces them with the lateral shift step. */ @SuppressWarnings("unused") private void transformLateralShift() { if (steps.size() < 3) { return; } final int index = steps.size() - 3; final MoveStep step1 = getStep(index); final MoveStep step2 = getStep(index + 1); final MoveStep step3 = getStep(index + 2); if (step1.oppositeTurn(step3) && ((step2.getType() == MovePath.MoveStepType.BACKWARDS) || (step2.getType() == MovePath.MoveStepType.FORWARDS))) { final MoveStepType stepType = step1.getType(); final MoveStepType direction = step2.getType(); // remove all old steps steps.removeElementAt(index); steps.removeElementAt(index); steps.removeElementAt(index); // add new step final MoveStep shift = new MoveStep(this, lateralShiftForTurn(stepType, direction)); addStep(shift); } }
currentStep = new MoveStep(straightLine, MoveStepType.NONE);
MoveStep step = temp.elementAt(i); if ((step.getTargetPosition() != null) && (step.getTarget(getGame()) != null)) { step = new MoveStep(this, step.getType(), step.getTarget(getGame()), step.getTargetPosition()); } else if (step.getTarget(getGame()) != null) { step = new MoveStep(this, step.getType(), step.getTarget(getGame())); } else if (step.getRecoveryUnit() != -1) { step = new MoveStep(this, step.getType(), step.getRecoveryUnit(), -1); } else if (step.getMineToLay() != -1) { step = new MoveStep(this, step.getType(), step.getMineToLay()); } else if (step.getLaunched().size() > 0) { step = new MoveStep(this, step.getType(), step.getLaunched()); } else if (step.getManeuverType() != ManeuverType.MAN_NONE) { step = new MoveStep(this, step.getType(), -1, -1, step.getManeuverType()); } else if (step.isManeuver()) { step = new MoveStep(this, step.getType(), step.hasNoCost(), step.isManeuver()); } else if (step.hasNoCost()) { step = new MoveStep(this, step.getType(), step.hasNoCost()); } else if (null != step.getMinefield()) { step = new MoveStep(this, step.getType(), step.getMinefield()); } else { step = new MoveStep(this, step.getType());
prev = new MoveStep(null, MoveStepType.FORWARDS); prev.setFromEntity(entity, game); prev.isCarefulPath = isCareful();