Partial 7.0 merge - API preview

This commit is contained in:
Anuken
2021-06-02 11:08:08 -04:00
parent ea75a357ca
commit 28b235ef07
531 changed files with 12356 additions and 6286 deletions

View File

@@ -0,0 +1,47 @@
package mindustry.entities.effect;
import arc.graphics.*;
import arc.graphics.g2d.*;
import arc.math.*;
import mindustry.entities.*;
import mindustry.graphics.*;
import static arc.graphics.g2d.Draw.*;
import static arc.graphics.g2d.Lines.*;
import static arc.math.Angles.*;
public class ExplosionEffect extends Effect{
public Color waveColor = Pal.missileYellow, smokeColor = Color.gray, sparkColor = Pal.missileYellowBack;
public float waveLife = 6f, waveStroke = 3f, waveRad = 15f, waveRadBase = 2f, sparkStroke = 1f, sparkRad = 23f, sparkLen = 3f, smokeSize = 4f, smokeSizeBase = 0.5f, smokeRad = 23f;
public int smokes = 5, sparks = 4;
public ExplosionEffect(){
clip = 100f;
lifetime = 22;
renderer = e -> {
color(waveColor);
e.scaled(waveLife, i -> {
stroke(waveStroke * i.fout());
Lines.circle(e.x, e.y, waveRadBase + i.fin() * waveRad);
});
color(smokeColor);
if(smokeSize > 0){
randLenVectors(e.id, smokes, 2f + smokeRad * e.finpow(), (x, y) -> {
Fill.circle(e.x + x, e.y + y, e.fout() * smokeSize + smokeSizeBase);
});
}
color(sparkColor);
stroke(e.fout() * sparkStroke);
randLenVectors(e.id + 1, sparks, 1f + sparkRad * e.finpow(), (x, y) -> {
lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), 1f + e.fout() * sparkLen);
Drawf.light(e.x + x, e.y + y, e.fout() * sparkLen * 4f, sparkColor, 0.7f);
});
};
}
}

View File

@@ -6,17 +6,28 @@ import arc.graphics.g2d.*;
import arc.math.*;
import arc.util.*;
import mindustry.entities.*;
import mindustry.graphics.*;
/** The most essential effect class. Can create particles in various shapes. */
public class ParticleEffect extends Effect{
public Color colorFrom = Color.white.cpy(), colorTo = Color.white.cpy();
public int particles = 6;
public float cone = 180f, length = 20f, baseLength = 0f;
/** Particle size/length/radius interpolation. */
public Interp interp = Interp.linear;
public float offsetX, offsetY;
public float lightScl = 2f, lightOpacity = 0.6f;
public @Nullable Color lightColor;
//region only
/** Spin in degrees per tick. */
public float spin = 0f;
/** Controls the initial and final sprite sizes. */
public float sizeFrom = 2f, sizeTo = 0f;
/** Rotation offset. */
public float offset = 0;
/** Sprite to draw. */
public String region = "circle";
//line only
@@ -37,19 +48,23 @@ public class ParticleEffect extends Effect{
float rawfin = e.fin();
float fin = e.fin(interp);
float rad = interp.apply(sizeFrom, sizeTo, rawfin) * 2;
float ox = e.x + Angles.trnsx(e.rotation, offsetX, offsetY), oy = e.y + Angles.trnsy(e.rotation, offsetX, offsetY);
Draw.color(colorFrom, colorTo, fin);
Color lightColor = this.lightColor == null ? Draw.getColor() : this.lightColor;
if(line){
Lines.stroke(interp.apply(strokeFrom, strokeTo, rawfin));
float len = interp.apply(lenFrom, lenTo, rawfin);
Angles.randLenVectors(e.id, particles, length * fin + baseLength, e.rotation, cone, (x, y) -> {
Lines.lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), len);
Lines.lineAngle(ox + x, oy + y, Mathf.angle(x, y), len);
Drawf.light(ox + x, oy + y, len * lightScl, lightColor, lightOpacity);
});
}else{
Angles.randLenVectors(e.id, particles, length * fin + baseLength, e.rotation, cone, (x, y) -> {
Draw.rect(tex, e.x + x, e.y + y, rad, rad, e.rotation + offset);
Draw.rect(tex, ox + x, oy + y, rad, rad, e.rotation + offset + e.time * spin);
Drawf.light(ox + x, oy + y, rad * lightScl, lightColor, lightOpacity);
});
}
}

View File

@@ -3,16 +3,21 @@ package mindustry.entities.effect;
import arc.graphics.*;
import arc.graphics.g2d.*;
import arc.math.*;
import arc.util.*;
import mindustry.entities.*;
import mindustry.graphics.*;
/** Effect that renders a basic shockwave. */
public class WaveEffect extends Effect{
public Color colorFrom = Color.white.cpy(), colorTo = Color.white.cpy();
public float sizeFrom = 0f, sizeTo = 100f;
public @Nullable Color lightColor;
public float sizeFrom = 0f, sizeTo = 100f, lightScl = 3f, lightOpacity = 0.8f;
public int sides = -1;
public float rotation = 0f;
public float strokeFrom = 2f, strokeTo = 0f;
public Interp interp = Interp.linear;
public Interp lightInterp = Interp.reverse;
public float offsetX, offsetY;
@Override
public void init(){
@@ -23,11 +28,14 @@ public class WaveEffect extends Effect{
public void render(EffectContainer e){
float fin = e.fin();
float ifin = e.fin(interp);
float ox = e.x + Angles.trnsx(e.rotation, offsetX, offsetY), oy = e.y + Angles.trnsy(e.rotation, offsetX, offsetY);
Draw.color(colorFrom, colorTo, ifin);
Lines.stroke(interp.apply(strokeFrom, strokeTo, fin));
float rad = interp.apply(sizeFrom, sizeTo, fin);
Lines.poly(e.x, e.y, sides <= 0 ? Lines.circleVertices(rad) : sides, rad, rotation + e.rotation);
Lines.poly(ox, oy, sides <= 0 ? Lines.circleVertices(rad) : sides, rad, rotation + e.rotation);
Drawf.light(ox, oy, rad * lightScl, lightColor == null ? Draw.getColor() : lightColor, lightOpacity * e.fin(lightInterp));
}
}