mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-01-28 00:19:57 +07:00
Added flyer shadows / Fixed block inventory rebuild spawn / Distributor
This commit is contained in:
parent
dbee30a412
commit
d31fbf3b6f
@ -41,7 +41,6 @@ public class DistributionBlocks extends BlockList implements ContentList{
|
||||
|
||||
distributor = new Splitter("distributor") {{
|
||||
size = 2;
|
||||
itemCapacity = 80;
|
||||
}};
|
||||
|
||||
overflowGate = new OverflowGate("overflow-gate");
|
||||
|
@ -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<? 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){
|
||||
for(Team team : Team.all){
|
||||
EntityGroup<BaseUnit> group = unitGroups[team.ordinal()];
|
||||
|
@ -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;
|
||||
|
@ -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());
|
||||
|
@ -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;
|
||||
|
@ -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 ++;
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,6 @@ public class MobileButton extends ImageButton {
|
||||
resizeImage(isize);
|
||||
clicked(listener);
|
||||
row();
|
||||
add(text);
|
||||
add(text).growX().wrap();
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user