mirror of
https://github.com/collinsmith/riiablo.git
synced 2025-07-04 15:27:30 +07:00
Refactor renamed Tile#orientation to Tile#tileType to be clearer on use
This commit is contained in:
@ -18,8 +18,8 @@ import com.riiablo.map5.util.BucketPool;
|
||||
import static com.riiablo.map5.Block.ISO_FORMAT;
|
||||
import static com.riiablo.map5.Block.ISO_RLE_FORMAT;
|
||||
import static com.riiablo.map5.Block.RLE_FORMAT;
|
||||
import static com.riiablo.map5.Orientation.FLOOR;
|
||||
import static com.riiablo.map5.Orientation.ROOF;
|
||||
import static com.riiablo.map5.TileType.FLOOR;
|
||||
import static com.riiablo.map5.TileType.ROOF;
|
||||
import static com.riiablo.map5.Tile.NUM_SUBTILES;
|
||||
import static com.riiablo.map5.Tile.SUBTILE_SIZE;
|
||||
|
||||
@ -103,7 +103,7 @@ public enum Dt1Decoder7 {
|
||||
tile.height = in.read32();
|
||||
tile.width = in.read32();
|
||||
tile.heightToBottom = in.read32();
|
||||
tile.orientation = in.readSafe32u();
|
||||
tile.tileType = in.readSafe32u();
|
||||
tile.mainIndex = in.readSafe32u();
|
||||
tile.subIndex = in.readSafe32u();
|
||||
tile.updateIndex();
|
||||
@ -158,7 +158,7 @@ public enum Dt1Decoder7 {
|
||||
readBlockHeaders(blocks, t.numBlocks, in);
|
||||
calculateBox(blocks, t.numBlocks, t.box);
|
||||
log.trace("bbox: {}", t.box);
|
||||
final int yOffs = yOffset(t.orientation);
|
||||
final int yOffs = yOffset(t.tileType);
|
||||
log.trace("yOffs: {}, box.yMax: {}", yOffs, t.box.yMax);
|
||||
byte[] pixmap = pool.obtain(t.box.width * t.box.height);
|
||||
try {
|
||||
@ -207,8 +207,8 @@ public enum Dt1Decoder7 {
|
||||
box.update();
|
||||
}
|
||||
|
||||
static int yOffset(int orientation) {
|
||||
switch (orientation) {
|
||||
static int yOffset(int tileType) {
|
||||
switch (tileType) {
|
||||
case ROOF:
|
||||
case FLOOR:
|
||||
// TODO: origin shifted Tile.HEIGHT up (positive y-down)
|
||||
|
@ -90,7 +90,7 @@ public class Tile implements Disposable {
|
||||
public int height;
|
||||
public int width;
|
||||
public int heightToBottom;
|
||||
public int orientation;
|
||||
public int tileType;
|
||||
public int mainIndex;
|
||||
public int subIndex;
|
||||
public int rarityFrame;
|
||||
@ -107,7 +107,7 @@ public class Tile implements Disposable {
|
||||
final TextureRegion region = new TextureRegion(MISSING_TEXTURE);
|
||||
|
||||
int updateIndex() {
|
||||
return tileIndex = Index.create(orientation, mainIndex, subIndex);
|
||||
return tileIndex = Index.create(tileType, mainIndex, subIndex);
|
||||
}
|
||||
|
||||
public int tileIndex() {
|
||||
@ -157,10 +157,10 @@ public class Tile implements Disposable {
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this)
|
||||
.append("tileIndex", String.format("0x%08x", tileIndex))
|
||||
.append("orientation", String.format("%d (%s)", orientation, Orientation.toString(orientation)))
|
||||
.append("tileType", String.format("%d (%s)", tileType, TileType.toString(tileType)))
|
||||
.append("mainIndex", mainIndex)
|
||||
.append("subIndex", subIndex)
|
||||
.append("lightDirection", String.format("%d (%s)", lightDirection, Orientation.directionToString(lightDirection)))
|
||||
.append("lightDirection", String.format("%d (%s)", lightDirection, TileType.directionToString(lightDirection)))
|
||||
.append("roofHeight", roofHeight)
|
||||
.append("materialFlags", materialFlags)
|
||||
.append("height", height)
|
||||
@ -178,23 +178,23 @@ public class Tile implements Disposable {
|
||||
public static final class Index {
|
||||
private Index() {}
|
||||
|
||||
private static final int MAIN_INDEX_OFFSET = 16;
|
||||
private static final int MAIN_INDEX_BITS = 0xFF;
|
||||
private static final int MAIN_INDEX_OFFSET = 16;
|
||||
private static final int MAIN_INDEX_BITS = 0xFF;
|
||||
|
||||
private static final int SUB_INDEX_OFFSET = 8;
|
||||
private static final int SUB_INDEX_BITS = 0xFF;
|
||||
private static final int SUB_INDEX_OFFSET = 8;
|
||||
private static final int SUB_INDEX_BITS = 0xFF;
|
||||
|
||||
private static final int ORIENTATION_OFFSET = 0;
|
||||
private static final int ORIENTATION_BITS = 0xFF;
|
||||
private static final int TILE_TYPE_OFFSET = 0;
|
||||
private static final int TILE_TYPE_BITS = 0xFF;
|
||||
|
||||
public static int create(int orientation, int mainIndex, int subIndex) {
|
||||
return (mainIndex & MAIN_INDEX_BITS) << MAIN_INDEX_OFFSET
|
||||
| (subIndex & SUB_INDEX_BITS) << SUB_INDEX_OFFSET
|
||||
| (orientation & ORIENTATION_BITS) << ORIENTATION_OFFSET;
|
||||
public static int create(int tileType, int mainIndex, int subIndex) {
|
||||
return (mainIndex & MAIN_INDEX_BITS) << MAIN_INDEX_OFFSET
|
||||
| (subIndex & SUB_INDEX_BITS) << SUB_INDEX_OFFSET
|
||||
| (tileType & TILE_TYPE_BITS) << TILE_TYPE_OFFSET;
|
||||
}
|
||||
|
||||
public static int mainIndex(int index) { return (index >>> MAIN_INDEX_OFFSET) & MAIN_INDEX_BITS; }
|
||||
public static int subIndex(int index) { return (index >>> SUB_INDEX_OFFSET) & SUB_INDEX_BITS; }
|
||||
public static int orientation(int index) { return (index >>> ORIENTATION_OFFSET) & ORIENTATION_BITS; }
|
||||
public static int mainIndex(int index) { return (index >>> MAIN_INDEX_OFFSET) & MAIN_INDEX_BITS; }
|
||||
public static int subIndex(int index) { return (index >>> SUB_INDEX_OFFSET) & SUB_INDEX_BITS; }
|
||||
public static int tileType(int index) { return (index >>> TILE_TYPE_OFFSET) & TILE_TYPE_BITS; }
|
||||
}
|
||||
}
|
||||
|
@ -14,8 +14,8 @@ public enum TileRenderer {
|
||||
private static final Color GRID_COLOR = new Color().fromHsv(0f, 0f, .15f);
|
||||
|
||||
public void draw(Batch batch, Tile tile, float x, float y) {
|
||||
// TODO: Perhaps Tile#roofHeight should only be applied when Tile#orientation
|
||||
// is Orientation#ROOF. Maybe that can be built into Tile#box#yMin at the
|
||||
// TODO: Perhaps Tile#roofHeight should only be applied when Tile#tileType
|
||||
// is TileType#ROOF. Maybe that can be built into Tile#box#yMin at the
|
||||
// end of reading the tile blocks from memory (since doing this before would
|
||||
// bloat the texture height by Tile#roofHeight). I'll revisit this later.
|
||||
final BBox box = tile.box();
|
||||
@ -35,7 +35,7 @@ public enum TileRenderer {
|
||||
shapes.setColor(Color.GREEN);
|
||||
final int xOffs;
|
||||
final int yOffs;
|
||||
if (tile.orientation == Orientation.FLOOR || tile.orientation == Orientation.ROOF) {
|
||||
if (tile.tileType == TileType.FLOOR || tile.tileType == TileType.ROOF) {
|
||||
xOffs = 0;
|
||||
yOffs = Tile.HEIGHT;
|
||||
} else {
|
||||
@ -91,7 +91,7 @@ public enum TileRenderer {
|
||||
shapes.setColor(Color.WHITE); // bbox
|
||||
shapes.rect(x + box.xMin, y + box.yMin, box.width, box.height);
|
||||
|
||||
if (Orientation.isRoof(tile.orientation)) {
|
||||
if (TileType.isRoof(tile.tileType)) {
|
||||
shapes.setColor(Color.ORANGE);
|
||||
shapes.line(x, y, x, y - tile.roofHeight);
|
||||
shapes.line(x - 3, y, x + 2, y);
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.riiablo.map5;
|
||||
|
||||
public final class Orientation {
|
||||
private Orientation() {}
|
||||
public final class TileType {
|
||||
private TileType() {}
|
||||
|
||||
/** Floors */
|
||||
public static final int FLOOR = 0;
|
||||
@ -36,35 +36,35 @@ public final class Orientation {
|
||||
/** Roofs */
|
||||
public static final int ROOF = 15;
|
||||
/**
|
||||
* Lower walls equivalent to Orientation 1
|
||||
* Lower walls equivalent to TileType 1
|
||||
*
|
||||
* @see #LEFT_WALL
|
||||
*/
|
||||
public static final int LOWER_LEFT_WALL = 16;
|
||||
/**
|
||||
* Lower walls equivalent to Orientation 2
|
||||
* Lower walls equivalent to TileType 2
|
||||
*
|
||||
* @see #RIGHT_WALL
|
||||
*/
|
||||
public static final int LOWER_RIGHT_WALL = 17;
|
||||
/**
|
||||
* Lower walls equivalent to Orientation 3 and 4
|
||||
* Lower walls equivalent to TileType 3 and 4
|
||||
*
|
||||
* @see #RIGHT_NORTH_CORNER_WALL
|
||||
* @see #LEFT_NORTH_CORNER_WALL
|
||||
*/
|
||||
public static final int LOWER_NORTH_CORNER_WALL = 18;
|
||||
/**
|
||||
* Lower walls equivalent to Orientation 7
|
||||
* Lower walls equivalent to TileType 7
|
||||
*
|
||||
* @see #SOUTH_CORNER_WALL
|
||||
*/
|
||||
public static final int LOWER_SOUTH_CORNER_WALL = 19;
|
||||
/** Unknown. Is an expected result for orientation lookup table. */
|
||||
/** Unknown. Is an expected result for tile type lookup table. */
|
||||
public static final int UNKNOWN_20 = 20;
|
||||
|
||||
public static String toString(int orientation) {
|
||||
switch (orientation) {
|
||||
public static String toString(int tileType) {
|
||||
switch (tileType) {
|
||||
case FLOOR:
|
||||
return "FLOOR";
|
||||
case LEFT_WALL:
|
||||
@ -110,8 +110,8 @@ public final class Orientation {
|
||||
}
|
||||
}
|
||||
|
||||
public static int toDirection(int orientation) {
|
||||
switch (orientation) {
|
||||
public static int toDirection(int tileType) {
|
||||
switch (tileType) {
|
||||
case LEFT_WALL:
|
||||
case LEFT_END_WALL:
|
||||
case LEFT_WALL_DOOR:
|
||||
@ -158,8 +158,8 @@ public final class Orientation {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isFloor(int orientation) {
|
||||
switch (orientation) {
|
||||
public static boolean isFloor(int tileType) {
|
||||
switch (tileType) {
|
||||
case FLOOR:
|
||||
return true;
|
||||
default:
|
||||
@ -167,8 +167,8 @@ public final class Orientation {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isRoof(int orientation) {
|
||||
switch (orientation) {
|
||||
public static boolean isRoof(int tileType) {
|
||||
switch (tileType) {
|
||||
case ROOF:
|
||||
return true;
|
||||
default:
|
||||
@ -176,8 +176,8 @@ public final class Orientation {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isWall(int orientation) {
|
||||
switch (orientation) {
|
||||
public static boolean isWall(int tileType) {
|
||||
switch (tileType) {
|
||||
case LEFT_WALL:
|
||||
case RIGHT_WALL:
|
||||
case RIGHT_NORTH_CORNER_WALL:
|
||||
@ -199,8 +199,8 @@ public final class Orientation {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isSpecial(int orientation) {
|
||||
switch (orientation) {
|
||||
public static boolean isSpecial(int tileType) {
|
||||
switch (tileType) {
|
||||
case SPECIAL_10:
|
||||
case SPECIAL_11:
|
||||
return true;
|
||||
@ -209,8 +209,8 @@ public final class Orientation {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isLowerWall(int orientation) {
|
||||
switch (orientation) {
|
||||
public static boolean isLowerWall(int tileType) {
|
||||
switch (tileType) {
|
||||
case LOWER_LEFT_WALL:
|
||||
case LOWER_RIGHT_WALL:
|
||||
case LOWER_NORTH_CORNER_WALL:
|
@ -96,8 +96,8 @@ public class Dt1Info extends VisTable {
|
||||
add(tileTable, "tileIndex: ", "0x%08x", tile.tileIndex());
|
||||
add(tileTable, "mainIndex: ", tile.mainIndex);
|
||||
add(tileTable, "subIndex: ", tile.subIndex);
|
||||
add(tileTable, "orientation: ", "%d (%s)", tile.orientation, Orientation.toString(tile.orientation));
|
||||
add(tileTable, "light direction: ", "%d (%s)", tile.lightDirection, Orientation.directionToString(tile.lightDirection));
|
||||
add(tileTable, "tileType: ", "%d (%s)", tile.tileType, TileType.toString(tile.tileType));
|
||||
add(tileTable, "light direction: ", "%d (%s)", tile.lightDirection, TileType.directionToString(tile.lightDirection));
|
||||
add(tileTable, "width,height: ", "%d,%d", tile.width, tile.height);
|
||||
add(tileTable, "texture: ", "%dx%d", tile.textureWidth(), tile.textureHeight());
|
||||
add(tileTable, "tile: ", "green");
|
||||
|
Reference in New Issue
Block a user