Gun sound fixes (#8592)
This commit is contained in:
@@ -143,7 +143,7 @@ public sealed partial class GunSystem : SharedGunSystem
|
||||
{
|
||||
SetCartridgeSpent(cartridge, true);
|
||||
MuzzleFlash(gun.Owner, cartridge, user);
|
||||
|
||||
PlaySound(gun.Owner, gun.SoundGunshot?.GetSound(Random, ProtoManager), user);
|
||||
// TODO: Can't predict entity deletions.
|
||||
//if (cartridge.DeleteOnSpawn)
|
||||
// Del(cartridge.Owner);
|
||||
@@ -159,11 +159,15 @@ public sealed partial class GunSystem : SharedGunSystem
|
||||
break;
|
||||
case AmmoComponent newAmmo:
|
||||
MuzzleFlash(gun.Owner, newAmmo, user);
|
||||
PlaySound(gun.Owner, gun.SoundGunshot?.GetSound(Random, ProtoManager), user);
|
||||
if (newAmmo.Owner.IsClientSide())
|
||||
Del(newAmmo.Owner);
|
||||
else
|
||||
RemComp<AmmoComponent>(newAmmo.Owner);
|
||||
break;
|
||||
case HitscanPrototype:
|
||||
PlaySound(gun.Owner, gun.SoundGunshot?.GetSound(Random, ProtoManager), user);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -242,11 +242,8 @@ public abstract partial class SharedGunSystem : EntitySystem
|
||||
return;
|
||||
}
|
||||
|
||||
// Shoot confirmed
|
||||
// Shoot confirmed - sounds also played here in case it's invalid (e.g. cartridge already spent).
|
||||
Shoot(gun, ev.Ammo, fromCoordinates, toCoordinates.Value, user);
|
||||
|
||||
// Predicted sound moment
|
||||
PlaySound(gun.Owner, gun.SoundGunshot?.GetSound(Random, ProtoManager), user);
|
||||
Dirty(gun);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
layers:
|
||||
- state: base
|
||||
map: ["enum.AmmoVisualLayers.Base"]
|
||||
- type: SpentAmmoVisuals
|
||||
- type: Appearance
|
||||
|
||||
- type: entity
|
||||
id: CartridgeCap
|
||||
|
||||
Reference in New Issue
Block a user