int yy1 = foot.y-dd, yy2 = foot.y+foot.height+dd-1;
int xx1 = foot.x-dd, xx2 = foot.x+foot.width+dd-1;
// get the corners
spots.add(
new StageLocation(xx1, yy1, (byte)DirectionCodes.SOUTHWEST));
spots.add(
new StageLocation(xx1, yy2, (byte)DirectionCodes.SOUTHEAST));
spots.add(
new StageLocation(xx2, yy1, (byte)DirectionCodes.NORTHWEST));
spots.add(
new StageLocation(xx2, yy2, (byte)DirectionCodes.NORTHEAST));
// then the sides
for (int xx = xx1+1; xx < xx2; xx++) {
spots.add(
new StageLocation(xx, yy1, (byte)DirectionCodes.WEST));
spots.add(
new StageLocation(xx, yy2, (byte)DirectionCodes.EAST));
}
for (int yy = yy1+1; yy < yy2; yy++) {
spots.add(
new StageLocation(xx1, yy, (byte)DirectionCodes.SOUTH));
spots.add(
new StageLocation(xx2, yy, (byte)DirectionCodes.NORTH));
}
// sort them in order of closeness to the players current
// coordinate
spots.sort(new Comparator<StageLocation>() {
public int compare (StageLocation o1, StageLocation o2) {
return dist(o1) - dist(o2);
}
private final int dist (StageLocation l) {
return Math.round(100*MathUtil.distance(
l.x, l.y, nearto.x, nearto.y));
}
});
// return the first spot that can be "traversed" which we're
// taking to mean "stood upon"
for (int ii = 0, ll = spots.size(); ii < ll; ii++) {
StageLocation loc = spots.get(ii);
if (pred.canTraverse(traverser, loc.x, loc.y)) {
// convert to full coordinates
loc.x = MisoUtil.toFull(loc.x, 2);
loc.y = MisoUtil.toFull(loc.y, 2);