TilePrefab now subclasses TileContainer

This commit is contained in:
Gered 2013-07-22 19:11:55 -04:00
parent a1f3a737b8
commit 549cb31149

View file

@ -5,7 +5,7 @@ import com.badlogic.gdx.math.collision.BoundingBox;
import com.blarg.gdx.tilemap3d.Tile; import com.blarg.gdx.tilemap3d.Tile;
import com.blarg.gdx.tilemap3d.TileContainer; import com.blarg.gdx.tilemap3d.TileContainer;
public class TilePrefab { public class TilePrefab extends TileContainer {
public enum Rotation { public enum Rotation {
ROT0(0), ROT0(0),
ROT90(90), ROT90(90),
@ -42,23 +42,62 @@ public class TilePrefab {
final BoundingBox rotationBounds = new BoundingBox(); final BoundingBox rotationBounds = new BoundingBox();
final BoundingBox tmpRotationBounds = new BoundingBox(); final BoundingBox tmpRotationBounds = new BoundingBox();
@Override
public int getWidth() { public int getWidth() {
return width; return width;
} }
@Override
public int getHeight() { public int getHeight() {
return height; return height;
} }
@Override
public int getDepth() { public int getDepth() {
return depth; return depth;
} }
@Override
public int getMinX() {
return 0;
}
@Override
public int getMinY() {
return 0;
}
@Override
public int getMinZ() {
return 0;
}
@Override
public int getMaxX() {
return width - 1;
}
@Override
public int getMaxY() {
return height - 1;
}
@Override
public int getMaxZ() {
return depth - 1;
}
@Override
public BoundingBox getBounds() { public BoundingBox getBounds() {
tmpBounds.set(bounds); tmpBounds.set(bounds);
return tmpBounds; return tmpBounds;
} }
@Override
public Vector3 getPosition() {
return null;
}
public Rotation getRotation() { public Rotation getRotation() {
return rotation; return rotation;
} }
@ -96,11 +135,20 @@ public class TilePrefab {
rotate(Rotation.ROT0); rotate(Rotation.ROT0);
} }
@Override
public Tile get(int x, int y, int z) { public Tile get(int x, int y, int z) {
int index = getIndexOf(x, y, z); int index = getIndexOf(x, y, z);
return data[index]; return data[index];
} }
@Override
public Tile getSafe(int x, int y, int z) {
if (!isWithinLocalBounds(x, y, z))
return null;
else
return get(x, y, z);
}
public void rotate(Rotation rotation) { public void rotate(Rotation rotation) {
this.rotation = rotation; this.rotation = rotation;