diff --git a/core/assets/maps/nuclearProductionComplex.msav b/core/assets/maps/nuclearProductionComplex.msav index e20fc7c73b..02a86783c1 100644 Binary files a/core/assets/maps/nuclearProductionComplex.msav and b/core/assets/maps/nuclearProductionComplex.msav differ diff --git a/core/assets/maps/overgrowth.msav b/core/assets/maps/overgrowth.msav index 4d58d57fda..58135743ed 100644 Binary files a/core/assets/maps/overgrowth.msav and b/core/assets/maps/overgrowth.msav differ diff --git a/core/assets/maps/ruinousShores.msav b/core/assets/maps/ruinousShores.msav index 32f0e7cd6c..1f3a1628bd 100644 Binary files a/core/assets/maps/ruinousShores.msav and b/core/assets/maps/ruinousShores.msav differ diff --git a/core/assets/maps/tarFields.msav b/core/assets/maps/tarFields.msav index 8c19d68047..b3910d34ce 100644 Binary files a/core/assets/maps/tarFields.msav and b/core/assets/maps/tarFields.msav differ diff --git a/core/src/io/anuke/mindustry/ui/dialogs/MapPlayDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/MapPlayDialog.java index 2c24c2c6f0..e2938b143a 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/MapPlayDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/MapPlayDialog.java @@ -83,7 +83,7 @@ public class MapPlayDialog extends FloatingDialog{ cont.add(sdif); cont.row(); - cont.add(new BorderImage(map.texture, 3f)).size(250f).get().setScaling(Scaling.fit); + cont.add(new BorderImage(map.texture, 3f)).size(mobile && !Core.graphics.isPortrait() ? 150f : 250f).get().setScaling(Scaling.fit); buttons.clearChildren(); addCloseButton(); diff --git a/core/src/io/anuke/mindustry/world/Block.java b/core/src/io/anuke/mindustry/world/Block.java index 9a051da8e3..177922ac47 100644 --- a/core/src/io/anuke/mindustry/world/Block.java +++ b/core/src/io/anuke/mindustry/world/Block.java @@ -103,6 +103,8 @@ public class Block extends BlockStorage{ public float buildCost; /** Whether this block is visible and can currently be built. */ public BooleanProvider buildVisibility = () -> false; + /** Whether this block has instant transfer.*/ + public boolean instantTransfer = false; public boolean alwaysUnlocked = false; protected TextureRegion[] cacheRegions = {}; diff --git a/core/src/io/anuke/mindustry/world/blocks/distribution/Junction.java b/core/src/io/anuke/mindustry/world/blocks/distribution/Junction.java index b157ffc34b..febd11f5d7 100644 --- a/core/src/io/anuke/mindustry/world/blocks/distribution/Junction.java +++ b/core/src/io/anuke/mindustry/world/blocks/distribution/Junction.java @@ -24,6 +24,7 @@ public class Junction extends Block{ super(name); update = true; solid = true; + instantTransfer = true; group = BlockGroup.transportation; } diff --git a/core/src/io/anuke/mindustry/world/blocks/distribution/OverflowGate.java b/core/src/io/anuke/mindustry/world/blocks/distribution/OverflowGate.java index 5f993a4039..7b77932bd0 100644 --- a/core/src/io/anuke/mindustry/world/blocks/distribution/OverflowGate.java +++ b/core/src/io/anuke/mindustry/world/blocks/distribution/OverflowGate.java @@ -1,22 +1,16 @@ package io.anuke.mindustry.world.blocks.distribution; import io.anuke.arc.math.Mathf; +import io.anuke.arc.util.Time; import io.anuke.mindustry.entities.type.TileEntity; -import io.anuke.mindustry.entities.type.Unit; import io.anuke.mindustry.type.Item; -import io.anuke.mindustry.world.Block; -import io.anuke.mindustry.world.DirectionalItemBuffer; -import io.anuke.mindustry.world.Edges; -import io.anuke.mindustry.world.Tile; +import io.anuke.mindustry.world.*; import io.anuke.mindustry.world.meta.BlockGroup; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; +import java.io.*; public class OverflowGate extends Block{ - protected int bufferCapacity = 10; - protected float speed = 45f; + protected float speed = 8f; public OverflowGate(String name){ super(name); @@ -27,22 +21,38 @@ public class OverflowGate extends Block{ } @Override - public int acceptStack(Item item, int amount, Tile tile, Unit source){ - return 0; + public boolean outputsItems(){ + return true; } + @Override + public int removeStack(Tile tile, Item item, int amount){ + OverflowGateEntity entity = tile.entity(); + int result = super.removeStack(tile, item, amount); + if(result != 0 && item == entity.lastItem){ + entity.lastItem = null; + } + return result; + } + + @Override public void update(Tile tile){ OverflowGateEntity entity = tile.entity(); - for(int i = 0; i < 4; i++){ - Item item = entity.buffer.poll(i); - if(item != null){ - Tile other = getTileTarget(tile, item, tile.getNearby(i), true); - if(other != null && other.block().acceptItem(item, other, tile)){ - other.block().handleItem(item, other, tile); - entity.buffer.remove(i); - } + if(entity.lastItem == null && entity.items.total() > 0){ + entity.items.clear(); + } + + if(entity.lastItem != null){ + entity.time += 1f / speed * Time.delta(); + Tile target = getTileTarget(tile, entity.lastItem, entity.lastInput, false); + + if(target != null && (entity.time >= 1f)){ + getTileTarget(tile, entity.lastItem, entity.lastInput, true); + target.block().handleItem(entity.lastItem, target, Edges.getFacingEdge(tile, target)); + entity.items.remove(entity.lastItem, 1); + entity.lastItem = null; } } } @@ -50,16 +60,17 @@ public class OverflowGate extends Block{ @Override public boolean acceptItem(Item item, Tile tile, Tile source){ OverflowGateEntity entity = tile.entity(); - return entity.buffer.accepts(tile.relativeTo(source.x, source.y)); + + return tile.getTeam() == source.getTeam() && entity.lastItem == null && entity.items.total() == 0; } @Override public void handleItem(Item item, Tile tile, Tile source){ OverflowGateEntity entity = tile.entity(); - int buffer = tile.relativeTo(source.x, source.y); - if(entity.buffer.accepts(buffer)){ - entity.buffer.accept(buffer, item); - } + entity.items.add(item, 1); + entity.lastItem = item; + entity.time = 0f; + entity.lastInput = source; } Tile getTileTarget(Tile tile, Item item, Tile src, boolean flip){ @@ -86,10 +97,10 @@ public class OverflowGate extends Block{ }else{ if(tile.rotation() == 0){ to = a; - if(flip) tile.rotation((byte)1); + if(flip) tile.rotation((byte) 1); }else{ to = b; - if(flip) tile.rotation((byte)0); + if(flip) tile.rotation((byte) 0); } } } @@ -103,24 +114,25 @@ public class OverflowGate extends Block{ } public class OverflowGateEntity extends TileEntity{ - DirectionalItemBuffer buffer = new DirectionalItemBuffer(bufferCapacity, speed); + Item lastItem; + Tile lastInput; + float time; @Override public byte version(){ - return 1; + return 2; } @Override public void write(DataOutput stream) throws IOException{ super.write(stream); - buffer.write(stream); } @Override public void read(DataInput stream, byte revision) throws IOException{ super.read(stream, revision); if(revision == 1){ - buffer.read(stream); + new DirectionalItemBuffer(25, 0f).read(stream); } } } diff --git a/core/src/io/anuke/mindustry/world/blocks/distribution/Sorter.java b/core/src/io/anuke/mindustry/world/blocks/distribution/Sorter.java index 41ec295b81..ef1047157a 100644 --- a/core/src/io/anuke/mindustry/world/blocks/distribution/Sorter.java +++ b/core/src/io/anuke/mindustry/world/blocks/distribution/Sorter.java @@ -5,9 +5,7 @@ import io.anuke.arc.Core; import io.anuke.arc.graphics.g2d.Draw; import io.anuke.arc.math.Mathf; import io.anuke.arc.scene.ui.layout.Table; -import io.anuke.mindustry.entities.type.Player; -import io.anuke.mindustry.entities.type.TileEntity; -import io.anuke.mindustry.entities.type.Unit; +import io.anuke.mindustry.entities.type.*; import io.anuke.mindustry.gen.Call; import io.anuke.mindustry.type.Item; import io.anuke.mindustry.world.*; @@ -21,22 +19,15 @@ import static io.anuke.mindustry.Vars.content; public class Sorter extends Block{ private static Item lastItem; - protected int bufferCapacity = 20; - protected float speed = 45f; - public Sorter(String name){ super(name); update = true; solid = true; + instantTransfer = true; group = BlockGroup.transportation; configurable = true; } - @Override - public int acceptStack(Item item, int amount, Tile tile, Unit source){ - return 0; - } - @Override public boolean outputsItems(){ return true; @@ -63,42 +54,28 @@ public class Sorter extends Block{ if(entity.sortItem == null) return; Draw.color(entity.sortItem.color); - Draw.rect("center", tile.worldx(), tile.worldy()); + Draw.rect("blank", tile.worldx(), tile.worldy(), 4f, 4f); Draw.color(); } - @Override - public void update(Tile tile){ - SorterEntity entity = tile.entity(); - - for(int i = 0; i < 4; i++){ - Item item = entity.buffer.poll(i); - if(item != null){ - Tile other = getTileTarget(item, tile, tile.getNearby(i), true); - if(other != null && other.block().acceptItem(item, other, tile)){ - other.block().handleItem(item, other, tile); - entity.buffer.remove(i); - } - } - } - } - @Override public boolean acceptItem(Item item, Tile tile, Tile source){ - SorterEntity entity = tile.entity(); - return entity.buffer.accepts(tile.relativeTo(source.x, source.y)); + Tile to = getTileTarget(item, tile, source, false); + + return to != null && to.block().acceptItem(item, to, tile); } @Override public void handleItem(Item item, Tile tile, Tile source){ - SorterEntity entity = tile.entity(); - int buffer = tile.relativeTo(source.x, source.y); - if(entity.buffer.accepts(buffer)){ - entity.buffer.accept(buffer, item); - } + Tile to = getTileTarget(item, tile, source, true); + + to.block().handleItem(item, to, tile); + } + + boolean isSame(Tile tile, Tile other){ + return other != null && other.block() == this && other.entity().sortItem == tile.entity().sortItem; } - @Nullable Tile getTileTarget(Item item, Tile dest, Tile source, boolean flip){ SorterEntity entity = dest.entity(); @@ -107,12 +84,18 @@ public class Sorter extends Block{ Tile to; if(item == entity.sortItem){ + //prevent 3-chains + if(isSame(dest, source) && isSame(dest, dest.getNearby(dir))){ + return null; + } to = dest.getNearby(dir); }else{ Tile a = dest.getNearby(Mathf.mod(dir - 1, 4)); Tile b = dest.getNearby(Mathf.mod(dir + 1, 4)); - boolean ac = a != null && a.block().acceptItem(item, a, dest); - boolean bc = b != null && b.block().acceptItem(item, b, dest); + boolean ac = a != null && !(a.block().instantTransfer && source.block().instantTransfer) && + a.block().acceptItem(item, a, dest); + boolean bc = b != null && !(b.block().instantTransfer && source.block().instantTransfer) && + b.block().acceptItem(item, b, dest); if(ac && !bc){ to = a; @@ -123,10 +106,12 @@ public class Sorter extends Block{ }else{ if(dest.rotation() == 0){ to = a; - if(flip) dest.rotation((byte)1); + if(flip) + dest.rotation((byte)1); }else{ to = b; - if(flip) dest.rotation((byte)0); + if(flip) + dest.rotation((byte)0); } } } @@ -148,20 +133,18 @@ public class Sorter extends Block{ return new SorterEntity(); } + public class SorterEntity extends TileEntity{ - DirectionalItemBuffer buffer = new DirectionalItemBuffer(bufferCapacity, speed); Item sortItem; @Override public byte version(){ - return 1; + return 2; } @Override public void write(DataOutput stream) throws IOException{ super.write(stream); - stream.writeShort(sortItem == null ? -1 : sortItem.id); - buffer.write(stream); } @Override @@ -169,7 +152,7 @@ public class Sorter extends Block{ super.read(stream, revision); sortItem = content.item(stream.readShort()); if(revision == 1){ - buffer.read(stream); + new ItemBuffer(20, 45f).read(stream); } } } diff --git a/server/src/io/anuke/mindustry/server/ServerControl.java b/server/src/io/anuke/mindustry/server/ServerControl.java index 80a506a21c..e674546239 100644 --- a/server/src/io/anuke/mindustry/server/ServerControl.java +++ b/server/src/io/anuke/mindustry/server/ServerControl.java @@ -157,7 +157,7 @@ public class ServerControl implements ApplicationListener{ ? "[YELLOW]The " + event.winner.name() + " team is victorious![]" : "[SCARLET]Game over![]") + "\nNext selected map:[accent] " + map.name() + "[]" + (map.tags.containsKey("author") && !map.tags.get("author").trim().isEmpty() ? " by[accent] " + map.author() + "[]" : "") + "." + - "\nNew game begins in " + roundExtraTime + " seconds."); + "\nNew game begins in " + roundExtraTime + "[] seconds."); info("Selected next map to be {0}.", map.name());