Many various campaign mechanic changes

This commit is contained in:
Anuken
2020-07-07 21:13:03 -04:00
parent b95206cf87
commit 26e70fa585
11 changed files with 220 additions and 31 deletions

View File

@@ -59,6 +59,15 @@ public class EventType{
/** Called when a game begins and the world is loaded. */
public static class WorldLoadEvent{}
/** Called when a sector is destroyed by waves when you're not there. */
public static class SectorLoseEvent{
public final Sector sector;
public SectorLoseEvent(Sector sector){
this.sector = sector;
}
}
public static class LaunchItemEvent{
public final ItemStack stack;

View File

@@ -23,6 +23,13 @@ public class Universe{
public Universe(){
load();
//update base coverage on capture
Events.on(SectorCaptureEvent.class, e -> {
if(state.isCampaign()){
state.getSector().planet.updateBaseCoverage();
}
});
}
/** Update regardless of whether the player is in the campaign. */
@@ -131,6 +138,17 @@ public class Universe{
//increment seconds passed for this sector by the time that just passed with this turn
if(!sector.isBeingPlayed()){
sector.setSecondsPassed(sector.getSecondsPassed() + actuallyPassed);
//check if the sector has been attacked too many times...
if(sector.hasBase() && sector.getSecondsPassed() * 60f > turnDuration * sectorDestructionTurns){
//fire event for losing the sector
Events.fire(new SectorLoseEvent(sector));
//if so, just delete the save for now. it's lost.
//TODO don't delete it later maybe
sector.save.delete();
sector.save = null;
}
}
//reset time spent to 0