Fixed low-FPS continuous bullets

This commit is contained in:
Anuken
2022-04-24 23:12:28 -04:00
parent 1d74011c3e
commit eb880ba2be
4 changed files with 12 additions and 3 deletions

View File

@@ -14,7 +14,7 @@ public class ContinuousLaserBulletType extends ContinuousBulletType{
public float lightStroke = 40f;
public int divisions = 11;
public Color[] colors = {Color.valueOf("ec745855"), Color.valueOf("ec7458aa"), Color.valueOf("ff9c5a"), Color.white};
public float strokeFrom = 2f, strokeTo = 0.5f;
public float strokeFrom = 2f, strokeTo = 0.5f, pointyScaling = 0.75f;
public float backLength = 7f, frontLength = 35f;
public float width = 9f, oscScl = 0.8f, oscMag = 1.5f;
@@ -52,7 +52,7 @@ public class ContinuousLaserBulletType extends ContinuousBulletType{
float colorFin = i / (float)(colors.length - 1);
float baseStroke = Mathf.lerp(strokeFrom, strokeTo, colorFin);
float stroke = (width + Mathf.absin(Time.time, oscScl, oscMag)) * fout * baseStroke;
float ellipseLenScl = Mathf.lerp(1 - i / (float)(colors.length), 1f, 0.75f);
float ellipseLenScl = Mathf.lerp(1 - i / (float)(colors.length), 1f, pointyScaling);
Lines.stroke(stroke);
Lines.lineAngle(b.x, b.y, rot, length - frontLength, false);

View File

@@ -25,7 +25,7 @@ import static mindustry.Vars.*;
abstract class BulletComp implements Timedc, Damagec, Hitboxc, Teamc, Posc, Drawc, Shielderc, Ownerc, Velc, Bulletc, Timerc{
@Import Team team;
@Import Entityc owner;
@Import float x, y, damage, lastX, lastY;
@Import float x, y, damage, lastX, lastY, time, lifetime;
@Import Vec2 vel;
IntSeq collided = new IntSeq(6);
@@ -37,6 +37,8 @@ abstract class BulletComp implements Timedc, Damagec, Hitboxc, Teamc, Posc, Draw
@ReadOnly
private float rotation;
//setting this variable to true prevents lifetime from decreasing for a frame.
transient boolean keepAlive;
transient @Nullable Tile aimTile;
transient float originX, originY;
transient @Nullable Mover mover;
@@ -140,6 +142,11 @@ abstract class BulletComp implements Timedc, Damagec, Hitboxc, Teamc, Posc, Draw
hit = true;
remove();
}
if(keepAlive){
time -= Time.delta;
keepAlive = false;
}
}
public void moveRelative(float x, float y){