boolean found = false;
// Find a tile that will toggle
for (int i = 0; i < fTilesets.length; i++) {
String type = fTilesets[i].type(tile(i, xy.x(), xy.y()));
ToggleInfo info = GruntzGame.resourceManager().toggle(type);
if (info != null && info.tile() != null) {
// Check for giant rock
if (type.startsWith("GROCK") && !fGiantRockBreaking) {
if (type.equals("GROCK")) found = breakGiantRock(xy.subtract(GridCoordinate.NORTH_WEST));
else if (type.equals("GROCK_T")) found = breakGiantRock(xy.subtract(GridCoordinate.WEST));
else if (type.equals("GROCK_R")) found = breakGiantRock(xy.add(new GridCoordinate(-2, -1)));
else if (type.equals("GROCK_B")) found = breakGiantRock(xy.add(new GridCoordinate(-1, -2)));
else if (type.equals("GROCK_L")) found = breakGiantRock(xy.add(GridCoordinate.NORTH));
else if (type.equals("GROCK_TR")) found = breakGiantRock(xy.add(new GridCoordinate(-2, 0)));
else if (type.equals("GROCK_BR")) found = breakGiantRock(xy.add(new GridCoordinate(-2, -2)));
else if (type.equals("GROCK_BL")) found = breakGiantRock(xy.add(new GridCoordinate(0, -2)));
else if (type.equals("GROCK_TL")) found = breakGiantRock(xy);
} else {
int rep = fTilesets[i].tile(info.tile());
if (rep >= 0) tile(i, xy.x(), xy.y(), rep);
found = true;
}
// Do sfx
if (info.graphics("") != null && !fGiantRockBreaking) {
int layer = i;
if (info.layer() >= 0) layer = info.layer();
sfx(layer, info.animation(fTilesets[i].area()), info.graphics(fTilesets[i].area()), info.sound(fTilesets[i].area()), xy);
}
break;
}
}