Allow fluid type configuration for ConsumeCoolant (#8841)

* Allow fluid type configuration for ConsumeCoolant

* Methods
This commit is contained in:
MEEPofFaith
2023-07-25 18:47:46 -07:00
committed by GitHub
parent dc8783d4a6
commit e5ded1f2dd
2 changed files with 14 additions and 2 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);