Sprite: cleanup logic for how to destroy a tile

and remove the dependency on tile numbers
This commit is contained in:
Jason Long 2014-09-21 14:20:19 -04:00
parent f944e5293c
commit ac1dc2bf92
2 changed files with 18 additions and 24 deletions

View file

@ -179,28 +179,28 @@ public abstract class Sprite
return; return;
int t = city.getTile(xpos, ypos); int t = city.getTile(xpos, ypos);
if (isOverWater(t)) {
// becomes water
city.setTile(xpos, ypos, RIVER);
return;
}
if (t >= TREEBASE) { if (!isCombustible(t)) {
if (isBridge(t)) { // cannot destroy it
city.setTile(xpos, ypos, RIVER); return;
}
if (isZoneCenter(t)) {
city.killZone(xpos, ypos, t);
CityDimension d = getZoneSizeFor(t);
if (d.width >= 3 && d.height >= 3) {
city.makeExplosion(xpos, ypos);
return; return;
} }
if (!isCombustible(t)) {
return; //cannot destroy it
}
if (isZoneCenter(t)) {
city.killZone(xpos, ypos, t);
if (t > RZB) {
city.makeExplosion(xpos, ypos);
}
}
if (isOverWater(t)) {
city.setTile(xpos, ypos, RIVER);
}
else {
city.setTile(xpos, ypos, TINYEXP);
}
} }
city.setTile(xpos, ypos, TINYEXP);
} }
/** /**

View file

@ -275,12 +275,6 @@ public class TileConstants
); );
} }
//used by Sprite::destroyTile
public static boolean isBridge(int tile)
{
return isRoad(tile) && !isCombustible(tile);
}
public static boolean isCombustible(int tile) public static boolean isCombustible(int tile)
{ {
assert (tile & LOMASK) == tile; assert (tile & LOMASK) == tile;