From 4ff1b5ac087a9cdb802313041ac8c9aee8f0aa19 Mon Sep 17 00:00:00 2001 From: Anuken Date: Wed, 23 Feb 2022 17:52:52 -0500 Subject: [PATCH] Fixed compilation --- .../entities/pattern/ShotPattern.java | 12 +++++++++ core/src/mindustry/type/Weapon.java | 25 +++++++------------ .../type/weapons/PointDefenseWeapon.java | 2 +- .../type/weapons/RepairBeamWeapon.java | 2 +- 4 files changed, 23 insertions(+), 18 deletions(-) create mode 100644 core/src/mindustry/entities/pattern/ShotPattern.java diff --git a/core/src/mindustry/entities/pattern/ShotPattern.java b/core/src/mindustry/entities/pattern/ShotPattern.java new file mode 100644 index 0000000000..d9be232034 --- /dev/null +++ b/core/src/mindustry/entities/pattern/ShotPattern.java @@ -0,0 +1,12 @@ +package mindustry.entities.pattern; + +import arc.func.*; +import arc.math.geom.*; + +//TODO +public class ShotPattern{ + + public void shoot(Cons positionSetter, Cons positionHandler){ + + } +} diff --git a/core/src/mindustry/type/Weapon.java b/core/src/mindustry/type/Weapon.java index 829a208c07..ebde50d2ea 100644 --- a/core/src/mindustry/type/Weapon.java +++ b/core/src/mindustry/type/Weapon.java @@ -369,12 +369,11 @@ public class Weapon implements Cloneable{ } protected void shoot(Unit unit, WeaponMount mount, float shootX, float shootY, float rotation){ - boolean delay = firstShotDelay + shotDelay > 0f; - Unit parent = bullet.keepVelocity || parentizeEffects ? unit : null; + unit.apply(shootStatus, shootStatusDuration); if(firstShotDelay > 0){ 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: @@ -384,14 +383,12 @@ public class Weapon implements Cloneable{ //TODO merge with Turret behavior if possible for(int i = 0; i < shots; i++){ float angleOffset = i * spacing - (shots - 1) * spacing / 2f; - if(delay){ + if(firstShotDelay + shotDelay > 0f){ Time.run(i * shotDelay + firstShotDelay, () -> shoot(unit, mount, angleOffset)); }else{ shoot(unit, mount, angleOffset); } } - - unit.apply(shootStatus, shootStatusDuration); } protected void shoot(Unit unit, WeaponMount mount, float angleOffset){ @@ -404,18 +401,16 @@ public class Weapon implements Cloneable{ shootAngle = bulletRotation(unit, mount, bulletX, bulletY), 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){ - if(!unit.isAdded()) return null; + 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; - float - xr = Mathf.range(xRand), - x = shootX + Angles.trnsx(angle, 0, xr), - y = shootY + Angles.trnsy(angle, 0, xr); + //TODO should be part of shoot pattern. + float xr = Mathf.range(xRand), 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){ shootSound.at(shootX, shootY, Mathf.random(soundPitchMin, soundPitchMax)); @@ -429,8 +424,6 @@ public class Weapon implements Cloneable{ Effect.shake(shake, shake, shootX, shootY); mount.recoil = recoil; mount.heat = 1f; - - return result; } public Weapon copy(){ diff --git a/core/src/mindustry/type/weapons/PointDefenseWeapon.java b/core/src/mindustry/type/weapons/PointDefenseWeapon.java index 7df83e1148..2cf6d6a612 100644 --- a/core/src/mindustry/type/weapons/PointDefenseWeapon.java +++ b/core/src/mindustry/type/weapons/PointDefenseWeapon.java @@ -45,7 +45,7 @@ public class PointDefenseWeapon extends Weapon{ } @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(target.damage() > bullet.damage){ diff --git a/core/src/mindustry/type/weapons/RepairBeamWeapon.java b/core/src/mindustry/type/weapons/RepairBeamWeapon.java index 62bc1edc24..e69b163156 100644 --- a/core/src/mindustry/type/weapons/RepairBeamWeapon.java +++ b/core/src/mindustry/type/weapons/RepairBeamWeapon.java @@ -95,7 +95,7 @@ public class RepairBeamWeapon extends Weapon{ } @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() }