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