Payload router
This commit is contained in:
@@ -45,6 +45,7 @@ public class Block extends UnlockableContent{
|
||||
public boolean consumesPower = true;
|
||||
public boolean outputsPower = false;
|
||||
public boolean outputsPayload = false;
|
||||
public boolean outputFacing = true;
|
||||
public boolean acceptsItems = false;
|
||||
|
||||
public int itemCapacity = 10;
|
||||
|
||||
@@ -95,20 +95,30 @@ public class PayloadConveyor extends Block{
|
||||
//move forward.
|
||||
next.handlePayload(this, item);
|
||||
item = null;
|
||||
moved();
|
||||
}
|
||||
}else if(!blocked){
|
||||
//dump item forward
|
||||
if(item.dump()){
|
||||
item = null;
|
||||
moved();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void moved(){
|
||||
|
||||
}
|
||||
|
||||
public void drawBottom(){
|
||||
super.draw();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
super.draw();
|
||||
drawBottom();
|
||||
|
||||
float dst = 0.8f;
|
||||
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package mindustry.world.blocks.distribution;
|
||||
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.util.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.graphics.*;
|
||||
|
||||
public class PayloadRouter extends PayloadConveyor{
|
||||
public @Load("@-over") TextureRegion overRegion;
|
||||
|
||||
public PayloadRouter(String name){
|
||||
super(name);
|
||||
|
||||
outputsPayload = true;
|
||||
outputFacing = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawRequestRegion(BuildRequest req, Eachable<BuildRequest> list){
|
||||
super.drawRequestRegion(req, list);
|
||||
|
||||
Draw.rect(overRegion, req.drawx(), req.drawy());
|
||||
}
|
||||
|
||||
public class PayloadRouterEntity extends PayloadConveyorEntity{
|
||||
|
||||
@Override
|
||||
public void moved(){
|
||||
int rotations = 0;
|
||||
do{
|
||||
tile.rotation((tile.rotation() + 1) % 4);
|
||||
onProximityUpdate();
|
||||
}while((blocked || next == null) && ++rotations < 4);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
super.draw();
|
||||
|
||||
Draw.z(Layer.block);
|
||||
|
||||
Draw.rect(overRegion, x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package mindustry.world.blocks.payloads;
|
||||
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.util.io.*;
|
||||
import mindustry.*;
|
||||
import mindustry.gen.*;
|
||||
@@ -32,6 +33,8 @@ public class UnitPayload implements Payload{
|
||||
//no client dumping
|
||||
if(Vars.net.client()) return true;
|
||||
|
||||
//prevents stacking
|
||||
unit.vel().add(Mathf.range(0.5f), Mathf.range(0.5f));
|
||||
unit.add();
|
||||
|
||||
return true;
|
||||
|
||||
@@ -28,7 +28,8 @@ public class PayloadAcceptor extends Block{
|
||||
accept.block().size == size &&
|
||||
accept.block().outputsPayload &&
|
||||
//block must either be facing this one, or not be rotating
|
||||
((accept.tileX() + Geometry.d4(accept.rotation()).x * size == tile.tileX() && accept.tileY() + Geometry.d4(accept.rotation()).y * size == tile.tileY()) || !accept.block().rotate);
|
||||
((accept.tileX() + Geometry.d4(accept.rotation()).x * size == tile.tileX() && accept.tileY() + Geometry.d4(accept.rotation()).y * size == tile.tileY())
|
||||
|| !accept.block().rotate || (accept.block().rotate && !accept.block().outputFacing));
|
||||
}
|
||||
|
||||
public class PayloadAcceptorEntity<T extends Payload> extends TileEntity{
|
||||
|
||||
Reference in New Issue
Block a user