diff --git a/core/assets-raw/sprites/blocks/defense/shield-breaker.png b/core/assets-raw/sprites/blocks/defense/shield-breaker.png new file mode 100644 index 0000000000..3012ca2867 Binary files /dev/null and b/core/assets-raw/sprites/blocks/defense/shield-breaker.png differ diff --git a/core/src/mindustry/ai/BlockIndexer.java b/core/src/mindustry/ai/BlockIndexer.java index e5cf94e462..a1a014fc5d 100644 --- a/core/src/mindustry/ai/BlockIndexer.java +++ b/core/src/mindustry/ai/BlockIndexer.java @@ -114,7 +114,8 @@ public class BlockIndexer{ } //no longer part of the building list - data.buildings.remove(tile.build); + data.buildings.remove(build); + data.buildingTypes.get(build.block, () -> new Seq<>(false)).remove(build); //update the unit cap when building is removed data.unitCap -= tile.block().unitCapModifier; @@ -449,6 +450,7 @@ public class BlockIndexer{ //record in list of buildings data.buildings.add(tile.build); + data.buildingTypes.get(tile.block(), () -> new Seq<>(false)).add(tile.build); //update the unit cap when new tile is registered data.unitCap += tile.block().unitCapModifier; diff --git a/core/src/mindustry/content/Blocks.java b/core/src/mindustry/content/Blocks.java index 766d98a6a5..9651026dad 100644 --- a/core/src/mindustry/content/Blocks.java +++ b/core/src/mindustry/content/Blocks.java @@ -91,6 +91,7 @@ public class Blocks{ //campaign only shieldProjector, largeShieldProjector, + shieldBreaker, //transport conveyor, titaniumConveyor, plastaniumConveyor, armoredConveyor, distributor, junction, itemBridge, phaseConveyor, sorter, invertedSorter, router, @@ -1781,6 +1782,14 @@ public class Blocks{ consumePower(5f); }}; + shieldBreaker = new BaseShield("shield-breaker"){{ + requirements(Category.effect, BuildVisibility.editorOnly, with()); + + size = 5; + + consumeItem(Items.tungsten, 100); + }}; + //endregion //region distribution diff --git a/core/src/mindustry/game/Teams.java b/core/src/mindustry/game/Teams.java index 54bbd84c6f..e92e7e677c 100644 --- a/core/src/mindustry/game/Teams.java +++ b/core/src/mindustry/game/Teams.java @@ -10,6 +10,7 @@ import mindustry.*; import mindustry.ai.*; import mindustry.gen.*; import mindustry.type.*; +import mindustry.world.*; import mindustry.world.blocks.payloads.*; import mindustry.world.blocks.storage.CoreBlock.*; @@ -260,6 +261,8 @@ public class Teams{ public int unitCount; /** Counts for each type of unit. Do not access directly. */ public @Nullable int[] typeCounts; + /** Cached buildings by type. */ + public ObjectMap> buildingTypes = new ObjectMap<>(); /** Units of this team. Updated each frame. */ public Seq units = new Seq<>(false); /** Same as units, but players. */ @@ -273,6 +276,10 @@ public class Teams{ this.team = team; } + public Seq getBuildings(Block block){ + return buildingTypes.get(block, () -> new Seq<>(false)); + } + /** Destroys this team's presence on the map, killing part of its buildings and converting everything to 'derelict'. */ public void destroyToDerelict(){ diff --git a/core/src/mindustry/world/blocks/defense/ShieldBreaker.java b/core/src/mindustry/world/blocks/defense/ShieldBreaker.java index 76f94a8c99..b0cda79ded 100644 --- a/core/src/mindustry/world/blocks/defense/ShieldBreaker.java +++ b/core/src/mindustry/world/blocks/defense/ShieldBreaker.java @@ -1,9 +1,16 @@ package mindustry.world.blocks.defense; +import arc.math.*; +import arc.util.*; +import mindustry.*; +import mindustry.content.*; +import mindustry.entities.*; import mindustry.gen.*; import mindustry.world.*; public class ShieldBreaker extends Block{ + public @Nullable Block toDestroy; + public Effect effect = Fx.shockwave, breakEffect = Fx.reactorExplosion, selfKillEffect = Fx.massiveExplosion; public ShieldBreaker(String name){ super(name); @@ -11,11 +18,30 @@ public class ShieldBreaker extends Block{ solid = update = true; } + @Override + public boolean canBreak(Tile tile){ + return false; + } + public class ShieldBreakerBuild extends Building{ @Override public void updateTile(){ - + if(Mathf.equal(efficiency, 1f)){ + if(toDestroy != null){ + effect.at(this); + for(var other : Vars.state.teams.active){ + if(team != other.team){ + other.getBuildings(toDestroy).copy().each(b -> { + breakEffect.at(b); + b.kill(); + }); + } + } + selfKillEffect.at(this); + kill(); + } + } } } } diff --git a/gradle.properties b/gradle.properties index b4b546230d..55f4b48e62 100644 --- a/gradle.properties +++ b/gradle.properties @@ -25,4 +25,4 @@ org.gradle.caching=true #used for slow jitpack builds; TODO see if this actually works org.gradle.internal.http.socketTimeout=100000 org.gradle.internal.http.connectionTimeout=100000 -archash=6daca211b7 +archash=b2eb1dd566