Merged turret types
This commit is contained in:
@@ -1513,7 +1513,7 @@ public class Blocks implements ContentList{
|
||||
flags = EnumSet.of(BlockFlag.turret, BlockFlag.extinguisher);
|
||||
}};
|
||||
|
||||
lancer = new ChargeTurret("lancer"){{
|
||||
lancer = new PowerTurret("lancer"){{
|
||||
requirements(Category.turret, with(Items.copper, 25, Items.lead, 50, Items.silicon, 45));
|
||||
range = 165f;
|
||||
chargeTime = 40f;
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
package mindustry.world.blocks.defense.turrets;
|
||||
|
||||
import arc.audio.*;
|
||||
import arc.math.*;
|
||||
import arc.util.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.entities.bullet.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.gen.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class ChargeTurret extends PowerTurret{
|
||||
public float chargeTime = 30f;
|
||||
public int chargeEffects = 5;
|
||||
public float chargeMaxDelay = 10f;
|
||||
public Effect chargeEffect = Fx.none;
|
||||
public Effect chargeBeginEffect = Fx.none;
|
||||
public Sound chargeSound = Sounds.none;
|
||||
|
||||
public ChargeTurret(String name){
|
||||
super(name);
|
||||
}
|
||||
|
||||
public class ChargeTurretBuild extends PowerTurretBuild{
|
||||
public boolean shooting;
|
||||
|
||||
@Override
|
||||
public void shoot(BulletType ammo){
|
||||
useAmmo();
|
||||
|
||||
tr.trns(rotation, size * tilesize / 2f);
|
||||
chargeBeginEffect.at(x + tr.x, y + tr.y, rotation);
|
||||
chargeSound.at(x + tr.x, y + tr.y, 1);
|
||||
|
||||
for(int i = 0; i < chargeEffects; i++){
|
||||
Time.run(Mathf.random(chargeMaxDelay), () -> {
|
||||
if(!isValid()) return;
|
||||
tr.trns(rotation, size * tilesize / 2f);
|
||||
chargeEffect.at(x + tr.x, y + tr.y, rotation);
|
||||
});
|
||||
}
|
||||
|
||||
shooting = true;
|
||||
|
||||
Time.run(chargeTime, () -> {
|
||||
if(!isValid()) return;
|
||||
tr.trns(rotation, size * tilesize / 2f);
|
||||
recoil = recoilAmount;
|
||||
heat = 1f;
|
||||
bullet(ammo, rotation + Mathf.range(inaccuracy));
|
||||
effects();
|
||||
shooting = false;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldTurn(){
|
||||
return !shooting;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -40,6 +40,7 @@ public abstract class Turret extends ReloadTurret{
|
||||
public Effect ammoUseEffect = Fx.none;
|
||||
public Sound shootSound = Sounds.shoot;
|
||||
|
||||
//general info
|
||||
public int maxAmmo = 30;
|
||||
public int ammoPerShot = 1;
|
||||
public float ammoEjectBack = 1f;
|
||||
@@ -61,6 +62,14 @@ public abstract class Turret extends ReloadTurret{
|
||||
public boolean targetAir = true;
|
||||
public boolean targetGround = true;
|
||||
|
||||
//charging
|
||||
public float chargeTime = -1f;
|
||||
public int chargeEffects = 5;
|
||||
public float chargeMaxDelay = 10f;
|
||||
public Effect chargeEffect = Fx.none;
|
||||
public Effect chargeBeginEffect = Fx.none;
|
||||
public Sound chargeSound = Sounds.none;
|
||||
|
||||
public Sortf unitSort = Unit::dst2;
|
||||
|
||||
protected Vec2 tr = new Vec2();
|
||||
@@ -136,7 +145,7 @@ public abstract class Turret extends ReloadTurret{
|
||||
public @Nullable Posc target;
|
||||
public Vec2 targetPos = new Vec2();
|
||||
public BlockUnitc unit = Nulls.blockUnit;
|
||||
public boolean wasShooting;
|
||||
public boolean wasShooting, charging;
|
||||
|
||||
@Override
|
||||
public void created(){
|
||||
@@ -313,7 +322,7 @@ public abstract class Turret extends ReloadTurret{
|
||||
}
|
||||
|
||||
public boolean shouldTurn(){
|
||||
return true;
|
||||
return !charging;
|
||||
}
|
||||
|
||||
/** Consume ammo and return a type. */
|
||||
@@ -352,11 +361,37 @@ public abstract class Turret extends ReloadTurret{
|
||||
}
|
||||
|
||||
protected void shoot(BulletType type){
|
||||
recoil = recoilAmount;
|
||||
heat = 1f;
|
||||
|
||||
//when burst spacing is enabled, use the burst pattern
|
||||
if(burstSpacing > 0.0001f){
|
||||
//when charging is enabled, use the charge shoot pattern
|
||||
if(chargeTime > 0){
|
||||
useAmmo();
|
||||
|
||||
tr.trns(rotation, size * tilesize / 2f);
|
||||
chargeBeginEffect.at(x + tr.x, y + tr.y, rotation);
|
||||
chargeSound.at(x + tr.x, y + tr.y, 1);
|
||||
|
||||
for(int i = 0; i < chargeEffects; i++){
|
||||
Time.run(Mathf.random(chargeMaxDelay), () -> {
|
||||
if(!isValid()) return;
|
||||
tr.trns(rotation, size * tilesize / 2f);
|
||||
chargeEffect.at(x + tr.x, y + tr.y, rotation);
|
||||
});
|
||||
}
|
||||
|
||||
charging = true;
|
||||
|
||||
Time.run(chargeTime, () -> {
|
||||
if(!isValid()) return;
|
||||
tr.trns(rotation, size * tilesize / 2f);
|
||||
recoil = recoilAmount;
|
||||
heat = 1f;
|
||||
bullet(type, rotation + Mathf.range(inaccuracy));
|
||||
effects();
|
||||
charging = false;
|
||||
});
|
||||
|
||||
//when burst spacing is enabled, use the burst pattern
|
||||
}else if(burstSpacing > 0.0001f){
|
||||
for(int i = 0; i < shots; i++){
|
||||
Time.run(burstSpacing * i, () -> {
|
||||
if(!isValid() || !hasAmmo()) return;
|
||||
@@ -367,6 +402,8 @@ public abstract class Turret extends ReloadTurret{
|
||||
bullet(type, rotation + Mathf.range(inaccuracy));
|
||||
effects();
|
||||
useAmmo();
|
||||
recoil = recoilAmount;
|
||||
heat = 1f;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -388,6 +425,8 @@ public abstract class Turret extends ReloadTurret{
|
||||
|
||||
shotCounter++;
|
||||
|
||||
recoil = recoilAmount;
|
||||
heat = 1f;
|
||||
effects();
|
||||
useAmmo();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user