Updated item transfer visuals, centered block inventory
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package io.anuke.mindustry.entities;
|
||||
|
||||
import com.badlogic.gdx.math.Interpolation;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.utils.Pools;
|
||||
import io.anuke.mindustry.Vars;
|
||||
@@ -7,6 +8,10 @@ import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.ucore.entities.Entity;
|
||||
import io.anuke.ucore.entities.TimedEntity;
|
||||
import io.anuke.ucore.function.Callable;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.graphics.Fill;
|
||||
import io.anuke.ucore.graphics.Lines;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
import io.anuke.ucore.util.Position;
|
||||
|
||||
public class ItemTransfer extends TimedEntity{
|
||||
@@ -14,6 +19,7 @@ public class ItemTransfer extends TimedEntity{
|
||||
private Vector2 current = new Vector2();
|
||||
private Vector2 tovec = new Vector2();
|
||||
private Item item;
|
||||
private float seed;
|
||||
private Position to;
|
||||
private Callable done;
|
||||
|
||||
@@ -24,6 +30,7 @@ public class ItemTransfer extends TimedEntity{
|
||||
tr.to = to;
|
||||
tr.done = done;
|
||||
tr.lifetime = 60f;
|
||||
tr.seed = Mathf.range(1f);
|
||||
tr.add();
|
||||
}
|
||||
|
||||
@@ -42,19 +49,33 @@ public class ItemTransfer extends TimedEntity{
|
||||
|
||||
@Override
|
||||
public void removed() {
|
||||
done.run();
|
||||
Pools.free(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
super.update();
|
||||
current.set(from).lerp(tovec.set(to.getX(), to.getY()), fin());
|
||||
current.set(from).interpolate(tovec.set(to.getX(), to.getY()), fin(), Interpolation.pow3);
|
||||
current.add(tovec.set(to.getX(), to.getY()).sub(from).nor().rotate90(1).scl(seed * fslope() * 10f));
|
||||
set(current.x, current.y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw() {
|
||||
float length = fslope()*6f;
|
||||
float angle = current.set(x, y).sub(from).angle();
|
||||
Draw.color("accent");
|
||||
Lines.stroke(fslope()*2f);
|
||||
|
||||
Lines.circle(x, y, fslope()*2f);
|
||||
Lines.lineAngleCenter(x, y, angle, length);
|
||||
Lines.lineAngle(x, y, angle, fout()*6f);
|
||||
|
||||
Draw.color(item.color);
|
||||
Fill.circle(x, y, fslope()*1.5f);
|
||||
|
||||
Draw.reset();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user