From b4ec629b9fe5ad5bf9c4c011234e282774d73ae9 Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Sun, 21 Jul 2024 16:09:16 +1000 Subject: [PATCH] Fix muzzle flash tracking (#30163) * Fix muzzle flash tracking User was never set on the networked event but we don't really need it anyway. * Also this one --- Content.Client/Weapons/Ranged/Systems/GunSystem.cs | 12 +++++++----- .../Weapons/Ranged/Systems/SharedGunSystem.cs | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Content.Client/Weapons/Ranged/Systems/GunSystem.cs b/Content.Client/Weapons/Ranged/Systems/GunSystem.cs index 840d1a9091..1af471f28a 100644 --- a/Content.Client/Weapons/Ranged/Systems/GunSystem.cs +++ b/Content.Client/Weapons/Ranged/Systems/GunSystem.cs @@ -88,7 +88,9 @@ public sealed partial class GunSystem : SharedGunSystem private void OnMuzzleFlash(MuzzleFlashEvent args) { - CreateEffect(GetEntity(args.Uid), args); + var gunUid = GetEntity(args.Uid); + + CreateEffect(gunUid, args, gunUid); } private void OnHitscan(HitscanEvent ev) @@ -271,7 +273,7 @@ public sealed partial class GunSystem : SharedGunSystem PopupSystem.PopupEntity(message, uid.Value, user.Value); } - protected override void CreateEffect(EntityUid gunUid, MuzzleFlashEvent message, EntityUid? user = null) + protected override void CreateEffect(EntityUid gunUid, MuzzleFlashEvent message, EntityUid? tracked = null) { if (!Timing.IsFirstTimePredicted) return; @@ -280,7 +282,7 @@ public sealed partial class GunSystem : SharedGunSystem // TODO: Check to see why invalid entities are firing effects. if (gunUid == EntityUid.Invalid) { - Log.Debug($"Invalid Entity sent MuzzleFlashEvent (proto: {message.Prototype}, user: {user})"); + Log.Debug($"Invalid Entity sent MuzzleFlashEvent (proto: {message.Prototype}, gun: {ToPrettyString(gunUid)})"); return; } @@ -304,10 +306,10 @@ public sealed partial class GunSystem : SharedGunSystem var ent = Spawn(message.Prototype, coordinates); TransformSystem.SetWorldRotationNoLerp(ent, message.Angle); - if (user != null) + if (tracked != null) { var track = EnsureComp(ent); - track.User = user; + track.User = tracked; track.Offset = Vector2.UnitX / 2f; } diff --git a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs index 47648a07ad..794237b145 100644 --- a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs +++ b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs @@ -476,7 +476,7 @@ public abstract partial class SharedGunSystem : EntitySystem return; var ev = new MuzzleFlashEvent(GetNetEntity(gun), sprite, worldAngle); - CreateEffect(gun, ev, user); + CreateEffect(gun, ev, gun); } public void CauseImpulse(EntityCoordinates fromCoordinates, EntityCoordinates toCoordinates, EntityUid user, PhysicsComponent userPhysics) -- 2.51.2