From 6547a385674e8297331e019a4e4da25484d8441b Mon Sep 17 00:00:00 2001 From: Anuken Date: Sun, 19 Jul 2020 16:34:06 -0400 Subject: [PATCH] Cached Block#offset() --- core/src/mindustry/ai/BaseRegistry.java | 2 +- core/src/mindustry/editor/MapRenderer.java | 6 ++-- .../mindustry/entities/comp/PayloadComp.java | 2 +- .../mindustry/entities/units/BuildPlan.java | 4 +-- core/src/mindustry/game/Schematics.java | 6 ++-- .../src/mindustry/graphics/BlockRenderer.java | 4 +-- core/src/mindustry/graphics/Drawf.java | 4 +-- core/src/mindustry/input/InputHandler.java | 36 +++++++++---------- core/src/mindustry/input/MobileInput.java | 12 +++---- core/src/mindustry/input/Placement.java | 2 +- core/src/mindustry/world/Block.java | 13 ++++--- core/src/mindustry/world/Build.java | 4 +-- core/src/mindustry/world/Tile.java | 4 +-- .../world/blocks/defense/MendProjector.java | 2 +- .../blocks/defense/OverdriveProjector.java | 2 +- .../blocks/defense/PointDefenseTurret.java | 2 +- .../blocks/defense/TractorBeamTurret.java | 2 +- .../world/blocks/defense/turrets/Turret.java | 2 +- .../world/blocks/distribution/MassDriver.java | 2 +- .../world/blocks/power/PowerNode.java | 6 ++-- .../world/blocks/production/Drill.java | 2 +- .../world/blocks/production/Pump.java | 2 +- .../world/blocks/units/RepairPoint.java | 2 +- .../world/blocks/units/ResupplyPoint.java | 2 +- 24 files changed, 60 insertions(+), 65 deletions(-) diff --git a/core/src/mindustry/ai/BaseRegistry.java b/core/src/mindustry/ai/BaseRegistry.java index da6a11a562..98e4744da0 100644 --- a/core/src/mindustry/ai/BaseRegistry.java +++ b/core/src/mindustry/ai/BaseRegistry.java @@ -62,7 +62,7 @@ public class BaseRegistry{ //calculate averages if(tile.block instanceof Drill || tile.block instanceof Pump){ - Tmp.v1.add(tile.x*tilesize + tile.block.offset(), tile.y*tilesize + tile.block.offset()); + Tmp.v1.add(tile.x*tilesize + tile.block.offset, tile.y*tilesize + tile.block.offset); drills ++; } } diff --git a/core/src/mindustry/editor/MapRenderer.java b/core/src/mindustry/editor/MapRenderer.java index 91345b37ea..63c27ade24 100644 --- a/core/src/mindustry/editor/MapRenderer.java +++ b/core/src/mindustry/editor/MapRenderer.java @@ -112,14 +112,14 @@ public class MapRenderer implements Disposable{ if(wall.rotate){ mesh.draw(idxWall, region, - wx * tilesize + wall.offset(), wy * tilesize + wall.offset(), + wx * tilesize + wall.offset, wy * tilesize + wall.offset, region.getWidth() * Draw.scl, region.getHeight() * Draw.scl, tile.rotdeg() - 90); }else{ float width = region.getWidth() * Draw.scl, height = region.getHeight() * Draw.scl; mesh.draw(idxWall, region, - wx * tilesize + wall.offset() + (tilesize - width) / 2f, - wy * tilesize + wall.offset() + (tilesize - height) / 2f, + wx * tilesize + wall.offset + (tilesize - width) / 2f, + wy * tilesize + wall.offset + (tilesize - height) / 2f, width, height); } }else{ diff --git a/core/src/mindustry/entities/comp/PayloadComp.java b/core/src/mindustry/entities/comp/PayloadComp.java index 52cecc0181..87d9e7509a 100644 --- a/core/src/mindustry/entities/comp/PayloadComp.java +++ b/core/src/mindustry/entities/comp/PayloadComp.java @@ -87,7 +87,7 @@ abstract class PayloadComp implements Posc, Rotc, Hitboxc{ /** @return whether the tile has been successfully placed. */ boolean dropBlock(BlockPayload payload){ Building tile = payload.entity; - int tx = Vars.world.toTile(x - tile.block().offset()), ty = Vars.world.toTile(y - tile.block().offset()); + int tx = Vars.world.toTile(x - tile.block().offset), ty = Vars.world.toTile(y - tile.block().offset); Tile on = Vars.world.tile(tx, ty); if(on != null && Build.validPlace(tile.block(), tile.team(), tx, ty, tile.rotation())){ int rot = (int)((rotation + 45f) / 90f) % 4; diff --git a/core/src/mindustry/entities/units/BuildPlan.java b/core/src/mindustry/entities/units/BuildPlan.java index af7d760219..3e265cba92 100644 --- a/core/src/mindustry/entities/units/BuildPlan.java +++ b/core/src/mindustry/entities/units/BuildPlan.java @@ -117,11 +117,11 @@ public class BuildPlan{ } public float drawx(){ - return x*tilesize + block.offset(); + return x*tilesize + block.offset; } public float drawy(){ - return y*tilesize + block.offset(); + return y*tilesize + block.offset; } public BuildPlan configure(Object config){ diff --git a/core/src/mindustry/game/Schematics.java b/core/src/mindustry/game/Schematics.java index c02b60cece..29b44a6efd 100644 --- a/core/src/mindustry/game/Schematics.java +++ b/core/src/mindustry/game/Schematics.java @@ -601,7 +601,7 @@ public class Schematics implements Loadable{ }); //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; @@ -610,8 +610,8 @@ public class Schematics implements Loadable{ wx = wy; wy = -x; } - req.x = (short)(world.toTile(wx - req.block.offset()) + ox); - req.y = (short)(world.toTile(wy - req.block.offset()) + oy); + req.x = (short)(world.toTile(wx - req.block.offset) + ox); + req.y = (short)(world.toTile(wy - req.block.offset) + oy); req.rotation = (byte)Mathf.mod(req.rotation + direction, 4); }); diff --git a/core/src/mindustry/graphics/BlockRenderer.java b/core/src/mindustry/graphics/BlockRenderer.java index 3e37bfe90e..97382dd6d7 100644 --- a/core/src/mindustry/graphics/BlockRenderer.java +++ b/core/src/mindustry/graphics/BlockRenderer.java @@ -114,11 +114,11 @@ public class BlockRenderer implements Disposable{ if(brokenFade > 0.001f){ for(BlockPlan block : state.teams.get(player.team()).blocks){ Block b = content.block(block.block); - if(!camera.bounds(Tmp.r1).grow(tilesize * 2f).overlaps(Tmp.r2.setSize(b.size * tilesize).setCenter(block.x * tilesize + b.offset(), block.y * tilesize + b.offset()))) continue; + if(!camera.bounds(Tmp.r1).grow(tilesize * 2f).overlaps(Tmp.r2.setSize(b.size * tilesize).setCenter(block.x * tilesize + b.offset, block.y * tilesize + b.offset))) continue; Draw.alpha(0.33f * brokenFade); Draw.mixcol(Color.white, 0.2f + Mathf.absin(Time.globalTime(), 6f, 0.2f)); - Draw.rect(b.icon(Cicon.full), block.x * tilesize + b.offset(), block.y * tilesize + b.offset(), b.rotate ? block.rotation * 90 : 0f); + Draw.rect(b.icon(Cicon.full), block.x * tilesize + b.offset, block.y * tilesize + b.offset, b.rotate ? block.rotation * 90 : 0f); } Draw.reset(); } diff --git a/core/src/mindustry/graphics/Drawf.java b/core/src/mindustry/graphics/Drawf.java index 05de2877d8..0a5bbb39c0 100644 --- a/core/src/mindustry/graphics/Drawf.java +++ b/core/src/mindustry/graphics/Drawf.java @@ -68,8 +68,8 @@ public class Drawf{ Point2 p = Geometry.d8edge[i]; float offset = -Math.max(block.size - 1, 0) / 2f * tilesize; Draw.rect("block-select", - x*tilesize + block.offset() + offset * p.x, - y*tilesize + block.offset() + offset * p.y, i * 90); + x*tilesize + block.offset + offset * p.x, + y*tilesize + block.offset + offset * p.y, i * 90); } Draw.reset(); } diff --git a/core/src/mindustry/input/InputHandler.java b/core/src/mindustry/input/InputHandler.java index d2faceeeb8..b2862ad9a1 100644 --- a/core/src/mindustry/input/InputHandler.java +++ b/core/src/mindustry/input/InputHandler.java @@ -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); } } diff --git a/core/src/mindustry/input/MobileInput.java b/core/src/mindustry/input/MobileInput.java index 7f61008385..4ebc918347 100644 --- a/core/src/mindustry/input/MobileInput.java +++ b/core/src/mindustry/input/MobileInput.java @@ -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); } } diff --git a/core/src/mindustry/input/Placement.java b/core/src/mindustry/input/Placement.java index 1d06fbd907..d2c3eb7d41 100644 --- a/core/src/mindustry/input/Placement.java +++ b/core/src/mindustry/input/Placement.java @@ -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; diff --git a/core/src/mindustry/world/Block.java b/core/src/mindustry/world/Block.java index 6628c74dea..ee08bb03ed 100644 --- a/core/src/mindustry/world/Block.java +++ b/core/src/mindustry/world/Block.java @@ -96,6 +96,8 @@ public class Block extends UnlockableContent{ public boolean floating = false; /** multiblock size */ public int size = 1; + /** multiblock offset */ + public float offset = 0f; /** Whether to draw this block in the expanded draw range. */ public boolean expanded = false; /** Max of timers used. */ @@ -242,7 +244,7 @@ public class Block extends UnlockableContent{ float width = layout.width; font.setColor(color); - float dx = x * tilesize + offset(), dy = y * tilesize + offset() + size * tilesize / 2f + 3; + float dx = x * tilesize + offset, dy = y * tilesize + offset + size * tilesize / 2f + 3; font.draw(text, dx, dy + layout.height + 1, Align.center); dy -= 1f; Lines.stroke(2f, Color.darkGray); @@ -470,13 +472,8 @@ public class Block extends UnlockableContent{ return entityType.get(); } - /** Offset for placing and drawing multiblocks. */ - public float offset(){ - return ((size + 1) % 2) * tilesize / 2f; - } - public Rect bounds(int x, int y, Rect rect){ - return rect.setSize(size * tilesize).setCenter(x * tilesize + offset(), y * tilesize + offset()); + return rect.setSize(size * tilesize).setCenter(x * tilesize + offset, y * tilesize + offset); } public boolean isMultiblock(){ @@ -604,6 +601,8 @@ public class Block extends UnlockableContent{ health = size * size * 40; } + offset = ((size + 1) % 2) * tilesize / 2f; + buildCost = 0f; for(ItemStack stack : requirements){ buildCost += stack.amount * stack.item.cost; diff --git a/core/src/mindustry/world/Build.java b/core/src/mindustry/world/Build.java index bf421592b3..5ea1ef3aae 100644 --- a/core/src/mindustry/world/Build.java +++ b/core/src/mindustry/world/Build.java @@ -73,11 +73,11 @@ public class Build{ return false; } - if((type.solid || type.solidifes) && Units.anyEntities(x * tilesize + type.offset() - type.size*tilesize/2f, y * tilesize + type.offset() - type.size*tilesize/2f, type.size * tilesize, type.size*tilesize)){ + if((type.solid || type.solidifes) && Units.anyEntities(x * tilesize + type.offset - type.size*tilesize/2f, y * tilesize + type.offset - type.size*tilesize/2f, type.size * tilesize, type.size*tilesize)){ return false; } - if(state.teams.eachEnemyCore(team, core -> Mathf.dst(x * tilesize + type.offset(), y * tilesize + type.offset(), core.x, core.y) < state.rules.enemyCoreBuildRadius + type.size * tilesize / 2f)){ + if(state.teams.eachEnemyCore(team, core -> Mathf.dst(x * tilesize + type.offset, y * tilesize + type.offset, core.x, core.y) < state.rules.enemyCoreBuildRadius + type.size * tilesize / 2f)){ return false; } diff --git a/core/src/mindustry/world/Tile.java b/core/src/mindustry/world/Tile.java index 15bb4cc4c5..93aab9bcc9 100644 --- a/core/src/mindustry/world/Tile.java +++ b/core/src/mindustry/world/Tile.java @@ -121,11 +121,11 @@ public class Tile implements Position, QuadTreeObject, Displayable{ } public float drawx(){ - return block().offset() + worldx(); + return block().offset + worldx(); } public float drawy(){ - return block().offset() + worldy(); + return block().offset + worldy(); } public boolean isDarkened(){ diff --git a/core/src/mindustry/world/blocks/defense/MendProjector.java b/core/src/mindustry/world/blocks/defense/MendProjector.java index eea22dc31a..dfa10b9383 100644 --- a/core/src/mindustry/world/blocks/defense/MendProjector.java +++ b/core/src/mindustry/world/blocks/defense/MendProjector.java @@ -52,7 +52,7 @@ public class MendProjector extends Block{ @Override public void drawPlace(int x, int y, int rotation, boolean valid){ - Drawf.dashCircle(x * tilesize + offset(), y * tilesize + offset(), range, Pal.accent); + Drawf.dashCircle(x * tilesize + offset, y * tilesize + offset, range, Pal.accent); } public class MendEntity extends Building{ diff --git a/core/src/mindustry/world/blocks/defense/OverdriveProjector.java b/core/src/mindustry/world/blocks/defense/OverdriveProjector.java index d0279dc4ad..034b7407b7 100644 --- a/core/src/mindustry/world/blocks/defense/OverdriveProjector.java +++ b/core/src/mindustry/world/blocks/defense/OverdriveProjector.java @@ -43,7 +43,7 @@ public class OverdriveProjector extends Block{ @Override public void drawPlace(int x, int y, int rotation, boolean valid){ - Drawf.dashCircle(x * tilesize + offset(), y * tilesize + offset(), range, Pal.accent); + Drawf.dashCircle(x * tilesize + offset, y * tilesize + offset, range, Pal.accent); } @Override diff --git a/core/src/mindustry/world/blocks/defense/PointDefenseTurret.java b/core/src/mindustry/world/blocks/defense/PointDefenseTurret.java index 25e5439c69..51df62d6fe 100644 --- a/core/src/mindustry/world/blocks/defense/PointDefenseTurret.java +++ b/core/src/mindustry/world/blocks/defense/PointDefenseTurret.java @@ -44,7 +44,7 @@ public class PointDefenseTurret extends Block{ @Override public void drawPlace(int x, int y, int rotation, boolean valid){ - Drawf.dashCircle(x * tilesize + offset(), y * tilesize + offset(), range, Pal.accent); + Drawf.dashCircle(x * tilesize + offset, y * tilesize + offset, range, Pal.accent); } @Override diff --git a/core/src/mindustry/world/blocks/defense/TractorBeamTurret.java b/core/src/mindustry/world/blocks/defense/TractorBeamTurret.java index 941393b22d..5bffb5c032 100644 --- a/core/src/mindustry/world/blocks/defense/TractorBeamTurret.java +++ b/core/src/mindustry/world/blocks/defense/TractorBeamTurret.java @@ -42,7 +42,7 @@ public class TractorBeamTurret extends Block{ @Override public void drawPlace(int x, int y, int rotation, boolean valid){ - Drawf.dashCircle(x * tilesize + offset(), y * tilesize + offset(), range, Pal.accent); + Drawf.dashCircle(x * tilesize + offset, y * tilesize + offset, range, Pal.accent); } @Override diff --git a/core/src/mindustry/world/blocks/defense/turrets/Turret.java b/core/src/mindustry/world/blocks/defense/turrets/Turret.java index 9e01b91c3a..73b478d582 100644 --- a/core/src/mindustry/world/blocks/defense/turrets/Turret.java +++ b/core/src/mindustry/world/blocks/defense/turrets/Turret.java @@ -128,7 +128,7 @@ public abstract class Turret extends Block{ @Override public void drawPlace(int x, int y, int rotation, boolean valid){ - Drawf.dashCircle(x * tilesize + offset(), y * tilesize + offset(), range, Pal.placing); + Drawf.dashCircle(x * tilesize + offset, y * tilesize + offset, range, Pal.placing); } public static abstract class AmmoEntry{ diff --git a/core/src/mindustry/world/blocks/distribution/MassDriver.java b/core/src/mindustry/world/blocks/distribution/MassDriver.java index 4e023a6216..6cd1e57d6c 100644 --- a/core/src/mindustry/world/blocks/distribution/MassDriver.java +++ b/core/src/mindustry/world/blocks/distribution/MassDriver.java @@ -62,7 +62,7 @@ public class MassDriver extends Block{ //if so, draw a dotted line towards it while it is in range float sin = Mathf.absin(Time.time(), 6f, 1f); - Tmp.v1.set(x * tilesize + offset(), y * tilesize + offset()).sub(selected.x, selected.y).limit((size / 2f + 1) * tilesize + sin + 0.5f); + Tmp.v1.set(x * tilesize + offset, y * tilesize + offset).sub(selected.x, selected.y).limit((size / 2f + 1) * tilesize + sin + 0.5f); float x2 = x * tilesize - Tmp.v1.x, y2 = y * tilesize - Tmp.v1.y, x1 = selected.x + Tmp.v1.x, y1 = selected.y + Tmp.v1.y; int segs = (int)(selected.dst(x * tilesize, y * tilesize) / tilesize); diff --git a/core/src/mindustry/world/blocks/power/PowerNode.java b/core/src/mindustry/world/blocks/power/PowerNode.java index a3b79498e5..ae76588b8b 100644 --- a/core/src/mindustry/world/blocks/power/PowerNode.java +++ b/core/src/mindustry/world/blocks/power/PowerNode.java @@ -119,7 +119,7 @@ public class PowerNode extends PowerBlock{ Lines.stroke(1f); Draw.color(Pal.placing); - Drawf.circles(x * tilesize + offset(), y * tilesize + offset(), laserRange * tilesize); + Drawf.circles(x * tilesize + offset, y * tilesize + offset, laserRange * tilesize); getPotentialLinks(tile, other -> { Drawf.square(other.x, other.y, other.block().size * tilesize / 2f + 2f, Pal.place); @@ -167,13 +167,13 @@ public class PowerNode extends PowerBlock{ public boolean overlaps(@Nullable Tile src, @Nullable Tile other){ if(src == null || other == null) return true; - return Intersector.overlaps(Tmp.cr1.set(src.worldx() + offset(), src.worldy() + offset(), laserRange * tilesize), Tmp.r1.setSize(size * tilesize).setCenter(other.worldx() + offset(), other.worldy() + offset())); + return Intersector.overlaps(Tmp.cr1.set(src.worldx() + offset, src.worldy() + offset, laserRange * tilesize), Tmp.r1.setSize(size * tilesize).setCenter(other.worldx() + offset, other.worldy() + offset)); } protected void getPotentialLinks(Tile tile, Cons others){ Boolf valid = other -> other != null && other.tile() != tile && other.power() != null && ((!other.block().outputsPower && other.block().consumesPower) || (other.block().outputsPower && !other.block().consumesPower) || other.block() instanceof PowerNode) && - overlaps(tile.x * tilesize + offset(), tile.y * tilesize + offset(), other.tile(), laserRange * tilesize) && other.team() == player.team() + overlaps(tile.x * tilesize + offset, tile.y * tilesize + offset, other.tile(), laserRange * tilesize) && other.team() == player.team() && !other.proximity().contains(e -> e.tile() == tile) && !graphs.contains(other.power().graph); tempTileEnts.clear(); diff --git a/core/src/mindustry/world/blocks/production/Drill.java b/core/src/mindustry/world/blocks/production/Drill.java index cd827ade21..a893041396 100644 --- a/core/src/mindustry/world/blocks/production/Drill.java +++ b/core/src/mindustry/world/blocks/production/Drill.java @@ -117,7 +117,7 @@ public class Drill extends Block{ if(returnItem != null){ float width = drawPlaceText(Core.bundle.formatFloat("bar.drillspeed", 60f / (drillTime + hardnessDrillMultiplier * returnItem.hardness) * returnCount, 2), x, y, valid); - float dx = x * tilesize + offset() - width/2f - 4f, dy = y * tilesize + offset() + size * tilesize / 2f + 5; + float dx = x * tilesize + offset - width/2f - 4f, dy = y * tilesize + offset + size * tilesize / 2f + 5; Draw.mixcol(Color.darkGray, 1f); Draw.rect(returnItem.icon(Cicon.small), dx, dy - 1); Draw.reset(); diff --git a/core/src/mindustry/world/blocks/production/Pump.java b/core/src/mindustry/world/blocks/production/Pump.java index 0dff2b248b..d6762ecb06 100644 --- a/core/src/mindustry/world/blocks/production/Pump.java +++ b/core/src/mindustry/world/blocks/production/Pump.java @@ -45,7 +45,7 @@ public class Pump extends LiquidBlock{ if(liquidDrop != null){ float width = drawPlaceText(Core.bundle.formatFloat("bar.pumpspeed", tiles * pumpAmount / size / size * 60f, 0), x, y, valid); - float dx = x * tilesize + offset() - width/2f - 4f, dy = y * tilesize + offset() + size * tilesize / 2f + 5; + float dx = x * tilesize + offset - width/2f - 4f, dy = y * tilesize + offset + size * tilesize / 2f + 5; Draw.mixcol(Color.darkGray, 1f); Draw.rect(liquidDrop.icon(Cicon.small), dx, dy - 1); Draw.reset(); diff --git a/core/src/mindustry/world/blocks/units/RepairPoint.java b/core/src/mindustry/world/blocks/units/RepairPoint.java index b7108d4524..a5a5646dc6 100644 --- a/core/src/mindustry/world/blocks/units/RepairPoint.java +++ b/core/src/mindustry/world/blocks/units/RepairPoint.java @@ -53,7 +53,7 @@ public class RepairPoint extends Block{ @Override public void drawPlace(int x, int y, int rotation, boolean valid){ - Drawf.dashCircle(x * tilesize + offset(), y * tilesize + offset(), repairRadius, Pal.accent); + Drawf.dashCircle(x * tilesize + offset, y * tilesize + offset, repairRadius, Pal.accent); } @Override diff --git a/core/src/mindustry/world/blocks/units/ResupplyPoint.java b/core/src/mindustry/world/blocks/units/ResupplyPoint.java index c58847f94c..5baa7f5f3b 100644 --- a/core/src/mindustry/world/blocks/units/ResupplyPoint.java +++ b/core/src/mindustry/world/blocks/units/ResupplyPoint.java @@ -30,7 +30,7 @@ public class ResupplyPoint extends Block{ @Override public void drawPlace(int x, int y, int rotation, boolean valid){ - Drawf.dashCircle(x * tilesize + offset(), y * tilesize + offset(), range, Pal.placing); + Drawf.dashCircle(x * tilesize + offset, y * tilesize + offset, range, Pal.placing); } public class ResupplyPointEntity extends Building{