Slower unloader

This commit is contained in:
Anuken
2018-11-14 23:46:33 -05:00
parent 9f97ed331b
commit 459256e83a
4 changed files with 11 additions and 25 deletions

View File

@@ -131,7 +131,7 @@ public class Recipes implements ContentList{
new Recipe(power, PowerBlocks.thoriumReactor, new ItemStack(Items.lead, 600), new ItemStack(Items.silicon, 400), new ItemStack(Items.densealloy, 300), new ItemStack(Items.thorium, 300));
new Recipe(power, PowerBlocks.rtgGenerator, new ItemStack(Items.lead, 200), new ItemStack(Items.silicon, 150), new ItemStack(Items.phasefabric, 50), new ItemStack(Items.plastanium, 150), new ItemStack(Items.thorium, 100));
new Recipe(distribution, StorageBlocks.unloader, new ItemStack(Items.densealloy, 40), new ItemStack(Items.silicon, 50));
new Recipe(distribution, StorageBlocks.unloader, new ItemStack(Items.densealloy, 50), new ItemStack(Items.silicon, 60));
new Recipe(distribution, StorageBlocks.container, new ItemStack(Items.densealloy, 200));
new Recipe(distribution, StorageBlocks.vault, new ItemStack(Items.densealloy, 500), new ItemStack(Items.thorium, 250));
//core disabled due to being broken

View File

@@ -17,16 +17,16 @@ public class StorageBlocks extends BlockList implements ContentList{
vault = new Vault("vault"){{
size = 3;
itemCapacity = 1000;
itemCapacity = 900;
}};
container = new Vault("container"){{
size = 2;
itemCapacity = 250;
itemCapacity = 200;
}};
unloader = new SortedUnloader("unloader"){{
speed = 5;
speed = 12f;
}};
}
}

View File

@@ -11,6 +11,7 @@ import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.blocks.SelectionTrait;
import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.scene.ui.layout.Table;
import io.anuke.ucore.util.Log;
import java.io.DataInput;
import java.io.DataOutput;
@@ -18,6 +19,7 @@ import java.io.IOException;
import static io.anuke.mindustry.Vars.*;
public class SortedUnloader extends Unloader implements SelectionTrait{
protected float speed = 1f;
public SortedUnloader(String name){
super(name);
@@ -35,13 +37,14 @@ public class SortedUnloader extends Unloader implements SelectionTrait{
public void update(Tile tile){
SortedUnloaderEntity entity = tile.entity();
if(entity.items.total() == 0 && entity.timer.get(timerUnload, speed)){
tile.allNearby(other -> {
if(tile.entity.timer.get(timerUnload, speed) && tile.entity.items.total() == 0){
Log.info(threads.getFrameID());
for(Tile other : tile.entity.proximity()){
if(other.getTeam() == tile.getTeam() && other.block() instanceof StorageBlock && entity.items.total() == 0 &&
((entity.sortItem == null && other.entity.items.total() > 0) || ((StorageBlock) other.block()).hasItem(other, entity.sortItem))){
offloadNear(tile, ((StorageBlock) other.block()).removeItem(other, entity.sortItem));
}
});
}
}
if(entity.items.total() > 0){

View File

@@ -5,9 +5,8 @@ import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.meta.BlockGroup;
public class Unloader extends Block{
public abstract class Unloader extends Block{
protected final int timerUnload = timers++;
protected int speed = 5;
public Unloader(String name){
super(name);
@@ -18,22 +17,6 @@ public class Unloader extends Block{
hasItems = true;
}
@Override
public void update(Tile tile){
if(tile.entity.items.total() == 0 && tile.entity.timer.get(timerUnload, speed)){
tile.allNearby(other -> {
if(other.getTeam() == tile.getTeam() && other.block() instanceof StorageBlock && tile.entity.items.total() == 0 &&
((StorageBlock) other.block()).hasItem(other, null)){
offloadNear(tile, ((StorageBlock) other.block()).removeItem(other, null));
}
});
}
if(tile.entity.items.total() > 0){
tryDump(tile);
}
}
@Override
public boolean canDump(Tile tile, Tile to, Item item){
Block block = to.target().block();