1
0
mirror of https://github.com/Anuken/Mindustry.git synced 2024-11-10 15:05:23 +03:00

ConsumeCoolant

This commit is contained in:
Anuken 2021-06-09 14:38:49 -04:00
parent c9ff84d03b
commit 6f609aa4ee
11 changed files with 32 additions and 9 deletions

View File

@ -1853,7 +1853,7 @@ public class Blocks implements ContentList{
}};
health = 200 * size * size;
consumes.add(new ConsumeLiquidFilter(liquid -> liquid.temperature <= 0.5f && liquid.flammability < 0.1f, 0.5f)).update(false);
consumes.add(new ConsumeCoolant(0.5f)).update(false);
}};
//endregion

View File

@ -228,6 +228,7 @@ public class ContentParser{
case "item" -> block.consumes.item(find(ContentType.item, child.asString()));
case "items" -> block.consumes.add((Consume)parser.readValue(ConsumeItems.class, child));
case "liquid" -> block.consumes.add((Consume)parser.readValue(ConsumeLiquid.class, child));
case "coolant" -> block.consumes.add((Consume)parser.readValue(ConsumeCoolant.class, child));
case "power" -> {
if(child.isNumber()){
block.consumes.power(child.asFloat());

View File

@ -53,7 +53,7 @@ public class ForceProjector extends Block{
hasItems = true;
ambientSound = Sounds.shield;
ambientSoundVolume = 0.08f;
consumes.add(new ConsumeLiquidFilter(liquid -> liquid.temperature <= 0.5f && liquid.flammability < 0.1f, 0.1f)).boost().update(false);
consumes.add(new ConsumeCoolant(0.1f)).boost().update(false);
}
@Override

View File

@ -37,7 +37,7 @@ public class BaseTurret extends Block{
public void init(){
if(acceptCoolant && !consumes.has(ConsumeType.liquid)){
hasLiquids = true;
consumes.add(new ConsumeLiquidFilter(liquid -> liquid.temperature <= 0.5f && liquid.flammability < 0.1f, 0.2f)).update(false).boost();
consumes.add(new ConsumeCoolant(0.2f)).update(false).boost();
}
super.init();

View File

@ -19,7 +19,7 @@ public class LaserTurret extends PowerTurret{
super(name);
canOverdrive = false;
consumes.add(new ConsumeLiquidFilter(liquid -> liquid.temperature <= 0.5f && liquid.flammability < 0.1f, 0.01f)).update(false);
consumes.add(new ConsumeCoolant(0.01f)).update(false);
coolantMultiplier = 1f;
}

View File

@ -116,7 +116,7 @@ public class Turret extends ReloadTurret{
public void init(){
if(acceptCoolant && !consumes.has(ConsumeType.liquid)){
hasLiquids = true;
consumes.add(new ConsumeLiquidFilter(liquid -> liquid.temperature <= 0.5f && liquid.flammability < 0.1f, coolantUsage)).update(false).boost();
consumes.add(new ConsumeCoolant(coolantUsage)).update(false).boost();
}
if(shootLength < 0) shootLength = size * tilesize / 2f;

View File

@ -76,7 +76,7 @@ public class RepairPoint extends Block{
public void init(){
if(acceptCoolant){
hasLiquids = true;
consumes.add(new ConsumeLiquidFilter(liquid -> liquid.temperature <= 0.5f && liquid.flammability < 0.1f, coolantUse)).optional(true, true);
consumes.add(new ConsumeCoolant(coolantUse)).optional(true, true);
}
consumes.powerCond(powerUse, (RepairPointBuild entity) -> entity.target != null);

View File

@ -0,0 +1,16 @@
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 ConsumeCoolant(float amount){
this.filter = liquid -> liquid.temperature <= maxTemp && liquid.flammability < maxFlammability;
this.amount = amount;
}
//mods
public ConsumeCoolant(){
this(0.1f);
}
}

View File

@ -4,12 +4,14 @@ import mindustry.gen.*;
public abstract class ConsumeLiquidBase extends Consume{
/** amount used per frame */
public final float amount;
public float amount;
public ConsumeLiquidBase(float amount){
this.amount = amount;
}
public ConsumeLiquidBase(){}
@Override
public ConsumeType type(){
return ConsumeType.liquid;

View File

@ -11,13 +11,17 @@ import mindustry.world.meta.*;
import static mindustry.Vars.*;
public class ConsumeLiquidFilter extends ConsumeLiquidBase{
public final Boolf<Liquid> filter;
public Boolf<Liquid> filter;
public ConsumeLiquidFilter(Boolf<Liquid> liquid, float amount){
super(amount);
this.filter = liquid;
}
public ConsumeLiquidFilter(){
this.filter = l -> false;
}
@Override
public void applyLiquidFilter(Bits arr){
content.liquids().each(filter, item -> arr.set(item.id));

View File

@ -9,4 +9,4 @@ kapt.use.worker.api=true
kapt.include.compile.classpath=false
# I don't need to use the kotlin stdlib yet, so remove it to prevent extra bloat & method count issues
kotlin.stdlib.default.dependency=false
archash=2583b8229309dbe5a5c30b647779be5163feb68f
archash=dabe9d3e89a9ed1b1c4cb8496a4525dedf29f613