diff --git a/core/src/mindustry/game/Universe.java b/core/src/mindustry/game/Universe.java index 4aa77d8be7..7466fb846e 100644 --- a/core/src/mindustry/game/Universe.java +++ b/core/src/mindustry/game/Universe.java @@ -253,7 +253,7 @@ public void runTurn(){ //queue random invasions if(!sector.isAttacked() && sector.planet.allowSectorInvasion && sector.info.minutesCaptured > invasionGracePeriod && sector.info.hasSpawns){ - int count = sector.near().count(s -> s.hasEnemyBase() && !s.hasBase()); + int count = sector.nearbyEnemyBases(); //invasion chance depends on # of nearby bases if(count > 0 && Mathf.chance(baseInvasionChance * (0.8f + (count - 1) * 0.3f))){ diff --git a/core/src/mindustry/graphics/OverlayRenderer.java b/core/src/mindustry/graphics/OverlayRenderer.java index 22b26cd0ef..396c9c26e9 100644 --- a/core/src/mindustry/graphics/OverlayRenderer.java +++ b/core/src/mindustry/graphics/OverlayRenderer.java @@ -235,14 +235,14 @@ public void drawTop(){ Lines.stroke(2f); Draw.color(Color.gray, Color.lightGray, Mathf.absin(Time.time, 8f, 1f)); - if(state.hasSpawns()){ + if(state.hasSpawns() || state.hasSector() && state.getSector().vulnerable()){ Core.camera.bounds(Tmp.r1); boolean isBuilding = input.isBreaking() || input.isPlacing() || input.selectPlans.any() || Core.settings.getBool("alwaysshowdropzone", true); - int r = state.rules.dropZoneRadius; + float r = state.rules.dropZoneRadius; for(Tile tile : spawner.getSpawns()){ if(tile.within(player.x, player.y, r + spawnerMargin) || (Tmp.r1.overlaps(tile.getX() - r, tile.getY() - r, r * 2, r * 2) && isBuilding)){ - Draw.alpha(building ? 1 : Mathf.clamp(1f - (player.dst(tile) - state.rules.dropZoneRadius) / spawnerMargin)); - Lines.dashCircle(tile.worldx(), tile.worldy(), state.rules.dropZoneRadius); + Draw.alpha(!state.hasSpawns() ? 0.3 : isBuilding ? 1 : Mathf.clamp(1f - (player.dst(tile) - r) / spawnerMargin)); + Lines.dashCircle(tile.worldx(), tile.worldy(), r); } } } diff --git a/core/src/mindustry/type/Sector.java b/core/src/mindustry/type/Sector.java index 921802e389..9a7e50c5ff 100644 --- a/core/src/mindustry/type/Sector.java +++ b/core/src/mindustry/type/Sector.java @@ -65,6 +65,28 @@ public void near(Cons cons){ } } + public int nearbyEnemyBases(){ + int bases = 0; + for(Ptile tile : tile.tiles){ + Sector s = planet.getSector(tile); + if(s.hasEnemyBase() && !s.hasBase()){ + bases ++; + } + } + return bases; + } + + public boolean vulnerable(){ + if(!planet.allowSectorInvasion) return false; + for(Ptile tile : tile.tiles){ + Sector s = planet.getSector(tile); + if(s.hasEnemyBase() && !s.hasBase()){ + return true; + } + } + return false; + } + /** Displays threat as a formatted string. */ public String displayThreat(){ float step = 0.25f;