diff --git a/core/src/io/anuke/mindustry/content/blocks/DistributionBlocks.java b/core/src/io/anuke/mindustry/content/blocks/DistributionBlocks.java index 2a7033b30d..cda352e0f6 100644 --- a/core/src/io/anuke/mindustry/content/blocks/DistributionBlocks.java +++ b/core/src/io/anuke/mindustry/content/blocks/DistributionBlocks.java @@ -41,7 +41,6 @@ public class DistributionBlocks extends BlockList implements ContentList{ distributor = new Splitter("distributor") {{ size = 2; - itemCapacity = 80; }}; overflowGate = new OverflowGate("overflow-gate"); diff --git a/core/src/io/anuke/mindustry/core/Renderer.java b/core/src/io/anuke/mindustry/core/Renderer.java index cf25d06aae..dfa84d2041 100644 --- a/core/src/io/anuke/mindustry/core/Renderer.java +++ b/core/src/io/anuke/mindustry/core/Renderer.java @@ -219,12 +219,13 @@ public class Renderer extends RendererModule{ Graphics.endShaders(); } - drawAllTeams(false); blocks.skipLayer(Layer.turret); blocks.drawBlocks(Layer.laser); + drawFlyerShadows(); + drawAllTeams(true); drawAndInterpolate(bulletGroup); @@ -251,6 +252,35 @@ public class Renderer extends RendererModule{ batch.end(); } + private void drawFlyerShadows(){ + Graphics.surface(effectSurface); + + float trnsX = 12, trnsY = -13; + + Graphics.end(); + Core.batch.getTransformMatrix().translate(trnsX, trnsY, 0); + Graphics.begin(); + + for(EntityGroup group : unitGroups){ + if(!group.isEmpty()){ + drawAndInterpolate(group, Unit::isFlying, Unit::drawShadow); + } + } + + if(!playerGroup.isEmpty()){ + drawAndInterpolate(playerGroup, Unit::isFlying, Unit::drawShadow); + } + + Graphics.end(); + Core.batch.getTransformMatrix().translate(-trnsX, -trnsY, 0); + Graphics.begin(); + + //TODO this actually isn't necessary + Draw.color(0, 0, 0, 0.15f); + Graphics.flushSurface(); + Draw.color(); + } + private void drawAllTeams(boolean flying){ for(Team team : Team.all){ EntityGroup group = unitGroups[team.ordinal()]; diff --git a/core/src/io/anuke/mindustry/entities/Player.java b/core/src/io/anuke/mindustry/entities/Player.java index 612b9bd379..89aecc1120 100644 --- a/core/src/io/anuke/mindustry/entities/Player.java +++ b/core/src/io/anuke/mindustry/entities/Player.java @@ -274,6 +274,11 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra return isLocal ? Float.MAX_VALUE : 40; } + @Override + public void drawShadow(){ + Draw.rect(mech.iconRegion, x + elevation*elevationScale, y - elevation*elevationScale, rotation - 90); + } + @Override public void draw(){ if((debug && (!showPlayer || !showUI)) || dead) return; diff --git a/core/src/io/anuke/mindustry/entities/Unit.java b/core/src/io/anuke/mindustry/entities/Unit.java index 80bbd239a7..53619b7fdd 100644 --- a/core/src/io/anuke/mindustry/entities/Unit.java +++ b/core/src/io/anuke/mindustry/entities/Unit.java @@ -38,6 +38,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ public static final float velocityPercision = 8f; /**Maximum absolute value of a velocity vector component.*/ public static final float maxAbsVelocity = 127f/velocityPercision; + public static final float elevationScale = 4f; private static final Vector2 moveVector = new Vector2(); @@ -52,6 +53,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ protected Vector2 velocity = new Translator(0f, 0.0001f); protected float hitTime; protected float drownTime; + protected float elevation; @Override public UnitInventory getInventory() { @@ -225,6 +227,8 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ if(isFlying()) { x += velocity.x / getMass() * Timers.delta(); y += velocity.y / getMass() * Timers.delta(); + + elevation = Mathf.lerpDelta(elevation, tile.elevation, 0.04f); }else{ boolean onLiquid = floor.isLiquid; @@ -299,6 +303,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ public void drawUnder(){} public void drawOver(){} + public void drawShadow(){} public void drawView(){ Fill.circle(x, y, getViewDistance()); diff --git a/core/src/io/anuke/mindustry/entities/units/FlyingUnit.java b/core/src/io/anuke/mindustry/entities/units/FlyingUnit.java index ebb3eb2287..7a65787501 100644 --- a/core/src/io/anuke/mindustry/entities/units/FlyingUnit.java +++ b/core/src/io/anuke/mindustry/entities/units/FlyingUnit.java @@ -32,6 +32,11 @@ public abstract class FlyingUnit extends BaseUnit implements CarryTrait{ } + @Override + public void drawShadow(){ + Draw.rect(type.region, x + elevation*elevationScale, y - elevation*elevationScale, rotation - 90); + } + @Override public CarriableTrait getCarry() { return carrying; diff --git a/core/src/io/anuke/mindustry/graphics/OverlayRenderer.java b/core/src/io/anuke/mindustry/graphics/OverlayRenderer.java index 8ebdefae5c..dcb7eb167f 100644 --- a/core/src/io/anuke/mindustry/graphics/OverlayRenderer.java +++ b/core/src/io/anuke/mindustry/graphics/OverlayRenderer.java @@ -134,8 +134,8 @@ public class OverlayRenderer { 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); + if(!cons.isOptional() && !cons.valid(block, entity)){ + Fill.crect(entity.x - 4 + idx*4, entity.y + block.size*tilesize/2f + values[0] + 4, 3, 3); idx ++; } } diff --git a/core/src/io/anuke/mindustry/ui/MobileButton.java b/core/src/io/anuke/mindustry/ui/MobileButton.java index af996644d7..6d7f8211d5 100644 --- a/core/src/io/anuke/mindustry/ui/MobileButton.java +++ b/core/src/io/anuke/mindustry/ui/MobileButton.java @@ -10,6 +10,6 @@ public class MobileButton extends ImageButton { resizeImage(isize); clicked(listener); row(); - add(text); + add(text).growX().wrap(); } } diff --git a/core/src/io/anuke/mindustry/ui/fragments/BlockInventoryFragment.java b/core/src/io/anuke/mindustry/ui/fragments/BlockInventoryFragment.java index 3e65ac45de..2720ad7096 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/BlockInventoryFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/BlockInventoryFragment.java @@ -95,7 +95,8 @@ public class BlockInventoryFragment extends Fragment { updateTablePosition(); if(tile.block().hasItems) { for (int i = 0; i < Item.all().size; i++) { - if ((tile.entity.items.has(Item.getByID(i))) == container.contains(i)) { + boolean has = tile.entity.items.has(Item.getByID(i)); + if (has != container.contains(i)) { rebuild(false); } } diff --git a/core/src/io/anuke/mindustry/world/blocks/distribution/Splitter.java b/core/src/io/anuke/mindustry/world/blocks/distribution/Splitter.java index e42a3f721c..fd5c57bf19 100644 --- a/core/src/io/anuke/mindustry/world/blocks/distribution/Splitter.java +++ b/core/src/io/anuke/mindustry/world/blocks/distribution/Splitter.java @@ -3,6 +3,7 @@ package io.anuke.mindustry.world.blocks.distribution; import com.badlogic.gdx.utils.Array; import io.anuke.mindustry.type.Item; import io.anuke.mindustry.world.Block; +import io.anuke.mindustry.world.Edges; import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.meta.BlockGroup; @@ -14,6 +15,7 @@ public class Splitter extends Block{ solid = true; instantTransfer = true; update = true; + hasItems = false; group = BlockGroup.transportation; } @@ -27,7 +29,7 @@ public class Splitter extends Block{ @Override public void handleItem(Item item, Tile tile, Tile source){ Tile to = getTileTarget(item, tile, source, true); - to.block().handleItem(item, to, tile); + to.block().handleItem(item, to, Edges.getFacingEdge(tile, to)); } Tile getTileTarget(Item item, Tile tile, Tile source, boolean flip){ @@ -36,8 +38,8 @@ public class Splitter extends Block{ for (int i = 0; i < proximity.size; i++) { Tile other = proximity.get((i + counter) % proximity.size); if(flip) tile.setDump((byte)((tile.getDump() + 1) % proximity.size)); - if(other != source && !(source.block().instantTransfer && other.block().instantTransfer && !(other.block() instanceof Splitter)) && - other.block().acceptItem(item, other, tile)){ + if(other != source && !(source.block().instantTransfer && other.block().instantTransfer) && !(other.block() instanceof Splitter) && + other.block().acceptItem(item, other, Edges.getFacingEdge(tile, other))){ return other; } }