Skip to content

Commit

Permalink
Methods
Browse files Browse the repository at this point in the history
  • Loading branch information
MEEPofFaith committed Jul 25, 2023
1 parent 1317407 commit a7816d8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 4 additions & 0 deletions core/src/mindustry/world/Block.java
Original file line number Diff line number Diff line change
Expand Up @@ -995,6 +995,10 @@ public ConsumeCoolant consumeCoolant(float amount){
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
Expand Down
11 changes: 9 additions & 2 deletions core/src/mindustry/world/consumers/ConsumeCoolant.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,17 @@ 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 && (allowLiquid && !liquid.gas || allowGas && 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);
Expand Down

0 comments on commit a7816d8

Please sign in to comment.