mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-01-27 15:02:03 -08:00
Cached Block#offset()
This commit is contained in:
parent
c398b89284
commit
6547a38567
24 changed files with 60 additions and 65 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue