Proper trails for point lasers (#8038)

* Proper trails for point lasers

* Take current size into account

* fh9weqfjpoepiofjwpiqoefjpoiwjieqpofpjioji

* Web editing moment

* Point laser bullets shouldn't have aa shoot effect

* h
This commit is contained in:
MEEPofFaith 2023-01-10 09:11:37 -08:00 committed by GitHub
parent 2c3210afce
commit 7455fb21a4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -10,6 +10,8 @@ import mindustry.entities.*;
import mindustry.gen.*;
import mindustry.graphics.*;
import static mindustry.Vars.*;
/** A continuous bullet type that only damages in a point. */
public class PointLaserBulletType extends BulletType{
public String sprite = "point-laser";
@ -29,7 +31,6 @@ public class PointLaserBulletType extends BulletType{
removeAfterPierce = false;
speed = 0f;
despawnEffect = Fx.none;
shootEffect = Fx.none;
lifetime = 20f;
impact = true;
keepVelocity = false;
@ -38,6 +39,7 @@ public class PointLaserBulletType extends BulletType{
hittable = false;
absorbable = false;
optimalLifeFract = 0.5f;
shootEffect = smokeEffect = Fx.none;
//just make it massive, users of this bullet can adjust as necessary
drawSize = 1000f;
@ -82,4 +84,30 @@ public class PointLaserBulletType extends BulletType{
Effect.shake(shake, shake, b);
}
}
@Override
public void updateTrailEffects(Bullet b){
if(trailChance > 0){
if(Mathf.chanceDelta(trailChance)){
trailEffect.at(b.aimX, b.aimY, trailRotation ? b.angleTo(b.aimX, b.aimY) : (trailParam * b.fslope()), trailColor);
}
}
if(trailInterval > 0f){
if(b.timer(0, trailInterval)){
trailEffect.at(b.aimX, b.aimY, trailRotation ? b.angleTo(b.aimX, b.aimY) : (trailParam * b.fslope()), trailColor);
}
}
}
@Override
public void updateTrail(Bullet b){
if(!headless && trailLength > 0){
if(b.trail == null){
b.trail = new Trail(trailLength);
}
b.trail.length = trailLength;
b.trail.update(b.aimX, b.aimY, b.fslope() * (1f - (trailSinMag > 0 ? Mathf.absin(Time.time, trailSinScl, trailSinMag) : 0f)));
}
}
}