Search in sources :

Example 11 with Item

use of io.anuke.mindustry.resource.Item in project Mindustry by Anuken.

the class Junction method update.

@Override
public void update(Tile tile) {
    JunctionEntity entity = tile.entity();
    for (int i = 0; i < 2; i++) {
        Buffer buffer = (i == 0 ? entity.bx : entity.by);
        if (buffer.index > 0) {
            if (buffer.index > buffer.items.length)
                buffer.index = buffer.items.length;
            long l = buffer.items[0];
            float time = NumberUtils.intBitsToFloat(Bits.getLeftInt(l));
            if (Timers.time() >= time + speed || Timers.time() < time) {
                int val = Bits.getRightInt(l);
                Item item = Item.getByID(Bits.getLeftShort(val));
                int direction = Bits.getRightShort(val);
                Tile dest = tile.getNearby(direction);
                if (dest == null || !dest.block().acceptItem(item, dest, tile))
                    continue;
                dest.block().handleItem(item, dest, tile);
                System.arraycopy(buffer.items, 1, buffer.items, 0, buffer.index - 1);
                buffer.index--;
            }
        }
    }
}
Also used : Item(io.anuke.mindustry.resource.Item) Tile(io.anuke.mindustry.world.Tile)

Aggregations

Item (io.anuke.mindustry.resource.Item)11 Tile (io.anuke.mindustry.world.Tile)7 Array (com.badlogic.gdx.utils.Array)4 Enemy (io.anuke.mindustry.entities.enemies.Enemy)4 IOException (java.io.IOException)4 Block (io.anuke.mindustry.world.Block)3 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)2 IntMap (com.badlogic.gdx.utils.IntMap)2 TextureRegionDrawable (io.anuke.ucore.scene.style.TextureRegionDrawable)1 ButtonGroup (io.anuke.ucore.scene.ui.ButtonGroup)1 ImageButton (io.anuke.ucore.scene.ui.ImageButton)1 Table (io.anuke.ucore.scene.ui.layout.Table)1