buildings: allow defining anim tiles as belonging to a building

git-svn-id: https://micropolis.googlecode.com/svn/trunk/micropolis-java@814 d9718cc8-9f43-0410-858b-315f434eb58c
This commit is contained in:
jason@long.name 2013-09-01 00:26:16 +00:00
parent 306058afeb
commit 4c66df859f
3 changed files with 42 additions and 12 deletions

View file

@ -854,14 +854,14 @@
830 misc_animation@0,48 (noburn)
831 misc_animation@0,64 (noburn)
# BEGIN RADAR DISH #
832 misc_animation@0,80 (conducts) (becomes=833)(onshutdown=711)
833 misc_animation@0,96 (conducts) (becomes=834)(onshutdown=711)
834 misc_animation@0,112 (conducts) (becomes=835)(onshutdown=711)
835 misc_animation@0,128 (conducts) (becomes=836)(onshutdown=711)
836 misc_animation@0,144 (conducts) (becomes=837)(onshutdown=711)
837 misc_animation@0,160 (conducts) (becomes=838)(onshutdown=711)
838 misc_animation@0,176 (conducts) (becomes=839)(onshutdown=711)
839 misc_animation@0,192 (conducts) (becomes=832)(onshutdown=711)
832 misc_animation@0,80 (conducts)(building-part=716,1,-1) (becomes=833)(onshutdown=711)
833 misc_animation@0,96 (conducts)(building-part=716,1,-1) (becomes=834)(onshutdown=711)
834 misc_animation@0,112 (conducts)(building-part=716,1,-1) (becomes=835)(onshutdown=711)
835 misc_animation@0,128 (conducts)(building-part=716,1,-1) (becomes=836)(onshutdown=711)
836 misc_animation@0,144 (conducts)(building-part=716,1,-1) (becomes=837)(onshutdown=711)
837 misc_animation@0,160 (conducts)(building-part=716,1,-1) (becomes=838)(onshutdown=711)
838 misc_animation@0,176 (conducts)(building-part=716,1,-1) (becomes=839)(onshutdown=711)
839 misc_animation@0,192 (conducts)(building-part=716,1,-1) (becomes=832)(onshutdown=711)
# BEGIN FOUNTAIN / FLAG #
840 misc_animation@0,208 (becomes=841)
841 misc_animation@0,224 (becomes=842)

View file

@ -231,4 +231,9 @@ public class TileSpec
return peekChar() != -1;
}
}
public String toString()
{
return "{tile#"+tileNumber+"}";
}
}

View file

@ -53,19 +53,44 @@ public class Tiles
if (tmp != null) {
tiles[i].onShutdown = get(Integer.parseInt(tmp));
}
tmp = tiles[i].getAttribute("building-part");
if (tmp != null) {
handleBuildingPart(tiles[i], tmp);
}
TileSpec.BuildingInfo bi = tiles[i].getBuildingInfo();
if (bi != null) {
for (int j = 0; j < bi.members.length; j++) {
int tid = bi.members[j];
tiles[tid].owner = tiles[i];
tiles[tid].ownerOffsetX = (bi.width >= 3 ? -1 : 0) + j % bi.width;
tiles[tid].ownerOffsetY = (bi.height >= 3 ? -1 : 0) + j / bi.width;
int offx = (bi.width >= 3 ? -1 : 0) + j % bi.width;
int offy = (bi.height >= 3 ? -1 : 0) + j / bi.width;
if (tiles[tid].owner == null &&
(offx != 0 || offy != 0)
)
{
tiles[tid].owner = tiles[i];
tiles[tid].ownerOffsetX = offx;
tiles[tid].ownerOffsetY = offy;
}
}
}
}
}
private static void handleBuildingPart(TileSpec partTile, String tmp)
{
String [] parts = tmp.split(",");
if (parts.length != 3) {
throw new Error("Invalid building-part specification");
}
partTile.owner = get(Integer.parseInt(parts[0]));
partTile.ownerOffsetX = Integer.parseInt(parts[1]);
partTile.ownerOffsetY = Integer.parseInt(parts[2]);
assert partTile.ownerOffsetX != 0 || partTile.ownerOffsetY != 0;
}
public static TileSpec get(int tileNumber)
{
if (tileNumber >= 0 && tileNumber < tiles.length) {