From 7455fb21a4eaa9eefc3a7efde8ec3fdf0be2a7ee Mon Sep 17 00:00:00 2001 From: MEEPofFaith <54301439+MEEPofFaith@users.noreply.github.com> Date: Tue, 10 Jan 2023 09:11:37 -0800 Subject: [PATCH] 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 --- .../entities/bullet/PointLaserBulletType.java | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/core/src/mindustry/entities/bullet/PointLaserBulletType.java b/core/src/mindustry/entities/bullet/PointLaserBulletType.java index c794f97f14..9434d1eb3f 100644 --- a/core/src/mindustry/entities/bullet/PointLaserBulletType.java +++ b/core/src/mindustry/entities/bullet/PointLaserBulletType.java @@ -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))); + } + } }