From f3cc8819305861b509679dab7bca3b7628ddba7c Mon Sep 17 00:00:00 2001 From: Anuken Date: Mon, 9 Jul 2018 14:25:52 -0400 Subject: [PATCH] Status bar cleanup / Fixed power distribution / Fixed adjacency updates --- .../src/io/anuke/annotations/Annotations.java | 2 +- .../content/blocks/CraftingBlocks.java | 8 ++--- .../anuke/mindustry/entities/TileEntity.java | 2 ++ .../mindustry/graphics/OverlayRenderer.java | 33 ++++++++++++------- .../mindustry/ui/fragments/DebugFragment.java | 3 ++ .../world/blocks/power/PowerNode.java | 11 ++++--- .../world/blocks/production/PowerSmelter.java | 4 +-- .../world/blocks/production/Separator.java | 2 +- .../mindustry/world/consumers/Consume.java | 4 +++ 9 files changed, 46 insertions(+), 23 deletions(-) diff --git a/annotations/src/io/anuke/annotations/Annotations.java b/annotations/src/io/anuke/annotations/Annotations.java index 5798d13cd8..d685729921 100644 --- a/annotations/src/io/anuke/annotations/Annotations.java +++ b/annotations/src/io/anuke/annotations/Annotations.java @@ -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.*/ diff --git a/core/src/io/anuke/mindustry/content/blocks/CraftingBlocks.java b/core/src/io/anuke/mindustry/content/blocks/CraftingBlocks.java index cc651b2476..6fe9a4db48 100644 --- a/core/src/io/anuke/mindustry/content/blocks/CraftingBlocks.java +++ b/core/src/io/anuke/mindustry/content/blocks/CraftingBlocks.java @@ -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") {{ diff --git a/core/src/io/anuke/mindustry/entities/TileEntity.java b/core/src/io/anuke/mindustry/entities/TileEntity.java index 5445bf8b95..61e3e44989 100644 --- a/core/src/io/anuke/mindustry/entities/TileEntity.java +++ b/core/src/io/anuke/mindustry/entities/TileEntity.java @@ -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); diff --git a/core/src/io/anuke/mindustry/graphics/OverlayRenderer.java b/core/src/io/anuke/mindustry/graphics/OverlayRenderer.java index 53aeee4a9b..8ebdefae5c 100644 --- a/core/src/io/anuke/mindustry/graphics/OverlayRenderer.java +++ b/core/src/io/anuke/mindustry/graphics/OverlayRenderer.java @@ -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(); } } diff --git a/core/src/io/anuke/mindustry/ui/fragments/DebugFragment.java b/core/src/io/anuke/mindustry/ui/fragments/DebugFragment.java index 7a19c45852..8b2b6338ca 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/DebugFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/DebugFragment.java @@ -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); diff --git a/core/src/io/anuke/mindustry/world/blocks/power/PowerNode.java b/core/src/io/anuke/mindustry/world/blocks/power/PowerNode.java index 331f2d4546..3f7db1fffe 100644 --- a/core/src/io/anuke/mindustry/world/blocks/power/PowerNode.java +++ b/core/src/io/anuke/mindustry/world/blocks/power/PowerNode.java @@ -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); } diff --git a/core/src/io/anuke/mindustry/world/blocks/production/PowerSmelter.java b/core/src/io/anuke/mindustry/world/blocks/production/PowerSmelter.java index a2949393c2..67b18228b8 100644 --- a/core/src/io/anuke/mindustry/world/blocks/production/PowerSmelter.java +++ b/core/src/io/anuke/mindustry/world/blocks/production/PowerSmelter.java @@ -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); diff --git a/core/src/io/anuke/mindustry/world/blocks/production/Separator.java b/core/src/io/anuke/mindustry/world/blocks/production/Separator.java index 3fbaab0ef2..9ba2cb2d7c 100644 --- a/core/src/io/anuke/mindustry/world/blocks/production/Separator.java +++ b/core/src/io/anuke/mindustry/world/blocks/production/Separator.java @@ -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); diff --git a/core/src/io/anuke/mindustry/world/consumers/Consume.java b/core/src/io/anuke/mindustry/world/consumers/Consume.java index 8712ecb175..6e3cbabb0e 100644 --- a/core/src/io/anuke/mindustry/world/consumers/Consume.java +++ b/core/src/io/anuke/mindustry/world/consumers/Consume.java @@ -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);