Fixed compilation

This commit is contained in:
Anuken
2022-02-23 17:52:52 -05:00
parent 8bbf060b12
commit 4ff1b5ac08
4 changed files with 23 additions and 18 deletions

View File

@@ -0,0 +1,12 @@
package mindustry.entities.pattern;
import arc.func.*;
import arc.math.geom.*;
//TODO
public class ShotPattern{
public void shoot(Cons<Vec2> positionSetter, Cons<Vec2> positionHandler){
}
}

View File

@@ -369,12 +369,11 @@ public class Weapon implements Cloneable{
} }
protected void shoot(Unit unit, WeaponMount mount, float shootX, float shootY, float rotation){ protected void shoot(Unit unit, WeaponMount mount, float shootX, float shootY, float rotation){
boolean delay = firstShotDelay + shotDelay > 0f; unit.apply(shootStatus, shootStatusDuration);
Unit parent = bullet.keepVelocity || parentizeEffects ? unit : null;
if(firstShotDelay > 0){ if(firstShotDelay > 0){
chargeSound.at(shootX, shootY, Mathf.random(soundPitchMin, soundPitchMax)); chargeSound.at(shootX, shootY, Mathf.random(soundPitchMin, soundPitchMax));
bullet.chargeEffect.at(shootX, shootY, rotation, parent); bullet.chargeEffect.at(shootX, shootY, rotation, bullet.keepVelocity || parentizeEffects ? unit : null);
} }
//shot patterns should be able to customize: //shot patterns should be able to customize:
@@ -384,14 +383,12 @@ public class Weapon implements Cloneable{
//TODO merge with Turret behavior if possible //TODO merge with Turret behavior if possible
for(int i = 0; i < shots; i++){ for(int i = 0; i < shots; i++){
float angleOffset = i * spacing - (shots - 1) * spacing / 2f; float angleOffset = i * spacing - (shots - 1) * spacing / 2f;
if(delay){ if(firstShotDelay + shotDelay > 0f){
Time.run(i * shotDelay + firstShotDelay, () -> shoot(unit, mount, angleOffset)); Time.run(i * shotDelay + firstShotDelay, () -> shoot(unit, mount, angleOffset));
}else{ }else{
shoot(unit, mount, angleOffset); shoot(unit, mount, angleOffset);
} }
} }
unit.apply(shootStatus, shootStatusDuration);
} }
protected void shoot(Unit unit, WeaponMount mount, float angleOffset){ protected void shoot(Unit unit, WeaponMount mount, float angleOffset){
@@ -404,18 +401,16 @@ public class Weapon implements Cloneable{
shootAngle = bulletRotation(unit, mount, bulletX, bulletY), shootAngle = bulletRotation(unit, mount, bulletX, bulletY),
lifeScl = bullet.scaleVelocity ? Mathf.clamp(Mathf.dst(shootX, shootY, mount.aimX, mount.aimY) / bullet.range) : 1f; lifeScl = bullet.scaleVelocity ? Mathf.clamp(Mathf.dst(shootX, shootY, mount.aimX, mount.aimY) / bullet.range) : 1f;
mount.bullet = bullet(mount, unit, shootX, shootY, angleOffset + shootAngle + Mathf.range(inaccuracy), lifeScl, shootAngle, mountX, mountY); bullet(mount, unit, shootX, shootY, angleOffset + shootAngle + Mathf.range(inaccuracy), lifeScl, shootAngle, mountX, mountY);
} }
protected @Nullable Bullet bullet(WeaponMount mount, Unit unit, float shootX, float shootY, float angle, float lifescl, float mountRotation, float mountX, float mountY){ protected void bullet(WeaponMount mount, Unit unit, float shootX, float shootY, float angle, float lifescl, float mountRotation, float mountX, float mountY){
if(!unit.isAdded()) return null; if(!unit.isAdded()) return;
float //TODO should be part of shoot pattern.
xr = Mathf.range(xRand), float xr = Mathf.range(xRand), x = shootX + Angles.trnsx(angle, 0, xr), y = shootY + Angles.trnsy(angle, 0, xr);
x = shootX + Angles.trnsx(angle, 0, xr),
y = shootY + Angles.trnsy(angle, 0, xr);
Bullet result = bullet.create(unit, unit.team, x, y, angle, (1f - velocityRnd) + Mathf.random(velocityRnd), lifescl); mount.bullet = bullet.create(unit, unit.team, x, y, angle, (1f - velocityRnd) + Mathf.random(velocityRnd), lifescl);
if(!continuous){ if(!continuous){
shootSound.at(shootX, shootY, Mathf.random(soundPitchMin, soundPitchMax)); shootSound.at(shootX, shootY, Mathf.random(soundPitchMin, soundPitchMax));
@@ -429,8 +424,6 @@ public class Weapon implements Cloneable{
Effect.shake(shake, shake, shootX, shootY); Effect.shake(shake, shake, shootX, shootY);
mount.recoil = recoil; mount.recoil = recoil;
mount.heat = 1f; mount.heat = 1f;
return result;
} }
public Weapon copy(){ public Weapon copy(){

View File

@@ -45,7 +45,7 @@ public class PointDefenseWeapon extends Weapon{
} }
@Override @Override
protected void shoot(Unit unit, WeaponMount mount, float shootX, float shootY, float aimX, float aimY, float mountX, float mountY, float rotation, int side){ protected void shoot(Unit unit, WeaponMount mount, float shootX, float shootY, float rotation){
if(!(mount.target instanceof Bullet target)) return; if(!(mount.target instanceof Bullet target)) return;
if(target.damage() > bullet.damage){ if(target.damage() > bullet.damage){

View File

@@ -95,7 +95,7 @@ public class RepairBeamWeapon extends Weapon{
} }
@Override @Override
protected void shoot(Unit unit, WeaponMount mount, float shootX, float shootY, float aimX, float aimY, float mountX, float mountY, float rotation, int side){ protected void shoot(Unit unit, WeaponMount mount, float shootX, float shootY, float rotation){
//does nothing, shooting is handled in update() //does nothing, shooting is handled in update()
} }