Fixed #2040 / Fixed #2039 / Fixed #2038 / Fixed #2037 / Fixed #2035

This commit is contained in:
Anuken
2020-05-12 09:34:26 -04:00
parent 7f3f1d7d76
commit f6d8658ee2
16 changed files with 111 additions and 113 deletions

View File

@@ -184,39 +184,8 @@ abstract class TileComp implements Posc, Teamc, Healthc, Tilec, Timerc, QuadTree
return relativeTo(tile.x, tile.y);
}
/** Return relative rotation to a coordinate. Returns -1 if the coordinate is not near this tile. */
public byte relativeTo(int cx, int cy){
int x = tile.x, y = tile.y;
if(x == cx && y == cy - 1) return 1;
if(x == cx && y == cy + 1) return 3;
if(x == cx - 1 && y == cy) return 0;
if(x == cx + 1 && y == cy) return 2;
return -1;
}
public byte absoluteRelativeTo(int cx, int cy){
int x = tile.x, y = tile.y;
//very straightforward for odd sizes
if(block.size % 2 == 1){
if(Math.abs(x - cx) > Math.abs(y - cy)){
if(x <= cx - 1) return 0;
if(x >= cx + 1) return 2;
}else{
if(y <= cy - 1) return 1;
if(y >= cy + 1) return 3;
}
}else{ //need offsets here
if(Math.abs(x - cx + 0.5f) > Math.abs(y - cy + 0.5f)){
if(x+0.5f <= cx - 1) return 0;
if(x+0.5f >= cx + 1) return 2;
}else{
if(y+0.5f <= cy - 1) return 1;
if(y+0.5f >= cy + 1) return 3;
}
}
return -1;
return tile.absoluteRelativeTo(cx, cy);
}
public @Nullable Tilec front(){