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

This commit is contained in:
Anuken
2021-11-25 13:29:51 -05:00
7 changed files with 41 additions and 35 deletions

View File

@@ -468,8 +468,15 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
}
unit.remove();
//needs new ID as it is now a payload
unit.id = EntityGroup.nextId();
if(net.client()){
unit.id = EntityGroup.nextId();
}else{
//server-side, this needs to be delayed until next frame because otherwise the packets sent out right after this event would have the wrong unit ID, leading to ghosts
Core.app.post(() -> unit.id = EntityGroup.nextId());
}
grabber.get(new UnitPayload(unit));
Fx.unitDrop.at(unit);
}

View File

@@ -32,6 +32,8 @@ public class ParticleEffect extends Effect{
public float spin = 0f;
/** Controls the initial and final sprite sizes. */
public float sizeFrom = 2f, sizeTo = 0f;
/** Whether the rotation adds with the parent */
public boolean useRotation = true;
/** Rotation offset. */
public float offset = 0;
/** Sprite to draw. */
@@ -53,10 +55,11 @@ 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 rawfin = e.fin();
float fin = e.fin(interp);
float rad = sizeInterp.apply(sizeFrom, sizeTo, rawfin) * 2;
float ox = e.x + Angles.trnsx(e.rotation, offsetX, offsetY), oy = e.y + Angles.trnsy(e.rotation, offsetX, offsetY);
float ox = e.x + Angles.trnsx(realRotation, offsetX, offsetY), oy = e.y + Angles.trnsy(realRotation, offsetX, offsetY);
Draw.color(colorFrom, colorTo, fin);
Color lightColor = this.lightColor == null ? Draw.getColor() : this.lightColor;
@@ -68,7 +71,7 @@ public class ParticleEffect extends Effect{
rand.setSeed(e.id);
for(int i = 0; i < particles; i++){
float l = length * fin + baseLength;
rv.trns(e.rotation + rand.range(cone), !randLength ? l : rand.random(l));
rv.trns(realRotation + rand.range(cone), !randLength ? l : rand.random(l));
float x = rv.x, y = rv.y;
Lines.lineAngle(ox + x, oy + y, Mathf.angle(x, y), len);
@@ -78,10 +81,10 @@ public class ParticleEffect extends Effect{
rand.setSeed(e.id);
for(int i = 0; i < particles; i++){
float l = length * fin + baseLength;
rv.trns(e.rotation + rand.range(cone), !randLength ? l : rand.random(l));
rv.trns(realRotation + rand.range(cone), !randLength ? l : rand.random(l));
float x = rv.x, y = rv.y;
Draw.rect(tex, ox + x, oy + y, rad, rad, e.rotation + offset + e.time * spin);
Draw.rect(tex, ox + x, oy + y, rad, rad, realRotation + offset + e.time * spin);
Drawf.light(ox + x, oy + y, rad * lightScl, lightColor, lightOpacity * Draw.getColor().a);
}
}