Cached Block#offset()
This commit is contained in:
@@ -431,7 +431,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
});
|
||||
|
||||
//rotate actual request, centered on its multiblock position
|
||||
float wx = (req.x - ox) * tilesize + req.block.offset(), wy = (req.y - oy) * tilesize + req.block.offset();
|
||||
float wx = (req.x - ox) * tilesize + req.block.offset, wy = (req.y - oy) * tilesize + req.block.offset;
|
||||
float x = wx;
|
||||
if(direction >= 0){
|
||||
wx = -wy;
|
||||
@@ -440,8 +440,8 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
wx = wy;
|
||||
wy = -x;
|
||||
}
|
||||
req.x = world.toTile(wx - req.block.offset()) + ox;
|
||||
req.y = world.toTile(wy - req.block.offset()) + oy;
|
||||
req.x = world.toTile(wx - req.block.offset) + ox;
|
||||
req.y = world.toTile(wy - req.block.offset) + oy;
|
||||
req.rotation = Mathf.mod(req.rotation + direction, 4);
|
||||
});
|
||||
}
|
||||
@@ -450,12 +450,12 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
int origin = (x ? schemOriginX() : schemOriginY()) * tilesize;
|
||||
|
||||
requests.each(req -> {
|
||||
float value = -((x ? req.x : req.y) * tilesize - origin + req.block.offset()) + origin;
|
||||
float value = -((x ? req.x : req.y) * tilesize - origin + req.block.offset) + origin;
|
||||
|
||||
if(x){
|
||||
req.x = (int)((value - req.block.offset()) / tilesize);
|
||||
req.x = (int)((value - req.block.offset) / tilesize);
|
||||
}else{
|
||||
req.y = (int)((value - req.block.offset()) / tilesize);
|
||||
req.y = (int)((value - req.block.offset) / tilesize);
|
||||
}
|
||||
|
||||
req.pointConfig(p -> {
|
||||
@@ -505,10 +505,10 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
|
||||
if(!req.breaking){
|
||||
r1.setSize(req.block.size * tilesize);
|
||||
r1.setCenter(other.worldx() + req.block.offset(), other.worldy() + req.block.offset());
|
||||
r1.setCenter(other.worldx() + req.block.offset, other.worldy() + req.block.offset);
|
||||
}else{
|
||||
r1.setSize(other.block().size * tilesize);
|
||||
r1.setCenter(other.worldx() + other.block().offset(), other.worldy() + other.block().offset());
|
||||
r1.setCenter(other.worldx() + other.block().offset, other.worldy() + other.block().offset);
|
||||
}
|
||||
|
||||
return r2.overlaps(r1);
|
||||
@@ -797,10 +797,6 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
&& tile.block() == Blocks.air && player.dst(tile.worldx(), tile.worldy()) <= miningRange;
|
||||
}
|
||||
|
||||
Building entAt(float x, float y){
|
||||
return world.build(tileX(x), tileY(y));
|
||||
}
|
||||
|
||||
/** Returns the tile at the specified MOUSE coordinates. */
|
||||
Tile tileAt(float x, float y){
|
||||
return world.tile(tileX(x), tileY(y));
|
||||
@@ -817,7 +813,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
int tileX(float cursorX){
|
||||
Vec2 vec = Core.input.mouseWorld(cursorX, 0);
|
||||
if(selectedBlock()){
|
||||
vec.sub(block.offset(), block.offset());
|
||||
vec.sub(block.offset, block.offset);
|
||||
}
|
||||
return world.toTile(vec.x);
|
||||
}
|
||||
@@ -825,7 +821,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
int tileY(float cursorY){
|
||||
Vec2 vec = Core.input.mouseWorld(0, cursorY);
|
||||
if(selectedBlock()){
|
||||
vec.sub(block.offset(), block.offset());
|
||||
vec.sub(block.offset, block.offset);
|
||||
}
|
||||
return world.toTile(vec.y);
|
||||
}
|
||||
@@ -989,15 +985,15 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
|
||||
Draw.color(!valid ? Pal.removeBack : Pal.accentBack);
|
||||
Draw.rect(Core.atlas.find("place-arrow"),
|
||||
x * tilesize + block.offset() + dx*trns,
|
||||
y * tilesize + block.offset() - 1 + dy*trns,
|
||||
x * tilesize + block.offset + dx*trns,
|
||||
y * tilesize + block.offset - 1 + dy*trns,
|
||||
Core.atlas.find("place-arrow").getWidth() * Draw.scl,
|
||||
Core.atlas.find("place-arrow").getHeight() * Draw.scl, rotation * 90 - 90);
|
||||
|
||||
Draw.color(!valid ? Pal.remove : Pal.accent);
|
||||
Draw.rect(Core.atlas.find("place-arrow"),
|
||||
x * tilesize + block.offset() + dx*trns,
|
||||
y * tilesize + block.offset() + dy*trns,
|
||||
x * tilesize + block.offset + dx*trns,
|
||||
y * tilesize + block.offset + dy*trns,
|
||||
Core.atlas.find("place-arrow").getWidth() * Draw.scl,
|
||||
Core.atlas.find("place-arrow").getHeight() * Draw.scl, rotation * 90 - 90);
|
||||
}
|
||||
@@ -1054,7 +1050,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
for(int i = 0; i < points.size; i++){
|
||||
Point2 point = points.get(i);
|
||||
|
||||
if(block != null && Tmp.r2.setSize(block.size * tilesize).setCenter(point.x * tilesize + block.offset(), point.y * tilesize + block.offset()).overlaps(Tmp.r3)){
|
||||
if(block != null && Tmp.r2.setSize(block.size * tilesize).setCenter(point.x * tilesize + block.offset, point.y * tilesize + block.offset).overlaps(Tmp.r3)){
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1069,7 +1065,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
line.last = next == null;
|
||||
cons.get(line);
|
||||
|
||||
Tmp.r3.setSize(block.size * tilesize).setCenter(point.x * tilesize + block.offset(), point.y * tilesize + block.offset());
|
||||
Tmp.r3.setSize(block.size * tilesize).setCenter(point.x * tilesize + block.offset, point.y * tilesize + block.offset);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
/** Returns whether this block overlaps any selection requests. */
|
||||
boolean checkOverlapPlacement(int x, int y, Block block){
|
||||
r2.setSize(block.size * tilesize);
|
||||
r2.setCenter(x * tilesize + block.offset(), y * tilesize + block.offset());
|
||||
r2.setCenter(x * tilesize + block.offset, y * tilesize + block.offset);
|
||||
|
||||
for(BuildPlan req : selectRequests){
|
||||
Tile other = req.tile();
|
||||
@@ -103,7 +103,7 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
if(other == null || req.breaking) continue;
|
||||
|
||||
r1.setSize(req.block.size * tilesize);
|
||||
r1.setCenter(other.worldx() + req.block.offset(), other.worldy() + req.block.offset());
|
||||
r1.setCenter(other.worldx() + req.block.offset, other.worldy() + req.block.offset);
|
||||
|
||||
if(r2.overlaps(r1)){
|
||||
return true;
|
||||
@@ -116,7 +116,7 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
if(other == null || req.breaking) continue;
|
||||
|
||||
r1.setSize(req.block.size * tilesize);
|
||||
r1.setCenter(other.worldx() + req.block.offset(), other.worldy() + req.block.offset());
|
||||
r1.setCenter(other.worldx() + req.block.offset, other.worldy() + req.block.offset);
|
||||
|
||||
if(r2.overlaps(r1)){
|
||||
return true;
|
||||
@@ -137,11 +137,11 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
|
||||
if(!req.breaking){
|
||||
r1.setSize(req.block.size * tilesize);
|
||||
r1.setCenter(other.worldx() + req.block.offset(), other.worldy() + req.block.offset());
|
||||
r1.setCenter(other.worldx() + req.block.offset, other.worldy() + req.block.offset);
|
||||
|
||||
}else{
|
||||
r1.setSize(other.block().size * tilesize);
|
||||
r1.setCenter(other.worldx() + other.block().offset(), other.worldy() + other.block().offset());
|
||||
r1.setCenter(other.worldx() + other.block().offset, other.worldy() + other.block().offset);
|
||||
}
|
||||
|
||||
if(r2.overlaps(r1)) return req;
|
||||
@@ -538,7 +538,7 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
Fx.tapBlock.at(cursor.worldx(), cursor.worldy(), 1f);
|
||||
}else if(block != null){
|
||||
updateLine(lineStartX, lineStartY, cursor.x, cursor.y);
|
||||
Fx.tapBlock.at(cursor.worldx() + block.offset(), cursor.worldy() + block.offset(), block.size);
|
||||
Fx.tapBlock.at(cursor.worldx() + block.offset, cursor.worldy() + block.offset, block.size);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -154,7 +154,7 @@ public class Placement{
|
||||
public static NormalizeDrawResult normalizeDrawArea(Block block, int startx, int starty, int endx, int endy, boolean snap, int maxLength, float scaling){
|
||||
normalizeArea(startx, starty, endx, endy, 0, snap, maxLength);
|
||||
|
||||
float offset = block.offset();
|
||||
float offset = block.offset;
|
||||
|
||||
drawResult.x = result.x * tilesize;
|
||||
drawResult.y = result.y * tilesize;
|
||||
|
||||
Reference in New Issue
Block a user