Improved power grid sprites / Bugfixes

This commit is contained in:
Anuken 2018-10-29 20:43:30 -04:00
parent b39f25ed51
commit 6e65096bb4
8 changed files with 54 additions and 44 deletions

View File

@ -27,9 +27,9 @@ repositories {
dependencies {
implementation project(":core")
implementation project(":kryonet")
implementation 'com.android.support:support-v4:25.3.1'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'org.sufficientlysecure:donations:2.5'
implementation 'com.google.android.gms:play-services-auth:11.8.0'
implementation 'com.google.android.gms:play-services-auth:16.0.1'
implementation "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 253 B

After

Width:  |  Height:  |  Size: 244 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 103 KiB

After

Width:  |  Height:  |  Size: 103 KiB

View File

@ -60,14 +60,15 @@ public class Palette{
bar = Color.SLATE,
interact = Color.ORANGE,
accent = Color.valueOf("f4ba6e"),
accentBack = new Color(accent.r * 0.8f, accent.g * 0.8f, accent.b * 0.8f, 1f),
accentBack = Color.valueOf("d58c4b"),
place = Color.valueOf("6335f8"),
remove = Color.valueOf("e55454"),
removeBack = Color.valueOf("a73e3e"),
placeRotate = accent,
breakInvalid = Color.valueOf("d44b3d"),
range = Color.valueOf("f4ba6e"),
power = Color.valueOf("fbd367"),
power = Color.valueOf("fbad67"),
powerLight = Color.valueOf("fbd367"),
placing = Color.valueOf("616161"),
lightTrail = Color.valueOf("ffe2a9"),

View File

@ -14,6 +14,7 @@ import io.anuke.mindustry.entities.traits.BuilderTrait.BuildRequest;
import io.anuke.mindustry.gen.Call;
import io.anuke.mindustry.net.Net;
import io.anuke.mindustry.net.ValidateException;
import io.anuke.mindustry.type.Item;
import io.anuke.mindustry.type.ItemStack;
import io.anuke.mindustry.type.Recipe;
import io.anuke.mindustry.ui.fragments.OverlayFragment;
@ -76,10 +77,11 @@ public abstract class InputHandler extends InputAdapter{
player.isTransferring = true;
ItemStack stack = player.inventory.getItem();
int accepted = tile.block().acceptStack(stack.item, stack.amount, tile, player);
Item item = player.inventory.getItem().item;
int amount = player.inventory.getItem().amount;
int accepted = tile.block().acceptStack(item, amount, tile, player);
player.inventory.getItem().amount -= accepted;
boolean clear = stack.amount == accepted;
int sent = Mathf.clamp(accepted / 4, 1, 8);
int removed = accepted / sent;
int[] remaining = {accepted, accepted};
@ -88,29 +90,24 @@ public abstract class InputHandler extends InputAdapter{
for(int i = 0; i < sent; i++){
boolean end = i == sent - 1;
Timers.run(i * 3, () -> {
tile.block().getStackOffset(stack.item, tile, stackTrns);
tile.block().getStackOffset(item, tile, stackTrns);
ItemTransfer.create(stack.item,
ItemTransfer.create(item,
player.x + Angles.trnsx(player.rotation + 180f, backTrns), player.y + Angles.trnsy(player.rotation + 180f, backTrns),
new Translator(tile.drawx() + stackTrns.x, tile.drawy() + stackTrns.y), () -> {
if(tile.block() != block || tile.entity == null) return;
tile.block().handleStack(stack.item, removed, tile, player);
tile.block().handleStack(item, removed, tile, player);
remaining[1] -= removed;
if(end && remaining[1] > 0){
tile.block().handleStack(stack.item, remaining[1], tile, player);
tile.block().handleStack(item, remaining[1], tile, player);
}
});
stack.amount -= removed;
remaining[0] -= removed;
if(end){
stack.amount -= remaining[0];
if(clear){
player.inventory.clearItem();
}
player.isTransferring = false;
}
});

View File

@ -52,7 +52,7 @@ public class BlockLocMission extends Mission{
float rot = players[0].angleTo(x * tilesize + block.offset(), y * tilesize + block.offset());
float len = 12f;
Draw.color(Palette.accent.r * 0.8f,Palette.accent.g * 0.8f,Palette.accent.b * 0.8f);
Draw.color(Palette.accentBack);
Draw.rect("icon-arrow", players[0].x + Angles.trnsx(rot, len), players[0].y + Angles.trnsy(rot, len), rot);
Draw.color(Palette.accent);
Draw.rect("icon-arrow", players[0].x + Angles.trnsx(rot, len), players[0].y + Angles.trnsy(rot, len) + 1f, rot);

View File

@ -159,7 +159,7 @@ public class Conveyor extends Block{
if(pos.item == null) continue;
tr1.trns(rotation * 90, tilesize, 0);
tr2.trns(rotation * 90, -tilesize / 2, pos.x * tilesize / 2);
tr2.trns(rotation * 90, -tilesize / 2f, pos.x * tilesize / 2f);
Draw.rect(pos.item.region,
(int) (tile.x * tilesize + tr1.x * pos.y + tr2.x),

View File

@ -8,7 +8,6 @@ import io.anuke.mindustry.entities.TileEntity;
import io.anuke.mindustry.gen.Call;
import io.anuke.mindustry.graphics.Layer;
import io.anuke.mindustry.graphics.Palette;
import io.anuke.mindustry.world.Edges;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.blocks.PowerBlock;
import io.anuke.mindustry.world.meta.BlockStat;
@ -17,7 +16,6 @@ import io.anuke.ucore.core.Settings;
import io.anuke.ucore.core.Timers;
import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.graphics.Lines;
import io.anuke.ucore.graphics.Shapes;
import io.anuke.ucore.util.Angles;
import io.anuke.ucore.util.Mathf;
import io.anuke.ucore.util.Translator;
@ -145,11 +143,10 @@ public class PowerNode extends PowerBlock{
public void drawSelect(Tile tile){
super.drawSelect(tile);
Draw.color(Palette.power);
Lines.stroke(1f);
Lines.poly(Edges.getPixelPolygon(laserRange), tile.worldx() - tilesize / 2, tile.worldy() - tilesize / 2, tilesize);
Draw.color(Palette.accent);
Lines.poly(tile.drawx(), tile.drawy(), 50, laserRange*tilesize);
Draw.reset();
}
@ -160,14 +157,10 @@ public class PowerNode extends PowerBlock{
Draw.color(Palette.accent);
Lines.stroke(1f);
Lines.square(tile.drawx(), tile.drawy(),
Lines.circle(tile.drawx(), tile.drawy(),
tile.block().size * tilesize / 2f + 1f + Mathf.absin(Timers.time(), 4f, 1f));
Lines.stroke(1f);
Lines.poly(Edges.getPixelPolygon(laserRange), tile.worldx() - tilesize / 2, tile.worldy() - tilesize / 2, tilesize);
Draw.color(Palette.power);
Lines.poly(tile.drawx(), tile.drawy(), 50, laserRange*tilesize);
for(int x = (int) (tile.x - laserRange); x <= tile.x + laserRange; x++){
for(int y = (int) (tile.y - laserRange); y <= tile.y + laserRange; y++){
@ -178,7 +171,7 @@ public class PowerNode extends PowerBlock{
boolean linked = linked(tile, link);
Draw.color(linked ? Palette.place : Palette.breakInvalid);
Lines.square(link.drawx(), link.drawy(),
Lines.circle(link.drawx(), link.drawy(),
link.block().size * tilesize / 2f + 1f + (linked ? 0f : Mathf.absin(Timers.time(), 4f, 1f)));
if((entity.power.links.size >= maxNodes || (link.block() instanceof PowerNode && link.entity.power.links.size >= ((PowerNode) link.block()).maxNodes)) && !linked){
@ -194,11 +187,9 @@ public class PowerNode extends PowerBlock{
@Override
public void drawPlace(int x, int y, int rotation, boolean valid){
Draw.color(Palette.placing);
Lines.stroke(1f);
Lines.poly(Edges.getPixelPolygon(laserRange), x * tilesize - tilesize / 2, y * tilesize - tilesize / 2, tilesize);
Draw.color(Palette.placing);
Lines.poly(x * tilesize + offset(), y * tilesize + offset(), 50, laserRange*tilesize);
Draw.reset();
}
@ -208,14 +199,15 @@ public class PowerNode extends PowerBlock{
TileEntity entity = tile.entity();
Draw.color(Palette.powerLaserFrom, Palette.powerLaserTo, 0f * (1f - flashScl) + Mathf.sin(Timers.time(), 1.7f, flashScl));
for(int i = 0; i < entity.power.links.size; i++){
Tile link = world.tile(entity.power.links.get(i));
if(linkValid(tile, link)) drawLaser(tile, link);
if(linkValid(tile, link) && (!(link.block() instanceof PowerNode)
|| ((tile.block().size > link.block().size) || (tile.block().size == link.block().size && tile.id() < link.id())))){
drawLaser(tile, link);
}
}
Draw.color();
Draw.reset();
}
protected boolean linked(Tile tile, Tile other){
@ -233,12 +225,12 @@ public class PowerNode extends PowerBlock{
TileEntity oe = link.entity();
return Vector2.dst(tile.drawx(), tile.drawy(), link.drawx(), link.drawy()) <= Math.max(laserRange * tilesize,
((PowerNode) link.block()).laserRange * tilesize) - tilesize / 2f
((PowerNode) link.block()).laserRange * tilesize)
+ (link.block().size - 1) * tilesize / 2f + (tile.block().size - 1) * tilesize / 2f &&
(!checkMaxNodes || (oe.power.links.size < ((PowerNode) link.block()).maxNodes || oe.power.links.contains(tile.packedPosition())));
}else{
return Vector2.dst(tile.drawx(), tile.drawy(), link.drawx(), link.drawy())
<= laserRange * tilesize - tilesize / 2f + (link.block().size - 1) * tilesize;
<= laserRange * tilesize + (link.block().size - 1) * tilesize;
}
}
@ -249,11 +241,31 @@ public class PowerNode extends PowerBlock{
float angle1 = Angles.angle(x1, y1, x2, y2);
float angle2 = angle1 + 180f;
t1.trns(angle1, tile.block().size * tilesize / 2f + 1f);
t2.trns(angle2, target.block().size * tilesize / 2f + 1f);
t1.trns(angle1, tile.block().size * tilesize / 2f - 1f);
t2.trns(angle2, target.block().size * tilesize / 2f - 1f);
Shapes.laser("laser", "laser-end", x1 + t1.x, y1 + t1.y,
x2 + t2.x, y2 + t2.y, thicknessScl);
x1 += t1.x;
y1 += t1.y;
x2 += t2.x;
y2 += t2.y;
float space = Vector2.dst(x1, y1, x2, y2);
float scl = 4f, mag = 2f, tscl = 4f, segscl = 3f;
int segments = Mathf.ceil(space / segscl);
Draw.color(Palette.power, Palette.powerLight, Mathf.absin(Timers.time(), 5f, 1f));
Lines.stroke(1f);
for(int i = 0; i < segments; i++){
float f1 = (float)i / segments;
float f2 = (float)(i+1) / segments;
t1.trns(angle1 + 90f, Mathf.lerp(Mathf.sin(tile.entity.id * 124f + Timers.time()/tscl + f1 * space, scl, mag), 0f, Math.abs(f1 - 0.5f)*2f));
t2.trns(angle1 + 90f, Mathf.lerp(Mathf.sin(tile.entity.id * 124f + Timers.time()/tscl + f2 * space, scl, mag), 0f, Math.abs(f2 - 0.5f)*2f));
Lines.line(x1 + (x2 - x1) * f1 + t1.x, y1 + (y2 - y1) * f1 + t1.y,
x1 + (x2 - x1) * f2 + t2.x, y1 + (y2 - y1) * f2 + t2.y);
}
}
}