Merged turret types
This commit is contained in:
@@ -1513,7 +1513,7 @@ public class Blocks implements ContentList{
|
|||||||
flags = EnumSet.of(BlockFlag.turret, BlockFlag.extinguisher);
|
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));
|
requirements(Category.turret, with(Items.copper, 25, Items.lead, 50, Items.silicon, 45));
|
||||||
range = 165f;
|
range = 165f;
|
||||||
chargeTime = 40f;
|
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 Effect ammoUseEffect = Fx.none;
|
||||||
public Sound shootSound = Sounds.shoot;
|
public Sound shootSound = Sounds.shoot;
|
||||||
|
|
||||||
|
//general info
|
||||||
public int maxAmmo = 30;
|
public int maxAmmo = 30;
|
||||||
public int ammoPerShot = 1;
|
public int ammoPerShot = 1;
|
||||||
public float ammoEjectBack = 1f;
|
public float ammoEjectBack = 1f;
|
||||||
@@ -61,6 +62,14 @@ public abstract class Turret extends ReloadTurret{
|
|||||||
public boolean targetAir = true;
|
public boolean targetAir = true;
|
||||||
public boolean targetGround = 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;
|
public Sortf unitSort = Unit::dst2;
|
||||||
|
|
||||||
protected Vec2 tr = new Vec2();
|
protected Vec2 tr = new Vec2();
|
||||||
@@ -136,7 +145,7 @@ public abstract class Turret extends ReloadTurret{
|
|||||||
public @Nullable Posc target;
|
public @Nullable Posc target;
|
||||||
public Vec2 targetPos = new Vec2();
|
public Vec2 targetPos = new Vec2();
|
||||||
public BlockUnitc unit = Nulls.blockUnit;
|
public BlockUnitc unit = Nulls.blockUnit;
|
||||||
public boolean wasShooting;
|
public boolean wasShooting, charging;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void created(){
|
public void created(){
|
||||||
@@ -313,7 +322,7 @@ public abstract class Turret extends ReloadTurret{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean shouldTurn(){
|
public boolean shouldTurn(){
|
||||||
return true;
|
return !charging;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Consume ammo and return a type. */
|
/** Consume ammo and return a type. */
|
||||||
@@ -352,11 +361,37 @@ public abstract class Turret extends ReloadTurret{
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void shoot(BulletType type){
|
protected void shoot(BulletType type){
|
||||||
recoil = recoilAmount;
|
|
||||||
heat = 1f;
|
|
||||||
|
|
||||||
//when burst spacing is enabled, use the burst pattern
|
//when charging is enabled, use the charge shoot pattern
|
||||||
if(burstSpacing > 0.0001f){
|
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++){
|
for(int i = 0; i < shots; i++){
|
||||||
Time.run(burstSpacing * i, () -> {
|
Time.run(burstSpacing * i, () -> {
|
||||||
if(!isValid() || !hasAmmo()) return;
|
if(!isValid() || !hasAmmo()) return;
|
||||||
@@ -367,6 +402,8 @@ public abstract class Turret extends ReloadTurret{
|
|||||||
bullet(type, rotation + Mathf.range(inaccuracy));
|
bullet(type, rotation + Mathf.range(inaccuracy));
|
||||||
effects();
|
effects();
|
||||||
useAmmo();
|
useAmmo();
|
||||||
|
recoil = recoilAmount;
|
||||||
|
heat = 1f;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -388,6 +425,8 @@ public abstract class Turret extends ReloadTurret{
|
|||||||
|
|
||||||
shotCounter++;
|
shotCounter++;
|
||||||
|
|
||||||
|
recoil = recoilAmount;
|
||||||
|
heat = 1f;
|
||||||
effects();
|
effects();
|
||||||
useAmmo();
|
useAmmo();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user