Automatic tech node cost generation

This commit is contained in:
Anuken
2019-01-20 15:44:54 -05:00
parent cbdce79d7d
commit bc77ebc10c
3 changed files with 128 additions and 107 deletions

View File

@@ -5,36 +5,36 @@ import io.anuke.mindustry.game.ContentList;
import io.anuke.mindustry.type.ItemStack; import io.anuke.mindustry.type.ItemStack;
import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.Block;
import static io.anuke.mindustry.type.ItemStack.with; import static io.anuke.mindustry.content.Blocks.*;
public class TechTree implements ContentList{ public class TechTree implements ContentList{
public static TechNode root; public static TechNode root;
@Override @Override
public void load(){ public void load(){
root = node(Blocks.core, with(), () -> { root = node(core, () -> {
node(Blocks.conveyor, with(Items.copper, 100), () -> { node(conveyor, () -> {
node(Blocks.launchPad, with(Items.copper, 100), () -> { node(launchPad, () -> {
}); });
node(Blocks.junction, with(Items.copper, 100), () -> { node(junction, () -> {
node(Blocks.itemBridge, with(Items.copper, 100)); node(itemBridge);
node(Blocks.router, with(Items.copper, 100), () -> { node(router, () -> {
node(Blocks.distributor, with(Items.copper, 100)); node(distributor);
node(Blocks.overflowGate, with(Items.copper, 100)); node(overflowGate);
node(Blocks.sorter, with(Items.copper, 100)); node(sorter);
node(Blocks.container, with(Items.copper, 100), () -> { node(container, () -> {
node(Blocks.unloader, with(Items.copper, 100)); node(unloader);
node(Blocks.vault, with(Items.copper, 100), () -> { node(vault, () -> {
}); });
}); });
}); });
node(Blocks.titaniumConveyor, with(Items.copper, 100), () -> { node(titaniumConveyor, () -> {
node(Blocks.phaseConveyor, with(Items.copper, 100), () -> { node(phaseConveyor, () -> {
node(Blocks.massDriver, with(Items.copper, 100), () -> { node(massDriver, () -> {
}); });
}); });
@@ -42,55 +42,55 @@ public class TechTree implements ContentList{
}); });
}); });
node(Blocks.duo, with(Items.copper, 100), () -> { node(duo, () -> {
node(Blocks.hail, with(Items.copper, 100), () -> { node(hail, () -> {
node(Blocks.salvo, with(Items.copper, 100), () -> { node(salvo, () -> {
node(Blocks.swarmer, with(Items.copper, 100), () -> { node(swarmer, () -> {
node(Blocks.cyclone, with(Items.copper, 100), () -> { node(cyclone, () -> {
node(Blocks.spectre, with(Items.copper, 100), () -> { node(spectre, () -> {
}); });
}); });
}); });
node(Blocks.ripple, with(Items.copper, 100), () -> { node(ripple, () -> {
node(Blocks.fuse, with(Items.copper, 100), () -> { node(fuse, () -> {
}); });
}); });
}); });
}); });
node(Blocks.arc, with(Items.copper, 100), () -> { node(arc, () -> {
node(Blocks.wave, with(Items.copper, 100), () -> { node(wave, () -> {
}); });
node(Blocks.lancer, with(Items.copper, 100), () -> { node(lancer, () -> {
node(Blocks.meltdown, with(Items.copper, 100), () -> { node(meltdown, () -> {
}); });
node(Blocks.shockMine, with(Items.metaglass, 100), () -> { node(shockMine, () -> {
}); });
}); });
}); });
node(Blocks.copperWall, with(Items.copper, 100), () -> { node(copperWall, () -> {
node(Blocks.copperWallLarge, with(Items.copper, 100)); node(copperWallLarge);
node(Blocks.titaniumWall, with(Items.copper, 100), () -> { node(titaniumWall, () -> {
node(Blocks.door, with(Items.copper, 100), () -> { node(door, () -> {
node(Blocks.doorLarge, with(Items.copper, 100)); node(doorLarge);
}); });
node(Blocks.titaniumWallLarge, with(Items.copper, 100)); node(titaniumWallLarge);
node(Blocks.thoriumWall, with(Items.copper, 100), () -> { node(thoriumWall, () -> {
node(Blocks.thoriumWallLarge, with(Items.copper, 100)); node(thoriumWallLarge);
node(Blocks.surgeWall, with(Items.copper, 100), () -> { node(surgeWall, () -> {
node(Blocks.surgeWallLarge, with(Items.copper, 100)); node(surgeWallLarge);
node(Blocks.phaseWall, with(Items.copper, 100), () -> { node(phaseWall, () -> {
node(Blocks.phaseWallLarge, with(Items.copper, 100)); node(phaseWallLarge);
}); });
}); });
}); });
@@ -98,145 +98,145 @@ public class TechTree implements ContentList{
}); });
}); });
node(Blocks.mechanicalDrill, with(Items.copper, 100), () -> { node(mechanicalDrill, () -> {
node(Blocks.pneumaticDrill, with(Items.copper, 100), () -> { node(pneumaticDrill, () -> {
node(Blocks.cultivator, with(Items.copper, 100), () -> { node(cultivator, () -> {
}); });
node(Blocks.laserDrill, with(Items.copper, 100), () -> { node(laserDrill, () -> {
node(Blocks.blastDrill, with(Items.copper, 100), () -> { node(blastDrill, () -> {
}); });
node(Blocks.waterExtractor, with(Items.copper, 100), () -> { node(waterExtractor, () -> {
node(Blocks.oilExtractor, with(Items.copper, 100), () -> { node(oilExtractor, () -> {
}); });
}); });
}); });
}); });
node(Blocks.siliconSmelter, with(Items.copper, 100), () -> { node(siliconSmelter, () -> {
node(Blocks.pyratiteMixer, with(Items.copper, 100), () -> { node(pyratiteMixer, () -> {
node(Blocks.blastMixer, with(Items.copper, 100), () -> { node(blastMixer, () -> {
}); });
}); });
node(Blocks.biomatterCompressor, with(Items.copper, 100), () -> { node(biomatterCompressor, () -> {
node(Blocks.plastaniumCompressor, with(Items.copper, 100), () -> { node(plastaniumCompressor, () -> {
node(Blocks.phaseWeaver, with(Items.copper, 100), () -> { node(phaseWeaver, () -> {
}); });
}); });
}); });
node(Blocks.incinerator, with(Items.copper, 100), () -> { node(incinerator, () -> {
node(Blocks.melter, with(Items.copper, 100), () -> { node(melter, () -> {
node(Blocks.surgeSmelter, with(Items.copper, 100), () -> { node(surgeSmelter, () -> {
}); });
node(Blocks.separator, with(Items.copper, 100), () -> { node(separator, () -> {
node(Blocks.pulverizer, with(Items.copper, 100), () -> { node(pulverizer, () -> {
}); });
}); });
node(Blocks.cryofluidMixer, with(Items.copper, 100), () -> { node(cryofluidMixer, () -> {
}); });
}); });
}); });
}); });
node(Blocks.mechanicalPump, with(Items.metaglass, 100), () -> { node(mechanicalPump, () -> {
node(Blocks.conduit, with(Items.metaglass, 100), () -> { node(conduit, () -> {
node(Blocks.liquidJunction, with(Items.metaglass, 100), () -> { node(liquidJunction, () -> {
node(Blocks.liquidRouter, with(Items.metaglass, 100), () -> { node(liquidRouter, () -> {
node(Blocks.liquidTank, with(Items.metaglass, 100)); node(liquidTank);
node(Blocks.pulseConduit, with(Items.metaglass, 100), () -> { node(pulseConduit, () -> {
node(Blocks.phaseConduit, with(Items.metaglass, 100), () -> { node(phaseConduit, () -> {
}); });
}); });
node(Blocks.rotaryPump, with(Items.metaglass, 100), () -> { node(rotaryPump, () -> {
node(Blocks.thermalPump, with(Items.metaglass, 100), () -> { node(thermalPump, () -> {
}); });
}); });
}); });
node(Blocks.bridgeConduit, with(Items.metaglass, 100)); node(bridgeConduit);
}); });
}); });
}); });
}); });
node(Blocks.powerNode, with(Items.copper, 100), () -> { node(powerNode, () -> {
node(Blocks.combustionGenerator, with(Items.copper, 100), () -> { node(combustionGenerator, () -> {
node(Blocks.powerNodeLarge, with(Items.copper, 100), () -> { node(powerNodeLarge, () -> {
node(Blocks.battery, with(Items.copper, 100), () -> { node(battery, () -> {
node(Blocks.batteryLarge, with(Items.copper, 100), () -> { node(batteryLarge, () -> {
}); });
}); });
node(Blocks.mendProjector, with(Items.copper, 100), () -> { node(mendProjector, () -> {
node(Blocks.forceProjector, with(Items.copper, 100), () -> { node(forceProjector, () -> {
node(Blocks.overdriveProjector, with(Items.copper, 100), () -> { node(overdriveProjector, () -> {
}); });
}); });
node(Blocks.repairPoint, with(Items.copper, 100), () -> { node(repairPoint, () -> {
}); });
}); });
}); });
node(Blocks.turbineGenerator, with(Items.copper, 100), () -> { node(turbineGenerator, () -> {
node(Blocks.thermalGenerator, with(Items.copper, 100), () -> { node(thermalGenerator, () -> {
node(Blocks.rtgGenerator, with(Items.copper, 100), () -> { node(rtgGenerator, () -> {
node(Blocks.thoriumReactor, with(Items.copper, 100), () -> { node(thoriumReactor, () -> {
}); });
}); });
}); });
}); });
node(Blocks.solarPanel, with(Items.copper, 100), () -> { node(solarPanel, () -> {
node(Blocks.largeSolarPanel, with(Items.copper, 100), () -> { node(largeSolarPanel, () -> {
}); });
}); });
}); });
node(Blocks.alphaPad, with(Items.copper, 100), () -> { node(alphaPad, () -> {
node(Blocks.dartPad, with(Items.copper, 100)); node(dartPad);
node(Blocks.deltaPad, with(Items.copper, 100), () -> { node(deltaPad, () -> {
node(Blocks.javelinPad, with(Items.copper, 100)); node(javelinPad);
node(Blocks.tauPad, with(Items.copper, 100), () -> { node(tauPad, () -> {
node(Blocks.tridentPad, with(Items.copper, 100)); node(tridentPad);
node(Blocks.omegaPad, with(Items.copper, 100), () -> { node(omegaPad, () -> {
node(Blocks.glaivePad, with(Items.copper, 100)); node(glaivePad);
}); });
}); });
}); });
node(Blocks.spiritFactory, with(Items.copper, 100), () -> { node(spiritFactory, () -> {
node(Blocks.daggerFactory, with(Items.copper, 100), () -> { node(daggerFactory, () -> {
node(Blocks.daggerFactory, with(Items.copper, 100), () -> { node(daggerFactory, () -> {
node(Blocks.titanFactory, with(Items.copper, 100), () -> { node(titanFactory, () -> {
node(Blocks.fortressFactory, with(Items.copper, 100)); node(fortressFactory);
}); });
node(Blocks.wraithFactory, with(Items.copper, 100), () -> { node(wraithFactory, () -> {
node(Blocks.phantomFactory, with(Items.copper, 100)); node(phantomFactory);
node(Blocks.ghoulFactory, with(Items.copper, 100), () -> { node(ghoulFactory, () -> {
node(Blocks.revenantFactory, with(Items.copper, 100)); node(revenantFactory);
}); });
}); });
}); });
@@ -247,12 +247,17 @@ public class TechTree implements ContentList{
}); });
} }
private TechNode node(Block block, ItemStack[] requirements, Runnable children){ private TechNode node(Block block, Runnable children){
ItemStack[] requirements = new ItemStack[block.buildRequirements.length];
for(int i = 0; i < requirements.length; i++){
requirements[i] = new ItemStack(block.buildRequirements[i].item, block.buildRequirements[i].amount * 40);
}
return new TechNode(block, requirements, children); return new TechNode(block, requirements, children);
} }
private void node(Block block, ItemStack[] requirements){ private TechNode node(Block block){
new TechNode(block, requirements, () -> {}); return node(block, () -> {});
} }
public static class TechNode{ public static class TechNode{
@@ -267,6 +272,7 @@ public class TechTree implements ContentList{
context.children.add(this); context.children.add(this);
} }
//TODO remove requirements... for now
this.block = block; this.block = block;
this.requirements = requirements; this.requirements = requirements;

View File

@@ -210,8 +210,16 @@ public class PlacementFragment extends Fragment{
}else if(tileDisplayBlock() != null){ //show selected tile }else if(tileDisplayBlock() != null){ //show selected tile
lastDisplay = tileDisplayBlock(); lastDisplay = tileDisplayBlock();
topTable.add(new Image(lastDisplay.getDisplayIcon(hoverTile))).size(8 * 4); topTable.table(t -> {
topTable.labelWrap(lastDisplay.getDisplayName(hoverTile)).left().width(190f).padLeft(5); t.left();
t.add(new Image(lastDisplay.getDisplayIcon(hoverTile))).size(8 * 4);
t.labelWrap(lastDisplay.getDisplayName(hoverTile)).left().width(190f).padLeft(5);
}).growX().left();
topTable.row();
topTable.table(t -> {
t.left().defaults().left();
lastDisplay.display(hoverTile, t);
}).left();
} }
}); });
}).colspan(3).fillX().visible(() -> getSelected() != null || tileDisplayBlock() != null).touchable(Touchable.enabled); }).colspan(3).fillX().visible(() -> getSelected() != null || tileDisplayBlock() != null).touchable(Touchable.enabled);

View File

@@ -462,6 +462,13 @@ public class Block extends BlockStorage{
return icon(Icon.medium); return icon(Icon.medium);
} }
public void display(Tile tile, Table table){
if(tile.entity != null){
//TODO remove/replace
table.label(() -> "Health: [LIGHT_GRAY]" + (int)tile.entity.health + " / " + health);
}
}
public TextureRegion icon(Icon icon){ public TextureRegion icon(Icon icon){
if(icons[icon.ordinal()] == null){ if(icons[icon.ordinal()] == null){
icons[icon.ordinal()] = Core.atlas.find(name + "-icon-" + icon.name()); icons[icon.ordinal()] = Core.atlas.find(name + "-icon-" + icon.name());