Fixed #11203
This commit is contained in:
@@ -418,6 +418,8 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(sector.planet.generator == null) return false;
|
||||
|
||||
if(sector.hasBase() || sector.id == sector.planet.startSector) return true;
|
||||
//preset sectors can only be selected once unlocked
|
||||
if(sector.preset != null && sector.preset.requireUnlock){
|
||||
@@ -425,33 +427,13 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
||||
return sector.preset.unlocked() || node == null || node.parent == null || (node.parent.content.unlocked() && (!(node.parent.content instanceof SectorPreset preset) || preset.sector.hasBase()));
|
||||
}
|
||||
|
||||
return sector.planet.generator != null ?
|
||||
//use planet impl when possible
|
||||
(mode == planetLaunch ? sector.planet.generator.allowAcceleratorLanding(sector) : sector.planet.generator.allowLanding(sector)) :
|
||||
mode == planetLaunch || sector.hasBase() || sector.near().contains(Sector::hasBase); //near an occupied sector
|
||||
return mode == planetLaunch ? sector.planet.generator.allowAcceleratorLanding(sector) : sector.planet.generator.allowLanding(sector);
|
||||
}
|
||||
|
||||
Sector findLauncher(Sector to){
|
||||
if(mode == planetLaunch){
|
||||
return launchSector;
|
||||
}
|
||||
if(mode == planetLaunch || to.planet.generator == null) return launchSector;
|
||||
|
||||
Sector launchSector = this.launchSector != null && this.launchSector.planet == to.planet && this.launchSector.hasBase() ? this.launchSector : null;
|
||||
//directly nearby.
|
||||
if(to.near().contains(launchSector)) return launchSector;
|
||||
|
||||
Sector launchFrom = launchSector;
|
||||
if(launchFrom == null || (to.preset == null && !to.near().contains(launchSector))){
|
||||
//TODO pick one with the most resources
|
||||
launchFrom = to.near().find(Sector::hasBase);
|
||||
if(launchFrom == null && to.preset != null){
|
||||
if(launchSector != null) return launchSector;
|
||||
launchFrom = state.planet.sectors.min(s -> !s.hasBase() ? Float.MAX_VALUE : s.tile.v.dst2(to.tile.v));
|
||||
if(!launchFrom.hasBase()) launchFrom = null;
|
||||
}
|
||||
}
|
||||
|
||||
return launchFrom;
|
||||
return to.planet.generator.findLaunchCandidate(to, launchSector);
|
||||
}
|
||||
|
||||
boolean showing(){
|
||||
@@ -484,7 +466,6 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
||||
}
|
||||
|
||||
Sector hoverOrSelect = hovered != null ? hovered : selected;
|
||||
Sector launchFrom = hoverOrSelect != null && !hoverOrSelect.hasBase() ? findLauncher(hoverOrSelect) : null;
|
||||
|
||||
Sector current = Vars.state.getSector() != null && Vars.state.getSector().isBeingPlayed() && Vars.state.getSector().planet == state.planet ? Vars.state.getSector() : null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user