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

@@ -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){