Minor sound tweaks / Limited launches to not-in-progress sectors
This commit is contained in:
@@ -69,25 +69,24 @@ public abstract class PlanetGenerator extends BasicGenerator implements HexMeshe
|
||||
}
|
||||
|
||||
//currently played (selected) sector has all the resources
|
||||
if(selected != null && selected.planet == destination.planet && selected.hasBase() && selected.items().has(tmpItems)){
|
||||
if(selected != null && selected.planet == destination.planet && selected.hasBase() && selected.items().has(tmpItems) && !selected.isAttacked()){
|
||||
return selected;
|
||||
}else{
|
||||
//find the closest sector that has resources (ranked by distance, not item quantity)
|
||||
return destination.planet.sectors.min(s -> s.hasBase() && s.items().has(tmpItems), s -> s.tile.v.dst(destination.tile.v));
|
||||
return destination.planet.sectors.min(s -> s.hasBase() && !s.isAttacked() && s.items().has(tmpItems), s -> s.tile.v.dst(destination.tile.v));
|
||||
}
|
||||
}else{
|
||||
Sector launchSector = selected != null && selected.planet == destination.planet && selected.hasBase() ? selected : null;
|
||||
Sector launchSector = selected != null && selected.planet == destination.planet && selected.hasBase() && !selected.isAttacked() ? selected : null;
|
||||
//directly nearby.
|
||||
if(destination.near().contains(launchSector)) return launchSector;
|
||||
|
||||
Sector launchFrom = launchSector;
|
||||
if(launchFrom == null || destination.preset == null){
|
||||
//TODO pick one with the most resources
|
||||
launchFrom = destination.near().find(Sector::hasBase);
|
||||
launchFrom = destination.near().find(s -> s.hasBase() && !s.isAttacked());
|
||||
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;
|
||||
launchFrom = destination.planet.sectors.min(s -> s.hasBase() && !s.isAttacked(), s -> s.tile.v.dst2(destination.tile.v));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ public class SerpuloPlanetGenerator extends PlanetGenerator{
|
||||
}
|
||||
|
||||
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));
|
||||
return s.hasBase() && !s.isAttacked() && (s.info.bestCoreType.size >= 4 || s.isBeingPlayed() && state.rules.defaultTeam.cores().contains(b -> b.block.size >= 4));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -434,7 +434,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
||||
if(mode == planetLaunch || to.planet.generator == null) return launchSector;
|
||||
|
||||
Sector candidate = to.planet.generator.findLaunchCandidate(to, launchSector);
|
||||
return candidate == null ? launchSector : candidate;
|
||||
return candidate == null && launchSector != null && (mode == planetLaunch || !launchSector.isAttacked()) ? launchSector : candidate;
|
||||
}
|
||||
|
||||
boolean showing(){
|
||||
@@ -1316,12 +1316,16 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
||||
}
|
||||
}
|
||||
|
||||
boolean noCandidate = sector != sector.planet.getStartSector() && !sector.hasBase() && findLauncher(sector) == null;
|
||||
|
||||
stable.button(
|
||||
mode == select ? "@sectors.select" :
|
||||
sector.isBeingPlayed() ? "@sectors.resume" :
|
||||
sector.hasBase() ? "@sectors.go" :
|
||||
locked ? "@locked" : "@sectors.launch",
|
||||
locked ? Icon.lock : Icon.play, this::playSelected).growX().height(54f).minWidth(170f).padTop(4).disabled(locked);
|
||||
locked ? "@locked" :
|
||||
noCandidate ? "@sectors.nolaunchcandidate" :
|
||||
"@sectors.launch",
|
||||
locked ? Icon.lock : Icon.play, this::playSelected).growX().height(54f).minWidth(170f).padTop(4).disabled(locked || noCandidate);
|
||||
}
|
||||
|
||||
stable.pack();
|
||||
|
||||
Reference in New Issue
Block a user