mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-01-10 23:28:52 +07:00
Reverted buffers / Added Dexapnow's fixed zone maps [untested]
This commit is contained in:
parent
4458ae042e
commit
c8ce195522
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -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();
|
||||
|
@ -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 = {};
|
||||
|
@ -24,6 +24,7 @@ public class Junction extends Block{
|
||||
super(name);
|
||||
update = true;
|
||||
solid = true;
|
||||
instantTransfer = true;
|
||||
group = BlockGroup.transportation;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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.<SorterEntity>entity().sortItem == tile.<SorterEntity>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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user