Turret pattern rewrite

This commit is contained in:
Anuken
2022-02-24 23:29:36 -05:00
parent c3e9a961c5
commit 45f27eaeec
17 changed files with 239 additions and 240 deletions

View File

@@ -1,6 +1,6 @@
package mindustry.entities.pattern;
public class AlternatePattern extends ShotPattern{
public class ShootAlternate extends ShootPattern{
/** number of barrels used for shooting. */
public int barrels = 2;
/** spread between barrels, in world units - not degrees. */

View File

@@ -0,0 +1,16 @@
package mindustry.entities.pattern;
public class ShootBarrel extends ShootPattern{
/** barrels [in x, y, rotation] format. */
public float[] barrels = {0f, 0f, 0f};
/** offset of barrel to start on */
public int barrelOffset = 0;
@Override
public void shoot(int totalShots, BulletHandler handler){
for(int i = 0; i < shots; i++){
int index = ((i + totalShots + barrelOffset) % (barrels.length / 3)) * 3;
handler.shoot(barrels[index], barrels[index + 1], barrels[index + 2], firstShotDelay + shotDelay * i);
}
}
}

View File

@@ -1,15 +1,15 @@
package mindustry.entities.pattern;
public class MultiPattern extends ShotPattern{
public ShotPattern source;
public ShotPattern[] dest = {};
public class ShootMulti extends ShootPattern{
public ShootPattern source;
public ShootPattern[] dest = {};
public MultiPattern(ShotPattern source, ShotPattern... dest){
public ShootMulti(ShootPattern source, ShootPattern... dest){
this.source = source;
this.dest = dest;
}
public MultiPattern(){
public ShootMulti(){
}
@Override

View File

@@ -1,7 +1,7 @@
package mindustry.entities.pattern;
/** Handles different types of bullet patterns for shooting. */
public class ShotPattern{
public class ShootPattern{
/** amount of shots per "trigger pull" */
public int shots = 1;
/** delay in ticks before first shot */

View File

@@ -2,18 +2,18 @@ package mindustry.entities.pattern;
import arc.math.*;
public class SinePattern extends ShotPattern{
public class ShootSine extends ShootPattern{
/** scaling applied to bullet index */
public float scl = 4f;
/** magnitude of sine curve for position displacement */
public float mag = 20f;
public SinePattern(float scl, float mag){
public ShootSine(float scl, float mag){
this.scl = scl;
this.mag = mag;
}
public SinePattern(){
public ShootSine(){
}
@Override

View File

@@ -1,6 +1,6 @@
package mindustry.entities.pattern;
public class SpreadPattern extends ShotPattern{
public class ShootSpread extends ShootPattern{
/** spread between bullets, in degrees. */
public float spread = 5f;