PayloadDeconstructor progress
This commit is contained in:
@@ -127,7 +127,7 @@ public class UnitType extends UnlockableContent{
|
||||
softShadowRegion, jointRegion, footRegion, legBaseRegion, baseJointRegion, outlineRegion;
|
||||
public TextureRegion[] wreckRegions;
|
||||
|
||||
protected float maxBuildTime = -1f;
|
||||
protected float buildTime = -1f;
|
||||
protected @Nullable ItemStack[] cachedRequirements;
|
||||
protected @Nullable ItemStack[] totalRequirements;
|
||||
|
||||
@@ -462,10 +462,10 @@ public class UnitType extends UnlockableContent{
|
||||
}
|
||||
}
|
||||
|
||||
/** @return the time required to build this unit, as a maximum value that takes into account reconstructors */
|
||||
/** @return the time required to build this unit, as a value that takes into account reconstructors */
|
||||
public float getBuildTime(){
|
||||
getTotalRequirements();
|
||||
return maxBuildTime;
|
||||
return buildTime;
|
||||
}
|
||||
|
||||
/** @return all items needed to build this unit, including reconstructor steps. */
|
||||
@@ -479,16 +479,18 @@ public class UnitType extends UnlockableContent{
|
||||
totalRequirements = ItemStack.empty;
|
||||
|
||||
if(result != null){
|
||||
maxBuildTime = timeret[0];
|
||||
ItemSeq total = new ItemSeq();
|
||||
|
||||
total.add(result);
|
||||
if(ret[0] != null){
|
||||
total.add(ret[0].getTotalRequirements());
|
||||
maxBuildTime = Math.max(ret[0].maxBuildTime, maxBuildTime);
|
||||
}
|
||||
totalRequirements = total.toArray();
|
||||
}
|
||||
|
||||
for(var stack : totalRequirements){
|
||||
buildTime += stack.item.cost * stack.amount;
|
||||
}
|
||||
}
|
||||
return totalRequirements;
|
||||
}
|
||||
|
||||
@@ -7,9 +7,12 @@ import arc.util.io.*;
|
||||
import mindustry.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.ui.*;
|
||||
|
||||
public class PayloadDeconstructor extends PayloadBlock{
|
||||
public float deconstructSpeed = 2f;
|
||||
public float maxPayloadSize = 4;
|
||||
public float deconstructSpeed = 2.5f;
|
||||
public int dumpRate = 4;
|
||||
|
||||
public PayloadDeconstructor(String name){
|
||||
super(name);
|
||||
@@ -32,6 +35,13 @@ public class PayloadDeconstructor extends PayloadBlock{
|
||||
return new TextureRegion[]{region, topRegion};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBars(){
|
||||
super.setBars();
|
||||
|
||||
bars.add("progress", (PayloadDeconstructorBuild e) -> new Bar("bar.progress", Pal.ammo, () -> e.progress));
|
||||
}
|
||||
|
||||
public class PayloadDeconstructorBuild extends PayloadBlockBuild<Payload>{
|
||||
public @Nullable Payload deconstructing;
|
||||
public @Nullable float[] accum;
|
||||
@@ -58,6 +68,7 @@ public class PayloadDeconstructor extends PayloadBlock{
|
||||
//deconstructing.draw();
|
||||
|
||||
//TODO shadow
|
||||
//TODO looks really bad
|
||||
Draw.draw(Layer.blockOver, () -> {
|
||||
Drawf.construct(x, y, deconstructing.icon(), Pal.remove, 0f, 1f - progress, speedScl, time);
|
||||
Draw.color(Pal.remove);
|
||||
@@ -80,13 +91,20 @@ public class PayloadDeconstructor extends PayloadBlock{
|
||||
|
||||
@Override
|
||||
public boolean acceptPayload(Building source, Payload payload){
|
||||
return deconstructing == null && super.acceptPayload(source, payload) && payload.requirements().length > 0;
|
||||
return deconstructing == null && super.acceptPayload(source, payload) && payload.requirements().length > 0 && payload.fits(maxPayloadSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTile(){
|
||||
//always dump items
|
||||
dumpAccumulate();
|
||||
if(items.total() > 0){
|
||||
for(int i = 0; i < dumpRate; i++){
|
||||
dumpAccumulate();
|
||||
}
|
||||
}
|
||||
|
||||
if(deconstructing == null){
|
||||
progress = 0f;
|
||||
}
|
||||
|
||||
if(deconstructing != null){
|
||||
var reqs = deconstructing.requirements();
|
||||
|
||||
Reference in New Issue
Block a user