Added flyer shadows / Fixed block inventory rebuild spawn / Distributor

This commit is contained in:
Anuken 2018-07-09 20:18:50 -04:00
parent dbee30a412
commit d31fbf3b6f
9 changed files with 56 additions and 9 deletions

View File

@ -41,7 +41,6 @@ public class DistributionBlocks extends BlockList implements ContentList{
distributor = new Splitter("distributor") {{ distributor = new Splitter("distributor") {{
size = 2; size = 2;
itemCapacity = 80;
}}; }};
overflowGate = new OverflowGate("overflow-gate"); overflowGate = new OverflowGate("overflow-gate");

View File

@ -219,12 +219,13 @@ public class Renderer extends RendererModule{
Graphics.endShaders(); Graphics.endShaders();
} }
drawAllTeams(false); drawAllTeams(false);
blocks.skipLayer(Layer.turret); blocks.skipLayer(Layer.turret);
blocks.drawBlocks(Layer.laser); blocks.drawBlocks(Layer.laser);
drawFlyerShadows();
drawAllTeams(true); drawAllTeams(true);
drawAndInterpolate(bulletGroup); drawAndInterpolate(bulletGroup);
@ -251,6 +252,35 @@ public class Renderer extends RendererModule{
batch.end(); 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<? extends BaseUnit> 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){ private void drawAllTeams(boolean flying){
for(Team team : Team.all){ for(Team team : Team.all){
EntityGroup<BaseUnit> group = unitGroups[team.ordinal()]; EntityGroup<BaseUnit> group = unitGroups[team.ordinal()];

View File

@ -274,6 +274,11 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
return isLocal ? Float.MAX_VALUE : 40; return isLocal ? Float.MAX_VALUE : 40;
} }
@Override
public void drawShadow(){
Draw.rect(mech.iconRegion, x + elevation*elevationScale, y - elevation*elevationScale, rotation - 90);
}
@Override @Override
public void draw(){ public void draw(){
if((debug && (!showPlayer || !showUI)) || dead) return; if((debug && (!showPlayer || !showUI)) || dead) return;

View File

@ -38,6 +38,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
public static final float velocityPercision = 8f; public static final float velocityPercision = 8f;
/**Maximum absolute value of a velocity vector component.*/ /**Maximum absolute value of a velocity vector component.*/
public static final float maxAbsVelocity = 127f/velocityPercision; public static final float maxAbsVelocity = 127f/velocityPercision;
public static final float elevationScale = 4f;
private static final Vector2 moveVector = new Vector2(); 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 Vector2 velocity = new Translator(0f, 0.0001f);
protected float hitTime; protected float hitTime;
protected float drownTime; protected float drownTime;
protected float elevation;
@Override @Override
public UnitInventory getInventory() { public UnitInventory getInventory() {
@ -225,6 +227,8 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
if(isFlying()) { if(isFlying()) {
x += velocity.x / getMass() * Timers.delta(); x += velocity.x / getMass() * Timers.delta();
y += velocity.y / getMass() * Timers.delta(); y += velocity.y / getMass() * Timers.delta();
elevation = Mathf.lerpDelta(elevation, tile.elevation, 0.04f);
}else{ }else{
boolean onLiquid = floor.isLiquid; boolean onLiquid = floor.isLiquid;
@ -299,6 +303,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
public void drawUnder(){} public void drawUnder(){}
public void drawOver(){} public void drawOver(){}
public void drawShadow(){}
public void drawView(){ public void drawView(){
Fill.circle(x, y, getViewDistance()); Fill.circle(x, y, getViewDistance());

View File

@ -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 @Override
public CarriableTrait getCarry() { public CarriableTrait getCarry() {
return carrying; return carrying;

View File

@ -134,8 +134,8 @@ public class OverlayRenderer {
int idx = 0; int idx = 0;
for(Consume cons : block.consumes.all()){ for(Consume cons : block.consumes.all()){
if(!cons.valid(block, entity)){ if(!cons.isOptional() && !cons.valid(block, entity)){
Fill.crect(entity.x - block.size/2f + idx*4 - 3, entity.y + block.size/2f + values[0] + 11, 3, 3); Fill.crect(entity.x - 4 + idx*4, entity.y + block.size*tilesize/2f + values[0] + 4, 3, 3);
idx ++; idx ++;
} }
} }

View File

@ -10,6 +10,6 @@ public class MobileButton extends ImageButton {
resizeImage(isize); resizeImage(isize);
clicked(listener); clicked(listener);
row(); row();
add(text); add(text).growX().wrap();
} }
} }

View File

@ -95,7 +95,8 @@ public class BlockInventoryFragment extends Fragment {
updateTablePosition(); updateTablePosition();
if(tile.block().hasItems) { if(tile.block().hasItems) {
for (int i = 0; i < Item.all().size; i++) { 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); rebuild(false);
} }
} }

View File

@ -3,6 +3,7 @@ package io.anuke.mindustry.world.blocks.distribution;
import com.badlogic.gdx.utils.Array; import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.type.Item; import io.anuke.mindustry.type.Item;
import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Edges;
import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.meta.BlockGroup; import io.anuke.mindustry.world.meta.BlockGroup;
@ -14,6 +15,7 @@ public class Splitter extends Block{
solid = true; solid = true;
instantTransfer = true; instantTransfer = true;
update = true; update = true;
hasItems = false;
group = BlockGroup.transportation; group = BlockGroup.transportation;
} }
@ -27,7 +29,7 @@ public class Splitter extends Block{
@Override @Override
public void handleItem(Item item, Tile tile, Tile source){ public void handleItem(Item item, Tile tile, Tile source){
Tile to = getTileTarget(item, tile, source, true); 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){ 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++) { for (int i = 0; i < proximity.size; i++) {
Tile other = proximity.get((i + counter) % proximity.size); Tile other = proximity.get((i + counter) % proximity.size);
if(flip) tile.setDump((byte)((tile.getDump() + 1) % 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)) && if(other != source && !(source.block().instantTransfer && other.block().instantTransfer) && !(other.block() instanceof Splitter) &&
other.block().acceptItem(item, other, tile)){ other.block().acceptItem(item, other, Edges.getFacingEdge(tile, other))){
return other; return other;
} }
} }