public void addSteps(Vector<MoveStep> path, boolean compile) { for (MoveStep step : path) { addStep(step, compile); } }
private void adjustPathForBridge(MovePath path) { boolean needsAdjust = false; for (Coords c : path.getCoordsSet()) { IHex hex = getGame().getBoard().getHex(c); if ((hex != null) && hex.containsTerrain(Terrains.BRIDGE)) { if (getGame().getBoard().getBuildingAt(c).getCurrentCF(c) >= path.getEntity().getWeight()) { needsAdjust = true; break; } else { needsAdjust = false; break; } } } if (!needsAdjust) { return; } MovePath adjusted = new MovePath(getGame(), path.getEntity()); adjusted.addStep(MoveStepType.CLIMB_MODE_ON); adjusted.addSteps(path.getStepVector(), true); adjusted.addStep(MoveStepType.CLIMB_MODE_OFF); path.replaceSteps(adjusted.getStepVector()); }
protected MovePath addStep(final MoveStep step) { return addStep(step, true); }
public MovePath addStep(final MoveStepType type, final int mineToLay) { return addStep(type, -1, mineToLay); }
/** * 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(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)); }
public MovePath addStep(MoveStepType type, TreeMap<Integer, Vector<Integer>> targets) { return addStep(new MoveStep(this, type, targets)); }
/** * Generates a list of possible step combinations that should be done at the beginning of a path * Has side effect of updating the visited coordinates map and adding it to the list of generated paths * @return List of all possible "starting" paths */ protected List<MovePath> generateStartingPaths(MovePath startingEdge) { List<MovePath> startingPaths = new ArrayList<>(); MovePath defaultPath = startingEdge.clone(); aerospacePaths.add(defaultPath); visitedCoords.put(new CoordsWithFacing(defaultPath), defaultPath.getMpUsed()); startingPaths.add(defaultPath); MovePath reverseEdge = startingEdge.clone(); reverseEdge.addStep(MoveStepType.YAW); aerospacePaths.add(reverseEdge); visitedCoords.put(new CoordsWithFacing(reverseEdge), reverseEdge.getMpUsed()); startingPaths.add(defaultPath); return startingPaths; }
/** * Rotate from the current facing to the destination facing. */ public void rotatePathfinder(final int destFacing, final boolean isManeuver) { while (getFinalFacing() != destFacing) { final MoveStepType stepType = getDirection(getFinalFacing(), destFacing); addStep(stepType, isManeuver, isManeuver); } }
/** * Given a list of MovePaths, applies adjustTowardsDesiredAltitude to each of them. * @param startingPaths The collection of paths to process * @return The new collection of resulting paths. */ protected List<MovePath> getAltitudeAdjustedPaths(List<MovePath> startingPaths) { List<MovePath> desiredAltitudes = new ArrayList<MovePath>(); for(MovePath start : startingPaths) { boolean choppedOffFlyOff = false; // if we are going off board, we need to take some special actions, meaning chopping off the tail end if(start.fliesOffBoard()) { start.removeLastStep(); choppedOffFlyOff = true; } // repeat with 1, 3, 7 when we settle things down? MovePath desiredAltitudePath = adjustTowardsDesiredAltitude(start, OPTIMAL_STRIKE_ALTITUDE); if(choppedOffFlyOff) { desiredAltitudePath.addStep(MoveStepType.RETURN); } desiredAltitudes.add(desiredAltitudePath); } return desiredAltitudes; }
/** * Worker method that adds "UP" and "DOWN" steps to the given move path collection if * the entity is eligible to do so * * @param result The collection of move paths to improve * @param last The last step along the parent move path * @param entity The entity taking the move path * @param movePath The parent movePath * @see AbstractPathFinder.AdjacencyMap */ void addUpAndDown(Collection<MovePath> result, final MoveStep last, final Entity entity, final MovePath mp) { Coords pos; int elevation; pos = last != null ? last.getPosition() : entity.getPosition(); elevation = last != null ? last.getElevation() : entity.getElevation(); if (entity.canGoUp(elevation, pos)) { result.add(mp.clone().addStep(MoveStepType.UP)); } if (entity.canGoDown(elevation, pos)) { result.add(mp.clone().addStep(MoveStepType.DOWN)); } } }
/** * Generates a list of possible step combinations that should be done at the beginning of a path * This implementation generates exactly one path, which is either no moves or one hex forward when velocity > 0 * @return "List" of all possible "starting" paths */ @Override protected List<MovePath> generateStartingPaths(MovePath startingEdge) { List<MovePath> startingPaths = new ArrayList<>(); // calculate max and min safe velocity // in space, we can go as slow or as fast as we want. IAero aero = (IAero) startingEdge.getEntity(); int maxThrust = AeroPathUtil.calculateMaxSafeThrust(aero); int maxVelocity = aero.getCurrentVelocity() + maxThrust; int minVelocity = Math.max(0, aero.getCurrentVelocity() - maxThrust); startingPaths.addAll(AeroPathUtil.generateValidAccelerations(startingEdge, minVelocity, maxVelocity)); // all non-zero-velocity paths must move at least one hex forward for(MovePath path : startingPaths) { if(path.getFinalVelocity() > 0) { path.addStep(MoveStepType.FORWARDS); } } return startingPaths; }
/** * Helper function that appends an unjam RAC command to the end of a qualifying path. * @param path The path to process. */ private void unjamRAC(MovePath path) { if(path.getEntity().canUnjamRAC() && (path.getMpUsed() <= path.getEntity().getWalkMP()) && !path.isJumping()) { path.addStep(MoveStepType.UNJAM_RAC); } }
/** * Helper function that insinuates an "evade" step for aircraft that will not be shooting. * @param path The path to process */ private void evadeIfNotFiring(MovePath path, boolean possibleToInflictDamage) { Entity pathEntity = path.getEntity(); // we cannot evade if we are out of control if(pathEntity.isAero() && pathEntity.isAirborne() && ((IAero) pathEntity).isOutControlTotal()) { return; } // if we're an airborne aircraft // and we're not going to do any damage anyway // and we can do so without causing a PSR // then evade if(pathEntity.isAirborne() && !possibleToInflictDamage && (path.getMpUsed() <= AeroPathUtil.calculateMaxSafeThrust((IAero) path.getEntity()) - 2)) { path.addStep(MoveStepType.EVADE); } }