Fixed stinger grenade lag spikes (#36641)

* Fixed stinger lag spikes

* Simplify nullable checks

* More cleanup of projectile grenades

* Remove null default from ShootProjectile
This commit is contained in:
TGRCDev
2025-04-25 19:12:18 -07:00
committed by GitHub
parent bd51fd76d7
commit 79ae7e7abe
2 changed files with 5 additions and 3 deletions

View File

@@ -77,7 +77,7 @@ public sealed class ProjectileGrenadeSystem : EntitySystem
// slightly uneven, doesn't really change much, but it looks better // slightly uneven, doesn't really change much, but it looks better
var direction = angle.ToVec().Normalized(); var direction = angle.ToVec().Normalized();
var velocity = _random.NextVector2(component.MinVelocity, component.MaxVelocity); var velocity = _random.NextVector2(component.MinVelocity, component.MaxVelocity);
_gun.ShootProjectile(contentUid, direction, velocity, uid, null); _gun.ShootProjectile(contentUid, direction, velocity, null);
} }
} }

View File

@@ -415,7 +415,7 @@ public abstract partial class SharedGunSystem : EntitySystem
EntityUid? user = null, EntityUid? user = null,
bool throwItems = false); 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); var physics = EnsureComp<PhysicsComponent>(uid);
Physics.SetBodyStatus(uid, physics, BodyStatus.InAir); Physics.SetBodyStatus(uid, physics, BodyStatus.InAir);
@@ -426,8 +426,10 @@ public abstract partial class SharedGunSystem : EntitySystem
Physics.SetLinearVelocity(uid, finalLinear, body: physics); Physics.SetLinearVelocity(uid, finalLinear, body: physics);
var projectile = EnsureComp<ProjectileComponent>(uid); var projectile = EnsureComp<ProjectileComponent>(uid);
Projectiles.SetShooter(uid, projectile, user ?? gunUid);
projectile.Weapon = gunUid; projectile.Weapon = gunUid;
var shooter = user ?? gunUid;
if (shooter != null)
Projectiles.SetShooter(uid, projectile, shooter.Value);
TransformSystem.SetWorldRotation(uid, direction.ToWorldAngle() + projectile.Angle); TransformSystem.SetWorldRotation(uid, direction.ToWorldAngle() + projectile.Angle);
} }