Status bar cleanup / Fixed power distribution / Fixed adjacency updates

This commit is contained in:
Anuken 2018-07-09 14:25:52 -04:00
parent 3d9c9e639d
commit f3cc881930
9 changed files with 46 additions and 23 deletions

View File

@ -67,7 +67,7 @@ public class Annotations {
client(false, true),
/**Method can be invoked from anywhere*/
both(true, true),
/**Neither server no client.*/
/**Neither server nor client.*/
none(false, false);
/**If true, this method can be invoked ON clients FROM servers.*/

View File

@ -175,8 +175,8 @@ public class CraftingBlocks extends BlockList implements ContentList {
itemCapacity = 40;
health = 50;
consumes.item(Items.stone);
consumes.liquid(Liquids.water, 0.2f);
consumes.item(Items.stone, 2);
consumes.liquid(Liquids.water, 0.3f);
}};
centrifuge = new Separator("centrifuge") {{
@ -201,9 +201,9 @@ public class CraftingBlocks extends BlockList implements ContentList {
spinnerSpeed = 3f;
size = 2;
consumes.item(Items.stone);
consumes.item(Items.stone, 2);
consumes.power(0.2f);
consumes.liquid(Liquids.water, 0.35f);
consumes.liquid(Liquids.water, 0.5f);
}};
biomatterCompressor = new Compressor("biomattercompressor") {{

View File

@ -151,6 +151,7 @@ public class TileEntity extends BaseEntity implements TargetTrait {
for (GridPoint2 point : nearby) {
Tile other = world.tile(tile.x + point.x, tile.y + point.y);
//remove this tile from all nearby tile's proximities
if(other != null) other = other.target();
if(other != null && other.entity != null){
other.entity.proximity.removeValue(tile, true);
}
@ -164,6 +165,7 @@ public class TileEntity extends BaseEntity implements TargetTrait {
GridPoint2[] nearby = Edges.getEdges(tile.block().size);
for (GridPoint2 point : nearby) {
Tile other = world.tile(tile.x + point.x, tile.y + point.y);
if(other != null) other = other.target();
if(other != null && other.entity != null){
tmpTiles.add(other);

View File

@ -12,6 +12,7 @@ import io.anuke.mindustry.game.TeamInfo.TeamData;
import io.anuke.mindustry.input.InputHandler;
import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.consumers.Consume;
import io.anuke.mindustry.world.meta.BlockBar;
import io.anuke.ucore.core.Graphics;
import io.anuke.ucore.core.Settings;
@ -129,6 +130,18 @@ public class OverlayRenderer {
drawEncloser(target.drawx(), target.drawy() - block.size * tilesize/2f - 2f - values[1], values[1]);
}
Draw.color(Palette.bar);
int idx = 0;
for(Consume cons : block.consumes.all()){
if(!cons.valid(block, entity)){
Fill.crect(entity.x - block.size/2f + idx*4 - 3, entity.y + block.size/2f + values[0] + 11, 3, 3);
idx ++;
}
}
Draw.color();
doDraw[0] = true;
values[0] = 0;
values[1] = 1;
@ -193,25 +206,23 @@ public class OverlayRenderer {
float len = 3;
float w = (int) (len * 2 * finion) + 0.5f;
x -= 0.5f;
y += 0.5f;
float w = (int) (len * 2 * finion);
Draw.color(Color.BLACK);
Lines.line(x - len + 1, y, x + len + 0.5f, y);
Draw.color(color);
if(w >= 1)
Lines.line(x - len + 1, y, x - len + w, y);
Draw.reset();
Fill.crect(x - len, y, len*2f, 1);
if(finion > 0){
Draw.color(color);
Fill.crect(x - len, y, Math.max(1, w), 1);
}
Draw.color();
}
void drawEncloser(float x, float y, float height){
float len = 3;
float len = 4;
Draw.color(Palette.bar);
Fill.crect(x - len - 1, y - 1, len*2f + 2f, height + 2f);
Fill.crect(x - len, y - 1, len*2f, height + 2f);
Draw.color();
}
}

View File

@ -55,6 +55,9 @@ public class DebugFragment extends Fragment {
new table("pane"){{
defaults().fillX().width(100f);
new label(() -> Gdx.app.getJavaHeap() / 1024 / 1024 + "MB");
row();
new label("Debug");
row();
new button("noclip", "toggle", () -> noclip = !noclip);

View File

@ -184,9 +184,12 @@ public class PowerNode extends PowerBlock{
entity.powerRecieved = 0f;
}
float added = super.addPower(tile, amount);
entity.powerRecieved += added;
return added;
float canAccept = Math.min(powerCapacity * Timers.delta() - tile.entity.power.amount, amount);
tile.entity.power.amount += canAccept;
entity.powerRecieved += canAccept;
return canAccept;
}
protected boolean shouldDistribute(Tile tile, Tile other) {
@ -226,7 +229,7 @@ public class PowerNode extends PowerBlock{
Tile target = world.tile(entity.links.get(i));
if(shouldDistribute(tile, target)) {
float transmit = Math.min(result * Timers.delta(), entity.power.amount);
float transmit = Math.min(result, entity.power.amount);
if (target.block().acceptPower(target, tile, transmit)) {
entity.power.amount -= target.block().addPower(target, transmit);
}

View File

@ -90,11 +90,11 @@ public class PowerSmelter extends PowerBlock {
//heat it up if there's enough power
if(entity.cons.valid()){
entity.heat += 1f / heatUpTime;
entity.heat += 1f / heatUpTime * Timers.delta();
if(Mathf.chance(Timers.delta() * burnEffectChance))
Effects.effect(burnEffect, entity.x + Mathf.range(size*4f), entity.y + Mathf.range(size*4));
}else{
entity.heat -= 1f / heatUpTime;
entity.heat -= 1f / heatUpTime * Timers.delta();
}
entity.heat = Mathf.clamp(entity.heat);

View File

@ -94,7 +94,7 @@ public class Separator extends Block {
if(entity.progress >= 1f){
entity.progress = 0f;
Item item = Mathf.select(results);
entity.items.remove(consumes.item(), 1);
entity.items.remove(consumes.item(), consumes.itemAmount());
if(item != null){
offloading = true;
offloadNear(tile, item);

View File

@ -26,6 +26,10 @@ public abstract class Consume {
return update;
}
public void draw(TileEntity entity){
}
public abstract void update(Block block, TileEntity entity);
public abstract boolean valid(Block block, TileEntity entity);
public abstract void display(BlockStats stats);