diff --git a/core/src/io/anuke/mindustry/content/fx/BlockFx.java b/core/src/io/anuke/mindustry/content/fx/BlockFx.java index ff390d4558..2319d71586 100644 --- a/core/src/io/anuke/mindustry/content/fx/BlockFx.java +++ b/core/src/io/anuke/mindustry/content/fx/BlockFx.java @@ -322,9 +322,9 @@ public class BlockFx extends FxList implements ContentList{ }); shieldBreak = new Effect(40, e -> { - Draw.color(Color.WHITE); + Draw.color(Palette.accent); Lines.stroke(3f * e.fout()); - Lines.poly(e.x, e.y, 6, e.rotation, 90); + Lines.poly(e.x, e.y, 6, e.rotation + e.fin(), 90); Draw.reset(); }); } diff --git a/core/src/io/anuke/mindustry/graphics/FogRenderer.java b/core/src/io/anuke/mindustry/graphics/FogRenderer.java index 031abfe8c1..e974414838 100644 --- a/core/src/io/anuke/mindustry/graphics/FogRenderer.java +++ b/core/src/io/anuke/mindustry/graphics/FogRenderer.java @@ -96,12 +96,6 @@ public class FogRenderer implements Disposable{ })); } - public void setLoadingOffset(int x, int y){ - isOffseted = true; - offsettedX = x; - offsettedY = y; - } - public void writeFog(){ if(buffer == null) return; diff --git a/core/src/io/anuke/mindustry/world/blocks/defense/ForceProjector.java b/core/src/io/anuke/mindustry/world/blocks/defense/ForceProjector.java index ad6aa4d585..41ddb64976 100644 --- a/core/src/io/anuke/mindustry/world/blocks/defense/ForceProjector.java +++ b/core/src/io/anuke/mindustry/world/blocks/defense/ForceProjector.java @@ -7,9 +7,11 @@ import io.anuke.mindustry.content.fx.BulletFx; import io.anuke.mindustry.entities.TileEntity; import io.anuke.mindustry.entities.traits.AbsorbTrait; import io.anuke.mindustry.graphics.Palette; +import io.anuke.mindustry.world.BarType; import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.consumers.ConsumeLiquidFilter; +import io.anuke.mindustry.world.meta.BlockBar; import io.anuke.mindustry.world.meta.BlockStat; import io.anuke.mindustry.world.meta.StatUnit; import io.anuke.ucore.core.Effects; @@ -68,6 +70,13 @@ public class ForceProjector extends Block { stats.add(BlockStat.powerDamage, powerDamage, StatUnit.powerUnits); } + @Override + public void setBars(){ + super.setBars(); + + bars.add(new BlockBar(BarType.heat, true, tile -> tile.entity().buildup / breakage)); + } + @Override public void update(Tile tile){ ForceEntity entity = tile.entity(); @@ -91,7 +100,7 @@ public class ForceProjector extends Block { } if(!entity.cons.valid() && !cheat){ - entity.warmup = Mathf.lerpDelta(entity.warmup, 0f, 0.1f); + entity.warmup = Mathf.lerpDelta(entity.warmup, 0f, 0.15f); if(entity.warmup <= 0.09f){ entity.broken = true; } @@ -136,6 +145,10 @@ public class ForceProjector extends Block { float hit = trait.getShieldDamage()*powerDamage; entity.hit = 1f; entity.power.amount -= Math.min(hit, entity.power.amount); + + if(entity.power.amount <= 0.0001f){ + entity.buildup += trait.getShieldDamage() * entity.warmup*2f; + } entity.buildup += trait.getShieldDamage() * entity.warmup; } }); diff --git a/core/src/io/anuke/mindustry/world/blocks/production/PhaseWeaver.java b/core/src/io/anuke/mindustry/world/blocks/production/PhaseWeaver.java index 2808b2c9bc..c14533d27f 100644 --- a/core/src/io/anuke/mindustry/world/blocks/production/PhaseWeaver.java +++ b/core/src/io/anuke/mindustry/world/blocks/production/PhaseWeaver.java @@ -45,6 +45,7 @@ public class PhaseWeaver extends PowerSmelter{ Shaders.build.region = weaveRegion; Shaders.build.progress = progress; Shaders.build.color.set(Palette.accent); + Shaders.build.color.a = entity.heat; Shaders.build.time = -entity.time / 10f; Graphics.shader(Shaders.build, false); @@ -53,6 +54,7 @@ public class PhaseWeaver extends PowerSmelter{ Graphics.shader(); Draw.color(Palette.accent); + Draw.alpha(entity.heat); Lines.lineAngleCenter( tile.drawx() + Mathf.sin(entity.time, 6f, Vars.tilesize / 3f * size), diff --git a/core/src/io/anuke/mindustry/world/blocks/storage/CoreBlock.java b/core/src/io/anuke/mindustry/world/blocks/storage/CoreBlock.java index 4e5f9875f9..2fa3d52cf8 100644 --- a/core/src/io/anuke/mindustry/world/blocks/storage/CoreBlock.java +++ b/core/src/io/anuke/mindustry/world/blocks/storage/CoreBlock.java @@ -242,7 +242,7 @@ public class CoreBlock extends StorageBlock{ return new CoreEntity(); } - public class CoreEntity extends TileEntity implements SpawnerTrait{ + public class CoreEntity extends StorageEntity implements SpawnerTrait{ public Unit currentUnit; int droneID = -1; boolean solid = true; diff --git a/core/src/io/anuke/mindustry/world/blocks/storage/StorageBlock.java b/core/src/io/anuke/mindustry/world/blocks/storage/StorageBlock.java index 25f3d4a220..acb586fabb 100644 --- a/core/src/io/anuke/mindustry/world/blocks/storage/StorageBlock.java +++ b/core/src/io/anuke/mindustry/world/blocks/storage/StorageBlock.java @@ -1,5 +1,6 @@ package io.anuke.mindustry.world.blocks.storage; +import com.badlogic.gdx.utils.Array; import io.anuke.mindustry.entities.TileEntity; import io.anuke.mindustry.type.Item; import io.anuke.mindustry.world.Block; @@ -17,6 +18,42 @@ public abstract class StorageBlock extends Block{ return false; } + @Override + public void onProximityUpdate(Tile tile){ + super.onProximityUpdate(tile); + StorageEntity entity = tile.entity(); + entity.graph.add(tile); + + for(Tile prox : tile.entity.proximity()){ + if(prox.block() instanceof StorageBlock){ + StorageEntity other = prox.entity(); + entity.graph.merge(other.graph); + } + } + } + + @Override + public void removed(Tile tile){ + super.removed(tile); + StorageEntity entity = tile.entity(); + entity.graph.remove(tile); + } + + @Override + public TileEntity newEntity(){ + return new StorageEntity(); + } + + @Override + public Array getDebugInfo(Tile tile){ + Array arr = super.getDebugInfo(tile); + + StorageEntity entity = tile.entity(); + arr.addAll("storage graph", entity.graph.getID()); + + return arr; + } + /** * Removes an item and returns it. If item is not null, it should return the item. * Returns null if no items are there. @@ -48,4 +85,8 @@ public abstract class StorageBlock extends Block{ return entity.items.has(item); } } + + public class StorageEntity extends TileEntity{ + public StorageGraph graph = new StorageGraph(); + } } diff --git a/core/src/io/anuke/mindustry/world/blocks/storage/StorageGraph.java b/core/src/io/anuke/mindustry/world/blocks/storage/StorageGraph.java new file mode 100644 index 0000000000..6fbb31ec39 --- /dev/null +++ b/core/src/io/anuke/mindustry/world/blocks/storage/StorageGraph.java @@ -0,0 +1,79 @@ +package io.anuke.mindustry.world.blocks.storage; + +import com.badlogic.gdx.utils.IntSet; +import com.badlogic.gdx.utils.ObjectSet; +import com.badlogic.gdx.utils.Queue; +import io.anuke.mindustry.world.Tile; +import io.anuke.mindustry.world.blocks.storage.StorageBlock.StorageEntity; + +public class StorageGraph{ + private static IntSet closedSet = new IntSet(); + private static Queue queue = new Queue<>(); + private static int lastID; + + private ObjectSet tiles = new ObjectSet<>(); + private int cores; + private int id = lastID++; + + public void add(Tile tile){ + if(tiles.add(tile) && tile.block() instanceof CoreBlock){ + cores ++; + } + } + + public void remove(Tile tile){ + for(Tile other : tiles){ + other.entity().graph = null; + } + + if(tiles.remove(tile) && tile.block() instanceof CoreBlock){ + cores --; + } + + cores = 0; + + for(Tile other : tile.entity.proximity()){ + if(other.block() instanceof StorageBlock){ + reflow(tile, other); + } + } + } + + public void reflow(Tile base, Tile tile){ + queue.clear(); + queue.addLast(tile); + closedSet.clear(); + while(queue.size > 0){ + Tile child = queue.removeFirst(); + StorageEntity entity = child.entity(); + entity.graph = this; + add(child); + for(Tile next : child.entity.proximity()){ + if(next != base && next.block() instanceof StorageBlock && next.entity().graph == null && !closedSet.contains(next.packedPosition())){ + queue.addLast(next); + closedSet.add(next.packedPosition()); + } + } + } + } + + public void merge(StorageGraph other){ + if(this == other) return; + + for(Tile tile : other.tiles){ + StorageEntity e = tile.entity(); + e.graph = this; + } + + tiles.addAll(other.tiles); + cores += other.cores; + } + + public boolean hasCores(){ + return cores > 0; + } + + public int getID(){ + return id; + } +}