mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-01-10 23:28:52 +07:00
Mass driver fixes
This commit is contained in:
parent
b43c542213
commit
fc8d9febf6
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user