From 459256e83abf01d3f02020fb481c8b4d77517d68 Mon Sep 17 00:00:00 2001 From: Anuken Date: Wed, 14 Nov 2018 23:46:33 -0500 Subject: [PATCH] Slower unloader --- .../io/anuke/mindustry/content/Recipes.java | 2 +- .../content/blocks/StorageBlocks.java | 6 +++--- .../world/blocks/storage/SortedUnloader.java | 9 ++++++--- .../world/blocks/storage/Unloader.java | 19 +------------------ 4 files changed, 11 insertions(+), 25 deletions(-) diff --git a/core/src/io/anuke/mindustry/content/Recipes.java b/core/src/io/anuke/mindustry/content/Recipes.java index bdc35d2cbd..08a7f8fac1 100644 --- a/core/src/io/anuke/mindustry/content/Recipes.java +++ b/core/src/io/anuke/mindustry/content/Recipes.java @@ -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 diff --git a/core/src/io/anuke/mindustry/content/blocks/StorageBlocks.java b/core/src/io/anuke/mindustry/content/blocks/StorageBlocks.java index d00275a05f..460a79da77 100644 --- a/core/src/io/anuke/mindustry/content/blocks/StorageBlocks.java +++ b/core/src/io/anuke/mindustry/content/blocks/StorageBlocks.java @@ -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; }}; } } diff --git a/core/src/io/anuke/mindustry/world/blocks/storage/SortedUnloader.java b/core/src/io/anuke/mindustry/world/blocks/storage/SortedUnloader.java index c50509f413..5c3a970112 100644 --- a/core/src/io/anuke/mindustry/world/blocks/storage/SortedUnloader.java +++ b/core/src/io/anuke/mindustry/world/blocks/storage/SortedUnloader.java @@ -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){ diff --git a/core/src/io/anuke/mindustry/world/blocks/storage/Unloader.java b/core/src/io/anuke/mindustry/world/blocks/storage/Unloader.java index ab7c951836..f07756b4d2 100644 --- a/core/src/io/anuke/mindustry/world/blocks/storage/Unloader.java +++ b/core/src/io/anuke/mindustry/world/blocks/storage/Unloader.java @@ -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();