WIP launch pad rework

This commit is contained in:
Anuken
2025-01-31 17:58:35 -05:00
parent bcb7cdae73
commit ab65c9d29a
9 changed files with 136 additions and 47 deletions
@@ -0,0 +1,70 @@
package mindustry.world.blocks.campaign;
import arc.util.*;
import arc.util.io.*;
import mindustry.gen.*;
import mindustry.io.*;
import mindustry.type.*;
import mindustry.world.*;
public class LandingPad extends Block{
public LandingPad(String name){
super(name);
hasItems = true;
solid = true;
update = true;
configurable = true;
acceptsItems = false;
config(Item.class, (LandingPadBuild build, Item item) -> build.config = item);
configClear((LandingPadBuild build) -> build.config = null);
}
@Override
public boolean outputsItems(){
return true;
}
public class LandingPadBuild extends Building{
public @Nullable Item config;
@Override
public void updateTile(){
if(items.total() > 0){
dumpAccumulate(config == null || items.get(config) != items.total() ? null : config);
}
}
@Override
public boolean canDump(Building to, Item item){
//hack: canDump is only ever called right before item offload, so count the item as "produced" before that.
//TODO: is this necessary?
produced(item);
return true;
}
@Override
public boolean acceptItem(Building source, Item item){
return false;
}
@Override
public @Nullable Object config(){
return config;
}
@Override
public void read(Reads read, byte revision){
super.read(read, revision);
config = TypeIO.readItem(read);
}
@Override
public void write(Writes write){
super.write(write);
TypeIO.writeItem(write, config);
}
}
}
@@ -27,13 +27,14 @@ import mindustry.world.meta.*;
import static mindustry.Vars.*;
public class LaunchPad extends Block{
/** Time inbetween launches. */
/** Time between launches. */
public float launchTime = 1f;
public Sound launchSound = Sounds.none;
public @Load("@-light") TextureRegion lightRegion;
public @Load(value = "@-pod", fallback = "launchpod") TextureRegion podRegion;
public Color lightColor = Color.valueOf("eab678");
public boolean acceptMultipleItems = false;
public LaunchPad(String name){
super(name);
@@ -116,7 +117,7 @@ public class LaunchPad extends Block{
@Override
public boolean acceptItem(Building source, Item item){
return items.total() < itemCapacity;
return items.total() < itemCapacity && (acceptMultipleItems || items.total() == 0 || items.first() == item);
}
@Override
@@ -159,7 +160,8 @@ public class LaunchPad extends Block{
@Override
public void buildConfiguration(Table table){
if(!state.isCampaign() || net.client()){
//TODO: this UI should be on landing pads
if(!state.isCampaign() || net.client() || true){
deselect();
return;
}