]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fixed stinger grenade lag spikes (#36641)
authorTGRCDev <tgrc@tgrc.dev>
Sat, 26 Apr 2025 02:12:18 +0000 (19:12 -0700)
committerGitHub <noreply@github.com>
Sat, 26 Apr 2025 02:12:18 +0000 (04:12 +0200)
* Fixed stinger lag spikes

* Simplify nullable checks

* More cleanup of projectile grenades

* Remove null default from ShootProjectile

Content.Server/Explosion/EntitySystems/ProjectileGrenadeSystem.cs
Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs

index 555ce3399e750834bea9cfbca3e7ade3839e1faa..dbb96e06a5f5e03f18dbf6fdf5ed493353fe0e6c 100644 (file)
@@ -77,7 +77,7 @@ public sealed class ProjectileGrenadeSystem : EntitySystem
             // slightly uneven, doesn't really change much, but it looks better
             var direction = angle.ToVec().Normalized();
             var velocity = _random.NextVector2(component.MinVelocity, component.MaxVelocity);
-            _gun.ShootProjectile(contentUid, direction, velocity, uid, null);
+            _gun.ShootProjectile(contentUid, direction, velocity, null);
         }
     }
 
index 8ed9e4949e51f607a02321547fe6b5dc4fa323e4..bebfe6f92290bad8e14370cda31df029d6b3af18 100644 (file)
@@ -415,7 +415,7 @@ public abstract partial class SharedGunSystem : EntitySystem
         EntityUid? user = null,
         bool throwItems = false);
 
-    public void ShootProjectile(EntityUid uid, Vector2 direction, Vector2 gunVelocity, EntityUid gunUid, EntityUid? user = null, float speed = 20f)
+    public void ShootProjectile(EntityUid uid, Vector2 direction, Vector2 gunVelocity, EntityUid? gunUid, EntityUid? user = null, float speed = 20f)
     {
         var physics = EnsureComp<PhysicsComponent>(uid);
         Physics.SetBodyStatus(uid, physics, BodyStatus.InAir);
@@ -426,8 +426,10 @@ public abstract partial class SharedGunSystem : EntitySystem
         Physics.SetLinearVelocity(uid, finalLinear, body: physics);
 
         var projectile = EnsureComp<ProjectileComponent>(uid);
-        Projectiles.SetShooter(uid, projectile, user ?? gunUid);
         projectile.Weapon = gunUid;
+        var shooter = user ?? gunUid;
+        if (shooter != null)
+            Projectiles.SetShooter(uid, projectile, shooter.Value);
 
         TransformSystem.SetWorldRotation(uid, direction.ToWorldAngle() + projectile.Angle);
     }