Bullet/weapon cleanup

This commit is contained in:
Anuken
2022-02-23 17:02:00 -05:00
parent a6c9ce7612
commit 8234aa1b98
13 changed files with 149 additions and 144 deletions

View File

@@ -2,6 +2,7 @@ package mindustry.world.blocks.defense.turrets;
import arc.math.*;
import arc.struct.*;
import arc.util.*;
import mindustry.content.*;
import mindustry.entities.bullet.*;
import mindustry.gen.*;
@@ -31,7 +32,7 @@ public class ContinuousTurret extends Turret{
}
public class ContinuousTurretBuild extends TurretBuild{
public Bullet bullet;
public @Nullable Bullet bullet;
@Override
protected void updateCooling(){

View File

@@ -29,7 +29,7 @@ public class LaserTurret extends PowerTurret{
}
public class LaserTurretBuild extends PowerTurretBuild{
public Bullet bullet;
public @Nullable Bullet bullet;
public float bulletLife;
@Override

View File

@@ -512,7 +512,6 @@ public class Turret extends ReloadTurret{
recoil = recoilAmount;
heat = 1f;
bullet(type, rotation + Mathf.range(inaccuracy + type.inaccuracy));
effects();
charging = false;
});
@@ -525,7 +524,6 @@ public class Turret extends ReloadTurret{
bulletOffset.trns(rotation, shootLength, Mathf.range(xRand));
bullet(peekAmmo(), rotation + Mathf.range(inaccuracy + peekAmmo().inaccuracy) + (ii - (int)(shots / 2f)) * spread);
effects();
useAmmo();
recoil = recoilAmount;
heat = 1f;
@@ -544,7 +542,6 @@ public class Turret extends ReloadTurret{
bulletOffset.trns(rotation - 90, (spread) * i + Mathf.range(xRand), shootLength);
bullet(type, rotation + Mathf.range(inaccuracy + type.inaccuracy));
shotCounter ++;
effects();
}
}else{
bulletOffset.trns(rotation, shootLength, Mathf.range(xRand));
@@ -553,7 +550,6 @@ public class Turret extends ReloadTurret{
bullet(type, rotation + Mathf.range(inaccuracy + type.inaccuracy) + (i - (int)(shots / 2f)) * spread);
shotCounter ++;
}
effects();
}
recoil = recoilAmount;
@@ -563,9 +559,10 @@ public class Turret extends ReloadTurret{
}
protected void bullet(BulletType type, float angle){
float lifeScl = type.scaleVelocity ? Mathf.clamp(Mathf.dst(x + bulletOffset.x, y + bulletOffset.y, targetPos.x, targetPos.y) / type.range(), minRange / type.range(), range() / type.range()) : 1f;
float lifeScl = type.scaleVelocity ? Mathf.clamp(Mathf.dst(x + bulletOffset.x, y + bulletOffset.y, targetPos.x, targetPos.y) / type.range, minRange / type.range, range() / type.range) : 1f;
type.create(this, team, x + bulletOffset.x, y + bulletOffset.y, angle, 1f + Mathf.range(velocityInaccuracy), lifeScl);
effects();
}
protected void effects(){