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

@@ -549,3 +549,4 @@
63143=armored-duct|block-armored-duct-ui 63143=armored-duct|block-armored-duct-ui
63142=anthicus|unit-anthicus-ui 63142=anthicus|unit-anthicus-ui
63141=anthicus-missile|unit-anthicus-missile-ui 63141=anthicus-missile|unit-anthicus-missile-ui
63140=shield-breaker|block-shield-breaker-ui

Binary file not shown.

View File

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

View File

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

View File

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