Allow shock mines to spawn bullets (#5454)

* Allow shock mines to spawn bullets

* Fix up some issues
This commit is contained in:
MEEP of Faith 2021-06-24 05:39:37 -07:00 committed by GitHub
parent 38a9ad9ec1
commit d4c409252b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3,8 +3,10 @@ package mindustry.world.blocks.defense;
import arc.graphics.*;
import arc.graphics.g2d.*;
import arc.math.*;
import arc.util.*;
import mindustry.annotations.Annotations.*;
import mindustry.entities.*;
import mindustry.entities.bullet.*;
import mindustry.gen.*;
import mindustry.graphics.*;
import mindustry.world.*;
@ -18,6 +20,9 @@ public class ShockMine extends Block{
public int length = 10;
public int tendrils = 6;
public Color lightningColor = Pal.lancerLaser;
public int shots = 6;
public float inaccuracy = 0f;
public @Nullable BulletType bullet;
public float teamAlpha = 0.3f;
public @Load("@-team-top") TextureRegion teamRegion;
@ -46,17 +51,26 @@ public class ShockMine extends Block{
@Override
public void drawCracks(){
//no
}
@Override
public void unitOn(Unit unit){
if(enabled && unit.team != team && timer(timerDamage, cooldown)){
for(int i = 0; i < tendrils; i++){
Lightning.create(team, lightningColor, damage, x, y, Mathf.random(360f), length);
}
triggered();
damage(tileDamage);
}
}
public void triggered(){
for(int i = 0; i < tendrils; i++){
Lightning.create(team, lightningColor, damage, x, y, Mathf.random(360f), length);
}
if(bullet != null){
for(int i = 0; i < shots; i++){
bullet.create(this, x, y, (360f / shots) * i + Mathf.random(inaccuracy));
}
}
}
}
}