Gun sound fixes (#8592)

This commit is contained in:
metalgearsloth
2022-06-02 19:13:13 +10:00
committed by GitHub
parent 5ed2c27658
commit c021cadd46
4 changed files with 12 additions and 6 deletions

View File

@@ -73,6 +73,7 @@ public sealed partial class GunSystem : SharedGunSystem
SetCartridgeSpent(cartridge, true);
MuzzleFlash(gun.Owner, cartridge, user);
PlaySound(gun.Owner, gun.SoundGunshot?.GetSound(Random, ProtoManager), user);
if (cartridge.DeleteOnSpawn)
Del(cartridge.Owner);
@@ -92,6 +93,7 @@ public sealed partial class GunSystem : SharedGunSystem
case AmmoComponent newAmmo:
shotProjectiles.Add(newAmmo.Owner);
MuzzleFlash(gun.Owner, newAmmo, user);
PlaySound(gun.Owner, gun.SoundGunshot?.GetSound(Random, ProtoManager), user);
// Do a throw
if (!HasComp<ProjectileComponent>(newAmmo.Owner))
@@ -139,6 +141,7 @@ public sealed partial class GunSystem : SharedGunSystem
{
FireEffects(fromCoordinates, hitscan.MaxLength, entityDirection.ToAngle(), hitscan);
}
PlaySound(gun.Owner, gun.SoundGunshot?.GetSound(Random, ProtoManager), user);
break;
default:
throw new ArgumentOutOfRangeException();
@@ -200,7 +203,7 @@ public sealed partial class GunSystem : SharedGunSystem
protected override void PlaySound(EntityUid gun, string? sound, EntityUid? user = null)
{
if (sound == null) return;
if (string.IsNullOrEmpty(sound)) return;
SoundSystem.Play(Filter.Pvs(gun, entityManager: EntityManager).RemoveWhereAttachedEntity(e => e == user), sound, gun);
}