Gun sound fixes (#8592)
This commit is contained in:
@@ -143,7 +143,7 @@ public sealed partial class GunSystem : SharedGunSystem
|
|||||||
{
|
{
|
||||||
SetCartridgeSpent(cartridge, true);
|
SetCartridgeSpent(cartridge, true);
|
||||||
MuzzleFlash(gun.Owner, cartridge, user);
|
MuzzleFlash(gun.Owner, cartridge, user);
|
||||||
|
PlaySound(gun.Owner, gun.SoundGunshot?.GetSound(Random, ProtoManager), user);
|
||||||
// TODO: Can't predict entity deletions.
|
// TODO: Can't predict entity deletions.
|
||||||
//if (cartridge.DeleteOnSpawn)
|
//if (cartridge.DeleteOnSpawn)
|
||||||
// Del(cartridge.Owner);
|
// Del(cartridge.Owner);
|
||||||
@@ -159,11 +159,15 @@ public sealed partial class GunSystem : SharedGunSystem
|
|||||||
break;
|
break;
|
||||||
case AmmoComponent newAmmo:
|
case AmmoComponent newAmmo:
|
||||||
MuzzleFlash(gun.Owner, newAmmo, user);
|
MuzzleFlash(gun.Owner, newAmmo, user);
|
||||||
|
PlaySound(gun.Owner, gun.SoundGunshot?.GetSound(Random, ProtoManager), user);
|
||||||
if (newAmmo.Owner.IsClientSide())
|
if (newAmmo.Owner.IsClientSide())
|
||||||
Del(newAmmo.Owner);
|
Del(newAmmo.Owner);
|
||||||
else
|
else
|
||||||
RemComp<AmmoComponent>(newAmmo.Owner);
|
RemComp<AmmoComponent>(newAmmo.Owner);
|
||||||
break;
|
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);
|
SetCartridgeSpent(cartridge, true);
|
||||||
MuzzleFlash(gun.Owner, cartridge, user);
|
MuzzleFlash(gun.Owner, cartridge, user);
|
||||||
|
PlaySound(gun.Owner, gun.SoundGunshot?.GetSound(Random, ProtoManager), user);
|
||||||
|
|
||||||
if (cartridge.DeleteOnSpawn)
|
if (cartridge.DeleteOnSpawn)
|
||||||
Del(cartridge.Owner);
|
Del(cartridge.Owner);
|
||||||
@@ -92,6 +93,7 @@ public sealed partial class GunSystem : SharedGunSystem
|
|||||||
case AmmoComponent newAmmo:
|
case AmmoComponent newAmmo:
|
||||||
shotProjectiles.Add(newAmmo.Owner);
|
shotProjectiles.Add(newAmmo.Owner);
|
||||||
MuzzleFlash(gun.Owner, newAmmo, user);
|
MuzzleFlash(gun.Owner, newAmmo, user);
|
||||||
|
PlaySound(gun.Owner, gun.SoundGunshot?.GetSound(Random, ProtoManager), user);
|
||||||
|
|
||||||
// Do a throw
|
// Do a throw
|
||||||
if (!HasComp<ProjectileComponent>(newAmmo.Owner))
|
if (!HasComp<ProjectileComponent>(newAmmo.Owner))
|
||||||
@@ -139,6 +141,7 @@ public sealed partial class GunSystem : SharedGunSystem
|
|||||||
{
|
{
|
||||||
FireEffects(fromCoordinates, hitscan.MaxLength, entityDirection.ToAngle(), hitscan);
|
FireEffects(fromCoordinates, hitscan.MaxLength, entityDirection.ToAngle(), hitscan);
|
||||||
}
|
}
|
||||||
|
PlaySound(gun.Owner, gun.SoundGunshot?.GetSound(Random, ProtoManager), user);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new ArgumentOutOfRangeException();
|
throw new ArgumentOutOfRangeException();
|
||||||
@@ -200,7 +203,7 @@ public sealed partial class GunSystem : SharedGunSystem
|
|||||||
|
|
||||||
protected override void PlaySound(EntityUid gun, string? sound, EntityUid? user = null)
|
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);
|
SoundSystem.Play(Filter.Pvs(gun, entityManager: EntityManager).RemoveWhereAttachedEntity(e => e == user), sound, gun);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -242,11 +242,8 @@ public abstract partial class SharedGunSystem : EntitySystem
|
|||||||
return;
|
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);
|
Shoot(gun, ev.Ammo, fromCoordinates, toCoordinates.Value, user);
|
||||||
|
|
||||||
// Predicted sound moment
|
|
||||||
PlaySound(gun.Owner, gun.SoundGunshot?.GetSound(Random, ProtoManager), user);
|
|
||||||
Dirty(gun);
|
Dirty(gun);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,8 @@
|
|||||||
layers:
|
layers:
|
||||||
- state: base
|
- state: base
|
||||||
map: ["enum.AmmoVisualLayers.Base"]
|
map: ["enum.AmmoVisualLayers.Base"]
|
||||||
|
- type: SpentAmmoVisuals
|
||||||
|
- type: Appearance
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
id: CartridgeCap
|
id: CartridgeCap
|
||||||
|
|||||||
Reference in New Issue
Block a user