WIP Turret field rename / More JSON consume support

This commit is contained in:
Anuken
2022-05-08 23:17:37 -04:00
parent 668b09e955
commit 5a3c8573c3
16 changed files with 120 additions and 76 deletions

View File

@@ -93,7 +93,7 @@ public class ContinuousTurret extends Turret{
wasShooting = true;
heat = 1f;
recoil = recoilAmount;
curRecoil = recoil;
}
}

View File

@@ -76,7 +76,7 @@ public class LaserTurret extends PowerTurret{
wasShooting = true;
heat = 1f;
recoil = recoilAmount;
curRecoil = recoil;
}else if(reloadCounter > 0){
wasShooting = true;

View File

@@ -34,35 +34,20 @@ public class Turret extends ReloadTurret{
public final static float logicControlCooldown = 60 * 2;
public final int timerTarget = timers++;
public int targetInterval = 20;
public Color heatColor = Pal.turretHeat;
public Effect shootEffect = Fx.none;
public Effect smokeEffect = Fx.none;
public Effect ammoUseEffect = Fx.none;
public Sound shootSound = Sounds.shoot;
public Sound chargeSound = Sounds.none;
public float soundPitchMin = 0.9f, soundPitchMax = 1.1f;
//visuals TODO document
public float ammoEjectBack = 1f;
public float shootWarmupSpeed = 0.1f;
public boolean linearWarmup = false;
public float recoilAmount = 1f;
public float restitution = 0.02f;
public float cooldown = 0.02f;
public float elevation = -1f;
public float shootShake = 0f;
/** Ticks between attempt at finding a target. */
public float targetInterval = 20;
/** Maximum ammo units stored. */
public int maxAmmo = 30;
/** Ammo units used per shot. */
public int ammoPerShot = 1;
/** If true, ammo is only consumed once per shot regardless of bullet count. */
public boolean consumeAmmoOnce = false;
/** Minimum input heat required to fire. */
public float heatRequirement = -1f;
/** Maximum efficiency possible, if this turret uses heat. */
public float maxHeatEfficiency = 3f;
//TODO clean all of this up + weapon consistency
/** Bullet angle randomness in degrees. */
public float inaccuracy = 0f;
/** Fraction of bullet velocity that is random. */
@@ -71,7 +56,7 @@ public class Turret extends ReloadTurret{
public float shootCone = 8f;
/** Turret shoot point. */
public float shootX = 0f, shootY = Float.NEGATIVE_INFINITY;
/** Currently used for artillery only. */
/** Minimum bullet range. Used for artillery only. */
public float minRange = 0f;
/** Minimum warmup needed to fire. */
public float minWarmup = 0f;
@@ -82,15 +67,55 @@ public class Turret extends ReloadTurret{
/** pattern used for bullets */
public ShootPattern shoot = new ShootPattern();
/** If true, this block targets air units. */
public boolean targetAir = true;
/** If true, this block targets ground units and structures. */
public boolean targetGround = true;
/** If true, this block targets friend blocks, to heal them. */
public boolean targetHealing = false;
/** If true, this turret can be controlled by players. */
public boolean playerControllable = true;
/** If true, this block will display ammo multipliers in its stats (irrelevant for certain types of turrets). */
public boolean displayAmmoMultiplier = true;
/** Function for choosing which unit to target. */
public Sortf unitSort = UnitSorts.closest;
/** Filter for types of units to attack. */
public Boolf<Unit> unitFilter = u -> true;
/** Filter for types of buildings to attack. */
public Boolf<Building> buildingFilter = b -> !b.block.underBullets;
/** Color of heat region drawn on top (if found) */
public Color heatColor = Pal.turretHeat;
/** Optional override for all shoot effects. */
public @Nullable Effect shootEffect;
/** Optional override for all smoke effects. */
public @Nullable Effect smokeEffect;
/** Optional override for all ammo use effects. */
public @Nullable Effect ammoUseEffect;
/** Sound emitted when a single bullet is shot. */
public Sound shootSound = Sounds.shoot;
/** Sound emitted when shoot.firstShotDelay is >0 and shooting begins. */
public Sound chargeSound = Sounds.none;
/** Range for pitch of shoot sound. */
public float soundPitchMin = 0.9f, soundPitchMax = 1.1f;
/** Backwards Y offset of ammo eject effect. */
public float ammoEjectBack = 1f;
/** Lerp speed of turret warmup. */
public float shootWarmupSpeed = 0.1f;
/** If true, turret warmup is linear instead of a curve. */
public boolean linearWarmup = false;
/** Visual amount by which the turret recoils back per shot. */
public float recoil = 1f;
/** TODO rename */
public float restitution = 0.02f;
/** TODO rename */
public float cooldown = 0.02f;
/** Visual elevation of turret shadow, -1 to use defaults. */
public float elevation = -1f;
/** How much the screen shakes per shot. */
public float shake = 0f;
/** Defines drawing behavior for this turret. */
public DrawBlock drawer = new DrawTurret();
public Turret(String name){
@@ -168,7 +193,7 @@ public class Turret extends ReloadTurret{
public Seq<AmmoEntry> ammo = new Seq<>();
public int totalAmmo;
public float recoil, heat, logicControlTime = -1;
public float curRecoil, heat, logicControlTime = -1;
public float shootWarmup;
public int totalShots;
public boolean logicShooting = false;
@@ -315,13 +340,13 @@ public class Turret extends ReloadTurret{
wasShooting = false;
//TODO do not lerp
recoil = Mathf.lerpDelta(recoil, 0f, restitution);
curRecoil = Mathf.lerpDelta(curRecoil, 0f, restitution);
heat = Mathf.lerpDelta(heat, 0f, cooldown);
unit.tile(this);
unit.rotation(rotation);
unit.team(team);
recoilOffset.trns(rotation, -recoil);
recoilOffset.trns(rotation, -curRecoil);
if(logicControlTime > 0){
logicControlTime -= Time.delta;
@@ -511,8 +536,8 @@ public class Turret extends ReloadTurret{
//TODO aimX / aimY for multi shot turrets?
handleBullet(type.create(this, team, bulletX, bulletY, shootAngle, -1f, (1f - velocityRnd) + Mathf.random(velocityRnd), lifeScl, null, mover, targetPos.x, targetPos.y), xOffset, yOffset, angleOffset);
(shootEffect == Fx.none ? type.shootEffect : shootEffect).at(bulletX, bulletY, rotation + angleOffset, type.hitColor);
(smokeEffect == Fx.none ? type.smokeEffect : smokeEffect).at(bulletX, bulletY, rotation + angleOffset, type.hitColor);
(shootEffect == null ? type.shootEffect : shootEffect).at(bulletX, bulletY, rotation + angleOffset, type.hitColor);
(smokeEffect == null ? type.smokeEffect : smokeEffect).at(bulletX, bulletY, rotation + angleOffset, type.hitColor);
shootSound.at(bulletX, bulletY, Mathf.random(soundPitchMin, soundPitchMax));
ammoUseEffect.at(
@@ -521,11 +546,11 @@ public class Turret extends ReloadTurret{
rotation * Mathf.sign(xOffset)
);
if(shootShake > 0){
Effect.shake(shootShake, shootShake, this);
if(shake > 0){
Effect.shake(shake, shake, this);
}
recoil = recoilAmount;
curRecoil = recoil;
heat = 1f;
if(!consumeAmmoOnce){

View File

@@ -138,7 +138,7 @@ public class Conveyor extends Block implements Autotiler{
@Override
public void draw(){
int frame = enabled && clogHeat <= 0.5f ? (int)(((Time.time * speed * 8f * timeScale)) % 4) : 0;
int frame = enabled && clogHeat <= 0.5f ? (int)(((Time.time * speed * 8f * timeScale * efficiency)) % 4) : 0;
//draw extra conveyors facing this one for non-square tiling purposes
Draw.z(Layer.blockUnder);

View File

@@ -4,9 +4,11 @@ import mindustry.gen.*;
/** For mods. I don't use this (yet). */
public class ConsumeItemCharged extends ConsumeItemFilter{
public float minCharge;
public ConsumeItemCharged(float minCharge){
super(item -> item.charge >= minCharge);
this.minCharge = minCharge;
filter = item -> item.charge >= this.minCharge;
}
public ConsumeItemCharged(){

View File

@@ -3,9 +3,11 @@ package mindustry.world.consumers;
import mindustry.gen.*;
public class ConsumeItemExplosive extends ConsumeItemFilter{
public float minExplosiveness;
public ConsumeItemExplosive(float minExplosiveness){
super(item -> item.explosiveness >= minExplosiveness);
public ConsumeItemExplosive(float minCharge){
this.minExplosiveness = minCharge;
filter = item -> item.explosiveness >= this.minExplosiveness;
}
public ConsumeItemExplosive(){

View File

@@ -12,12 +12,15 @@ import mindustry.world.meta.*;
import static mindustry.Vars.*;
public class ConsumeItemFilter extends Consume{
public final Boolf<Item> filter;
public Boolf<Item> filter = i -> false;
public ConsumeItemFilter(Boolf<Item> item){
this.filter = item;
}
public ConsumeItemFilter(){
}
@Override
public void apply(Block block){
block.hasItems = true;

View File

@@ -3,9 +3,11 @@ package mindustry.world.consumers;
import mindustry.gen.*;
public class ConsumeItemFlammable extends ConsumeItemFilter{
public float minFlammability;
public ConsumeItemFlammable(float minFlammability){
super(item -> item.flammability >= minFlammability);
this.minFlammability = minFlammability;
filter = item -> item.flammability >= this.minFlammability;
}
public ConsumeItemFlammable(){

View File

@@ -3,9 +3,11 @@ package mindustry.world.consumers;
import mindustry.gen.*;
public class ConsumeItemRadioactive extends ConsumeItemFilter{
public float minRadioactivity;
public ConsumeItemRadioactive(float minRadioactivity){
super(item -> item.radioactivity >= minRadioactivity);
this.minRadioactivity = minRadioactivity;
filter = item -> item.radioactivity >= this.minRadioactivity;
}
public ConsumeItemRadioactive(){

View File

@@ -13,7 +13,7 @@ import mindustry.world.meta.*;
import static mindustry.Vars.*;
public class ConsumeLiquidFilter extends ConsumeLiquidBase{
public Boolf<Liquid> filter;
public Boolf<Liquid> filter = l -> false;
public ConsumeLiquidFilter(Boolf<Liquid> liquid, float amount){
super(amount);
@@ -21,7 +21,6 @@ public class ConsumeLiquidFilter extends ConsumeLiquidBase{
}
public ConsumeLiquidFilter(){
this.filter = l -> false;
}
@Override

View File

@@ -3,13 +3,15 @@ package mindustry.world.consumers;
import mindustry.gen.*;
public class ConsumeLiquidFlammable extends ConsumeLiquidFilter{
public float minFlammability;
public ConsumeLiquidFlammable(float minFlammability, float amount){
super(item -> item.flammability >= minFlammability, amount);
public ConsumeLiquidFlammable(float minFlammability){
this.minFlammability = minFlammability;
filter = liquid -> liquid.flammability >= this.minFlammability;
}
public ConsumeLiquidFlammable(float amount){
this(0.2f, amount);
public ConsumeLiquidFlammable(){
this(0.2f);
}
@Override

View File

@@ -18,6 +18,7 @@ public class DrawTurret extends DrawBlock{
protected static final Rand rand = new Rand();
public Seq<DrawPart> parts = new Seq<>();
/** Prefix to use when loading base region. */
public String basePrefix = "";
/** Overrides the liquid to draw in the liquid region. */
public @Nullable Liquid liquidDraw;