From 32b9ff9f5ded85d5fd1cd0a8a2e96383a6346071 Mon Sep 17 00:00:00 2001 From: Anuken Date: Mon, 29 Sep 2025 08:47:59 -0400 Subject: [PATCH] Added difficulty modifier for clearing sectors upon loss --- core/assets/bundles/bundle.properties | 2 ++ core/src/mindustry/core/Control.java | 7 +++++-- core/src/mindustry/game/CampaignRules.java | 1 + core/src/mindustry/ui/dialogs/CampaignRulesDialog.java | 4 ++++ tests/src/test/java/ApplicationTests.java | 6 ++++-- tests/src/test/java/ModTestAllure.java | 2 +- 6 files changed, 17 insertions(+), 5 deletions(-) diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index e0684e5ebe..cdf0a74b57 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -1450,6 +1450,8 @@ rules.buildaitier = Builder AI Tier rules.rtsai = RTS AI rules.rtsai.campaign = RTS Attack AI rules.rtsai.campaign.info = In attack maps, makes units group up and attack player bases in a more intelligent manner. +rules.clearsectoronloss = Clear Sector On Loss +rules.clearsectoronloss.info = When the sector is lost, player buildings from the previous attempt will not carry over. rules.rtsminsquadsize = Min Squad Size rules.rtsmaxsquadsize = Max Squad Size rules.rtsminattackweight = Min Attack Weight diff --git a/core/src/mindustry/core/Control.java b/core/src/mindustry/core/Control.java index 840f7f2e6e..252327a0f9 100644 --- a/core/src/mindustry/core/Control.java +++ b/core/src/mindustry/core/Control.java @@ -420,7 +420,10 @@ public class Control implements ApplicationListener, Loadable{ ui.planet.hide(); SaveSlot slot = sector.save; sector.planet.setLastSector(sector); - if(slot != null && !clearSectors && (!sector.planet.clearSectorOnLose || sector.info.hasCore)){ + + boolean clearSave = sector.planet.clearSectorOnLose || sector.planet.campaignRules.clearSectorOnLose; + + if(slot != null && !clearSectors && (!clearSave || sector.info.hasCore)){ try{ boolean hadNoCore = !sector.info.hasCore; @@ -435,7 +438,7 @@ public class Control implements ApplicationListener, Loadable{ if(state.rules.defaultTeam.cores().isEmpty() || hadNoCore){ //don't carry over the spawn position and plans if the sector preset name or map size changed - if(sector.planet.clearSectorOnLose || sector.info.spawnPosition == 0 || !sector.info.sectorDataMatches(sector)){ + if(clearSave || sector.info.spawnPosition == 0 || !sector.info.sectorDataMatches(sector)){ playNewSector(origin, sector, reloader); }else{ int spawnPos = sector.info.spawnPosition; diff --git a/core/src/mindustry/game/CampaignRules.java b/core/src/mindustry/game/CampaignRules.java index 2761f3c842..fa1d71ee16 100644 --- a/core/src/mindustry/game/CampaignRules.java +++ b/core/src/mindustry/game/CampaignRules.java @@ -12,6 +12,7 @@ public class CampaignRules{ public boolean randomWaveAI; public boolean legacyLaunchPads; public boolean rtsAI; + public boolean clearSectorOnLose; public void apply(Planet planet, Rules rules){ rules.staticFog = rules.fog = fog; diff --git a/core/src/mindustry/ui/dialogs/CampaignRulesDialog.java b/core/src/mindustry/ui/dialogs/CampaignRulesDialog.java index e9e6e868e7..bcbc4eebe8 100644 --- a/core/src/mindustry/ui/dialogs/CampaignRulesDialog.java +++ b/core/src/mindustry/ui/dialogs/CampaignRulesDialog.java @@ -74,6 +74,10 @@ public class CampaignRulesDialog extends BaseDialog{ check("@rules.rtsai.campaign", b -> rules.rtsAI = b, () -> rules.rtsAI); } + if(!planet.clearSectorOnLose){ + check("@rules.clearsectoronloss", b -> rules.clearSectorOnLose = b, () -> rules.clearSectorOnLose); + } + //TODO: this is intentionally hidden until the new mechanics have been well-tested. I don't want people immediately switching to the old mechanics if(planet.allowLegacyLaunchPads){ // check("@rules.legacylaunchpads", b -> rules.legacyLaunchPads = b, () -> rules.legacyLaunchPads); diff --git a/tests/src/test/java/ApplicationTests.java b/tests/src/test/java/ApplicationTests.java index 269eedff7c..a3eb36f283 100644 --- a/tests/src/test/java/ApplicationTests.java +++ b/tests/src/test/java/ApplicationTests.java @@ -603,13 +603,15 @@ public class ApplicationTests{ entities.each(Building::updateProximity); + final int iterations = 100_000; + //warmup - for(int i = 0; i < 100000; i++){ + for(int i = 0; i < iterations; i++){ entities.each(Building::update); } Time.mark(); - for(int i = 0; i < 200000; i++){ + for(int i = 0; i < iterations*2; i++){ entities.each(Building::update); } Log.info(Time.elapsed() + "ms to process " + itemsa[0] + " items"); diff --git a/tests/src/test/java/ModTestAllure.java b/tests/src/test/java/ModTestAllure.java index 9d1db792dc..06f902d09b 100644 --- a/tests/src/test/java/ModTestAllure.java +++ b/tests/src/test/java/ModTestAllure.java @@ -17,7 +17,7 @@ public class ModTestAllure extends GenericModTest{ @Test public void begin(){ - grabMod("https://github.com/LixieWulf/Allure/archive/4150f74db1ea6058dc090959cf0fe5dc9d239e37.zip"); + grabMod("https://github.com/LixieWulf/Allure/archive/7dff39df9b07719315a8379a88542fa0fe80fd30.zip"); checkExistence("allure"); UnitType type = Vars.content.unit("allure-0b11-exodus");