diff --git a/core/src/mindustry/content/SectorPresets.java b/core/src/mindustry/content/SectorPresets.java index 1253ed6417..41cf6d41bf 100644 --- a/core/src/mindustry/content/SectorPresets.java +++ b/core/src/mindustry/content/SectorPresets.java @@ -159,8 +159,6 @@ public class SectorPresets{ isLastSector = true; }}; - //TODO: show up differently with PLT selected. - new SectorPreset("geothermalStronghold", serpulo, 264){{ requireUnlock = false; difficulty = 10; diff --git a/core/src/mindustry/graphics/g3d/PlanetRenderer.java b/core/src/mindustry/graphics/g3d/PlanetRenderer.java index fe0c9febcf..59b7257736 100644 --- a/core/src/mindustry/graphics/g3d/PlanetRenderer.java +++ b/core/src/mindustry/graphics/g3d/PlanetRenderer.java @@ -9,6 +9,7 @@ import arc.math.geom.*; import arc.util.*; import mindustry.game.EventType.*; import mindustry.graphics.*; +import mindustry.graphics.g3d.PlanetGrid.*; import mindustry.type.*; public class PlanetRenderer implements Disposable{ @@ -229,6 +230,37 @@ public class PlanetRenderer implements Disposable{ sector.planet.drawSelection(batch, sector, color, stroke, length); } + /** Draws sector when selected. Supply the batch with {@link Gl#triangles triangle} vertices. */ + public void drawSpecialSelection(Sector sector, Color color, float stroke, float length){ + drawSelection(sector, color, stroke, length); + + float arad = (outlineRad + length) * sector.planet.radius; + float span = 0.1f; + + for(int i = 0; i < sector.tile.corners.length; i += 2){ + Corner next = sector.tile.corners[(i + 1) % sector.tile.corners.length]; + Corner curr = sector.tile.corners[i]; + + next.v.scl(arad); + curr.v.scl(arad); + sector.tile.v.scl(arad); + + Tmp.v31.set(curr.v).sub(sector.tile.v).setLength(curr.v.dst(sector.tile.v) - stroke).add(sector.tile.v); + Tmp.v32.set(next.v).sub(sector.tile.v).setLength(next.v.dst(sector.tile.v) - stroke).add(sector.tile.v); + Tmp.v33.set(Tmp.v31).lerp(Tmp.v32, span); + Tmp.v34.set(Tmp.v31).lerp(Tmp.v32, 1f - span); + + Tmp.v31.set(Tmp.v33).sub(sector.tile.v).setLength(Tmp.v31.len() - stroke).add(sector.tile.v); + Tmp.v32.set(Tmp.v34).sub(sector.tile.v).setLength(Tmp.v32.len() - stroke).add(sector.tile.v); + + batch.quad(Tmp.v33, Tmp.v34, Tmp.v32, Tmp.v31, color); + + sector.tile.v.scl(1f / arad); + next.v.scl(1f / arad); + curr.v.scl(1f / arad); + } + } + @Override public void dispose(){ skybox.dispose(); diff --git a/core/src/mindustry/input/InputHandler.java b/core/src/mindustry/input/InputHandler.java index a6134aa397..bdd7d3c8ca 100644 --- a/core/src/mindustry/input/InputHandler.java +++ b/core/src/mindustry/input/InputHandler.java @@ -37,7 +37,6 @@ import mindustry.ui.fragments.*; import mindustry.world.*; import mindustry.world.blocks.ConstructBlock.*; import mindustry.world.blocks.*; -import mindustry.world.blocks.defense.turrets.*; import mindustry.world.blocks.distribution.*; import mindustry.world.blocks.payloads.*; import mindustry.world.blocks.storage.*; @@ -1842,7 +1841,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ if((!config.isShown() && build.shouldShowConfigure(player)) //if the config fragment is hidden, show //alternatively, the current selected block can 'agree' to switch config tiles || (config.isShown() && config.getSelected().onConfigureBuildTapped(build) && build.shouldShowConfigure(player))){ - Sounds.click.at(build); + build.block.configureSound.at(build); config.showConfig(build); } //otherwise... diff --git a/core/src/mindustry/type/Planet.java b/core/src/mindustry/type/Planet.java index b8dc3db005..554e58361f 100644 --- a/core/src/mindustry/type/Planet.java +++ b/core/src/mindustry/type/Planet.java @@ -549,8 +549,7 @@ public class Planet extends UnlockableContent{ Tmp.v31.set(curr.v).sub(sector.tile.v).setLength(curr.v.dst(sector.tile.v) - stroke).add(sector.tile.v); Tmp.v32.set(next.v).sub(sector.tile.v).setLength(next.v.dst(sector.tile.v) - stroke).add(sector.tile.v); - batch.tri(curr.v, next.v, Tmp.v31, color); - batch.tri(Tmp.v31, next.v, Tmp.v32, color); + batch.quad(curr.v, next.v, Tmp.v32, Tmp.v31, color); sector.tile.v.scl(1f / arad); next.v.scl(1f / arad); diff --git a/core/src/mindustry/type/Sector.java b/core/src/mindustry/type/Sector.java index a5adb64529..c8a1ca63b7 100644 --- a/core/src/mindustry/type/Sector.java +++ b/core/src/mindustry/type/Sector.java @@ -31,6 +31,7 @@ public class Sector{ public @Nullable SaveSlot save; public @Nullable SectorPreset preset; + public @Nullable Sector shieldTarget; public SectorInfo info = new SectorInfo(); /** Number 0-1 indicating the difficulty based on nearby bases. */ @@ -121,6 +122,10 @@ public class Sector{ Core.settings.remove(planet.name + "-s-" + id + "-info"); } + public boolean isShielded(){ + return preset != null && preset.shieldSectors.size > 0 && preset.shieldSectors.contains(s -> !s.isCaptured()); + } + public boolean isAttacked(){ if(isBeingPlayed()) return state.rules.waves || state.rules.attackMode; return save != null && (info.waves || info.attack) && info.hasCore; diff --git a/core/src/mindustry/type/SectorPreset.java b/core/src/mindustry/type/SectorPreset.java index 77b0484d50..53b5984998 100644 --- a/core/src/mindustry/type/SectorPreset.java +++ b/core/src/mindustry/type/SectorPreset.java @@ -2,6 +2,7 @@ package mindustry.type; import arc.*; import arc.func.*; +import arc.struct.*; import arc.util.*; import mindustry.ctype.*; import mindustry.game.*; @@ -38,6 +39,8 @@ public class SectorPreset extends UnlockableContent{ public boolean attackAfterWaves = false; /** The original position of this sector; used for migration. Internal use for vanilla campaign only! */ public int originalPosition; + /** Sectors that prevent this sector from being landed on until they are completed. */ + public Seq shieldSectors = new Seq<>(); public SectorPreset(String name, Planet planet, int sector){ this(name, null, planet, sector); @@ -81,6 +84,16 @@ public class SectorPreset extends UnlockableContent{ } } + @Override + public void init(){ + super.init(); + + //note that sectors can only have one visual shield target + for(var other : shieldSectors){ + other.shieldTarget = sector; + } + } + @Override public void loadIcon(){ if(Icon.terrain != null){ diff --git a/core/src/mindustry/ui/dialogs/PlanetDialog.java b/core/src/mindustry/ui/dialogs/PlanetDialog.java index f5526fc655..7950c399c5 100644 --- a/core/src/mindustry/ui/dialogs/PlanetDialog.java +++ b/core/src/mindustry/ui/dialogs/PlanetDialog.java @@ -414,13 +414,14 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{ boolean canSelect(Sector sector){ if(mode == select) return sector.hasBase() && launchSector != null && sector.planet == launchSector.planet; - if(mode == planetLaunch && sector.hasBase()){ - return false; - } + if(mode == planetLaunch && sector.hasBase()) return false; if(sector.planet.generator == null) return false; + if(sector.isShielded()) return false; + if(sector.hasBase() || sector.id == sector.planet.startSector) return true; + //preset sectors can only be selected once unlocked if(sector.preset != null && sector.preset.requireUnlock){ TechNode node = sector.preset.techNode; @@ -444,9 +445,10 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{ @Override public void renderSectors(Planet planet){ - //draw all sector stuff if(state.uiAlpha > 0.01f){ for(Sector sec : planet.sectors){ + if(sec == selected) continue; + if(canSelect(sec) || sec.unlocked() || debugSelect){ Color color = @@ -458,7 +460,12 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{ null; if(color != null){ - planets.drawSelection(sec, Tmp.c1.set(color).mul(0.8f).a(state.uiAlpha), 0.026f, -0.001f); + var destColor = Tmp.c1.set(color).mul(0.8f).a(state.uiAlpha); + if(!sec.isCaptured() && sec.preset != null && sec.preset.showHidden){ + planets.drawSpecialSelection(sec, destColor, 0.026f, -0.001f); + }else{ + planets.drawSelection(sec, destColor, 0.026f, -0.001f); + } } }else{ planets.fill(sec, Tmp.c1.set(shadowColor).mul(1, 1, 1, state.uiAlpha), -0.001f); @@ -502,6 +509,12 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{ if(state.uiAlpha > 0.001f){ for(Sector sec : planet.sectors){ + + //draw shield arc + if(sec.shieldTarget != null && !sec.isCaptured() && !sec.shieldTarget.isCaptured()){ + planets.drawArcLine(planet, sec.tile.v, sec.shieldTarget.tile.v, Team.crux.color.write(Tmp.c2).a(state.uiAlpha), Tmp.c3.set(Tmp.c2).mulA(0.5f), 0.15f, 110f, 25, 0.006f); + } + if(sec.hasBase()){ //draw vulnerable sector attack arc if(planet.campaignRules.sectorInvasion){ diff --git a/core/src/mindustry/world/Block.java b/core/src/mindustry/world/Block.java index 66c8bafd00..606a1a5351 100644 --- a/core/src/mindustry/world/Block.java +++ b/core/src/mindustry/world/Block.java @@ -247,6 +247,8 @@ public class Block extends UnlockableContent implements Senseable{ public int unitCapModifier = 0; /** Whether the block can be tapped and selected to configure. */ public boolean configurable; + /** Sound played when this block is configured. */ + public Sound configureSound = Sounds.click; /** If true, this block does not have pointConfig with a transform called on map resize. */ public boolean ignoreResizeConfig; /** If true, this building can be selected like a unit when commanding. */ diff --git a/core/src/mindustry/world/blocks/logic/SwitchBlock.java b/core/src/mindustry/world/blocks/logic/SwitchBlock.java index 7a470f27d4..48c5d634e4 100644 --- a/core/src/mindustry/world/blocks/logic/SwitchBlock.java +++ b/core/src/mindustry/world/blocks/logic/SwitchBlock.java @@ -21,6 +21,7 @@ public class SwitchBlock extends Block{ update = true; drawDisabled = false; autoResetEnabled = false; + configureSound = Sounds.none; group = BlockGroup.logic; envEnabled = Env.any; diff --git a/gradle.properties b/gradle.properties index 1fe2b84dfe..823e4fa247 100644 --- a/gradle.properties +++ b/gradle.properties @@ -26,4 +26,4 @@ org.gradle.caching=true org.gradle.internal.http.socketTimeout=100000 org.gradle.internal.http.connectionTimeout=100000 android.enableR8.fullMode=false -archash=eaf9d2cdea +archash=b82cebe3d8