Proper shield breaker

This commit is contained in:
Anuken
2022-04-21 14:39:30 -04:00
parent 09221f952a
commit 45a0f3c588
5 changed files with 14 additions and 10 deletions

View File

@@ -1782,12 +1782,14 @@ public class Blocks{
consumePower(5f);
}};
shieldBreaker = new BaseShield("shield-breaker"){{
shieldBreaker = new ShieldBreaker("shield-breaker"){{
requirements(Category.effect, BuildVisibility.editorOnly, with());
size = 5;
toDestroy = new Block[]{Blocks.shieldProjector, Blocks.largeShieldProjector};
consumeItem(Items.tungsten, 100);
itemCapacity = 100;
}};
//endregion

View File

@@ -58,6 +58,7 @@ public class BaseShield extends Block{
hasPower = true;
update = solid = true;
rebuildable = false;
}
@Override

View File

@@ -1,7 +1,6 @@
package mindustry.world.blocks.defense;
import arc.math.*;
import arc.util.*;
import mindustry.*;
import mindustry.content.*;
import mindustry.entities.*;
@@ -9,13 +8,14 @@ import mindustry.gen.*;
import mindustry.world.*;
public class ShieldBreaker extends Block{
public @Nullable Block toDestroy;
public Block[] toDestroy = {};
public Effect effect = Fx.shockwave, breakEffect = Fx.reactorExplosion, selfKillEffect = Fx.massiveExplosion;
public ShieldBreaker(String name){
super(name);
solid = update = true;
rebuildable = false;
}
@Override
@@ -28,19 +28,19 @@ public class ShieldBreaker extends Block{
@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 -> {
effect.at(this);
for(var other : Vars.state.teams.active){
if(team != other.team){
for(var block : toDestroy){
other.getBuildings(block).copy().each(b -> {
breakEffect.at(b);
b.kill();
});
}
}
selfKillEffect.at(this);
kill();
}
selfKillEffect.at(this);
kill();
}
}
}