Laser crash fix
This commit is contained in:
@@ -6,6 +6,7 @@ import arc.util.*;
|
|||||||
import mindustry.entities.bullet.*;
|
import mindustry.entities.bullet.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
|
import mindustry.world.consumers.*;
|
||||||
import mindustry.world.meta.*;
|
import mindustry.world.meta.*;
|
||||||
|
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
@@ -29,6 +30,15 @@ public class LaserTurret extends PowerTurret{
|
|||||||
stats.add(Stat.input, StatValues.boosters(reload, coolant.amount, coolantMultiplier, false, this::consumesLiquid));
|
stats.add(Stat.input, StatValues.boosters(reload, coolant.amount, coolantMultiplier, false, this::consumesLiquid));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(){
|
||||||
|
super.init();
|
||||||
|
|
||||||
|
if(coolant == null){
|
||||||
|
coolant = findConsumer(c -> c instanceof ConsumeLiquidBase);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class LaserTurretBuild extends PowerTurretBuild{
|
public class LaserTurretBuild extends PowerTurretBuild{
|
||||||
public Seq<BulletEntry> bullets = new Seq<>();
|
public Seq<BulletEntry> bullets = new Seq<>();
|
||||||
|
|
||||||
@@ -69,15 +79,20 @@ public class LaserTurret extends PowerTurret{
|
|||||||
recoil = recoilAmount;
|
recoil = recoilAmount;
|
||||||
}else if(reloadCounter > 0){
|
}else if(reloadCounter > 0){
|
||||||
wasShooting = true;
|
wasShooting = true;
|
||||||
//TODO does not handle multi liquid req?
|
|
||||||
Liquid liquid = liquids.current();
|
|
||||||
float maxUsed = coolant.amount;
|
|
||||||
float used = (cheating() ? maxUsed : Math.min(liquids.get(liquid), maxUsed)) * delta();
|
|
||||||
reloadCounter -= used * liquid.heatCapacity * coolantMultiplier;
|
|
||||||
liquids.remove(liquid, used);
|
|
||||||
|
|
||||||
if(Mathf.chance(0.06 * used)){
|
if(coolant != null){
|
||||||
coolEffect.at(x + Mathf.range(size * tilesize / 2f), y + Mathf.range(size * tilesize / 2f));
|
//TODO does not handle multi liquid req?
|
||||||
|
Liquid liquid = liquids.current();
|
||||||
|
float maxUsed = coolant.amount;
|
||||||
|
float used = (cheating() ? maxUsed : Math.min(liquids.get(liquid), maxUsed)) * delta();
|
||||||
|
reloadCounter -= used * liquid.heatCapacity * coolantMultiplier;
|
||||||
|
liquids.remove(liquid, used);
|
||||||
|
|
||||||
|
if(Mathf.chance(0.06 * used)){
|
||||||
|
coolEffect.at(x + Mathf.range(size * tilesize / 2f), y + Mathf.range(size * tilesize / 2f));
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
reloadCounter -= edelta();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user