This commit is contained in:
Anuken
2020-05-11 13:20:27 -04:00
parent 37c92302f0
commit 9cca79adaa
8 changed files with 251 additions and 72 deletions
+18 -6
View File
@@ -196,12 +196,24 @@ abstract class TileComp implements Posc, Teamc, Healthc, Tilec, Timerc, QuadTree
public byte absoluteRelativeTo(int cx, int cy){
int x = tile.x, y = tile.y;
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;
//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;