Merge remote-tracking branch 'origin/master'

This commit is contained in:
Anuken
2023-07-26 10:31:24 -04:00
4 changed files with 78 additions and 68 deletions

View File

@@ -997,6 +997,10 @@ public class Block extends UnlockableContent implements Senseable{
return consume(new ConsumeCoolant(amount));
}
public ConsumeCoolant consumeCoolant(float amount, boolean allowLiquid, boolean allowGas){
return consume(new ConsumeCoolant(amount, allowLiquid, allowGas));
}
public <T extends Consume> T consume(T consume){
if(consume instanceof ConsumePower){
//there can only be one power consumer

View File

@@ -3,11 +3,19 @@ package mindustry.world.consumers;
/** A ConsumeLiquidFilter that consumes specific coolant, selected based on stats. */
public class ConsumeCoolant extends ConsumeLiquidFilter{
public float maxTemp = 0.5f, maxFlammability = 0.1f;
public boolean allowLiquid = true, allowGas = false;
public ConsumeCoolant(float amount){
this.filter = liquid -> liquid.coolant && !liquid.gas && liquid.temperature <= maxTemp && liquid.flammability < maxFlammability;
public ConsumeCoolant(float amount, boolean allowLiquid, boolean allowGas){
this.allowLiquid = allowLiquid;
this.allowGas = allowGas;
this.filter = liquid -> liquid.coolant && (this.allowLiquid && !liquid.gas || this.allowGas && liquid.gas) && liquid.temperature <= maxTemp && liquid.flammability < maxFlammability;
this.amount = amount;
}
public ConsumeCoolant(float amount){
this(amount, true, false);
}
public ConsumeCoolant(){
this(1f);