Turret instant reload fix

This commit is contained in:
Anuken
2022-05-14 23:28:15 -04:00
parent bc65e63654
commit 67344ffd7d
3 changed files with 6 additions and 8 deletions

View File

@@ -25,13 +25,6 @@ public class ReloadTurret extends BaseTurret{
public class ReloadTurretBuild extends BaseTurretBuild{
public float reloadCounter;
@Override
public void created(){
super.created();
//for visual reasons, the turret does not need reloading when placed; however, it should not be *fully* reloaded, so firing will not occur
reloadCounter = reload - 0.0001f;
}
protected void updateCooling(){
if(reloadCounter < reload && coolant != null && coolant.efficiency(this) > 0 && efficiency > 0){
float capacity = coolant instanceof ConsumeLiquidFilter filter ? filter.getConsumed(this).heatCapacity : 1f;

View File

@@ -200,6 +200,8 @@ public class Turret extends ReloadTurret{
public float curRecoil, heat, logicControlTime = -1;
public float shootWarmup;
public int totalShots;
//turrets need to shoot once for 'visual reload' to be valid, otherwise they seem stuck at reload 0 when placed.
public boolean visualReloadValid;
public boolean logicShooting = false;
public @Nullable Posc target;
public Vec2 targetPos = new Vec2();
@@ -491,6 +493,7 @@ public class Turret extends ReloadTurret{
protected void updateShooting(){
if(reloadCounter >= reload && !charging() && shootWarmup >= minWarmup){
visualReloadValid = true;
BulletType type = peekAmmo();
shoot(type);

View File

@@ -67,8 +67,10 @@ public class DrawTurret extends DrawBlock{
Draw.z(Layer.turret);
}
float progress = tb.visualReloadValid ? tb.progress() : 1f;
//TODO no smooth reload
var params = DrawPart.params.set(build.warmup(), 1f - tb.progress(), 1f - tb.progress(), tb.heat, tb.x + tb.recoilOffset.x, tb.y + tb.recoilOffset.y, tb.rotation);
var params = DrawPart.params.set(build.warmup(), 1f - progress, 1f - progress, tb.heat, tb.x + tb.recoilOffset.x, tb.y + tb.recoilOffset.y, tb.rotation);
for(var part : parts){
part.draw(params);