Fixed bugs with router distribution, added max router capacity
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
package io.anuke.mindustry.world.blocks;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.utils.ObjectMap;
|
||||
|
||||
import io.anuke.mindustry.Inventory;
|
||||
import io.anuke.mindustry.Renderer;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.resource.Item;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
@@ -38,6 +42,8 @@ public class ProductionBlocks{
|
||||
}},
|
||||
|
||||
router = new Block("router"){
|
||||
private ObjectMap<Tile, Byte> lastmap = new ObjectMap<>();
|
||||
int maxitems = 20;
|
||||
{
|
||||
update = true;
|
||||
solid = true;
|
||||
@@ -46,14 +52,32 @@ public class ProductionBlocks{
|
||||
@Override
|
||||
public void update(Tile tile){
|
||||
if(Timers.get(tile, 2) && tile.entity.totalItems() > 0){
|
||||
tryDump(tile, tile.rotation++, null);
|
||||
if(lastmap.get(tile, (byte)-1) != tile.rotation)
|
||||
tryDump(tile, tile.rotation, null);
|
||||
|
||||
tile.rotation ++;
|
||||
tile.rotation %= 4;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleItem(Tile tile, Item item, Tile source){
|
||||
super.handleItem(tile, item, source);
|
||||
lastmap.put(tile, (byte)tile.relativeTo(source.x, source.y));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean accept(Item item, Tile dest, Tile source){
|
||||
return true;
|
||||
int items = dest.entity.totalItems();
|
||||
return items < maxitems;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawPixelOverlay(Tile tile){
|
||||
|
||||
float fract = (float)tile.entity.totalItems()/maxitems;
|
||||
|
||||
Renderer.drawBar(Color.GREEN, tile.worldx(), tile.worldy() + 13, fract);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user