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,29 +179,29 @@ public abstract class Sprite
return; return;
int t = city.getTile(xpos, ypos); int t = city.getTile(xpos, ypos);
if (isOverWater(t)) {
if (t >= TREEBASE) { // becomes water
if (isBridge(t)) {
city.setTile(xpos, ypos, RIVER); city.setTile(xpos, ypos, RIVER);
return; return;
} }
if (!isCombustible(t)) { if (!isCombustible(t)) {
return; //cannot destroy it // cannot destroy it
return;
} }
if (isZoneCenter(t)) { if (isZoneCenter(t)) {
city.killZone(xpos, ypos, t); city.killZone(xpos, ypos, t);
if (t > RZB) {
CityDimension d = getZoneSizeFor(t);
if (d.width >= 3 && d.height >= 3) {
city.makeExplosion(xpos, ypos); city.makeExplosion(xpos, ypos);
return;
} }
} }
if (isOverWater(t)) {
city.setTile(xpos, ypos, RIVER);
}
else {
city.setTile(xpos, ypos, TINYEXP); city.setTile(xpos, ypos, TINYEXP);
} }
}
}
/** /**
* Helper function for rotating a sprite. * Helper function for rotating a sprite.

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;