Fixed power bug

This commit is contained in:
Anuken
2019-03-09 09:51:12 -05:00
parent 64533de597
commit 563e015c92
12 changed files with 12 additions and 6 deletions

View File

@@ -685,7 +685,7 @@ public class Bullets implements ContentList{
lifetime = 23f;
speed = 1f;
splashDamageRadius = 50f;
splashDamage = 30f;
splashDamage = 20f;
}
@Override

View File

@@ -363,7 +363,11 @@ public class Block extends BlockStorage{
}
if(hasPower && consumes.has(ConsumePower.class)){
bars.add("power", entity -> new Bar(consumes.get(ConsumePower.class).isBuffered ? "blocks.power" : "blocks.power.satisfaction", Pal.powerBar, () -> entity.power.satisfaction));
boolean buffered = consumes.get(ConsumePower.class).isBuffered;
float capacity = consumes.get(ConsumePower.class).powerCapacity;
bars.add("power", entity -> new Bar(() -> buffered ? Core.bundle.format("blocks.powerbalance", Float.isNaN(entity.power.satisfaction * capacity) ? "<BUGGED>" : (int)(entity.power.satisfaction * capacity)) :
Core.bundle.get("blocks.power"), () -> Pal.powerBar, () -> entity.power.satisfaction));
}
}

View File

@@ -111,7 +111,7 @@ public class MassDriver extends Block{
@Override
public TextureRegion[] generateIcons(){
return new TextureRegion[]{Core.atlas.find(name + "-base"), Core.atlas.find(name + "-turret")};
return new TextureRegion[]{Core.atlas.find(name + "-base"), Core.atlas.find(name)};
}
@Override

View File

@@ -123,7 +123,7 @@ public class PowerGraph{
public void distributePower(float needed, float produced){
//distribute even if not needed. this is because some might be requiring power but not requesting it; it updates consumers
float coverage = Math.min(1, produced / needed);
float coverage = Math.min(1, produced / (Mathf.isZero(needed) ? 1f : needed));
for(Tile consumer : consumers){
Consumers consumes = consumer.block().consumes;
if(consumes.has(ConsumePower.class)){

View File

@@ -77,7 +77,7 @@ public class Unloader extends Block implements SelectionTrait{
SortedUnloaderEntity entity = tile.entity();
Draw.color(entity.sortItem == null ? Color.WHITE : entity.sortItem.color);
Draw.color(entity.sortItem == null ? Color.CLEAR : entity.sortItem.color);
Draw.rect("blank", tile.worldx(), tile.worldy(), 2f, 2f);
Draw.color();
}

View File

@@ -4,6 +4,7 @@ import io.anuke.arc.scene.ui.layout.Table;
import io.anuke.mindustry.entities.type.TileEntity;
import io.anuke.mindustry.type.Item;
import io.anuke.mindustry.type.Item.Icon;
import io.anuke.mindustry.type.ItemStack;
import io.anuke.mindustry.ui.ItemImage;
import io.anuke.mindustry.ui.ReqImage;
import io.anuke.mindustry.world.Block;
@@ -60,6 +61,6 @@ public class ConsumeItem extends Consume{
@Override
public void display(BlockStats stats){
stats.add(boost ? BlockStat.boostItem : BlockStat.inputItem, item);
stats.add(boost ? BlockStat.boostItem : BlockStat.inputItem, new ItemStack(item, amount));
}
}

View File

@@ -34,5 +34,6 @@ public class PowerModule extends BlockModule{
links.add(stream.readInt());
}
satisfaction = stream.readFloat();
if(Float.isNaN(satisfaction) || Float.isInfinite(satisfaction)) satisfaction = 0f;
}
}