Payload fixes

This commit is contained in:
Anuken 2020-04-16 09:55:57 -04:00
parent ea0358d570
commit 256f805754
10 changed files with 664 additions and 634 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 926 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 707 B

After

Width:  |  Height:  |  Size: 707 B

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 728 KiB

After

Width:  |  Height:  |  Size: 737 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 129 KiB

After

Width:  |  Height:  |  Size: 128 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 221 KiB

After

Width:  |  Height:  |  Size: 221 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 817 KiB

After

Width:  |  Height:  |  Size: 819 KiB

View File

@ -4,17 +4,31 @@ import arc.*;
import arc.graphics.*;
import arc.graphics.g2d.*;
import arc.math.*;
import arc.math.geom.*;
import arc.util.ArcAnnotate.*;
import arc.util.*;
import mindustry.*;
import mindustry.gen.*;
import mindustry.type.*;
import mindustry.ui.*;
import mindustry.world.*;
import static mindustry.Vars.renderer;
import static mindustry.Vars.*;
public class Drawf{
public static void selected(int x, int y, Block block, Color color){
Draw.color(color);
for(int i = 0; i < 4; i++){
Point2 p = Geometry.d8edge[i];
float offset = -Math.max(block.size - 1, 0) / 2f * tilesize;
Draw.rect("block-select",
x*tilesize + block.offset() + offset * p.x,
y*tilesize + block.offset() + offset * p.y, i * 90);
}
Draw.reset();
}
public static void shadow(float x, float y, float rad){
Draw.color(0, 0, 0, 0.4f);
Draw.rect("circle-shadow", x, y, rad, rad);

View File

@ -229,15 +229,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
}
public void drawSelected(int x, int y, Block block, Color color){
Draw.color(color);
for(int i = 0; i < 4; i++){
Point2 p = Geometry.d8edge[i];
float offset = -Math.max(block.size - 1, 0) / 2f * tilesize;
Draw.rect("block-select",
x*tilesize + block.offset() + offset * p.x,
y*tilesize + block.offset() + offset * p.y, i * 90);
}
Draw.reset();
Drawf.selected(x, y, block, color);
}
public void drawBreaking(BuildRequest request){

View File

@ -40,6 +40,23 @@ public class MassConveyor extends Block{
edgeRegion = Core.atlas.find(name + "-edge");
}
@Override
protected TextureRegion[] generateIcons(){
return new TextureRegion[]{Core.atlas.find(name + "-icon")};
}
@Override
public void drawPlace(int x, int y, int rotation, boolean valid){
super.drawPlace(x, y, rotation, valid);
for(int i = 0; i < 4; i++){
Tilec other = world.ent(x + Geometry.d4x[i] * size, y + Geometry.d4y[i] * size);
if(other != null && other.block().outputsPayload && other.block().size == size){
Drawf.selected(other.tileX(), other.tileY(), other.block(), Pal.accent);
}
}
}
public class MassConveyorEntity extends TileEntity{
public @Nullable Payload item;
public float progress, itemRotation, animation;
@ -53,7 +70,7 @@ public class MassConveyor extends Block{
Tilec accept = nearby(Geometry.d4[rotation()].x * size, Geometry.d4[rotation()].y * size);
//next block must be aligned and of the same size
if(accept.block().size == size &&
if(accept != null && accept.block().size == size &&
tileX() + Geometry.d4[rotation()].x * size == accept.tileX() && tileY() + Geometry.d4[rotation()].y * size == accept.tileY()){
next = accept;
}
@ -191,7 +208,7 @@ public class MassConveyor extends Block{
return !blocked || next != null;
}else{
Tilec accept = nearby(Geometry.d4[direction].x * size, Geometry.d4[direction].y * size);
return accept.block().size == size && accept.block().outputsPayload &&
return accept != null && accept.block().size == size && accept.block().outputsPayload &&
//block must either be facing this one, or not be rotating
((accept.tileX() + Geometry.d4[accept.rotation()].x * size == tileX() && accept.tileY() + Geometry.d4[accept.rotation()].y * size == tileY()) || !accept.block().rotate);
}