Further bridge cleanup
This commit is contained in:
@@ -5,7 +5,6 @@ import arc.graphics.g2d.*;
|
|||||||
import arc.math.*;
|
import arc.math.*;
|
||||||
import arc.math.geom.*;
|
import arc.math.geom.*;
|
||||||
import arc.struct.*;
|
import arc.struct.*;
|
||||||
import arc.struct.IntSet.*;
|
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import arc.util.io.*;
|
import arc.util.io.*;
|
||||||
import mindustry.annotations.Annotations.*;
|
import mindustry.annotations.Annotations.*;
|
||||||
@@ -177,8 +176,7 @@ public class ItemBridge extends Block{
|
|||||||
|
|
||||||
public class ItemBridgeBuild extends Building{
|
public class ItemBridgeBuild extends Building{
|
||||||
public int link = -1;
|
public int link = -1;
|
||||||
//TODO awful
|
public IntSeq incoming = new IntSeq(false, 4);
|
||||||
public IntSet incoming = new IntSet();
|
|
||||||
public float warmup;
|
public float warmup;
|
||||||
public float time;
|
public float time;
|
||||||
public boolean wasMoved, moved;
|
public boolean wasMoved, moved;
|
||||||
@@ -278,13 +276,15 @@ public class ItemBridge extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void checkIncoming(){
|
public void checkIncoming(){
|
||||||
IntSetIterator it = incoming.iterator();
|
int idx = 0;
|
||||||
while(it.hasNext){
|
while(idx < incoming.size){
|
||||||
int i = it.next();
|
int i = incoming.items[idx];
|
||||||
Tile other = world.tile(i);
|
Tile other = world.tile(i);
|
||||||
if(!linkValid(tile, other, false) || ((ItemBridgeBuild)other.build).link != tile.pos()){
|
if(!linkValid(tile, other, false) || ((ItemBridgeBuild)other.build).link != tile.pos()){
|
||||||
it.remove();
|
incoming.removeIndex(idx);
|
||||||
|
idx --;
|
||||||
}
|
}
|
||||||
|
idx ++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -304,7 +304,11 @@ public class ItemBridge extends Block{
|
|||||||
doDump();
|
doDump();
|
||||||
warmup = 0f;
|
warmup = 0f;
|
||||||
}else{
|
}else{
|
||||||
((ItemBridgeBuild)other.build).incoming.add(tile.pos());
|
var inc = ((ItemBridgeBuild)other.build).incoming;
|
||||||
|
int pos = tile.pos();
|
||||||
|
if(!inc.contains(pos)){
|
||||||
|
inc.add(pos);
|
||||||
|
}
|
||||||
|
|
||||||
warmup = Mathf.approachDelta(warmup, efficiency(), 1f / 30f);
|
warmup = Mathf.approachDelta(warmup, efficiency(), 1f / 30f);
|
||||||
updateTransport(other.build);
|
updateTransport(other.build);
|
||||||
@@ -382,22 +386,7 @@ public class ItemBridge extends Block{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean acceptItem(Building source, Item item){
|
public boolean acceptItem(Building source, Item item){
|
||||||
if(team != source.team) return false;
|
return hasItems && team == source.team && items.total() < itemCapacity && checkAccept(source, world.tile(link));
|
||||||
|
|
||||||
Tile other = world.tile(link);
|
|
||||||
|
|
||||||
if(items.total() >= itemCapacity) return false;
|
|
||||||
|
|
||||||
if(linked(source)) return true;
|
|
||||||
|
|
||||||
if(linkValid(tile, other)){
|
|
||||||
int rel = relativeTo(other);
|
|
||||||
int rel2 = relativeTo(Edges.getFacingEdge(source, this));
|
|
||||||
|
|
||||||
return rel != rel2;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -407,16 +396,17 @@ public class ItemBridge extends Block{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean acceptLiquid(Building source, Liquid liquid){
|
public boolean acceptLiquid(Building source, Liquid liquid){
|
||||||
if(team != source.team || !hasLiquids) return false;
|
return
|
||||||
|
hasLiquids && team == source.team &&
|
||||||
Tile other = world.tile(link);
|
(liquids.current() == liquid || liquids.get(liquids.current()) < 0.2f) &&
|
||||||
|
checkAccept(source, world.tile(link));
|
||||||
if(!(liquids.current() == liquid || liquids.get(liquids.current()) < 0.2f)) return false;
|
}
|
||||||
|
|
||||||
|
protected boolean checkAccept(Building source, Tile other){
|
||||||
if(linked(source)) return true;
|
if(linked(source)) return true;
|
||||||
|
|
||||||
if(linkValid(tile, other)){
|
if(linkValid(tile, other)){
|
||||||
int rel = relativeTo(other.x, other.y);
|
int rel = relativeTo(other);
|
||||||
int rel2 = relativeTo(Edges.getFacingEdge(source, this));
|
int rel2 = relativeTo(Edges.getFacingEdge(source, this));
|
||||||
|
|
||||||
return rel != rel2;
|
return rel != rel2;
|
||||||
@@ -440,10 +430,8 @@ public class ItemBridge extends Block{
|
|||||||
Tile edge = Edges.getFacingEdge(to.tile, tile);
|
Tile edge = Edges.getFacingEdge(to.tile, tile);
|
||||||
int i = relativeTo(edge.x, edge.y);
|
int i = relativeTo(edge.x, edge.y);
|
||||||
|
|
||||||
IntSetIterator it = incoming.iterator();
|
for(int j = 0; j < incoming.size; j++){
|
||||||
|
int v = incoming.items[j];
|
||||||
while(it.hasNext){
|
|
||||||
int v = it.next();
|
|
||||||
if(relativeTo(Point2.x(v), Point2.y(v)) == i){
|
if(relativeTo(Point2.x(v), Point2.y(v)) == i){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -469,7 +457,7 @@ public class ItemBridge extends Block{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public byte version(){
|
public byte version(){
|
||||||
return 1; //TODO write cycleSpeed, 1
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -479,10 +467,8 @@ public class ItemBridge extends Block{
|
|||||||
write.f(warmup);
|
write.f(warmup);
|
||||||
write.b(incoming.size);
|
write.b(incoming.size);
|
||||||
|
|
||||||
IntSetIterator it = incoming.iterator();
|
for(int i = 0; i < incoming.size; i++){
|
||||||
|
write.i(incoming.items[i]);
|
||||||
while(it.hasNext){
|
|
||||||
write.i(it.next());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
write.bool(wasMoved || moved);
|
write.bool(wasMoved || moved);
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package mindustry.world.blocks.liquid;
|
package mindustry.world.blocks.liquid;
|
||||||
|
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.type.*;
|
|
||||||
import mindustry.world.blocks.distribution.*;
|
import mindustry.world.blocks.distribution.*;
|
||||||
import mindustry.world.meta.*;
|
import mindustry.world.meta.*;
|
||||||
|
|
||||||
@@ -20,7 +19,7 @@ public class LiquidBridge extends ItemBridge{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateTransport(Building other){
|
public void updateTransport(Building other){
|
||||||
if(warmup >= 0.5f){
|
if(warmup >= 0.25f){
|
||||||
moved |= moveLiquid(other, liquids.current()) > 0.05f;
|
moved |= moveLiquid(other, liquids.current()) > 0.05f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -29,10 +28,5 @@ public class LiquidBridge extends ItemBridge{
|
|||||||
public void doDump(){
|
public void doDump(){
|
||||||
dumpLiquid(liquids.current(), 1f);
|
dumpLiquid(liquids.current(), 1f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean acceptItem(Building source, Item item){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,4 +10,4 @@ kapt.include.compile.classpath=false
|
|||||||
kotlin.stdlib.default.dependency=false
|
kotlin.stdlib.default.dependency=false
|
||||||
#needed for android compilation
|
#needed for android compilation
|
||||||
android.useAndroidX=true
|
android.useAndroidX=true
|
||||||
archash=c066b6a3db27ce21fa4d07c28c0d70b86a87cd55
|
archash=d7b814ff69853e3bc8fa0703d3b2829cbff65e9e
|
||||||
|
|||||||
Reference in New Issue
Block a user