mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-04-02 12:20:53 -07:00
Updated uCore / Made splitter distribute properly
This commit is contained in:
parent
f3cc881930
commit
dbee30a412
6 changed files with 36 additions and 26 deletions
|
|
@ -27,7 +27,7 @@ allprojects {
|
|||
gdxVersion = '1.9.8'
|
||||
roboVMVersion = '2.3.0'
|
||||
aiVersion = '1.8.1'
|
||||
uCoreVersion = '2241e5402e'
|
||||
uCoreVersion = 'f937c5cad6'
|
||||
|
||||
getVersionString = {
|
||||
String buildVersion = getBuildVersion()
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package io.anuke.mindustry;
|
||||
|
||||
import com.badlogic.gdx.utils.async.AsyncExecutor;
|
||||
import io.anuke.mindustry.core.*;
|
||||
import io.anuke.mindustry.io.BundleLoader;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
|
|
@ -10,7 +9,6 @@ import io.anuke.ucore.util.Log;
|
|||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class Mindustry extends ModuleCore {
|
||||
private AsyncExecutor exec = new AsyncExecutor(1);
|
||||
|
||||
@Override
|
||||
public void init(){
|
||||
|
|
|
|||
|
|
@ -84,12 +84,12 @@ public class ProductionBlocks extends BlockList implements ContentList {
|
|||
updateEffect = BlockFx.pulverize;
|
||||
liquidCapacity = 50f;
|
||||
updateEffectChance = 0.05f;
|
||||
pumpAmount = 0.06f;
|
||||
pumpAmount = 0.08f;
|
||||
size = 3;
|
||||
liquidCapacity = 30f;
|
||||
|
||||
consumes.item(Items.sand);
|
||||
consumes.power(0.6f);
|
||||
consumes.power(0.5f);
|
||||
consumes.liquid(Liquids.water, 0.3f);
|
||||
}};
|
||||
|
||||
|
|
|
|||
|
|
@ -20,9 +20,13 @@ public class ItemBuffer {
|
|||
return index < buffer.length;
|
||||
}
|
||||
|
||||
public void accept(Item item){
|
||||
public void accept(Item item, short data){
|
||||
//if(!accepts()) return;
|
||||
buffer[index ++] = Bits.packLong(NumberUtils.floatToIntBits(Timers.time()), item.id);
|
||||
buffer[index ++] = Bits.packLong(NumberUtils.floatToIntBits(Timers.time()), Bits.packInt((short)item.id, data));
|
||||
}
|
||||
|
||||
public void accept(Item item){
|
||||
accept(item, (short)-1);
|
||||
}
|
||||
|
||||
public Item poll(){
|
||||
|
|
@ -31,12 +35,24 @@ public class ItemBuffer {
|
|||
float time = NumberUtils.intBitsToFloat(Bits.getLeftInt(l));
|
||||
|
||||
if(Timers.time() >= time + speed || Timers.time() < time){
|
||||
return Item.getByID(Bits.getRightInt(l));
|
||||
return Item.getByID(Bits.getLeftShort(Bits.getRightInt(l)));
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public short pollData(){
|
||||
if(index > 0){
|
||||
long l = buffer[0];
|
||||
float time = NumberUtils.intBitsToFloat(Bits.getLeftInt(l));
|
||||
|
||||
if(Timers.time() >= time + speed || Timers.time() < time){
|
||||
return Bits.getRightShort(Bits.getRightInt(l));
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public void remove(){
|
||||
System.arraycopy(buffer, 1, buffer, 0, index - 1);
|
||||
index --;
|
||||
|
|
|
|||
|
|
@ -1,21 +1,19 @@
|
|||
package io.anuke.mindustry.world.blocks.distribution;
|
||||
|
||||
import com.badlogic.gdx.math.GridPoint2;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Edges;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.meta.BlockGroup;
|
||||
|
||||
import static io.anuke.mindustry.Vars.world;
|
||||
|
||||
public class Splitter extends Block{
|
||||
protected float speed = 30f;
|
||||
|
||||
public Splitter(String name){
|
||||
super(name);
|
||||
solid = true;
|
||||
instantTransfer = true;
|
||||
destructible = true;
|
||||
update = true;
|
||||
group = BlockGroup.transportation;
|
||||
}
|
||||
|
||||
|
|
@ -23,26 +21,24 @@ public class Splitter extends Block{
|
|||
public boolean acceptItem(Item item, Tile tile, Tile source){
|
||||
Tile to = getTileTarget(item, tile, source, false);
|
||||
|
||||
return to != null && to.block().acceptItem(item, to, tile);
|
||||
return to != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleItem(Item item, Tile tile, Tile source){
|
||||
Tile to = getTileTarget(item, tile, source, true);
|
||||
|
||||
to.block().handleItem(item, to, tile);
|
||||
}
|
||||
|
||||
Tile getTileTarget(Item item, Tile dest, Tile source, boolean flip){
|
||||
GridPoint2[] points = Edges.getEdges(size);
|
||||
int counter = source.getDump();
|
||||
for (int i = 0; i < points.length; i++) {
|
||||
GridPoint2 point = points[(i + counter++) % points.length];
|
||||
source.setDump((byte)(counter % points.length));
|
||||
Tile tile = world.tile(dest.x + point.x, dest.y + point.y);
|
||||
if(tile != source && !(tile.block().instantTransfer && source.block().instantTransfer) &&
|
||||
tile.block().acceptItem(item, tile, dest)){
|
||||
return tile;
|
||||
Tile getTileTarget(Item item, Tile tile, Tile source, boolean flip){
|
||||
Array<Tile> proximity = tile.entity.proximity();
|
||||
int counter = tile.getDump();
|
||||
for (int i = 0; i < proximity.size; i++) {
|
||||
Tile other = proximity.get((i + counter) % proximity.size);
|
||||
if(flip) tile.setDump((byte)((tile.getDump() + 1) % proximity.size));
|
||||
if(other != source && !(source.block().instantTransfer && other.block().instantTransfer && !(other.block() instanceof Splitter)) &&
|
||||
other.block().acceptItem(item, other, tile)){
|
||||
return other;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ public class PowerNode extends PowerBlock{
|
|||
super.setStats();
|
||||
|
||||
stats.add(BlockStat.powerRange, laserRange, StatUnit.blocks);
|
||||
stats.add(BlockStat.powerTransferSpeed, powerSpeed * 60, StatUnit.powerSecond);
|
||||
stats.add(BlockStat.powerTransferSpeed, powerSpeed * 60 / 2f, StatUnit.powerSecond); //divided by 2 since passback exists
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue