Merge branch 'master' of https://github.com/Anuken/Mindustry into 7.0-features

 Conflicts:
	core/src/mindustry/ui/dialogs/JoinDialog.java
This commit is contained in:
Anuken
2022-04-20 14:16:20 -04:00
18 changed files with 487 additions and 429 deletions

View File

@@ -141,8 +141,8 @@ public class Fx{
float x = Tmp.v1.x, y = Tmp.v1.y;
float size = 1f;
stroke(e.fslope() * 2f * size, Pal.accent);
Lines.circle(x, y, e.fslope() * 2f * size);
color(Pal.accent);
Fill.circle(x, y, e.fslope() * 3f * size);
color(e.color);
Fill.circle(x, y, e.fslope() * 1.5f * size);

View File

@@ -17,6 +17,8 @@ public class ParticleEffect extends Effect{
public Color colorFrom = Color.white.cpy(), colorTo = Color.white.cpy();
public int particles = 6;
public boolean randLength = true;
/** Gives the effect flipping compatability like casing effects. */
public boolean casingFlip;
public float cone = 180f, length = 20f, baseLength = 0f;
/** Particle size/length/radius interpolation. */
public Interp interp = Interp.linear;
@@ -55,11 +57,12 @@ public class ParticleEffect extends Effect{
public void render(EffectContainer e){
if(tex == null) tex = Core.atlas.find(region);
float realRotation = (useRotation ? e.rotation : baseRotation);
float realRotation = (useRotation ? (casingFlip ? Math.abs(e.rotation) : e.rotation) : baseRotation);
int flip = casingFlip ? -Mathf.sign(e.rotation) : 1;
float rawfin = e.fin();
float fin = e.fin(interp);
float rad = sizeInterp.apply(sizeFrom, sizeTo, rawfin) * 2;
float ox = e.x + Angles.trnsx(realRotation, offsetX, offsetY), oy = e.y + Angles.trnsy(realRotation, offsetX, offsetY);
float ox = e.x + Angles.trnsx(realRotation, offsetX * flip, offsetY), oy = e.y + Angles.trnsy(realRotation, offsetX * flip, offsetY);
Draw.color(colorFrom, colorTo, fin);
Color lightColor = this.lightColor == null ? Draw.getColor() : this.lightColor;

View File

@@ -34,11 +34,19 @@ public class Teams{
@Nullable
public CoreBuild closestEnemyCore(float x, float y, Team team){
CoreBuild closest = null;
float closestDst = Float.MAX_VALUE;
for(Team enemy : team.data().coreEnemies){
CoreBuild tile = Geometry.findClosest(x, y, enemy.cores());
if(tile != null) return tile;
for(CoreBuild core : enemy.cores()){
float dst = Mathf.dst2(x, y, core.getX(), core.getY());
if(closestDst > dst){
closest = core;
closestDst = dst;
}
}
}
return null;
return closest;
}
@Nullable
@@ -409,4 +417,4 @@ public class Teams{
'}';
}
}
}
}

View File

@@ -20,7 +20,7 @@ import mindustry.logic.LStatements.*;
import mindustry.ui.*;
public class LCanvas extends Table{
public static final int maxJumpsDrawn = 100;
public static final int maxJumpsDrawn = 1000; // TODO Does nothing
//ew static variables
static LCanvas canvas;
@@ -106,14 +106,23 @@ public class LCanvas extends Table{
clear();
statements = new DragLayout();
jumps = new WidgetGroup();
jumps = new WidgetGroup(){
@Override
public void layout(){
cullable = false; //culling while scrolling results in weirdness
getChildren().each(h -> {
if(!(h instanceof JumpCurve c)) return;
c.setSize(width, c.getPrefHeight());
c.setPosition(c.button.x + c.button.getWidth()/2f, c.py);
});
cullable = true;
}
};
pane = pane(t -> {
t.center();
t.add(statements).pad(2f).center().width(targetWidth);
t.addChild(jumps);
jumps.cullable = false;
t.add(jumps).growY().width(100f).growY();
}).grow().get();
pane.setFlickScroll(false);
@@ -160,6 +169,7 @@ public class LCanvas extends Table{
}
this.statements.layout();
jumps.layout();
}
StatementElem checkHovered(){
@@ -187,21 +197,17 @@ public class LCanvas extends Table{
pane.setScrollY(pane.getScrollY() + sign * Scl.scl(15f) * Time.delta);
}
}
pane.scrolled(f -> jumps.layout()); //don't ask why this is needed, it just is
}
public class DragLayout extends WidgetGroup{
float space = Scl.scl(10f), prefWidth, prefHeight;
Seq<Element> seq = new Seq<>();
int insertPosition = 0;
boolean invalidated;
{
setTransform(true);
}
@Override
public void layout(){
invalidated = true;
float cy = 0;
seq.clear();
@@ -249,10 +255,9 @@ public class LCanvas extends Table{
}
}
invalidateHierarchy();
if(parent != null && parent instanceof Table){
if(parent instanceof Table){
setCullingArea(parent.getCullingArea());
jumps.setCullingArea(parent.getCullingArea());
}
}
@@ -279,16 +284,7 @@ public class LCanvas extends Table{
Tex.pane.draw(lastX, lastY - shiftAmount, width, dragging.getHeight());
}
if(invalidated){
children.each(c -> c.cullable = false);
}
super.draw();
if(invalidated){
children.each(c -> c.cullable = true);
invalidated = false;
}
}
void finishLayout(){
@@ -513,11 +509,17 @@ public class LCanvas extends Table{
public static class JumpCurve extends Element{
public JumpButton button;
float ph, py;
public JumpCurve(JumpButton button){
this.button = button;
}
@Override
public float getPrefHeight(){
return ph;
}
@Override
public void act(float delta){
super.act(delta);
@@ -536,7 +538,6 @@ public class LCanvas extends Table{
}
Element hover = button.to.get() == null && button.selecting ? canvas.hovered : button.to.get();
boolean draw = false;
Vec2 t = Tmp.v1, r = Tmp.v2;
Group desc = canvas.pane;
@@ -545,26 +546,25 @@ public class LCanvas extends Table{
if(hover != null){
hover.localToAscendantCoordinates(desc, t.set(hover.getWidth(), hover.getHeight()/2f));
draw = true;
}else if(button.selecting){
t.set(r).add(button.mx, button.my);
draw = true;
}else{
return;
}
float offset = canvas.pane.getVisualScrollY() - canvas.pane.getMaxY();
ph = Math.abs(t.y - r.y);
py = Math.min(t.y, r.y);
float offset = canvas.pane.getVisualScrollY() - canvas.pane.getMaxY();
t.y += offset;
r.y += offset;
if(draw){
drawCurve(r.x + button.getWidth()/2f, r.y + button.getHeight()/2f, t.x, t.y);
drawCurve(r.x + button.getWidth()/2f, r.y + button.getHeight()/2f, t.x, t.y);
float s = button.getWidth();
Draw.color(button.color);
Tex.logicNode.draw(t.x + s*0.75f, t.y - s/2f, -s, s);
Draw.reset();
}
float s = button.getWidth();
Draw.color(button.color);
Tex.logicNode.draw(t.x + s*0.75f, t.y - s/2f, -s, s);
Draw.reset();
}
public void drawCurve(float x, float y, float x2, float y2){

View File

@@ -44,6 +44,7 @@ import static mindustry.Vars.*;
public class UnitType extends UnlockableContent{
public static final float shadowTX = -12, shadowTY = -13;
private static final Vec2 legOffset = new Vec2();
private static TextureRegion itemCircleRegion;
/** If true, the unit is always at elevation 1. */
public boolean flying;
@@ -983,14 +984,16 @@ public class UnitType extends UnlockableContent{
unit.x + Angles.trnsx(unit.rotation + 180f, itemOffsetY),
unit.y + Angles.trnsy(unit.rotation + 180f, itemOffsetY),
size, size, unit.rotation);
Draw.mixcol();
Lines.stroke(1f, Pal.accent);
Lines.circle(
if(itemCircleRegion == null || itemCircleRegion.texture.isDisposed()){
itemCircleRegion = Core.atlas.find("ring-item");
}
size = (3f + Mathf.absin(Time.time, 5f, 1f)) * unit.itemTime + 0.5f;
Draw.color(Pal.accent);
Draw.rect(itemCircleRegion,
unit.x + Angles.trnsx(unit.rotation + 180f, itemOffsetY),
unit.y + Angles.trnsy(unit.rotation + 180f, itemOffsetY),
(3f + Mathf.absin(Time.time, 5f, 1f)) * unit.itemTime);
unit.y + Angles.trnsy(unit.rotation + 180f, itemOffsetY), size * 2, size * 2);
if(unit.isLocal() && !renderer.pixelator.enabled()){
Fonts.outline.draw(unit.stack.amount + "",