buildings: for component tiles, link back to the owner tile

git-svn-id: https://micropolis.googlecode.com/svn/trunk/micropolis-java@811 d9718cc8-9f43-0410-858b-315f434eb58c
This commit is contained in:
jason@long.name 2013-09-01 00:25:39 +00:00
parent 3941b35fa4
commit 7069c8150c
3 changed files with 20 additions and 0 deletions

View file

@ -11,6 +11,9 @@ public class TileSpec
boolean canBurn;
boolean canConduct;
boolean zone;
public TileSpec owner;
public int ownerOffsetX;
public int ownerOffsetY;
Map<String,String> attributes;
List<String> images;

View file

@ -53,6 +53,16 @@ public class Tiles
if (tmp != null) {
tiles[i].onShutdown = get(Integer.parseInt(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;
}
}
}
}

View file

@ -1093,6 +1093,13 @@ public class MainWindow extends JFrame
ZoneStatus z = engine.queryZoneStatus(xpos, ypos);
notificationPane.showZoneStatus(engine, xpos, ypos, z);
TileSpec ts = Tiles.get(engine.getTile(xpos, ypos) & TileConstants.LOMASK);
if (ts != null) {
System.out.println("owner: "+ts.owner);
System.out.println(" x: "+ts.ownerOffsetX);
System.out.println(" y: "+ts.ownerOffsetY);
}
}
private void doZoom(int dir, Point mousePt)