mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-03-09 20:29:06 +07:00
Factor in ammo reload multiplier + liquid heat capacity in turret coolant calculations
This commit is contained in:
parent
84dc0027a8
commit
d15a906402
@ -2812,7 +2812,7 @@ public class Blocks{
|
||||
output = Items.sand;
|
||||
fogRadius = 3;
|
||||
ambientSound = Sounds.drill;
|
||||
ambientSoundVolume = 0.05f;
|
||||
ambientSoundVolume = 0.08f;
|
||||
|
||||
consumeLiquid(Liquids.ozone, 1f / 60f);
|
||||
|
||||
|
@ -50,13 +50,6 @@ public class ContinuousLiquidTurret extends ContinuousTurret{
|
||||
public void display(Stats stats){
|
||||
|
||||
}
|
||||
|
||||
//TODO
|
||||
//@Override
|
||||
//protected float use(Building entity){
|
||||
// BulletType type = ammoTypes.get(entity.liquids.current());
|
||||
// return Math.min(amount * entity.edelta(), entity.block.liquidCapacity) / (type == null ? 1f : type.ammoMultiplier);
|
||||
//}
|
||||
});
|
||||
|
||||
ammoTypes.each((item, type) -> placeOverlapRange = Math.max(placeOverlapRange, range + type.rangeChange + placeOverlapMargin));
|
||||
|
@ -1,9 +1,6 @@
|
||||
package mindustry.world.blocks.defense.turrets;
|
||||
|
||||
import arc.math.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.consumers.*;
|
||||
import mindustry.world.meta.*;
|
||||
|
||||
@ -21,23 +18,7 @@ public class ReloadTurret extends BaseTurret{
|
||||
super.setStats();
|
||||
|
||||
if(coolant != null){
|
||||
stats.remove(Stat.booster);
|
||||
|
||||
//TODO this is very hacky, there is no current way to check if a ConsumeLiquidBase accepts something individually. fix later
|
||||
ObjectSet<Liquid> notBooster = content.liquids().select(l -> {
|
||||
for(Consume c : consumers){
|
||||
if(!c.booster && c != coolant &&
|
||||
((c instanceof ConsumeLiquid cl && cl.liquid == l) ||
|
||||
(c instanceof ConsumeLiquids cl2 && Structs.contains(cl2.liquids, s -> s.liquid == l)) ||
|
||||
(c instanceof ConsumeLiquidFilter clf && clf.filter.get(l)))){
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}).asSet();
|
||||
|
||||
stats.add(Stat.booster, StatValues.boosters(reload, coolant.amount, coolantMultiplier, true, l -> l.coolant && consumesLiquid(l) && !notBooster.contains(l)));
|
||||
stats.replace(Stat.booster, StatValues.boosters(reload, coolant.amount, coolantMultiplier, true, coolant::consumes));
|
||||
}
|
||||
}
|
||||
|
||||
@ -46,10 +27,10 @@ public class ReloadTurret extends BaseTurret{
|
||||
|
||||
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;
|
||||
float capacity = coolant instanceof ConsumeLiquidFilter filter ? filter.getConsumed(this).heatCapacity : (coolant.consumes(liquids.current()) ? liquids.current().heatCapacity : 0.4f);
|
||||
float amount = coolant.amount * coolant.efficiency(this);
|
||||
coolant.update(this);
|
||||
reloadCounter += amount * edelta() * capacity * coolantMultiplier;
|
||||
reloadCounter += amount * edelta() * capacity * coolantMultiplier * ammoReloadMultiplier();
|
||||
|
||||
if(Mathf.chance(0.06 * amount)){
|
||||
coolEffect.at(x + Mathf.range(size * tilesize / 2f), y + Mathf.range(size * tilesize / 2f));
|
||||
@ -57,6 +38,10 @@ public class ReloadTurret extends BaseTurret{
|
||||
}
|
||||
}
|
||||
|
||||
protected float ammoReloadMultiplier(){
|
||||
return 1f;
|
||||
}
|
||||
|
||||
protected float baseReloadSpeed(){
|
||||
return efficiency;
|
||||
}
|
||||
|
@ -575,13 +575,17 @@ public class Turret extends ReloadTurret{
|
||||
}
|
||||
|
||||
protected void updateReload(){
|
||||
float multiplier = hasAmmo() ? peekAmmo().reloadMultiplier : 1f;
|
||||
reloadCounter += delta() * multiplier * baseReloadSpeed();
|
||||
reloadCounter += delta() * ammoReloadMultiplier() * baseReloadSpeed();
|
||||
|
||||
//cap reload for visual reasons
|
||||
reloadCounter = Math.min(reloadCounter, reload);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float ammoReloadMultiplier(){
|
||||
return hasAmmo() ? peekAmmo().reloadMultiplier : 1f;
|
||||
}
|
||||
|
||||
protected void updateShooting(){
|
||||
|
||||
if(reloadCounter >= reload && !charging() && shootWarmup >= minWarmup){
|
||||
|
@ -73,6 +73,12 @@ public class Stats{
|
||||
add(stat, StatValues.string(format, args));
|
||||
}
|
||||
|
||||
/** Replaces a stat, removing the old value if it exists. */
|
||||
public void replace(Stat stat, StatValue value){
|
||||
remove(stat);
|
||||
add(stat, value);
|
||||
}
|
||||
|
||||
/** Adds a stat value. */
|
||||
public void add(Stat stat, StatValue value){
|
||||
if(map == null) map = new OrderedMap<>();
|
||||
|
Loading…
Reference in New Issue
Block a user