diff --git a/core/assets/sprites/sprites.atlas b/core/assets/sprites/sprites.atlas index 4b9a2411b7..95224a6200 100644 --- a/core/assets/sprites/sprites.atlas +++ b/core/assets/sprites/sprites.atlas @@ -34,14 +34,14 @@ mend-projector-top index: -1 mender rotate: false - xy: 1071, 467 + xy: 969, 331 size: 32, 32 orig: 32, 32 offset: 0, 0 index: -1 mender-top rotate: false - xy: 969, 331 + xy: 1003, 365 size: 32, 32 orig: 32, 32 offset: 0, 0 @@ -384,42 +384,42 @@ conveyor-4-3 index: -1 plastanium-conveyor rotate: false - xy: 1003, 297 + xy: 1037, 331 size: 32, 32 orig: 32, 32 offset: 0, 0 index: -1 plastanium-conveyor-0 rotate: false - xy: 1037, 331 + xy: 1071, 365 size: 32, 32 orig: 32, 32 offset: 0, 0 index: -1 plastanium-conveyor-1 rotate: false - xy: 1071, 365 + xy: 1105, 399 size: 32, 32 orig: 32, 32 offset: 0, 0 index: -1 plastanium-conveyor-2 rotate: false - xy: 1105, 399 + xy: 1139, 433 size: 32, 32 orig: 32, 32 offset: 0, 0 index: -1 plastanium-conveyor-edge rotate: false - xy: 1139, 433 + xy: 1173, 467 size: 32, 32 orig: 32, 32 offset: 0, 0 index: -1 plastanium-conveyor-stack rotate: false - xy: 1173, 467 + xy: 969, 229 size: 32, 32 orig: 32, 32 offset: 0, 0 @@ -615,35 +615,35 @@ mass-driver-base index: -1 overflow-gate rotate: false - xy: 1037, 399 + xy: 1071, 433 size: 32, 32 orig: 32, 32 offset: 0, 0 index: -1 phase-conveyor rotate: false - xy: 1037, 365 + xy: 1071, 399 size: 32, 32 orig: 32, 32 offset: 0, 0 index: -1 phase-conveyor-arrow rotate: false - xy: 1071, 399 + xy: 1105, 433 size: 32, 32 orig: 32, 32 offset: 0, 0 index: -1 phase-conveyor-bridge rotate: false - xy: 1105, 433 + xy: 1139, 467 size: 32, 32 orig: 32, 32 offset: 0, 0 index: -1 phase-conveyor-end rotate: false - xy: 1139, 467 + xy: 969, 263 size: 32, 32 orig: 32, 32 offset: 0, 0 @@ -867,7 +867,7 @@ conduit-liquid index: -1 message rotate: false - xy: 1003, 365 + xy: 1037, 399 size: 32, 32 orig: 32, 32 offset: 0, 0 @@ -1096,135 +1096,149 @@ mechanical-pump orig: 32, 32 offset: 0, 0 index: -1 -phase-conduit +mechanical-pump-liquid rotate: false - xy: 1071, 433 + xy: 1037, 433 size: 32, 32 orig: 32, 32 offset: 0, 0 index: -1 -phase-conduit-arrow +rotary-pump-liquid + rotate: false + xy: 1037, 433 + size: 32, 32 + orig: 32, 32 + offset: 0, 0 + index: -1 +thermal-pump-liquid + rotate: false + xy: 1037, 433 + size: 32, 32 + orig: 32, 32 + offset: 0, 0 + index: -1 +phase-conduit rotate: false xy: 1105, 467 size: 32, 32 orig: 32, 32 offset: 0, 0 index: -1 -phase-conduit-bridge +phase-conduit-arrow rotate: false xy: 969, 297 size: 32, 32 orig: 32, 32 offset: 0, 0 index: -1 -phase-conduit-end +phase-conduit-bridge rotate: false xy: 1003, 331 size: 32, 32 orig: 32, 32 offset: 0, 0 index: -1 -plated-conduit-cap +phase-conduit-end rotate: false - xy: 1003, 263 + xy: 1037, 365 size: 32, 32 orig: 32, 32 offset: 0, 0 index: -1 -plated-conduit-top-0 +plated-conduit-cap rotate: false xy: 1037, 297 size: 32, 32 orig: 32, 32 offset: 0, 0 index: -1 -plated-conduit-top-1 +plated-conduit-top-0 rotate: false xy: 1071, 331 size: 32, 32 orig: 32, 32 offset: 0, 0 index: -1 -plated-conduit-top-2 +plated-conduit-top-1 rotate: false xy: 1105, 365 size: 32, 32 orig: 32, 32 offset: 0, 0 index: -1 -plated-conduit-top-3 +plated-conduit-top-2 rotate: false xy: 1139, 399 size: 32, 32 orig: 32, 32 offset: 0, 0 index: -1 -plated-conduit-top-4 +plated-conduit-top-3 rotate: false xy: 1173, 433 size: 32, 32 orig: 32, 32 offset: 0, 0 index: -1 -plated-conduit-top-5 +plated-conduit-top-4 rotate: false xy: 1207, 467 size: 32, 32 orig: 32, 32 offset: 0, 0 index: -1 -plated-conduit-top-6 +plated-conduit-top-5 rotate: false xy: 969, 195 size: 32, 32 orig: 32, 32 offset: 0, 0 index: -1 -pulse-conduit-top-0 +plated-conduit-top-6 rotate: false - xy: 1105, 331 + xy: 1003, 229 size: 32, 32 orig: 32, 32 offset: 0, 0 index: -1 -pulse-conduit-top-1 +pulse-conduit-top-0 rotate: false xy: 1139, 365 size: 32, 32 orig: 32, 32 offset: 0, 0 index: -1 -pulse-conduit-top-2 +pulse-conduit-top-1 rotate: false xy: 1173, 399 size: 32, 32 orig: 32, 32 offset: 0, 0 index: -1 -pulse-conduit-top-4 +pulse-conduit-top-2 rotate: false xy: 1207, 433 size: 32, 32 orig: 32, 32 offset: 0, 0 index: -1 -pulse-conduit-top-5 +pulse-conduit-top-4 rotate: false xy: 1241, 467 size: 32, 32 orig: 32, 32 offset: 0, 0 index: -1 -pulse-conduit-top-6 +pulse-conduit-top-5 rotate: false xy: 1003, 195 size: 32, 32 orig: 32, 32 offset: 0, 0 index: -1 -pump-liquid +pulse-conduit-top-6 rotate: false - xy: 1105, 297 + xy: 1037, 229 size: 32, 32 orig: 32, 32 offset: 0, 0 @@ -1441,7 +1455,7 @@ impact-reactor-plasma-3 index: -1 power-node rotate: false - xy: 1003, 229 + xy: 1037, 263 size: 32, 32 orig: 32, 32 offset: 0, 0 @@ -1455,14 +1469,14 @@ power-node-large index: -1 power-source rotate: false - xy: 1037, 263 + xy: 1071, 297 size: 32, 32 orig: 32, 32 offset: 0, 0 index: -1 power-void rotate: false - xy: 1071, 297 + xy: 1105, 331 size: 32, 32 orig: 32, 32 offset: 0, 0 @@ -1693,7 +1707,7 @@ liquid-void index: -1 melter rotate: false - xy: 1037, 433 + xy: 1071, 467 size: 32, 32 orig: 32, 32 offset: 0, 0 @@ -1742,14 +1756,14 @@ plastanium-compressor-top index: -1 pulverizer rotate: false - xy: 1037, 229 + xy: 1071, 263 size: 32, 32 orig: 32, 32 offset: 0, 0 index: -1 pulverizer-rotator rotate: false - xy: 1071, 263 + xy: 1105, 297 size: 32, 32 orig: 32, 32 offset: 0, 0 @@ -2330,7 +2344,7 @@ door-open index: -1 phase-wall rotate: false - xy: 969, 263 + xy: 1003, 297 size: 32, 32 orig: 32, 32 offset: 0, 0 @@ -2344,7 +2358,7 @@ phase-wall-large index: -1 plastanium-wall rotate: false - xy: 969, 229 + xy: 1003, 263 size: 32, 32 orig: 32, 32 offset: 0, 0 diff --git a/core/assets/sprites/sprites.png b/core/assets/sprites/sprites.png index 4b0eab80a2..8d6b82740f 100644 Binary files a/core/assets/sprites/sprites.png and b/core/assets/sprites/sprites.png differ diff --git a/core/assets/sprites/sprites2.png b/core/assets/sprites/sprites2.png index c8703c3cf3..adb28e8adf 100644 Binary files a/core/assets/sprites/sprites2.png and b/core/assets/sprites/sprites2.png differ diff --git a/core/src/mindustry/entities/def/TileComp.java b/core/src/mindustry/entities/def/TileComp.java index 2ccdccbb36..02c5e9de69 100644 --- a/core/src/mindustry/entities/def/TileComp.java +++ b/core/src/mindustry/entities/def/TileComp.java @@ -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(){ diff --git a/core/src/mindustry/input/DesktopInput.java b/core/src/mindustry/input/DesktopInput.java index b4714d9f21..af37b716aa 100644 --- a/core/src/mindustry/input/DesktopInput.java +++ b/core/src/mindustry/input/DesktopInput.java @@ -153,8 +153,8 @@ public class DesktopInput extends InputHandler{ if(block.saveConfig && block.lastConfig != null){ brequest.set(cursorX, cursorY, rotation, block); brequest.config = block.lastConfig; - block.drawRequestConfig(brequest, allRequests()); + brequest.config = null; } } diff --git a/core/src/mindustry/input/InputHandler.java b/core/src/mindustry/input/InputHandler.java index cedc02046c..d25ee14842 100644 --- a/core/src/mindustry/input/InputHandler.java +++ b/core/src/mindustry/input/InputHandler.java @@ -508,7 +508,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ protected void drawRequest(BuildRequest request){ request.block.drawRequest(request, allRequests(), validPlace(request.x, request.y, request.block, request.rotation)); - if(request.block.saveConfig && request.block.lastConfig != null){ + if(request.block.saveConfig && request.block.lastConfig != null && !request.hasConfig){ Object conf = request.config; request.config = request.block.lastConfig; request.block.drawRequestConfig(request, allRequests()); diff --git a/core/src/mindustry/ui/fragments/BlockInventoryFragment.java b/core/src/mindustry/ui/fragments/BlockInventoryFragment.java index 186ec46121..550ee6f972 100644 --- a/core/src/mindustry/ui/fragments/BlockInventoryFragment.java +++ b/core/src/mindustry/ui/fragments/BlockInventoryFragment.java @@ -11,6 +11,7 @@ import arc.scene.actions.*; import arc.scene.event.*; import arc.scene.ui.*; import arc.scene.ui.layout.*; +import arc.scene.ui.layout.Stack; import arc.struct.*; import arc.util.*; import mindustry.annotations.Annotations.*; @@ -22,6 +23,8 @@ import mindustry.net.*; import mindustry.type.*; import mindustry.ui.*; +import java.util.*; + import static mindustry.Vars.*; public class BlockInventoryFragment extends Fragment{ @@ -94,6 +97,9 @@ public class BlockInventoryFragment extends Fragment{ private void rebuild(boolean actions){ IntSet container = new IntSet(); + Arrays.fill(shrinkHoldTimes, 0); + holdTime = emptyTime = 0f; + table.clearChildren(); table.clearActions(); table.background(Tex.inventory); diff --git a/core/src/mindustry/world/Tile.java b/core/src/mindustry/world/Tile.java index c19322cbb7..01361687aa 100644 --- a/core/src/mindustry/world/Tile.java +++ b/core/src/mindustry/world/Tile.java @@ -80,18 +80,26 @@ public class Tile implements Position, QuadTreeObject{ } public byte absoluteRelativeTo(int cx, int cy){ - 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 static byte absoluteRelativeTo(int x, int y, int cx, int cy){ - 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; + //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; } diff --git a/core/src/mindustry/world/blocks/distribution/ItemBridge.java b/core/src/mindustry/world/blocks/distribution/ItemBridge.java index 84ac3325e6..7ca39a2e37 100644 --- a/core/src/mindustry/world/blocks/distribution/ItemBridge.java +++ b/core/src/mindustry/world/blocks/distribution/ItemBridge.java @@ -237,7 +237,7 @@ public class ItemBridge extends Block{ float opacity = Core.settings.getInt("bridgeopacity") / 100f; if(Mathf.zero(opacity)) return; - int i = tile.absoluteRelativeTo(other.x, other.y); + int i = relativeTo(other.x, other.y); Draw.color(Color.white, Color.black, Mathf.absin(Time.time(), 6f, 0.07f)); Draw.alpha(Math.max(uptime, 0.25f) * opacity); @@ -275,8 +275,8 @@ public class ItemBridge extends Block{ Tile other = world.tile(link); if(linkValid(tile, other)){ - int rel = tile.absoluteRelativeTo(other.x, other.y); - int rel2 = tile.relativeTo(source.tileX(), source.tileY()); + int rel = relativeTo(other.x, other.y); + int rel2 = relativeTo(source.tileX(), source.tileY()); if(rel == rel2) return false; }else{ @@ -292,21 +292,21 @@ public class ItemBridge extends Block{ Tile other = world.tile(link); if(!linkValid(tile, other)){ Tile edge = Edges.getFacingEdge(to.tile(), tile); - int i = tile.absoluteRelativeTo(edge.x, edge.y); + int i = relativeTo(edge.x, edge.y); IntSetIterator it = incoming.iterator(); while(it.hasNext){ int v = it.next(); - if(tile.absoluteRelativeTo(Point2.x(v), Point2.y(v)) == i){ + if(relativeTo(Point2.x(v), Point2.y(v)) == i){ return false; } } return true; } - int rel = tile.absoluteRelativeTo(other.x, other.y); - int rel2 = tile.relativeTo(to.tileX(), to.tileY()); + int rel = relativeTo(other.x, other.y); + int rel2 = relativeTo(to.tileX(), to.tileY()); return rel != rel2; } @@ -318,8 +318,8 @@ public class ItemBridge extends Block{ Tile other = world.tile(link); if(linkValid(tile, other)){ - int rel = tile.absoluteRelativeTo(other.x, other.y); - int rel2 = tile.relativeTo(source.tileX(), source.tileY()); + int rel = relativeTo(other.x, other.y); + int rel2 = relativeTo(source.tileX(), source.tileY()); if(rel == rel2) return false; }else if(!(source.block() instanceof ItemBridge && ((ItemBridgeEntity)source).link == tile.pos())){ @@ -334,21 +334,21 @@ public class ItemBridge extends Block{ Tile other = world.tile(link); if(!linkValid(tile, other)){ Tile edge = Edges.getFacingEdge(to.tile(), tile); - int i = tile.absoluteRelativeTo(edge.x, edge.y); + int i = relativeTo(edge.x, edge.y); IntSetIterator it = incoming.iterator(); while(it.hasNext){ int v = it.next(); - if(tile.absoluteRelativeTo(Point2.x(v), Point2.y(v)) == i){ + if(relativeTo(Point2.x(v), Point2.y(v)) == i){ return false; } } return true; } - int rel = tile.absoluteRelativeTo(other.x, other.y); - int rel2 = tile.relativeTo(to.tileX(), to.tileY()); + int rel = relativeTo(other.x, other.y); + int rel2 = relativeTo(to.tileX(), to.tileY()); return rel != rel2; } diff --git a/core/src/mindustry/world/blocks/distribution/Junction.java b/core/src/mindustry/world/blocks/distribution/Junction.java index 6faa2fff8b..ba120e3097 100644 --- a/core/src/mindustry/world/blocks/distribution/Junction.java +++ b/core/src/mindustry/world/blocks/distribution/Junction.java @@ -63,13 +63,13 @@ public class Junction extends Block{ @Override public void handleItem(Tilec source, Item item){ - int relative = source.relativeTo(tile.x, tile.y); + int relative = source.relativeTo(tile); buffer.accept(relative, item); } @Override public boolean acceptItem(Tilec source, Item item){ - int relative = source.relativeTo(tile.x, tile.y); + int relative = source.relativeTo(tile); if(relative == -1 || !buffer.accepts(relative)) return false; Tilec to = nearby(relative); diff --git a/core/src/mindustry/world/blocks/distribution/Sorter.java b/core/src/mindustry/world/blocks/distribution/Sorter.java index 865fd5f0e2..62de4f8a1c 100644 --- a/core/src/mindustry/world/blocks/distribution/Sorter.java +++ b/core/src/mindustry/world/blocks/distribution/Sorter.java @@ -92,7 +92,7 @@ public class Sorter extends Block{ } Tilec getTileTarget(Item item, Tilec source, boolean flip){ - int dir = source.absoluteRelativeTo(tile.x, tile.y); + int dir = source.relativeTo(tile.x, tile.y); if(dir == -1) return null; Tilec to; diff --git a/core/src/mindustry/world/blocks/liquid/Conduit.java b/core/src/mindustry/world/blocks/liquid/Conduit.java index 5b452eff6d..0e03ad83d9 100644 --- a/core/src/mindustry/world/blocks/liquid/Conduit.java +++ b/core/src/mindustry/world/blocks/liquid/Conduit.java @@ -106,7 +106,7 @@ public class Conduit extends LiquidBlock implements Autotiler{ public boolean acceptLiquid(Tilec source, Liquid liquid, float amount){ noSleep(); return liquids.get(liquid) + amount < liquidCapacity && (liquids.current() == liquid || liquids.currentAmount() < 0.2f) - && ((source.absoluteRelativeTo(tile.x, tile.y) + 2) % 4 != tile.rotation()); + && ((source.relativeTo(tile.x, tile.y) + 2) % 4 != tile.rotation()); } @Override diff --git a/core/src/mindustry/world/blocks/liquid/LiquidJunction.java b/core/src/mindustry/world/blocks/liquid/LiquidJunction.java index a67b883940..1a85be6af8 100644 --- a/core/src/mindustry/world/blocks/liquid/LiquidJunction.java +++ b/core/src/mindustry/world/blocks/liquid/LiquidJunction.java @@ -37,7 +37,7 @@ public class LiquidJunction extends LiquidBlock{ @Override public Tilec getLiquidDestination(Tilec source, Liquid liquid){ - int dir = source.absoluteRelativeTo(tile.x, tile.y); + int dir = source.relativeTo(tile.x, tile.y); dir = (dir + 4) % 4; Tilec next = nearby(dir); if(next == null || (!next.acceptLiquid(this, liquid, 0f) && !(next.block() instanceof LiquidJunction))){ diff --git a/core/src/mindustry/world/blocks/production/Pump.java b/core/src/mindustry/world/blocks/production/Pump.java index d03932cb1c..4d8c655ec3 100644 --- a/core/src/mindustry/world/blocks/production/Pump.java +++ b/core/src/mindustry/world/blocks/production/Pump.java @@ -3,7 +3,6 @@ package mindustry.world.blocks.production; import arc.*; import arc.graphics.*; import arc.graphics.g2d.*; -import mindustry.annotations.Annotations.*; import mindustry.type.*; import mindustry.ui.*; import mindustry.world.*; @@ -13,7 +12,6 @@ import mindustry.world.meta.*; import static mindustry.Vars.*; public class Pump extends LiquidBlock{ - public @Load("pump-liquid") TextureRegion liquidRegion; public final int timerContentCheck = timers++; /** Pump amount, total. */ diff --git a/core/src/mindustry/world/blocks/production/SolidPump.java b/core/src/mindustry/world/blocks/production/SolidPump.java index e7299d0e38..8aecc70d85 100644 --- a/core/src/mindustry/world/blocks/production/SolidPump.java +++ b/core/src/mindustry/world/blocks/production/SolidPump.java @@ -5,6 +5,7 @@ import arc.graphics.g2d.*; import arc.math.*; import arc.util.ArcAnnotate.*; import arc.util.*; +import mindustry.annotations.Annotations.*; import mindustry.content.*; import mindustry.entities.*; import mindustry.graphics.*; @@ -24,6 +25,8 @@ public class SolidPump extends Pump{ /** Attribute that is checked when calculating output. */ public @Nullable Attribute attribute; + public @Load("@-rotator") TextureRegion rotatorRegion; + public SolidPump(String name){ super(name); hasPower = true; @@ -94,8 +97,8 @@ public class SolidPump extends Pump{ Draw.alpha(liquids.total() / liquidCapacity); Draw.rect(liquidRegion, x, y); Draw.color(); - Draw.rect(name + "-rotator", x, y, pumpTime * rotateSpeed); - Draw.rect(name + "-top", x, y); + Draw.rect(rotatorRegion, x, y, pumpTime * rotateSpeed); + Draw.rect(topRegion, x, y); } @Override diff --git a/gradle.properties b/gradle.properties index be3e01ffcd..be8e8da1b4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ org.gradle.daemon=true org.gradle.jvmargs=-Xms256m -Xmx1024m -archash=cb632c0f88ced85999a3b78e6b79e3056e1d15e1 +archash=67e3b0ca53bfe86fd5d195cbc9ffd392f8e13e98