From fc8d9febf6b7498864d5fa80d6a80c031dfee503 Mon Sep 17 00:00:00 2001 From: Anuken Date: Sat, 29 Sep 2018 22:53:24 -0400 Subject: [PATCH] Mass driver fixes --- .../world/blocks/distribution/MassDriver.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/core/src/io/anuke/mindustry/world/blocks/distribution/MassDriver.java b/core/src/io/anuke/mindustry/world/blocks/distribution/MassDriver.java index 1fe8301645..662c05e5d0 100644 --- a/core/src/io/anuke/mindustry/world/blocks/distribution/MassDriver.java +++ b/core/src/io/anuke/mindustry/world/blocks/distribution/MassDriver.java @@ -83,8 +83,11 @@ public class MassDriver extends Block{ DriverBulletData data = Pooling.obtain(DriverBulletData.class, DriverBulletData::new); data.from = entity; data.to = other; + int totalUsed = 0; for(int i = 0; i < content.items().size; i++){ - data.items[i] = entity.items.get(content.item(i)); + int maxTransfer = Math.min(entity.items.get(content.item(i)), ((MassDriver) tile.block()).itemCapacity - totalUsed); + data.items[i] = maxTransfer; + totalUsed += maxTransfer; } entity.items.clear(); @@ -150,6 +153,11 @@ public class MassDriver extends Block{ entity.reload = Mathf.clamp(entity.reload - entity.delta() / reloadTime); } + //unload when dest is full + if(!linkValid(tile) || (link.entity.items.total() >= itemCapacity) && entity.items.total() > 0){ + entity.isUnloading = true; + } + if(!entity.isRecieving){ if(entity.waiting.size > 0){ //accepting takes priority over shooting @@ -282,12 +290,12 @@ public class MassDriver extends Block{ //add all the items possible for(int i = 0; i < data.items.length; i++){ - int maxAdd = Math.min(data.items[i], itemCapacity - totalItems); + int maxAdd = Math.min(data.items[i], itemCapacity*2 - totalItems); items.add(content.item(i), maxAdd); data.items[i] -= maxAdd; totalItems += maxAdd; - if(totalItems >= itemCapacity){ + if(totalItems >= itemCapacity*2){ break; } } @@ -297,7 +305,6 @@ public class MassDriver extends Block{ int amountDropped = Mathf.random(0, data.items[i]); if(amountDropped > 0){ float angle = Mathf.range(180f); - float vs = Mathf.random(0f, 4f); Effects.effect(EnvironmentFx.dropItem, Color.WHITE, bullet.x, bullet.y, angle, content.item(i)); } } @@ -317,11 +324,13 @@ public class MassDriver extends Block{ @Override public void write(DataOutputStream stream) throws IOException{ stream.writeInt(link); + stream.writeFloat(rotation); } @Override public void read(DataInputStream stream) throws IOException{ link = stream.readInt(); + rotation = stream.readFloat(); } } }