Misc bugfixes
This commit is contained in:
@@ -448,6 +448,7 @@ public class Block extends UnlockableContent implements Senseable{
|
||||
/** Drawn when placing and when hovering over. */
|
||||
public void drawOverlay(float x, float y, int rotation){
|
||||
}
|
||||
|
||||
public float sumAttribute(@Nullable Attribute attr, int x, int y){
|
||||
if(attr == null) return 0;
|
||||
Tile tile = world.tile(x, y);
|
||||
|
||||
@@ -47,7 +47,7 @@ public class DuctRouter extends Block{
|
||||
public void setStats(){
|
||||
super.setStats();
|
||||
|
||||
stats.add(Stat.itemsMoved, 60f / speed, StatUnit.itemsSecond);
|
||||
stats.add(Stat.itemsMoved, 60f / speed * itemCapacity, StatUnit.itemsSecond);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -78,6 +78,8 @@ public class DuctRouter extends Block{
|
||||
public float progress;
|
||||
public @Nullable Item current;
|
||||
|
||||
protected int acceptors;
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
Draw.rect(region, x, y);
|
||||
@@ -99,8 +101,7 @@ public class DuctRouter extends Block{
|
||||
var target = target();
|
||||
if(target != null){
|
||||
target.handleItem(this, current);
|
||||
int mod = sortItem != null && current != sortItem ? 2 : 3;
|
||||
cdump = (byte)((cdump + 1) % mod);
|
||||
cdump = ((cdump + 1) % acceptors);
|
||||
items.remove(current, 1);
|
||||
current = null;
|
||||
progress %= (1f - 1f/speed);
|
||||
@@ -124,6 +125,18 @@ public class DuctRouter extends Block{
|
||||
public Building target(){
|
||||
if(current == null) return null;
|
||||
|
||||
acceptors = 0;
|
||||
|
||||
//TODO this is horrible.
|
||||
for(int i = -1; i <= 1; i++){
|
||||
int dir = Mathf.mod(rotation + i, 4);
|
||||
if(sortItem != null && (current == sortItem) != (dir == rotation)) continue;
|
||||
Building other = nearby(dir);
|
||||
if(other != null && other.team == team && other.acceptItem(this, current)){
|
||||
acceptors ++;
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = -1; i <= 1; i++){
|
||||
int dir = Mathf.mod(rotation + (((i + cdump + 1) % 3) - 1), 4);
|
||||
if(sortItem != null && (current == sortItem) != (dir == rotation)) continue;
|
||||
|
||||
Reference in New Issue
Block a user