This commit is contained in:
Anuken
2022-05-09 11:45:01 -04:00
parent 900e3ec334
commit 3bbb00db9a
2 changed files with 80 additions and 67 deletions

View File

@@ -407,6 +407,9 @@ public class Control implements ApplicationListener, Loadable{
//if there is no base, simulate a new game and place the right loadout at the spawn position //if there is no base, simulate a new game and place the right loadout at the spawn position
if(state.rules.defaultTeam.cores().isEmpty() || hadNoCore){ if(state.rules.defaultTeam.cores().isEmpty() || hadNoCore){
if(sector.planet.clearSectorOnLose){
playNewSector(origin, sector, reloader);
}else{
//no spawn set -> delete the sector save //no spawn set -> delete the sector save
if(sector.info.spawnPosition == 0){ if(sector.info.spawnPosition == 0){
//delete old save //delete old save
@@ -468,10 +471,14 @@ public class Control implements ApplicationListener, Loadable{
Events.fire(new SectorLaunchEvent(sector)); Events.fire(new SectorLaunchEvent(sector));
Events.fire(Trigger.newGame); Events.fire(Trigger.newGame);
}
state.set(State.playing); state.set(State.playing);
reloader.end(); reloader.end();
}
}else{
state.set(State.playing);
reloader.end();
}
}catch(SaveException e){ }catch(SaveException e){
Log.err(e); Log.err(e);
@@ -482,6 +489,12 @@ public class Control implements ApplicationListener, Loadable{
} }
ui.planet.hide(); ui.planet.hide();
}else{ }else{
playNewSector(origin, sector, reloader);
}
});
}
public void playNewSector(@Nullable Sector origin, Sector sector, WorldReloader reloader){
reloader.begin(); reloader.begin();
world.loadSector(sector); world.loadSector(sector);
state.rules.sector = sector; state.rules.sector = sector;
@@ -493,8 +506,7 @@ public class Control implements ApplicationListener, Loadable{
Events.fire(new SectorLaunchEvent(sector)); Events.fire(new SectorLaunchEvent(sector));
Events.fire(Trigger.newGame); Events.fire(Trigger.newGame);
reloader.end(); reloader.end();
} state.set(State.playing);
});
} }
public boolean isHighScore(){ public boolean isHighScore(){

View File

@@ -323,7 +323,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
} }
boolean canSelect(Sector sector){ boolean canSelect(Sector sector){
if(mode == select) return sector.hasBase(); if(mode == select) return sector.hasBase() && launchSector != null && sector.planet == launchSector.planet;
//cannot launch to existing sector w/ accelerator TODO test //cannot launch to existing sector w/ accelerator TODO test
if(mode == planetLaunch) return sector.id == sector.planet.startSector; if(mode == planetLaunch) return sector.id == sector.planet.startSector;
if(sector.hasBase() || sector.id == sector.planet.startSector) return true; if(sector.hasBase() || sector.id == sector.planet.startSector) return true;
@@ -489,6 +489,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
boolean selectable(Planet planet){ boolean selectable(Planet planet){
//TODO what if any sector is selectable? //TODO what if any sector is selectable?
//TODO launch criteria - which planets can be launched to? Where should this be defined? Should planets even be selectable? //TODO launch criteria - which planets can be launched to? Where should this be defined? Should planets even be selectable?
if(mode == select) return planet == state.planet;
if(mode == planetLaunch) return launchSector != null && planet != launchSector.planet && launchSector.planet.launchCandidates.contains(planet); if(mode == planetLaunch) return launchSector != null && planet != launchSector.planet && launchSector.planet.launchCandidates.contains(planet);
return (planet.alwaysUnlocked && planet.isLandable()) || planet.sectors.contains(Sector::hasBase) || debugSelect; return (planet.alwaysUnlocked && planet.isLandable()) || planet.sectors.contains(Sector::hasBase) || debugSelect;
} }