/** * Initialize the possible path rankers. * Has a dependency on the fire controls being initialized. */ public void initializePathRankers() { initializeFireControls(); pathRankers = new HashMap<>(); BasicPathRanker basicPathRanker = new BasicPathRanker(this); basicPathRanker.setFireControl(fireControls.get(FireControlType.Basic)); basicPathRanker.setPathEnumerator(precognition.getPathEnumerator()); pathRankers.put(PathRankerType.Basic, basicPathRanker); InfantryPathRanker infantryPathRanker = new InfantryPathRanker(this); infantryPathRanker.setFireControl(fireControls.get(FireControlType.Infantry)); infantryPathRanker.setPathEnumerator(precognition.getPathEnumerator()); pathRankers.put(PathRankerType.Infantry, infantryPathRanker); NewtonianAerospacePathRanker newtonianAerospacePathRanker = new NewtonianAerospacePathRanker(this); newtonianAerospacePathRanker.setFireControl(fireControls.get(FireControlType.Basic)); newtonianAerospacePathRanker.setPathEnumerator(precognition.getPathEnumerator()); pathRankers.put(PathRankerType.NewtonianAerospace, newtonianAerospacePathRanker); }
public InfantryPathRanker(Princess princess) { super(princess); setFireControl(new InfantryFireControl(princess)); setPathEnumerator(princess.getPrecognition().getPathEnumerator()); }
getPathEnumerator().getLastKnownLocations().remove(id); getPathEnumerator().getUnitMovableAreas().remove(id); getPathEnumerator().getUnitPaths().remove(id); getPathEnumerator().getUnitPotentialLocations().remove(id); return; getPathEnumerator().getEntitiesWithLocation( getGame().getEntity(id).getPosition(), true)); if (getPathEnumerator().getLastKnownLocations() .containsKey(id)) { if ((getGame().getEntity(id) != null) && getGame().getEntity(id).isSelectableThisTurn()) { toDirty.addAll(getPathEnumerator() .getEntitiesWithLocation(getPathEnumerator() .getLastKnownLocations().get(id) .getCoords(), true)); getDirtyUnits().add(id); } else if (entity != null) { getPathEnumerator().getLastKnownLocations().put(id, CoordFacingCombo.createCoordFacingCombo(entity));
continue; if (((!getPathEnumerator().getLastKnownLocations().containsKey(entity.getId())) || (!getPathEnumerator().getLastKnownLocations().get(entity.getId()) .equals(CoordFacingCombo.createCoordFacingCombo(entity))))) { if (entity != null) { getOwner().log(getClass(), METHOD_NAME, "recalculating paths for " + entity.getDisplayName()); getPathEnumerator().recalculateMovesFor(entity); getOwner().log(getClass(), METHOD_NAME, "finished recalculating paths for " + entity .getDisplayName());
public void run() { final String METHOD_NAME = "run()"; getOwner().methodBegin(getClass(), METHOD_NAME); try { // todo There's probably a better way to handle this than a loop that only exits on an error. //noinspection InfiniteLoopStatement while (!getDone().get()) { if (!getEventsToProcess().isEmpty()) { processGameEvents(); ecmInfo = ComputeECM.computeAllEntitiesECMInfo( getGame().getEntitiesVector()); } else if (!getDirtyUnits().isEmpty()) { Entity entity = getGame().getEntity(getDirtyUnits().pollFirst()); if ((entity != null) && isEntityOnMap(entity)) { unPause(); getOwner().log(getClass(), METHOD_NAME, "recalculating paths for " + entity.getDisplayName()); getPathEnumerator().recalculateMovesFor(entity); getOwner().log(getClass(), METHOD_NAME, "finished recalculating paths for " + entity .getDisplayName()); } } else if (getWaitWhenDone().get()) { waitForUnpause(); // paused for a reason } else { waitForUnpause(); // idling because there's nothing to do } } } finally { getOwner().methodEnd(getClass(), METHOD_NAME); } }
continue; if (position.equals(getPathEnumerator().getLastKnownCoords(entity.getId()))) { continue; // no sense in updating a unit if it hasn't moved getPathEnumerator().clear(); for (Entity entity : getGame().getEntitiesVector()) { if (entity.isActive() && entity.isDeployed() && entity.getPosition() != null) {
getPrecognition().getPathEnumerator() .getUnitPaths() .get(entity.getId());