mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-01-10 23:28:52 +07:00
Fixed NaN liquid efficiency
This commit is contained in:
parent
1e7219f7d1
commit
26fbf4c71e
@ -90,7 +90,7 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
void checkTargets(float x, float y){
|
||||
Unit unit = Units.closestEnemy(player.team(), x, y, 20f, u -> !u.dead);
|
||||
|
||||
if(unit != null){
|
||||
if(unit != null && player.unit().type.canAttack){
|
||||
player.unit().mineTile = null;
|
||||
target = unit;
|
||||
}else{
|
||||
|
@ -40,8 +40,10 @@ public class ConsumeLiquid extends ConsumeLiquidBase{
|
||||
|
||||
@Override
|
||||
public float efficiency(Building build){
|
||||
float ed = build.edelta();
|
||||
if(ed <= 0.00000001f) return 0f;
|
||||
//there can be more liquid than necessary, so cap at 1
|
||||
return Math.min(build.liquids.get(liquid) / (amount * build.edelta()), 1f);
|
||||
return Math.min(build.liquids.get(liquid) / (amount * ed), 1f);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -50,7 +50,9 @@ public class ConsumeLiquidFilter extends ConsumeLiquidBase{
|
||||
@Override
|
||||
public float efficiency(Building build){
|
||||
var liq = getConsumed(build);
|
||||
return liq != null ? Math.min(build.liquids.get(liq) / (amount * build.edelta()), 1f) : 0f;
|
||||
float ed = build.edelta();
|
||||
if(ed <= 0.00000001f) return 0f;
|
||||
return liq != null ? Math.min(build.liquids.get(liq) / (amount * ed), 1f) : 0f;
|
||||
}
|
||||
|
||||
public @Nullable Liquid getConsumed(Building build){
|
||||
|
@ -49,9 +49,11 @@ public class ConsumeLiquids extends Consume{
|
||||
|
||||
@Override
|
||||
public float efficiency(Building build){
|
||||
float min = 1f, delta = build.edelta();
|
||||
float ed = build.edelta();
|
||||
if(ed <= 0.00000001f) return 0f;
|
||||
float min = 1f;
|
||||
for(var stack : liquids){
|
||||
min = Math.min(build.liquids.get(stack.liquid) / (stack.amount * delta), min);
|
||||
min = Math.min(build.liquids.get(stack.liquid) / (stack.amount * ed), min);
|
||||
}
|
||||
return min;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user