Options for SectorPreset overriding plant launch fields. (#7478)

* Preset overriding loadouts

* a

* You know I should really learn what this actually does
This commit is contained in:
MEEPofFaith
2022-09-01 17:47:53 -07:00
committed by GitHub
parent b854b0ca22
commit e9d3adfef3
4 changed files with 20 additions and 6 deletions

View File

@@ -80,6 +80,14 @@ public class Sector{
return hasBase() || (preset != null && preset.alwaysUnlocked); return hasBase() || (preset != null && preset.alwaysUnlocked);
} }
public boolean allowLaunchSchematics(){
return (preset != null && preset.overrideLaunchDefaults) ? preset.allowLaunchSchematics : planet.allowLaunchSchematics;
}
public boolean allowLaunchLoadout(){
return (preset != null && preset.overrideLaunchDefaults) ? preset.allowLaunchLoadout : planet.allowLaunchLoadout;
}
public void saveInfo(){ public void saveInfo(){
Core.settings.putJson(planet.name + "-s-" + id + "-info", info); Core.settings.putJson(planet.name + "-s-" + id + "-info", info);
} }

View File

@@ -18,6 +18,12 @@ public class SectorPreset extends UnlockableContent{
public float startWaveTimeMultiplier = 2f; public float startWaveTimeMultiplier = 2f;
public boolean addStartingItems = false; public boolean addStartingItems = false;
public boolean showSectorLandInfo = true; public boolean showSectorLandInfo = true;
/** If true, uses this sector's launch fields instead */
public boolean overrideLaunchDefaults = false;
/** 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;
/** If true, switches to attack mode after waves end. */ /** If true, switches to attack mode after waves end. */
public boolean attackAfterWaves = false; public boolean attackAfterWaves = false;

View File

@@ -55,7 +55,7 @@ public class LaunchLoadoutDialog extends BaseDialog{
int capacity = lastCapacity; int capacity = lastCapacity;
if(!sector.planet.allowLaunchLoadout){ if(!destination.allowLaunchLoadout()){
resources.clear(); resources.clear();
//TODO this should be set to a proper loadout based on sector. //TODO this should be set to a proper loadout based on sector.
if(destination.preset != null){ if(destination.preset != null){
@@ -95,7 +95,7 @@ public class LaunchLoadoutDialog extends BaseDialog{
table.image(s.item.uiIcon).left().size(iconSmall); table.image(s.item.uiIcon).left().size(iconSmall);
String amountStr = (al + as) + (sector.planet.allowLaunchLoadout ? "[gray] (" + (al + " + " + as + ")") : ""); String amountStr = (al + as) + (destination.allowLaunchLoadout() ? "[gray] (" + (al + " + " + as + ")") : "");
table.add( table.add(
sitems.has(s.item, s.amount) ? amountStr : sitems.has(s.item, s.amount) ? amountStr :
@@ -111,7 +111,7 @@ public class LaunchLoadoutDialog extends BaseDialog{
Runnable rebuildItems = () -> rebuild.get(items); Runnable rebuildItems = () -> rebuild.get(items);
if(sector.planet.allowLaunchLoadout){ if(destination.allowLaunchLoadout()){
buttons.button("@resources.max", Icon.add, Styles.togglet, () -> { buttons.button("@resources.max", Icon.add, Styles.togglet, () -> {
setMax(!getMax()); setMax(!getMax());
update.run(); update.run();
@@ -154,7 +154,7 @@ public class LaunchLoadoutDialog extends BaseDialog{
cont.add(Core.bundle.format("launch.from", sector.name())).row(); cont.add(Core.bundle.format("launch.from", sector.name())).row();
if(sector.planet.allowLaunchSchematics){ if(destination.allowLaunchSchematics()){
cont.pane(t -> { cont.pane(t -> {
int[] i = {0}; int[] i = {0};
@@ -176,7 +176,7 @@ public class LaunchLoadoutDialog extends BaseDialog{
} }
}; };
if(sector.planet.allowLaunchSchematics || schematics.getDefaultLoadout(core) == null){ if(destination.allowLaunchSchematics() || schematics.getDefaultLoadout(core) == null){
for(var entry : schematics.getLoadouts()){ for(var entry : schematics.getLoadouts()){
if(entry.key.size <= core.size){ if(entry.key.size <= core.size){
for(Schematic s : entry.value){ for(Schematic s : entry.value){

View File

@@ -1160,7 +1160,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
//free launch. //free launch.
control.playSector(sector); control.playSector(sector);
}else{ }else{
CoreBlock block = from.planet.allowLaunchSchematics ? (from.info.bestCoreType instanceof CoreBlock b ? b : (CoreBlock)from.planet.defaultCore) : (CoreBlock)from.planet.defaultCore; CoreBlock block = sector.allowLaunchSchematics() ? (from.info.bestCoreType instanceof CoreBlock b ? b : (CoreBlock)from.planet.defaultCore) : (CoreBlock)from.planet.defaultCore;
loadouts.show(block, from, sector, () -> { loadouts.show(block, from, sector, () -> {
var schemCore = universe.getLastLoadout().findCore(); var schemCore = universe.getLastLoadout().findCore();