mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-26 15:27:19 +07:00
Implement queues for inbound resources
There are now input queues per resource (currently flat 20 per resource type) along with indicator of how full the queue is.
This commit is contained in:
parent
7f8598f2bc
commit
417db7b60c
@ -1,20 +1,25 @@
|
||||
package io.anuke.mindustry.world.blocks.types.production;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.graphics.Fx;
|
||||
import io.anuke.mindustry.resource.Item;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.ucore.core.Effects;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class Crafter extends Block{
|
||||
protected final int timerDump = timers++;
|
||||
|
||||
protected Item[] requirements;
|
||||
protected Item result;
|
||||
|
||||
int capacity = 20;
|
||||
|
||||
public Crafter(String name) {
|
||||
super(name);
|
||||
update = true;
|
||||
@ -26,12 +31,13 @@ public class Crafter extends Block{
|
||||
super.getStats(list);
|
||||
list.add("[craftinfo]Input: " + Arrays.toString(requirements));
|
||||
list.add("[craftinfo]Output: " + result);
|
||||
list.add("[craftinfo]Capacity per input type: " + capacity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Tile tile){
|
||||
|
||||
if(tile.entity.timer.get(timerDump, 15) && tile.entity.hasItem(result)){
|
||||
if(tile.entity.timer.get(timerDump, 20) && tile.entity.hasItem(result)){
|
||||
tryDump(tile, -1, result);
|
||||
}
|
||||
|
||||
@ -51,11 +57,19 @@ public class Crafter extends Block{
|
||||
|
||||
@Override
|
||||
public boolean acceptItem(Item item, Tile dest, Tile source){
|
||||
boolean craft = false;
|
||||
for(Item req : requirements){
|
||||
if(item == req){
|
||||
return true;
|
||||
return dest.entity.getItem(item) < capacity;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawSelect(Tile tile){
|
||||
float fract = (float)tile.entity.totalItems()/((requirements.length-1) *capacity);
|
||||
|
||||
Vars.renderer.drawBar(Color.GREEN, tile.worldx(), tile.worldy() + 6, fract);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user