Shield breaker block

This commit is contained in:
Anuken
2022-04-21 14:34:01 -04:00
parent bfdf07d0eb
commit 09221f952a
6 changed files with 47 additions and 3 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

View File

@@ -114,7 +114,8 @@ public class BlockIndexer{
} }
//no longer part of the building list //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 //update the unit cap when building is removed
data.unitCap -= tile.block().unitCapModifier; data.unitCap -= tile.block().unitCapModifier;
@@ -449,6 +450,7 @@ public class BlockIndexer{
//record in list of buildings //record in list of buildings
data.buildings.add(tile.build); 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 //update the unit cap when new tile is registered
data.unitCap += tile.block().unitCapModifier; data.unitCap += tile.block().unitCapModifier;

View File

@@ -91,6 +91,7 @@ public class Blocks{
//campaign only //campaign only
shieldProjector, shieldProjector,
largeShieldProjector, largeShieldProjector,
shieldBreaker,
//transport //transport
conveyor, titaniumConveyor, plastaniumConveyor, armoredConveyor, distributor, junction, itemBridge, phaseConveyor, sorter, invertedSorter, router, conveyor, titaniumConveyor, plastaniumConveyor, armoredConveyor, distributor, junction, itemBridge, phaseConveyor, sorter, invertedSorter, router,
@@ -1781,6 +1782,14 @@ public class Blocks{
consumePower(5f); consumePower(5f);
}}; }};
shieldBreaker = new BaseShield("shield-breaker"){{
requirements(Category.effect, BuildVisibility.editorOnly, with());
size = 5;
consumeItem(Items.tungsten, 100);
}};
//endregion //endregion
//region distribution //region distribution

View File

@@ -10,6 +10,7 @@ import mindustry.*;
import mindustry.ai.*; import mindustry.ai.*;
import mindustry.gen.*; import mindustry.gen.*;
import mindustry.type.*; import mindustry.type.*;
import mindustry.world.*;
import mindustry.world.blocks.payloads.*; import mindustry.world.blocks.payloads.*;
import mindustry.world.blocks.storage.CoreBlock.*; import mindustry.world.blocks.storage.CoreBlock.*;
@@ -260,6 +261,8 @@ public class Teams{
public int unitCount; public int unitCount;
/** Counts for each type of unit. Do not access directly. */ /** Counts for each type of unit. Do not access directly. */
public @Nullable int[] typeCounts; public @Nullable int[] typeCounts;
/** Cached buildings by type. */
public ObjectMap<Block, Seq<Building>> buildingTypes = new ObjectMap<>();
/** Units of this team. Updated each frame. */ /** Units of this team. Updated each frame. */
public Seq<Unit> units = new Seq<>(false); public Seq<Unit> units = new Seq<>(false);
/** Same as units, but players. */ /** Same as units, but players. */
@@ -273,6 +276,10 @@ public class Teams{
this.team = team; this.team = team;
} }
public Seq<Building> 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'. */ /** Destroys this team's presence on the map, killing part of its buildings and converting everything to 'derelict'. */
public void destroyToDerelict(){ public void destroyToDerelict(){

View File

@@ -1,9 +1,16 @@
package mindustry.world.blocks.defense; package mindustry.world.blocks.defense;
import arc.math.*;
import arc.util.*;
import mindustry.*;
import mindustry.content.*;
import mindustry.entities.*;
import mindustry.gen.*; import mindustry.gen.*;
import mindustry.world.*; import mindustry.world.*;
public class ShieldBreaker extends Block{ public class ShieldBreaker extends Block{
public @Nullable Block toDestroy;
public Effect effect = Fx.shockwave, breakEffect = Fx.reactorExplosion, selfKillEffect = Fx.massiveExplosion;
public ShieldBreaker(String name){ public ShieldBreaker(String name){
super(name); super(name);
@@ -11,11 +18,30 @@ public class ShieldBreaker extends Block{
solid = update = true; solid = update = true;
} }
@Override
public boolean canBreak(Tile tile){
return false;
}
public class ShieldBreakerBuild extends Building{ public class ShieldBreakerBuild extends Building{
@Override @Override
public void updateTile(){ 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();
}
}
} }
} }
} }

View File

@@ -25,4 +25,4 @@ org.gradle.caching=true
#used for slow jitpack builds; TODO see if this actually works #used for slow jitpack builds; TODO see if this actually works
org.gradle.internal.http.socketTimeout=100000 org.gradle.internal.http.socketTimeout=100000
org.gradle.internal.http.connectionTimeout=100000 org.gradle.internal.http.connectionTimeout=100000
archash=6daca211b7 archash=b2eb1dd566