diff --git a/core/assets/maps/aware.msav b/core/assets/maps/aware.msav index 3acacd3bbc..ed5728d63f 100644 Binary files a/core/assets/maps/aware.msav and b/core/assets/maps/aware.msav differ diff --git a/core/src/mindustry/content/Planets.java b/core/src/mindustry/content/Planets.java index 421bbda32e..006d5f66c2 100644 --- a/core/src/mindustry/content/Planets.java +++ b/core/src/mindustry/content/Planets.java @@ -68,7 +68,7 @@ public class Planets{ r.attributes.set(Attribute.heat, 0.8f); r.showSpawns = true; r.fog = true; - r.staticFog = false; + //r.staticFog = false; }; unlockedOnLand.add(Blocks.coreBastion); diff --git a/core/src/mindustry/content/SectorPresets.java b/core/src/mindustry/content/SectorPresets.java index ff5ceb258e..b1ae278159 100644 --- a/core/src/mindustry/content/SectorPresets.java +++ b/core/src/mindustry/content/SectorPresets.java @@ -111,17 +111,14 @@ public class SectorPresets{ onset = new SectorPreset("onset", erekir, 10){{ addStartingItems = true; alwaysUnlocked = true; - captureWave = 3; difficulty = 1; }}; two = new SectorPreset("aware", erekir, 88){{ - captureWave = 5; difficulty = 3; }}; three = new SectorPreset("three", erekir, 36){{ - captureWave = 8; difficulty = 5; }}; diff --git a/core/src/mindustry/core/Logic.java b/core/src/mindustry/core/Logic.java index 25c5ed2137..3dc0c5e05b 100644 --- a/core/src/mindustry/core/Logic.java +++ b/core/src/mindustry/core/Logic.java @@ -62,42 +62,45 @@ public class Logic implements ApplicationListener{ if(state.isCampaign()){ state.rules.coreIncinerates = true; - SectorInfo info = state.rules.sector.info; - info.write(); + //fresh map has no sector info + if(!e.isMap){ + SectorInfo info = state.rules.sector.info; + info.write(); - //only simulate waves if the planet allows it - if(state.rules.sector.planet.allowWaveSimulation){ - //how much wave time has passed - int wavesPassed = info.wavesPassed; + //only simulate waves if the planet allows it + if(state.rules.sector.planet.allowWaveSimulation){ + //how much wave time has passed + int wavesPassed = info.wavesPassed; - //wave has passed, remove all enemies, they are assumed to be dead - if(wavesPassed > 0){ - Groups.unit.each(u -> { - if(u.team == state.rules.waveTeam){ - u.remove(); - } - }); + //wave has passed, remove all enemies, they are assumed to be dead + if(wavesPassed > 0){ + Groups.unit.each(u -> { + if(u.team == state.rules.waveTeam){ + 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 - if(wavesPassed > 0){ - //simulate wave counter moving forward - state.wave += wavesPassed; - state.wavetime = state.rules.waveSpacing; + state.getSector().planet.applyRules(state.rules); - 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(); } }); diff --git a/core/src/mindustry/core/World.java b/core/src/mindustry/core/World.java index 21fd44951c..ef8e6478d5 100644 --- a/core/src/mindustry/core/World.java +++ b/core/src/mindustry/core/World.java @@ -311,7 +311,7 @@ public class World{ state.rules.env = sector.planet.defaultEnv; state.rules.hiddenBuildItems.clear(); 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.sort(Structs.comps(Structs.comparing(Content::getContentType), Structs.comparingInt(c -> c.id))); sector.saveInfo(); diff --git a/core/src/mindustry/game/EventType.java b/core/src/mindustry/game/EventType.java index 6537cb7696..b30f9d3df8 100644 --- a/core/src/mindustry/game/EventType.java +++ b/core/src/mindustry/game/EventType.java @@ -51,7 +51,6 @@ public class EventType{ public static class MapMakeEvent{} public static class MapPublishEvent{} public static class SaveWriteEvent{} - public static class SaveLoadEvent{} public static class ClientCreateEvent{} public static class ServerLoadEvent{} public static class DisposeEvent{} @@ -78,6 +77,14 @@ public class EventType{ /** Called when a game begins and the world is loaded. */ 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. */ public static class SectorLoseEvent{ public final Sector sector; diff --git a/core/src/mindustry/io/SaveIO.java b/core/src/mindustry/io/SaveIO.java index d23f360c37..41888cbb41 100644 --- a/core/src/mindustry/io/SaveIO.java +++ b/core/src/mindustry/io/SaveIO.java @@ -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?"); ver.read(stream, counter, context); - Events.fire(new SaveLoadEvent()); + Events.fire(new SaveLoadEvent(context.isMap())); }catch(Throwable e){ throw new SaveException(e); }finally{ diff --git a/core/src/mindustry/io/SaveVersion.java b/core/src/mindustry/io/SaveVersion.java index 0e7a7bf0ec..e0cf4fbabf 100644 --- a/core/src/mindustry/io/SaveVersion.java +++ b/core/src/mindustry/io/SaveVersion.java @@ -157,7 +157,7 @@ public abstract class SaveVersion extends SaveFileReader{ if(context.getSector() != null){ state.rules.sector = context.getSector(); if(state.rules.sector != null){ - state.rules.sector.planet.ruleSetter.get(state.rules); + state.rules.sector.planet.applyRules(state.rules); } } diff --git a/core/src/mindustry/maps/generators/FileMapGenerator.java b/core/src/mindustry/maps/generators/FileMapGenerator.java index a310a22495..ce6d561f83 100644 --- a/core/src/mindustry/maps/generators/FileMapGenerator.java +++ b/core/src/mindustry/maps/generators/FileMapGenerator.java @@ -48,6 +48,11 @@ public class FileMapGenerator implements WorldGenerator{ applyFilters(); //no super.end(), don't call world load event twice } + + @Override + public boolean isMap(){ + return true; + } }); world.setGenerating(true); diff --git a/core/src/mindustry/type/Planet.java b/core/src/mindustry/type/Planet.java index 5f8896d3ff..3537fe6012 100644 --- a/core/src/mindustry/type/Planet.java +++ b/core/src/mindustry/type/Planet.java @@ -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(){ if(sectors.isEmpty()){ return null; diff --git a/core/src/mindustry/ui/dialogs/CustomRulesDialog.java b/core/src/mindustry/ui/dialogs/CustomRulesDialog.java index f5f5cb4049..902e78eeb4 100644 --- a/core/src/mindustry/ui/dialogs/CustomRulesDialog.java +++ b/core/src/mindustry/ui/dialogs/CustomRulesDialog.java @@ -224,12 +224,7 @@ public class CustomRulesDialog extends BaseDialog{ //TODO dynamic selection of planets for(Planet planet : new Planet[]{Planets.serpulo, Planets.erekir}){ - t.button(planet.localizedName, style, () -> { - rules.env = planet.defaultEnv; - rules.hiddenBuildItems.clear(); - rules.hiddenBuildItems.addAll(planet.hiddenItems); - planet.ruleSetter.get(rules); - }).group(group).checked(rules.env == planet.defaultEnv); + t.button(planet.localizedName, style, () -> planet.applyRules(rules)).group(group).checked(rules.env == planet.defaultEnv); } }).left().fill(false).expand(false, false).row(); diff --git a/core/src/mindustry/world/WorldContext.java b/core/src/mindustry/world/WorldContext.java index 49d6ec9014..f0a2fc4b63 100644 --- a/core/src/mindustry/world/WorldContext.java +++ b/core/src/mindustry/world/WorldContext.java @@ -30,4 +30,9 @@ public interface WorldContext{ return null; } + /** @return whether the SaveLoadEvent fired after the end should be counted as a new map load. */ + default boolean isMap(){ + return false; + } + }