added buffered power consumer
This commit is contained in:
@@ -43,14 +43,6 @@ public abstract class BaseBlock extends MappableContent{
|
||||
return 0f;
|
||||
}
|
||||
|
||||
public float getPowerConsumption(Tile tile){
|
||||
return 0f;
|
||||
}
|
||||
|
||||
public float usePower(Tile tile){
|
||||
return 0f;
|
||||
}
|
||||
|
||||
/**Returns the amount of items this block can accept.*/
|
||||
public int acceptStack(Item item, int amount, Tile tile, Unit source){
|
||||
if(acceptItem(item, tile, tile) && hasItems && (source == null || source.getTeam() == tile.getTeam())){
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package io.anuke.mindustry.world.consumers;
|
||||
|
||||
import io.anuke.mindustry.entities.TileEntity;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.consumers.ConsumePower;
|
||||
|
||||
public class ConsumePowerBuffered extends ConsumePower{
|
||||
@Override
|
||||
public float getUse(Block block, TileEntity entity){
|
||||
return use * (1 - entity.power.satisfaction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPower(float amount){
|
||||
entity.power.satisfaction = Math.min(entity.power.satisfaction + (amount / use), 1);
|
||||
}
|
||||
|
||||
public void usePower(float amount){
|
||||
entity.power.satisfaction = Math.max(entity.power.satisfaction - (amount / use), 0);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user