This commit is contained in:
Anuken
2019-03-16 22:59:50 -04:00
parent 22fadab3b3
commit e7b813962d
4 changed files with 15 additions and 7 deletions

View File

@ -31,7 +31,7 @@ public class Build{
if(tile == null) return;
if(tile.entity != null){
prevPercent = tile.entity.health();
prevPercent = tile.entity.healthf();
}
tile = tile.target();

View File

@ -18,6 +18,11 @@ public class BlockPart extends Block{
hasPower = hasItems = hasLiquids = true;
}
@Override
public void drawTeam(Tile tile){
}
@Override
public boolean synthetic(){
return true;

View File

@ -56,8 +56,12 @@ public class BuildBlock extends Block{
@Remote(called = Loc.server)
public static void onConstructFinish(Tile tile, Block block, int builderID, byte rotation, Team team){
if(tile == null) return;
float healthf = tile.entity == null ? 1f : tile.entity.healthf();
tile.setRotation(rotation);
world.setBlock(tile, block, team);
if(tile.entity != null){
tile.entity.health = block.health * healthf;
}
Effects.effect(Fx.placeBlock, tile.drawx(), tile.drawy(), block.size);
Core.app.post(() -> tile.block().placed(tile));
@ -186,7 +190,7 @@ public class BuildBlock extends Block{
public void construct(Unit builder, TileEntity core, float amount){
if(block == null){
damage(99999);
kill();
return;
}

View File

@ -143,11 +143,6 @@ public class PowerGraph{
}
public void update(){
if(Core.graphics.getFrameId() == lastFrameUpdated || (consumers.size == 0 && producers.size == 0 && batteries.size == 0)){
powerBalance.addValue(0f);
return;
}
lastFrameUpdated = Core.graphics.getFrameId();
float powerNeeded = getPowerNeeded();
@ -155,6 +150,10 @@ public class PowerGraph{
powerBalance.addValue((powerProduced - powerNeeded) / Time.delta());
if(Core.graphics.getFrameId() == lastFrameUpdated || (consumers.size == 0 && producers.size == 0 && batteries.size == 0)){
return;
}
if(!Mathf.isEqual(powerNeeded, powerProduced)){
if(powerNeeded > powerProduced){
powerProduced += useBatteries(powerNeeded - powerProduced);