Better sector loadout selection

This commit is contained in:
Anuken
2022-04-10 23:39:19 -04:00
parent 677e0ee878
commit 0d66c7dec7
8 changed files with 102 additions and 65 deletions

View File

@@ -1699,12 +1699,12 @@ public class Blocks{
}};
radar = new Radar("radar"){{
requirements(Category.effect, BuildVisibility.fogOnly, with(Items.silicon, 30, Items.graphite, 30));
requirements(Category.effect, BuildVisibility.fogOnly, with(Items.silicon, 40, Items.graphite, 40));
outlineColor = Color.valueOf("4a4b53");
fogRadius = 30;
researchCost = with(Items.silicon, 50, Items.graphite, 50);
fogRadius = 28;
researchCost = with(Items.silicon, 70, Items.graphite, 70);
consumePower(0.1f);
consumePower(0.15f);
}};
buildTower = new BuildTurret("build-tower"){{
@@ -1719,12 +1719,11 @@ public class Blocks{
regenProjector = new RegenProjector("regen-projector"){{
requirements(Category.effect, with(Items.silicon, 80, Items.tungsten, 60, Items.oxide, 40, Items.beryllium, 80));
size = 3;
consumePower(1f);
range = 28;
baseColor = Pal.regen;
consumePower(1f);
consumeLiquid(Liquids.hydrogen, 1f / 60f);
consumeItem(Items.phaseFabric).boost();
healPercent = 4f / 60f;
@@ -2536,7 +2535,7 @@ public class Blocks{
drillTime = 160f;
tier = 3;
size = 2;
range = 4;
range = 5;
fogRadius = 3;
researchCost = with(Items.beryllium, 10);
@@ -2666,7 +2665,7 @@ public class Blocks{
//TODO should this be higher?
buildCostMultiplier = 0.75f;
unitCapModifier = 20;
unitCapModifier = 15;
researchCostMultiplier = 0.07f;
}};
@@ -2681,7 +2680,7 @@ public class Blocks{
armor = 10f;
incinerateNonBuildable = true;
unitCapModifier = 20;
unitCapModifier = 15;
researchCostMultipliers.put(Items.silicon, 0.4f);
researchCostMultiplier = 0.14f;
}};
@@ -2698,7 +2697,7 @@ public class Blocks{
armor = 15f;
incinerateNonBuildable = true;
unitCapModifier = 20;
unitCapModifier = 15;
researchCostMultipliers.put(Items.silicon, 0.3f);
researchCostMultiplier = 0.2f;
}};
@@ -4089,7 +4088,7 @@ public class Blocks{
requirements(Category.units, with(Items.silicon, 200, Items.beryllium, 250));
size = 3;
configurable = false;
plans.add(new UnitPlan(UnitTypes.stell, 60f * 60f * 1.5f, with(Items.beryllium, 100f, Items.silicon, 60f)));
plans.add(new UnitPlan(UnitTypes.stell, 60f * 60f * 1f, with(Items.beryllium, 50f, Items.silicon, 70f)));
researchCost = with(Items.beryllium, 200, Items.graphite, 80, Items.silicon, 80);
regionSuffix = "-dark";
fogRadius = 3;
@@ -4480,7 +4479,7 @@ public class Blocks{
}};
canvas = new CanvasBlock("canvas"){{
requirements(Category.logic, with(Items.silicon, 40));
requirements(Category.logic, BuildVisibility.debugOnly, with(Items.silicon, 50));
canvasSize = 12;
padding = 7f / 4f * 2f;

View File

@@ -122,6 +122,7 @@ public class Planets{
allowWaveSimulation = true;
allowSectorInvasion = true;
allowLaunchSchematics = true;
allowLaunchLoadout = true;
ruleSetter = r -> {
//TODO this planet is crux, need to update all maps.
//r.waveTeam = Team.crux;

View File

@@ -87,6 +87,8 @@ public class Planet extends UnlockableContent{
public boolean hasAtmosphere = true;
/** Whether to allow users to specify a custom launch schematic for this map. */
public boolean allowLaunchSchematics = false;
/** Whether to allow users to specify the resources they take to this map. */
public boolean allowLaunchLoadout = false;
/** Whether to allow sectors to simulate waves in the background. */
public boolean allowWaveSimulation = false;
/** Whether to simulate sector invasions from enemy bases. */

View File

@@ -35,7 +35,7 @@ public class LaunchLoadoutDialog extends BaseDialog{
super("@configure");
}
public void show(CoreBlock core, Sector sector, Runnable confirm){
public void show(CoreBlock core, Sector sector, Sector destination, Runnable confirm){
cont.clear();
buttons.clear();
@@ -69,7 +69,20 @@ public class LaunchLoadoutDialog extends BaseDialog{
ItemSeq launches = universe.getLaunchResources();
int capacity = lastCapacity;
if(getMax()){
if(!sector.planet.allowLaunchLoadout){
launches.clear();
//TODO this should be set to a proper loadout based on sector.
if(destination.preset != null){
var rules = destination.preset.generator.map.rules();
for(var stack : rules.loadout){
if(!sector.planet.hiddenItems.contains(stack.item)){
launches.add(stack.item, stack.amount);
}
}
}
universe.updateLaunchResources(launches);
}else if(getMax()){
for(Item item : content.items()){
launches.set(item, Mathf.clamp(sitems.get(item) - launches.get(item), 0, capacity));
}
@@ -78,10 +91,13 @@ public class LaunchLoadoutDialog extends BaseDialog{
}
for(ItemStack s : total){
table.image(s.item.uiIcon).left().size(iconSmall);
int as = schems.get(s.item), al = launches.get(s.item);
String amountStr = (al + as) + "[gray] (" + (al + " + " + as + ")");
if(as + al == 0) continue;
table.image(s.item.uiIcon).left().size(iconSmall);
String amountStr = (al + as) + (sector.planet.allowLaunchLoadout ? "[gray] (" + (al + " + " + as + ")") : "");
table.add(
sitems.has(s.item, s.amount) ? amountStr :
@@ -97,25 +113,27 @@ public class LaunchLoadoutDialog extends BaseDialog{
Runnable rebuildItems = () -> rebuild.get(items);
buttons.button("@resources.max", Icon.add, Styles.togglet, () -> {
setMax(!getMax());
update.run();
rebuildItems.run();
}).checked(b -> getMax());
buttons.button("@resources", Icon.edit, () -> {
ItemSeq stacks = universe.getLaunchResources();
Seq<ItemStack> out = stacks.toSeq();
ItemSeq realItems = sitems.copy();
selected.requirements().each(realItems::remove);
loadout.show(lastCapacity, realItems, out, UnlockableContent::unlocked, out::clear, () -> {}, () -> {
universe.updateLaunchResources(new ItemSeq(out));
if(sector.planet.allowLaunchLoadout){
buttons.button("@resources.max", Icon.add, Styles.togglet, () -> {
setMax(!getMax());
update.run();
rebuildItems.run();
});
}).disabled(b -> getMax());
}).checked(b -> getMax());
buttons.button("@resources", Icon.edit, () -> {
ItemSeq stacks = universe.getLaunchResources();
Seq<ItemStack> out = stacks.toSeq();
ItemSeq realItems = sitems.copy();
selected.requirements().each(realItems::remove);
loadout.show(lastCapacity, realItems, out, UnlockableContent::unlocked, out::clear, () -> {}, () -> {
universe.updateLaunchResources(new ItemSeq(out));
update.run();
rebuildItems.run();
});
}).disabled(b -> getMax());
}
boolean rows = Core.graphics.isPortrait() && mobile;
@@ -138,44 +156,48 @@ public class LaunchLoadoutDialog extends BaseDialog{
cont.add(Core.bundle.format("launch.from", sector.name())).row();
cont.pane(t -> {
int[] i = {0};
if(sector.planet.allowLaunchSchematics){
cont.pane(t -> {
int[] i = {0};
Cons<Schematic> handler = s -> {
if(s.tiles.contains(tile -> !tile.block.supportsEnv(sector.planet.defaultEnv) ||
//make sure block can be built here.
(!state.rules.hiddenBuildItems.isEmpty() && Structs.contains(tile.block.requirements, stack -> state.rules.hiddenBuildItems.contains(stack.item))))){
return;
}
Cons<Schematic> handler = s -> {
if(s.tiles.contains(tile -> !tile.block.supportsEnv(sector.planet.defaultEnv) ||
//make sure block can be built here.
(!sector.planet.hiddenItems.isEmpty() && Structs.contains(tile.block.requirements, stack -> sector.planet.hiddenItems.contains(stack.item))))){
return;
}
t.button(b -> b.add(new SchematicImage(s)), Styles.togglet, () -> {
selected = s;
update.run();
rebuildItems.run();
}).group(group).pad(4).checked(s == selected).size(200f);
t.button(b -> b.add(new SchematicImage(s)), Styles.togglet, () -> {
selected = s;
update.run();
rebuildItems.run();
}).group(group).pad(4).checked(s == selected).size(200f);
if(++i[0] % cols == 0){
t.row();
}
};
if(++i[0] % cols == 0){
t.row();
}
};
if(sector.planet.allowLaunchSchematics || schematics.getDefaultLoadout(core) == null){
for(var entry : schematics.getLoadouts()){
if(entry.key.size <= core.size){
for(Schematic s : entry.value){
handler.get(s);
if(sector.planet.allowLaunchSchematics || schematics.getDefaultLoadout(core) == null){
for(var entry : schematics.getLoadouts()){
if(entry.key.size <= core.size){
for(Schematic s : entry.value){
handler.get(s);
}
}
}
}else{
//only allow launching with the standard loadout schematic
handler.get(schematics.getDefaultLoadout(core));
}
}else{
//only allow launching with the standard loadout schematic
handler.get(schematics.getDefaultLoadout(core));
}
}).growX().scrollX(false);
}).growX().scrollX(false);
cont.row();
cont.label(() -> Core.bundle.format("launch.capacity", lastCapacity)).row();
cont.row();
}
cont.row();
cont.label(() -> Core.bundle.format("launch.capacity", lastCapacity)).row();
cont.row();
cont.pane(items);
cont.row();
cont.add("@sector.missingresources").visible(() -> !valid);

View File

@@ -1159,7 +1159,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
}else{
CoreBlock block = from.info.bestCoreType instanceof CoreBlock b ? b : (CoreBlock)Blocks.coreShard;
loadouts.show(block, from, () -> {
loadouts.show(block, from, sector, () -> {
var schemCore = universe.getLastLoadout().findCore();
from.removeItems(universe.getLastLoadout().requirements());
from.removeItems(universe.getLaunchResources());

View File

@@ -21,7 +21,7 @@ import static mindustry.Vars.*;
public class CanvasBlock extends Block{
public float padding = 0f;
public int canvasSize = 8;
public int[] palette = {0x000000ff, 0x55415f_ff, 0x646964_ff, 0xd77355_ff, 0x508cd7_ff, 0x64b964_ff, 0xe6c86e_ff, 0xdcf5ff_ff};
public int[] palette = {0x634b7dff, 0xc45d9f_ff, 0xe39aac_ff, 0xf0dab1_ff, 0x6461c2_ff, 0x2ba9b4_ff, 0x93d4b5_ff, 0xf0f6e8_ff};
public int bitsPerPixel;
public IntIntMap colorToIndex = new IntIntMap();

View File

@@ -114,6 +114,8 @@ public class MessageBlock extends Block{
return true;
});
a.setMaxLength(maxTextLength);
dialog.cont.row();
dialog.cont.label(() -> a.getText().length() + " / " + maxTextLength).color(Color.lightGray);
dialog.buttons.button("@ok", () -> {
if(!a.getText().equals(message.toString())) configure(a.getText());
dialog.hide();
@@ -123,12 +125,23 @@ public class MessageBlock extends Block{
dialog.hide();
}
});
dialog.closeOnBack();
dialog.show();
}
deselect();
}).size(40f);
}
@Override
public boolean onConfigureBuildTapped(Building other){
if(this == other){
deselect();
return false;
}
return true;
}
@Override
public void handleString(Object value){
message.setLength(0);