Allow flipped shot patterns
This commit is contained in:
@@ -6,6 +6,14 @@ public class ShootBarrel extends ShootPattern{
|
|||||||
/** offset of barrel to start on */
|
/** offset of barrel to start on */
|
||||||
public int barrelOffset = 0;
|
public int barrelOffset = 0;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void flip(){
|
||||||
|
barrels = barrels.clone();
|
||||||
|
for(int i = 0; i < barrels.length; i += 3){
|
||||||
|
barrels[i] *= -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void shoot(int totalShots, BulletHandler handler){
|
public void shoot(int totalShots, BulletHandler handler){
|
||||||
for(int i = 0; i < shots; i++){
|
for(int i = 0; i < shots; i++){
|
||||||
|
|||||||
@@ -12,6 +12,18 @@ public class ShootMulti extends ShootPattern{
|
|||||||
public ShootMulti(){
|
public ShootMulti(){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//deep copy needed for flips
|
||||||
|
@Override
|
||||||
|
public void flip(){
|
||||||
|
source = source.copy();
|
||||||
|
source.flip();
|
||||||
|
dest = dest.clone();
|
||||||
|
for(int i = 0; i < dest.length; i++){
|
||||||
|
dest[i] = dest[i].copy();
|
||||||
|
dest[i].flip();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void shoot(int totalShots, BulletHandler handler){
|
public void shoot(int totalShots, BulletHandler handler){
|
||||||
source.shoot(totalShots, (x, y, rotation, delay, move) -> {
|
source.shoot(totalShots, (x, y, rotation, delay, move) -> {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package mindustry.entities.pattern;
|
|||||||
import mindustry.entities.*;
|
import mindustry.entities.*;
|
||||||
|
|
||||||
/** Handles different types of bullet patterns for shooting. */
|
/** Handles different types of bullet patterns for shooting. */
|
||||||
public class ShootPattern{
|
public class ShootPattern implements Cloneable{
|
||||||
/** amount of shots per "trigger pull" */
|
/** amount of shots per "trigger pull" */
|
||||||
public int shots = 1;
|
public int shots = 1;
|
||||||
/** delay in ticks before first shot */
|
/** delay in ticks before first shot */
|
||||||
@@ -18,6 +18,19 @@ public class ShootPattern{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Subclasses should override this to flip its sides. */
|
||||||
|
public void flip(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShootPattern copy(){
|
||||||
|
try{
|
||||||
|
return (ShootPattern)clone();
|
||||||
|
}catch(CloneNotSupportedException absurd){
|
||||||
|
throw new RuntimeException("impending doom", absurd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public interface BulletHandler{
|
public interface BulletHandler{
|
||||||
/**
|
/**
|
||||||
* @param x x offset of bullet, should be transformed by weapon rotation
|
* @param x x offset of bullet, should be transformed by weapon rotation
|
||||||
|
|||||||
@@ -512,9 +512,7 @@ public class UnitType extends UnlockableContent{
|
|||||||
//mirrors are copies with X values negated
|
//mirrors are copies with X values negated
|
||||||
if(w.mirror){
|
if(w.mirror){
|
||||||
Weapon copy = w.copy();
|
Weapon copy = w.copy();
|
||||||
copy.x *= -1;
|
copy.flip();
|
||||||
copy.shootX *= -1;
|
|
||||||
copy.flipSprite = !copy.flipSprite;
|
|
||||||
mapped.add(copy);
|
mapped.add(copy);
|
||||||
|
|
||||||
//since there are now two weapons, the reload and recoil time must be doubled
|
//since there are now two weapons, the reload and recoil time must be doubled
|
||||||
|
|||||||
@@ -411,6 +411,14 @@ public class Weapon implements Cloneable{
|
|||||||
mount.heat = 1f;
|
mount.heat = 1f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void flip(){
|
||||||
|
x *= -1;
|
||||||
|
shootX *= -1;
|
||||||
|
flipSprite = !flipSprite;
|
||||||
|
shoot = shoot.copy();
|
||||||
|
shoot.flip();
|
||||||
|
}
|
||||||
|
|
||||||
public Weapon copy(){
|
public Weapon copy(){
|
||||||
try{
|
try{
|
||||||
return (Weapon)clone();
|
return (Weapon)clone();
|
||||||
|
|||||||
Reference in New Issue
Block a user