Fix ContinuousLiquidTurret not changing bullets when changing liquids. (#7561)
* Wrong liquid, don't keep bullet alive. * Better transition * Annihilate unnecessary code duplication * Further reduce duplicated code * Unnecessary imports
This commit is contained in:
@@ -72,6 +72,11 @@ public class ContinuousLiquidTurret extends ContinuousTurret{
|
||||
super.updateTile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConsume(){
|
||||
return hasCorrectAmmo() && super.canConsume();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BulletType useAmmo(){
|
||||
//does not consume ammo upon firing
|
||||
@@ -85,7 +90,11 @@ public class ContinuousLiquidTurret extends ContinuousTurret{
|
||||
|
||||
@Override
|
||||
public boolean hasAmmo(){
|
||||
return ammoTypes.get(liquids.current()) != null && liquids.currentAmount() >= 1f / ammoTypes.get(liquids.current()).ammoMultiplier;
|
||||
return hasCorrectAmmo() && ammoTypes.get(liquids.current()) != null && liquids.currentAmount() >= 1f / ammoTypes.get(liquids.current()).ammoMultiplier;
|
||||
}
|
||||
|
||||
public boolean hasCorrectAmmo(){
|
||||
return !bullets.any() || bullets.first().bullet.type == peekAmmo();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -81,6 +81,16 @@ public class ContinuousTurret extends Turret{
|
||||
|
||||
if(bullets.any()){
|
||||
for(var entry : bullets){
|
||||
updateBullet(entry);
|
||||
}
|
||||
|
||||
wasShooting = true;
|
||||
heat = 1f;
|
||||
curRecoil = recoil;
|
||||
}
|
||||
}
|
||||
|
||||
protected void updateBullet(BulletEntry entry){
|
||||
float
|
||||
bulletX = x + Angles.trnsx(rotation - 90, shootX + entry.x, shootY + entry.y),
|
||||
bulletY = y + Angles.trnsy(rotation - 90, shootX + entry.x, shootY + entry.y),
|
||||
@@ -107,12 +117,6 @@ public class ContinuousTurret extends Turret{
|
||||
}
|
||||
}
|
||||
|
||||
wasShooting = true;
|
||||
heat = 1f;
|
||||
curRecoil = recoil;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateReload(){
|
||||
//continuous turrets don't have a concept of reload, they are always firing when possible
|
||||
|
||||
Reference in New Issue
Block a user