Breach turret done / DrawTurret & reload fixes
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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){
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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];
|
||||
|
||||
Reference in New Issue
Block a user