Added consumers for repair/resupply points
This commit is contained in:
@@ -94,7 +94,7 @@ public class BlockConsumeFragment extends Fragment {
|
||||
|
||||
table.table("inventory", c::buildTooltip).visible(() -> hovered[0]).height(scale * 10 + 6).padBottom(-4).right().update(t -> {
|
||||
if(t.getChildren().size == 0) t.remove();
|
||||
});
|
||||
}).get().act(0);
|
||||
|
||||
Table result = table.table(out -> {
|
||||
out.addImage(c.getIcon()).size(10*scale).color(Color.DARK_GRAY).padRight(-10*scale).padBottom(-scale*2);
|
||||
|
||||
@@ -22,6 +22,9 @@ import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import static io.anuke.mindustry.Vars.control;
|
||||
import static io.anuke.mindustry.Vars.headless;
|
||||
|
||||
public class GenericCrafter extends Block{
|
||||
protected final int timerDump = timers++;
|
||||
|
||||
@@ -96,6 +99,12 @@ public class GenericCrafter extends Block{
|
||||
if(entity.progress >= 1f){
|
||||
|
||||
if(consumes.has(ConsumeItem.class)) tile.entity.items.remove(consumes.item(), consumes.itemAmount());
|
||||
|
||||
//unlock output item
|
||||
if(!headless){
|
||||
control.database().unlockContent(output);
|
||||
}
|
||||
|
||||
offloadNear(tile, output);
|
||||
Effects.effect(craftEffect, tile.drawx(), tile.drawy());
|
||||
entity.progress = 0f;
|
||||
|
||||
@@ -26,7 +26,6 @@ public class RepairPoint extends Block{
|
||||
|
||||
protected float repairRadius = 50f;
|
||||
protected float repairSpeed = 0.3f;
|
||||
protected float powerUsage = 0.2f;
|
||||
|
||||
protected TextureRegion topRegion;
|
||||
|
||||
@@ -39,6 +38,7 @@ public class RepairPoint extends Block{
|
||||
layer2 = Layer.laser;
|
||||
hasPower = true;
|
||||
powerCapacity = 20f;
|
||||
consumes.power(0.06f);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -92,10 +92,7 @@ public class RepairPoint extends Block{
|
||||
entity.rotation = Mathf.slerpDelta(entity.rotation, entity.angleTo(entity.target), 0.5f);
|
||||
}
|
||||
|
||||
float powerUse = Math.min(Timers.delta() * powerUsage, powerCapacity);
|
||||
|
||||
if(entity.target != null && entity.power.amount >= powerUse){
|
||||
entity.power.amount -= powerUse;
|
||||
if(entity.target != null && entity.cons.valid()){
|
||||
entity.strength = Mathf.lerpDelta(entity.strength, 1f, 0.08f * Timers.delta());
|
||||
}else{
|
||||
entity.strength = Mathf.lerpDelta(entity.strength, 0f, 0.07f * Timers.delta());
|
||||
@@ -108,6 +105,13 @@ public class RepairPoint extends Block{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldConsume(Tile tile) {
|
||||
RepairPointEntity entity = tile.entity();
|
||||
|
||||
return entity.target != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getEntity() {
|
||||
return new RepairPointEntity();
|
||||
|
||||
@@ -27,7 +27,6 @@ public class ResupplyPoint extends Block{
|
||||
|
||||
protected float supplyRadius = 50f;
|
||||
protected float supplyInterval = 10f;
|
||||
protected float powerUsage = 0.2f;
|
||||
|
||||
public ResupplyPoint(String name) {
|
||||
super(name);
|
||||
@@ -38,6 +37,8 @@ public class ResupplyPoint extends Block{
|
||||
hasItems = true;
|
||||
hasPower = true;
|
||||
powerCapacity = 20f;
|
||||
|
||||
consumes.power(0.02f);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -98,10 +99,7 @@ public class ResupplyPoint extends Block{
|
||||
entity.rotation = Mathf.slerpDelta(entity.rotation, entity.angleTo(entity.target), 0.5f);
|
||||
}
|
||||
|
||||
float powerUse = Math.min(Timers.delta() * powerUsage, powerCapacity);
|
||||
|
||||
if(entity.target != null && entity.power.amount >= powerUse){
|
||||
entity.power.amount -= powerUse;
|
||||
if(entity.target != null && entity.cons.valid()){
|
||||
entity.lastx = entity.target.x;
|
||||
entity.lasty = entity.target.y;
|
||||
entity.strength = Mathf.lerpDelta(entity.strength, 1f, 0.08f * Timers.delta());
|
||||
|
||||
Reference in New Issue
Block a user