From 79ae7e7abe47b94c28a47ab58789df50ef36cd96 Mon Sep 17 00:00:00 2001 From: TGRCDev Date: Fri, 25 Apr 2025 19:12:18 -0700 Subject: [PATCH] Fixed stinger grenade lag spikes (#36641) * Fixed stinger lag spikes * Simplify nullable checks * More cleanup of projectile grenades * Remove null default from ShootProjectile --- .../Explosion/EntitySystems/ProjectileGrenadeSystem.cs | 2 +- Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Content.Server/Explosion/EntitySystems/ProjectileGrenadeSystem.cs b/Content.Server/Explosion/EntitySystems/ProjectileGrenadeSystem.cs index 555ce3399e..dbb96e06a5 100644 --- a/Content.Server/Explosion/EntitySystems/ProjectileGrenadeSystem.cs +++ b/Content.Server/Explosion/EntitySystems/ProjectileGrenadeSystem.cs @@ -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); } } diff --git a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs index 8ed9e4949e..bebfe6f922 100644 --- a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs +++ b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs @@ -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(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(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); } -- 2.51.2