mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-01-27 16:09:57 +07:00
Add powerDynamic to Consumers (#5205)
* Add DynamicConsumePower, and powerDynamic to Consumers * Add period to description of DynamicConsumePower Co-authored-by: Patrick 'Quezler' Mounier <Quezler@me.com> * Remove redundant Boolf Co-authored-by: Patrick 'Quezler' Mounier <Quezler@me.com>
This commit is contained in:
parent
4a922e4c10
commit
79695086c6
@ -0,0 +1,20 @@
|
||||
package mindustry.world.blocks.power;
|
||||
|
||||
import arc.func.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.world.consumers.*;
|
||||
|
||||
/** A power consumer that uses a dynamic amount of power. */
|
||||
public class DynamicConsumePower extends ConsumePower{
|
||||
private final Floatf<Building> usage;
|
||||
|
||||
public DynamicConsumePower(Floatf<Building> usage){
|
||||
super(0, 0, false);
|
||||
this.usage = usage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float requestedPower(Building entity){
|
||||
return usage.get(entity);
|
||||
}
|
||||
}
|
@ -68,6 +68,11 @@ public class Consumers{
|
||||
return add(new ConditionalConsumePower(usage, (Boolf<Building>)cons));
|
||||
}
|
||||
|
||||
/** Creates a consumer that consumes a dynamic amount of power. */
|
||||
public <T extends Building> ConsumePower powerDynamic(Floatf<T> usage){
|
||||
return add(new DynamicConsumePower((Floatf<Building>)usage));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a consumer which stores power.
|
||||
* @param powerCapacity The maximum capacity in power units.
|
||||
|
Loading…
Reference in New Issue
Block a user