Fixed waves appearing on Erekir

This commit is contained in:
Anuken
2022-03-02 18:54:21 -05:00
parent d9ced82352
commit 315c273de3
12 changed files with 64 additions and 44 deletions

Binary file not shown.

View File

@@ -68,7 +68,7 @@ public class Planets{
r.attributes.set(Attribute.heat, 0.8f); r.attributes.set(Attribute.heat, 0.8f);
r.showSpawns = true; r.showSpawns = true;
r.fog = true; r.fog = true;
r.staticFog = false; //r.staticFog = false;
}; };
unlockedOnLand.add(Blocks.coreBastion); unlockedOnLand.add(Blocks.coreBastion);

View File

@@ -111,17 +111,14 @@ public class SectorPresets{
onset = new SectorPreset("onset", erekir, 10){{ onset = new SectorPreset("onset", erekir, 10){{
addStartingItems = true; addStartingItems = true;
alwaysUnlocked = true; alwaysUnlocked = true;
captureWave = 3;
difficulty = 1; difficulty = 1;
}}; }};
two = new SectorPreset("aware", erekir, 88){{ two = new SectorPreset("aware", erekir, 88){{
captureWave = 5;
difficulty = 3; difficulty = 3;
}}; }};
three = new SectorPreset("three", erekir, 36){{ three = new SectorPreset("three", erekir, 36){{
captureWave = 8;
difficulty = 5; difficulty = 5;
}}; }};

View File

@@ -62,42 +62,45 @@ public class Logic implements ApplicationListener{
if(state.isCampaign()){ if(state.isCampaign()){
state.rules.coreIncinerates = true; state.rules.coreIncinerates = true;
SectorInfo info = state.rules.sector.info; //fresh map has no sector info
info.write(); if(!e.isMap){
SectorInfo info = state.rules.sector.info;
info.write();
//only simulate waves if the planet allows it //only simulate waves if the planet allows it
if(state.rules.sector.planet.allowWaveSimulation){ if(state.rules.sector.planet.allowWaveSimulation){
//how much wave time has passed //how much wave time has passed
int wavesPassed = info.wavesPassed; int wavesPassed = info.wavesPassed;
//wave has passed, remove all enemies, they are assumed to be dead //wave has passed, remove all enemies, they are assumed to be dead
if(wavesPassed > 0){ if(wavesPassed > 0){
Groups.unit.each(u -> { Groups.unit.each(u -> {
if(u.team == state.rules.waveTeam){ if(u.team == state.rules.waveTeam){
u.remove(); u.remove();
} }
}); });
}
//simulate passing of waves
if(wavesPassed > 0){
//simulate wave counter moving forward
state.wave += wavesPassed;
state.wavetime = state.rules.waveSpacing;
SectorDamage.applyCalculatedDamage();
}
} }
//simulate passing of waves state.getSector().planet.applyRules(state.rules);
if(wavesPassed > 0){
//simulate wave counter moving forward
state.wave += wavesPassed;
state.wavetime = state.rules.waveSpacing;
SectorDamage.applyCalculatedDamage(); //reset values
} info.damage = 0f;
info.wavesPassed = 0;
info.hasCore = true;
info.secondsPassed = 0;
state.rules.sector.saveInfo();
} }
state.getSector().planet.ruleSetter.get(state.rules);
//reset values
info.damage = 0f;
info.wavesPassed = 0;
info.hasCore = true;
info.secondsPassed = 0;
state.rules.sector.saveInfo();
} }
}); });

View File

@@ -311,7 +311,7 @@ public class World{
state.rules.env = sector.planet.defaultEnv; state.rules.env = sector.planet.defaultEnv;
state.rules.hiddenBuildItems.clear(); state.rules.hiddenBuildItems.clear();
state.rules.hiddenBuildItems.addAll(sector.planet.hiddenItems); state.rules.hiddenBuildItems.addAll(sector.planet.hiddenItems);
sector.planet.ruleSetter.get(state.rules); sector.planet.applyRules(state.rules);
sector.info.resources = content.toSeq(); sector.info.resources = content.toSeq();
sector.info.resources.sort(Structs.comps(Structs.comparing(Content::getContentType), Structs.comparingInt(c -> c.id))); sector.info.resources.sort(Structs.comps(Structs.comparing(Content::getContentType), Structs.comparingInt(c -> c.id)));
sector.saveInfo(); sector.saveInfo();

View File

@@ -51,7 +51,6 @@ public class EventType{
public static class MapMakeEvent{} public static class MapMakeEvent{}
public static class MapPublishEvent{} public static class MapPublishEvent{}
public static class SaveWriteEvent{} public static class SaveWriteEvent{}
public static class SaveLoadEvent{}
public static class ClientCreateEvent{} public static class ClientCreateEvent{}
public static class ServerLoadEvent{} public static class ServerLoadEvent{}
public static class DisposeEvent{} public static class DisposeEvent{}
@@ -78,6 +77,14 @@ public class EventType{
/** Called when a game begins and the world is loaded. */ /** Called when a game begins and the world is loaded. */
public static class WorldLoadEvent{} public static class WorldLoadEvent{}
public static class SaveLoadEvent{
public final boolean isMap;
public SaveLoadEvent(boolean isMap){
this.isMap = isMap;
}
}
/** Called when a sector is destroyed by waves when you're not there. */ /** Called when a sector is destroyed by waves when you're not there. */
public static class SectorLoseEvent{ public static class SectorLoseEvent{
public final Sector sector; public final Sector sector;

View File

@@ -165,7 +165,7 @@ public class SaveIO{
if(ver == null) throw new IOException("Unknown save version: " + version + ". Are you trying to load a save from a newer version?"); if(ver == null) throw new IOException("Unknown save version: " + version + ". Are you trying to load a save from a newer version?");
ver.read(stream, counter, context); ver.read(stream, counter, context);
Events.fire(new SaveLoadEvent()); Events.fire(new SaveLoadEvent(context.isMap()));
}catch(Throwable e){ }catch(Throwable e){
throw new SaveException(e); throw new SaveException(e);
}finally{ }finally{

View File

@@ -157,7 +157,7 @@ public abstract class SaveVersion extends SaveFileReader{
if(context.getSector() != null){ if(context.getSector() != null){
state.rules.sector = context.getSector(); state.rules.sector = context.getSector();
if(state.rules.sector != null){ if(state.rules.sector != null){
state.rules.sector.planet.ruleSetter.get(state.rules); state.rules.sector.planet.applyRules(state.rules);
} }
} }

View File

@@ -48,6 +48,11 @@ public class FileMapGenerator implements WorldGenerator{
applyFilters(); applyFilters();
//no super.end(), don't call world load event twice //no super.end(), don't call world load event twice
} }
@Override
public boolean isMap(){
return true;
}
}); });
world.setGenerating(true); world.setGenerating(true);

View File

@@ -153,6 +153,14 @@ public class Planet extends UnlockableContent{
} }
} }
public void applyRules(Rules rules){
ruleSetter.get(rules);
rules.env = defaultEnv;
rules.hiddenBuildItems.clear();
rules.hiddenBuildItems.addAll(hiddenItems);
}
public @Nullable Sector getLastSector(){ public @Nullable Sector getLastSector(){
if(sectors.isEmpty()){ if(sectors.isEmpty()){
return null; return null;

View File

@@ -224,12 +224,7 @@ public class CustomRulesDialog extends BaseDialog{
//TODO dynamic selection of planets //TODO dynamic selection of planets
for(Planet planet : new Planet[]{Planets.serpulo, Planets.erekir}){ for(Planet planet : new Planet[]{Planets.serpulo, Planets.erekir}){
t.button(planet.localizedName, style, () -> { t.button(planet.localizedName, style, () -> planet.applyRules(rules)).group(group).checked(rules.env == planet.defaultEnv);
rules.env = planet.defaultEnv;
rules.hiddenBuildItems.clear();
rules.hiddenBuildItems.addAll(planet.hiddenItems);
planet.ruleSetter.get(rules);
}).group(group).checked(rules.env == planet.defaultEnv);
} }
}).left().fill(false).expand(false, false).row(); }).left().fill(false).expand(false, false).row();

View File

@@ -30,4 +30,9 @@ public interface WorldContext{
return null; return null;
} }
/** @return whether the SaveLoadEvent fired after the end should be counted as a new map load. */
default boolean isMap(){
return false;
}
} }