Fixed #11203
This commit is contained in:
@@ -54,6 +54,25 @@ public abstract class PlanetGenerator extends BasicGenerator implements HexMeshe
|
||||
return sector.planet.allowLaunchToNumbered && (sector.hasBase() || sector.near().contains(Sector::hasBase));
|
||||
}
|
||||
|
||||
public Sector findLaunchCandidate(Sector destination, Sector selected){
|
||||
Sector launchSector = selected != null && selected.planet == destination.planet && selected.hasBase() ? selected: null;
|
||||
//directly nearby.
|
||||
if(destination.near().contains(launchSector)) return launchSector;
|
||||
|
||||
Sector launchFrom = launchSector;
|
||||
if(launchFrom == null || (destination.preset == null && !destination.near().contains(launchSector))){
|
||||
//TODO pick one with the most resources
|
||||
launchFrom = destination.near().find(Sector::hasBase);
|
||||
if(launchFrom == null && destination.preset != null){
|
||||
if(launchSector != null) return launchSector;
|
||||
launchFrom = destination.planet.sectors.min(s -> !s.hasBase() ? Float.MAX_VALUE : s.tile.v.dst2(destination.tile.v));
|
||||
if(!launchFrom.hasBase()) launchFrom = null;
|
||||
}
|
||||
}
|
||||
|
||||
return launchFrom;
|
||||
}
|
||||
|
||||
/** @return whether to allow landing on the specified procedural sector */
|
||||
public boolean allowAcceleratorLanding(Sector sector){
|
||||
return sector.planet.allowLaunchToNumbered;
|
||||
|
||||
@@ -87,10 +87,26 @@ public class SerpuloPlanetGenerator extends PlanetGenerator{
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean allowNumberedLaunch(Sector s){
|
||||
return s.hasBase() && (s.info.bestCoreType.size >= 4 || s.isBeingPlayed() && state.rules.defaultTeam.cores().contains(b -> b.block.size >= 4));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowLanding(Sector sector){
|
||||
return sector.planet.allowLaunchToNumbered && (sector.hasBase() || sector.near().contains(s -> s.hasBase() &&
|
||||
(s.info.bestCoreType.size >= 4 || s.isBeingPlayed() && state.rules.defaultTeam.cores().contains(b -> b.block.size >= 4))));
|
||||
return sector.planet.allowLaunchToNumbered && (sector.hasBase() || sector.near().contains(this::allowNumberedLaunch));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Sector findLaunchCandidate(Sector destination, Sector selected){
|
||||
if(destination.preset == null || !destination.preset.requireUnlock){
|
||||
if(selected != null && selected.isNear(destination) && allowNumberedLaunch(selected)){
|
||||
return selected;
|
||||
}else{
|
||||
return destination.near().find(this::allowNumberedLaunch);
|
||||
}
|
||||
}else{
|
||||
return super.findLaunchCandidate(destination, selected);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user