Allow fluid type configuration for ConsumeCoolant (#8841)
* Allow fluid type configuration for ConsumeCoolant * Methods
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user