Breach turret done / DrawTurret & reload fixes

This commit is contained in:
Anuken
2021-12-03 12:28:13 -05:00
parent 9c9d147b95
commit 61bb4d2dac
11 changed files with 65 additions and 8 deletions

View File

@@ -95,13 +95,18 @@ public class ContinuousTurret extends Turret{
return super.sense(sensor);
}
@Override
protected void updateReload(){
//continuous turrets don't have a concept of reload, they are always firing when possible
}
@Override
protected void updateShooting(){
if(bullet != null){
return;
}
if(reload <= 0 && (consValid() || cheating()) && !charging){
if((consValid() || cheating()) && !charging){
BulletType type = peekAmmo();
shoot(type);
}

View File

@@ -90,6 +90,11 @@ public class LaserTurret extends PowerTurret{
return 1f - Mathf.clamp(reload / reloadTime);
}
@Override
protected void updateReload(){
//updated in updateTile() depending on coolant
}
@Override
protected void updateShooting(){
if(bulletLife > 0 && bullet != null){

View File

@@ -27,6 +27,13 @@ public class ReloadTurret extends BaseTurret{
public class ReloadTurretBuild extends BaseTurretBuild{
public float reload;
@Override
public void created(){
super.created();
//for visual reasons, the turret does not need reloading when placed
reload = reloadTime;
}
protected void updateCooling(){
if(reload < reloadTime){
float maxUsed = consumes.<ConsumeLiquidBase>get(ConsumeType.liquid).amount;

View File

@@ -309,6 +309,9 @@ public class Turret extends ReloadTurret{
logicControlTime -= Time.delta;
}
//turret always reloads regardless of whether it's targeting something
updateReload();
if(hasAmmo()){
if(Float.isNaN(reload)) rotation = 0;
@@ -412,8 +415,15 @@ public class Turret extends ReloadTurret{
return ammo.size > 0 && ammo.peek().amount >= ammoPerShot;
}
protected void updateReload(){
float multiplier = hasAmmo() ? peekAmmo().reloadMultiplier : 1f;
reload += delta() * multiplier * baseReloadSpeed();
//cap reload for visual reasons
reload = Math.min(reload, reloadTime);
}
protected void updateShooting(){
reload += delta() * peekAmmo().reloadMultiplier * baseReloadSpeed();
if(reload >= reloadTime && !charging){
BulletType type = peekAmmo();

View File

@@ -131,6 +131,9 @@ public class DrawTurret extends DrawBlock{
public boolean outline = true;
/** If true, the layer is overridden to be under the turret itself. */
public boolean under = false;
/** If true, progress is inverted. */
public boolean invert = false;
public Interp interp = Interp.linear;
public float layer = -1;
public float outlineLayerOffset = -0.01f;
public float rotation, rotMove;
@@ -154,10 +157,12 @@ public class DrawTurret extends DrawBlock{
}
float prevZ = layer > 0 ? layer : z;
float progress = useReload ? build.progress() : build.warmup();
if(oscMag > 0){
progress += oscAbs ? Mathf.absin(oscScl, oscMag) : Mathf.sin(oscScl, oscMag);
}
float progress = useReload ? 1f - build.progress() : build.warmup();
if(oscMag > 0) progress += oscAbs ? Mathf.absin(oscScl, oscMag) : Mathf.sin(oscScl, oscMag);
if(invert) progress = 1f - progress;
progress = interp.apply(progress);
for(int i = 0; i < regions.length; i++){
var region = regions[i];