Fix muzzle flashes for other players (#10454)

This commit is contained in:
metalgearsloth
2022-08-09 14:30:32 +10:00
committed by GitHub
parent 4becd815b1
commit 75dfbdb57f
3 changed files with 7 additions and 5 deletions

View File

@@ -63,7 +63,7 @@ public sealed partial class GunSystem : SharedGunSystem
base.Initialize(); base.Initialize();
UpdatesOutsidePrediction = true; UpdatesOutsidePrediction = true;
SubscribeLocalEvent<AmmoCounterComponent, ItemStatusCollectMessage>(OnAmmoCounterCollect); SubscribeLocalEvent<AmmoCounterComponent, ItemStatusCollectMessage>(OnAmmoCounterCollect);
SubscribeLocalEvent<GunComponent, MuzzleFlashEvent>(OnMuzzleFlash); SubscribeAllEvent<MuzzleFlashEvent>(OnMuzzleFlash);
// Plays animated effects on the client. // Plays animated effects on the client.
SubscribeNetworkEvent<HitscanEvent>(OnHitscan); SubscribeNetworkEvent<HitscanEvent>(OnHitscan);
@@ -72,9 +72,9 @@ public sealed partial class GunSystem : SharedGunSystem
InitializeSpentAmmo(); InitializeSpentAmmo();
} }
private void OnMuzzleFlash(EntityUid uid, GunComponent component, MuzzleFlashEvent args) private void OnMuzzleFlash(MuzzleFlashEvent args)
{ {
CreateEffect(uid, args); CreateEffect(args.Uid, args);
} }
private void OnHitscan(HitscanEvent ev) private void OnHitscan(HitscanEvent ev)

View File

@@ -8,10 +8,12 @@ namespace Content.Shared.Weapons.Ranged.Events;
[Serializable, NetSerializable] [Serializable, NetSerializable]
public sealed class MuzzleFlashEvent : EntityEventArgs public sealed class MuzzleFlashEvent : EntityEventArgs
{ {
public EntityUid Uid;
public string Prototype; public string Prototype;
public MuzzleFlashEvent(string prototype) public MuzzleFlashEvent(EntityUid uid, string prototype)
{ {
Uid = uid;
Prototype = prototype; Prototype = prototype;
} }
} }

View File

@@ -349,7 +349,7 @@ public abstract partial class SharedGunSystem : EntitySystem
if (sprite == null) if (sprite == null)
return; return;
var ev = new MuzzleFlashEvent(sprite); var ev = new MuzzleFlashEvent(gun, sprite);
CreateEffect(gun, ev, user); CreateEffect(gun, ev, user);
} }