replacing sound (collection) names with SoundSpecifier - part 1

This commit is contained in:
Galactic Chimp
2021-07-10 17:35:33 +02:00
parent 4500b66f28
commit ce3c59e0e6
131 changed files with 934 additions and 587 deletions

View File

@@ -1,5 +1,6 @@
using System;
using Content.Shared.Damage;
using Content.Shared.Sound;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
@@ -13,11 +14,11 @@ namespace Content.Server.Weapon.Melee.Components
[ViewVariables(VVAccess.ReadWrite)]
[DataField("hitSound")]
public string HitSound { get; set; } = "/Audio/Weapons/genhit1.ogg";
public SoundSpecifier HitSound { get; set; } = new SoundPathSpecifier("/Audio/Weapons/genhit1.ogg");
[ViewVariables(VVAccess.ReadWrite)]
[DataField("missSound")]
public string MissSound { get; set; } = "/Audio/Weapons/punchmiss.ogg";
public SoundSpecifier MissSound { get; set; } = new SoundPathSpecifier("/Audio/Weapons/punchmiss.ogg");
[ViewVariables]
[DataField("arcCooldownTime")]

View File

@@ -91,12 +91,14 @@ namespace Content.Server.Weapon.Melee
damageableComponent.ChangeDamage(comp.DamageType, comp.Damage, false, owner);
}
SoundSystem.Play(Filter.Pvs(owner), comp.HitSound, target);
if(comp.HitSound.TryGetSound(out var hitSound))
SoundSystem.Play(Filter.Pvs(owner), hitSound, target);
}
}
else
{
SoundSystem.Play(Filter.Pvs(owner), comp.MissSound, args.User);
if(comp.MissSound.TryGetSound(out var missSound))
SoundSystem.Play(Filter.Pvs(owner), missSound, args.User);
return;
}
@@ -146,11 +148,13 @@ namespace Content.Server.Weapon.Melee
{
if (entities.Count != 0)
{
SoundSystem.Play(Filter.Pvs(owner), comp.HitSound, entities.First().Transform.Coordinates);
if(comp.HitSound.TryGetSound(out var hitSound))
SoundSystem.Play(Filter.Pvs(owner), hitSound, entities.First().Transform.Coordinates);
}
else
{
SoundSystem.Play(Filter.Pvs(owner), comp.MissSound, args.User.Transform.Coordinates);
if(comp.MissSound.TryGetSound(out var missSound))
SoundSystem.Play(Filter.Pvs(owner), missSound, args.User.Transform.Coordinates);
}
foreach (var entity in hitEntities)

View File

@@ -1,5 +1,6 @@
using System;
using Content.Shared.Examine;
using Content.Shared.Sound;
using Content.Shared.Weapons.Ranged.Barrels.Components;
using Robust.Server.GameObjects;
using Robust.Shared.GameObjects;
@@ -82,7 +83,7 @@ namespace Content.Server.Weapon.Ranged.Ammunition.Components
private string _muzzleFlashSprite = "Objects/Weapons/Guns/Projectiles/bullet_muzzle.png";
[DataField("soundCollectionEject")]
public string? SoundCollectionEject { get; } = "CasingEject";
public SoundSpecifier SoundCollectionEject { get; } = new SoundCollectionSpecifier("CasingEject");
void ISerializationHooks.AfterDeserialization()
{

View File

@@ -7,6 +7,7 @@ using Content.Shared.Interaction;
using Content.Shared.Interaction.Events;
using Content.Shared.NetIDs;
using Content.Shared.Notification.Managers;
using Content.Shared.Sound;
using Content.Shared.Verbs;
using Content.Shared.Weapons.Ranged.Barrels.Components;
using Robust.Server.GameObjects;
@@ -74,17 +75,17 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
if (value)
{
TryEjectChamber();
if (_soundBoltOpen != null)
if (_soundBoltOpen.TryGetSound(out var soundBoltOpen))
{
SoundSystem.Play(Filter.Pvs(Owner), _soundBoltOpen, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2));
SoundSystem.Play(Filter.Pvs(Owner), soundBoltOpen, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2));
}
}
else
{
TryFeedChamber();
if (_soundBoltClosed != null)
if (_soundBoltClosed.TryGetSound(out var soundBoltClosed))
{
SoundSystem.Play(Filter.Pvs(Owner), _soundBoltClosed, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2));
SoundSystem.Play(Filter.Pvs(Owner), soundBoltClosed, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2));
}
}
@@ -101,13 +102,13 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
// Sounds
[DataField("soundCycle")]
private string _soundCycle = "/Audio/Weapons/Guns/Cock/sf_rifle_cock.ogg";
private SoundSpecifier _soundCycle = new SoundPathSpecifier( "/Audio/Weapons/Guns/Cock/sf_rifle_cock.ogg");
[DataField("soundBoltOpen")]
private string _soundBoltOpen = "/Audio/Weapons/Guns/Bolt/rifle_bolt_open.ogg";
private SoundSpecifier _soundBoltOpen = new SoundPathSpecifier("/Audio/Weapons/Guns/Bolt/rifle_bolt_open.ogg");
[DataField("soundBoltClosed")]
private string _soundBoltClosed = "/Audio/Weapons/Guns/Bolt/rifle_bolt_closed.ogg";
private SoundSpecifier _soundBoltClosed = new SoundPathSpecifier("/Audio/Weapons/Guns/Bolt/rifle_bolt_closed.ogg");
[DataField("soundInsert")]
private string _soundInsert = "/Audio/Weapons/Guns/MagIn/bullet_insert.ogg";
private SoundSpecifier _soundInsert = new SoundPathSpecifier("/Audio/Weapons/Guns/MagIn/bullet_insert.ogg");
void IMapInit.MapInit()
{
@@ -140,7 +141,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
chamber,
FireRateSelector,
count,
SoundGunshot);
SoundGunshot.GetSound());
}
protected override void Initialize()
@@ -224,9 +225,9 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
}
else
{
if (!string.IsNullOrEmpty(_soundCycle))
if (_soundCycle.TryGetSound(out var soundCycle))
{
SoundSystem.Play(Filter.Pvs(Owner), _soundCycle, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2));
SoundSystem.Play(Filter.Pvs(Owner), soundCycle, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2));
}
}
@@ -256,9 +257,9 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
if (_chamberContainer.ContainedEntity == null)
{
_chamberContainer.Insert(ammo);
if (_soundInsert != null)
if (_soundInsert.TryGetSound(out var soundInsert))
{
SoundSystem.Play(Filter.Pvs(Owner), _soundInsert, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2));
SoundSystem.Play(Filter.Pvs(Owner), soundInsert, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2));
}
Dirty();
UpdateAppearance();
@@ -269,9 +270,9 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
{
_ammoContainer.Insert(ammo);
_spawnedAmmo.Push(ammo);
if (_soundInsert != null)
if (_soundInsert.TryGetSound(out var soundInsert))
{
SoundSystem.Play(Filter.Pvs(Owner), _soundInsert, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2));
SoundSystem.Play(Filter.Pvs(Owner), soundInsert, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2));
}
Dirty();
UpdateAppearance();

View File

@@ -5,6 +5,7 @@ using Content.Shared.Interaction;
using Content.Shared.NetIDs;
using Content.Shared.Notification;
using Content.Shared.Notification.Managers;
using Content.Shared.Sound;
using Content.Shared.Weapons.Ranged.Barrels.Components;
using Robust.Server.GameObjects;
using Robust.Shared.Audio;
@@ -65,10 +66,10 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
// Sounds
[DataField("soundCycle")]
private string _soundCycle = "/Audio/Weapons/Guns/Cock/sf_rifle_cock.ogg";
private SoundSpecifier _soundCycle = new SoundPathSpecifier("/Audio/Weapons/Guns/Cock/sf_rifle_cock.ogg");
[DataField("soundInsert")]
private string _soundInsert = "/Audio/Weapons/Guns/MagIn/bullet_insert.ogg";
private SoundSpecifier _soundInsert = new SoundPathSpecifier("/Audio/Weapons/Guns/MagIn/bullet_insert.ogg");
void IMapInit.MapInit()
{
@@ -94,7 +95,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
chamber,
FireRateSelector,
count,
SoundGunshot);
SoundGunshot.GetSound());
}
void ISerializationHooks.AfterDeserialization()
@@ -189,9 +190,9 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
if (manual)
{
if (!string.IsNullOrEmpty(_soundCycle))
if (_soundCycle.TryGetSound(out var sound))
{
SoundSystem.Play(Filter.Pvs(Owner), _soundCycle, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2));
SoundSystem.Play(Filter.Pvs(Owner), sound, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2));
}
}
@@ -218,9 +219,9 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
_spawnedAmmo.Push(eventArgs.Using);
Dirty();
UpdateAppearance();
if (_soundInsert != null)
if (_soundInsert.TryGetSound(out var soundInsert))
{
SoundSystem.Play(Filter.Pvs(Owner), _soundInsert, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2));
SoundSystem.Play(Filter.Pvs(Owner), soundInsert, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2));
}
return true;
}

View File

@@ -6,6 +6,7 @@ using Content.Shared.Interaction;
using Content.Shared.Interaction.Events;
using Content.Shared.NetIDs;
using Content.Shared.Notification.Managers;
using Content.Shared.Sound;
using Content.Shared.Verbs;
using Content.Shared.Weapons.Ranged.Barrels.Components;
using Robust.Server.GameObjects;
@@ -60,13 +61,13 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
// Sounds
[DataField("soundEject")]
private string _soundEject = "/Audio/Weapons/Guns/MagOut/revolver_magout.ogg";
private SoundSpecifier _soundEject = new SoundPathSpecifier("/Audio/Weapons/Guns/MagOut/revolver_magout.ogg");
[DataField("soundInsert")]
private string _soundInsert = "/Audio/Weapons/Guns/MagIn/revolver_magin.ogg";
private SoundSpecifier _soundInsert = new SoundPathSpecifier("/Audio/Weapons/Guns/MagIn/revolver_magin.ogg");
[DataField("soundSpin")]
private string _soundSpin = "/Audio/Weapons/Guns/Misc/revolver_spin.ogg";
private SoundSpecifier _soundSpin = new SoundPathSpecifier("/Audio/Weapons/Guns/Misc/revolver_spin.ogg");
void ISerializationHooks.BeforeSerialization()
{
@@ -96,7 +97,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
_currentSlot,
FireRateSelector,
slotsSpent,
SoundGunshot);
SoundGunshot.GetSound());
}
protected override void Initialize()
@@ -164,9 +165,9 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
_currentSlot = i;
_ammoSlots[i] = entity;
_ammoContainer.Insert(entity);
if (_soundInsert != null)
if (_soundInsert.TryGetSound(out var sound))
{
SoundSystem.Play(Filter.Pvs(Owner), _soundInsert, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2));
SoundSystem.Play(Filter.Pvs(Owner), sound, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2));
}
Dirty();
@@ -194,9 +195,9 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
{
var random = _random.Next(_ammoSlots.Length - 1);
_currentSlot = random;
if (!string.IsNullOrEmpty(_soundSpin))
if (_soundSpin.TryGetSound(out var sound))
{
SoundSystem.Play(Filter.Pvs(Owner), _soundSpin, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2));
SoundSystem.Play(Filter.Pvs(Owner), sound, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2));
}
Dirty();
}
@@ -248,9 +249,9 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
if (_ammoContainer.ContainedEntities.Count > 0)
{
if (_soundEject != null)
if (_soundEject.TryGetSound(out var sound))
{
SoundSystem.Play(Filter.Pvs(Owner), _soundEject, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-1));
SoundSystem.Play(Filter.Pvs(Owner), sound, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-1));
}
}

View File

@@ -10,6 +10,7 @@ using Content.Shared.Damage;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Events;
using Content.Shared.NetIDs;
using Content.Shared.Sound;
using Content.Shared.Verbs;
using Content.Shared.Weapons.Ranged.Barrels.Components;
using Robust.Server.GameObjects;
@@ -83,9 +84,9 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
// Sounds
[DataField("soundPowerCellInsert")]
private string? _soundPowerCellInsert = default;
private SoundSpecifier _soundPowerCellInsert = default!;
[DataField("soundPowerCellEject")]
private string? _soundPowerCellEject = default;
private SoundSpecifier _soundPowerCellEject = default!;
public override ComponentState GetComponentState(ICommonSession player)
{
@@ -222,9 +223,9 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
return false;
}
if (_soundPowerCellInsert != null)
if (_soundPowerCellInsert.TryGetSound(out var sound))
{
SoundSystem.Play(Filter.Pvs(Owner), _soundPowerCellInsert, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2));
SoundSystem.Play(Filter.Pvs(Owner), sound, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2));
}
_powerCellContainer.Insert(entity);
@@ -275,9 +276,9 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
cell.Owner.Transform.Coordinates = user.Transform.Coordinates;
}
if (_soundPowerCellEject != null)
if (_soundPowerCellEject.TryGetSound(out var sound))
{
SoundSystem.Play(Filter.Pvs(Owner), _soundPowerCellEject, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2));
SoundSystem.Play(Filter.Pvs(Owner), sound, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2));
}
return true;
}

View File

@@ -10,6 +10,7 @@ using Content.Shared.Interaction;
using Content.Shared.Interaction.Events;
using Content.Shared.NetIDs;
using Content.Shared.Notification.Managers;
using Content.Shared.Sound;
using Content.Shared.Verbs;
using Content.Shared.Weapons.Ranged;
using Content.Shared.Weapons.Ranged.Barrels.Components;
@@ -97,17 +98,17 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
if (value)
{
TryEjectChamber();
if (_soundBoltOpen != null)
if (_soundBoltOpen.TryGetSound(out var soundBoltOpen))
{
SoundSystem.Play(Filter.Pvs(Owner), _soundBoltOpen, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2));
SoundSystem.Play(Filter.Pvs(Owner), soundBoltOpen, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2));
}
}
else
{
TryFeedChamber();
if (_soundBoltClosed != null)
if (_soundBoltClosed.TryGetSound(out var soundBoltClosed))
{
SoundSystem.Play(Filter.Pvs(Owner), _soundBoltClosed, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2));
SoundSystem.Play(Filter.Pvs(Owner), soundBoltClosed, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2));
}
}
@@ -129,17 +130,17 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
// Sounds
[DataField("soundBoltOpen")]
private string? _soundBoltOpen = default;
private SoundSpecifier _soundBoltOpen = default!;
[DataField("soundBoltClosed")]
private string? _soundBoltClosed = default;
private SoundSpecifier _soundBoltClosed = default!;
[DataField("soundRack")]
private string? _soundRack = default;
private SoundSpecifier _soundRack = default!;
[DataField("soundMagInsert")]
private string? _soundMagInsert = default;
private SoundSpecifier _soundMagInsert = default!;
[DataField("soundMagEject")]
private string? _soundMagEject = default;
private SoundSpecifier _soundMagEject = default!;
[DataField("soundAutoEject")]
private string _soundAutoEject = "/Audio/Weapons/Guns/EmptyAlarm/smg_empty_alarm.ogg";
private SoundSpecifier _soundAutoEject = new SoundPathSpecifier("/Audio/Weapons/Guns/EmptyAlarm/smg_empty_alarm.ogg");
private List<MagazineType> GetMagazineTypes()
{
@@ -169,7 +170,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
_chamberContainer.ContainedEntity != null,
FireRateSelector,
count,
SoundGunshot);
SoundGunshot.GetSound());
}
protected override void Initialize()
@@ -228,9 +229,9 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
if (_chamberContainer.ContainedEntity == null && !BoltOpen)
{
if (_soundBoltOpen != null)
if (_soundBoltOpen.TryGetSound(out var soundBoltOpen))
{
SoundSystem.Play(Filter.Pvs(Owner), _soundBoltOpen, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-5));
SoundSystem.Play(Filter.Pvs(Owner), soundBoltOpen, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-5));
}
if (Owner.TryGetContainer(out var container))
@@ -243,9 +244,9 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
if (manual)
{
if (_soundRack != null)
if (_soundRack.TryGetSound(out var soundRack))
{
SoundSystem.Play(Filter.Pvs(Owner), _soundRack, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2));
SoundSystem.Play(Filter.Pvs(Owner), soundRack, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2));
}
}
@@ -271,9 +272,9 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
if (BoltOpen)
{
if (_soundBoltClosed != null)
if (_soundBoltClosed.TryGetSound(out var soundBoltClosed))
{
SoundSystem.Play(Filter.Pvs(Owner), _soundBoltClosed, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-5));
SoundSystem.Play(Filter.Pvs(Owner), soundBoltClosed, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-5));
}
Owner.PopupMessage(eventArgs.User, Loc.GetString("server-magazine-barrel-component-use-entity-bolt-closed"));
BoltOpen = false;
@@ -325,9 +326,9 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
if (_autoEjectMag && magazine != null && magazine.GetComponent<RangedMagazineComponent>().ShotsLeft == 0)
{
if (_soundAutoEject != null)
if (_soundAutoEject.TryGetSound(out var soundAutoEject))
{
SoundSystem.Play(Filter.Pvs(Owner), _soundAutoEject, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2));
SoundSystem.Play(Filter.Pvs(Owner), soundAutoEject, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2));
}
_magazineContainer.Remove(magazine);
@@ -352,9 +353,9 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
}
_magazineContainer.Remove(mag);
if (_soundMagEject != null)
if (_soundMagEject.TryGetSound(out var soundMagEject))
{
SoundSystem.Play(Filter.Pvs(Owner), _soundMagEject, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2));
SoundSystem.Play(Filter.Pvs(Owner), soundMagEject, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2));
}
if (user.TryGetComponent(out HandsComponent? handsComponent))
@@ -391,9 +392,9 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
if (_magazineContainer.ContainedEntity == null)
{
if (_soundMagInsert != null)
if (_soundMagInsert.TryGetSound(out var soundMagInsert))
{
SoundSystem.Play(Filter.Pvs(Owner), _soundMagInsert, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2));
SoundSystem.Play(Filter.Pvs(Owner), soundMagInsert, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2));
}
Owner.PopupMessage(eventArgs.User, Loc.GetString("server-magazine-barrel-component-interact-using-success"));
_magazineContainer.Insert(eventArgs.Using);

View File

@@ -9,6 +9,7 @@ using Content.Shared.Audio;
using Content.Shared.Damage.Components;
using Content.Shared.Examine;
using Content.Shared.Interaction;
using Content.Shared.Sound;
using Content.Shared.Weapons.Ranged.Components;
using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
@@ -97,10 +98,10 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
// Sounds
[DataField("soundGunshot")]
public string? SoundGunshot { get; set; }
public SoundSpecifier SoundGunshot { get; set; } = default!;
[DataField("soundEmpty")]
public string SoundEmpty { get; } = "/Audio/Weapons/Guns/Empty/empty.ogg";
public SoundSpecifier SoundEmpty { get; } = new SoundPathSpecifier("/Audio/Weapons/Guns/Empty/empty.ogg");
void ISerializationHooks.BeforeSerialization()
{
@@ -196,9 +197,9 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
{
if (ShotsLeft == 0)
{
if (SoundEmpty != null)
if (SoundEmpty.TryGetSound(out var sound))
{
SoundSystem.Play(Filter.Broadcast(), SoundEmpty, Owner.Transform.Coordinates);
SoundSystem.Play(Filter.Broadcast(), sound, Owner.Transform.Coordinates);
}
return;
}
@@ -207,7 +208,8 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
var projectile = TakeProjectile(shooter.Transform.Coordinates);
if (projectile == null)
{
SoundSystem.Play(Filter.Broadcast(), SoundEmpty, Owner.Transform.Coordinates);
if(SoundEmpty.TryGetSound(out var soundEmpty))
SoundSystem.Play(Filter.Broadcast(), soundEmpty, Owner.Transform.Coordinates);
return;
}
@@ -220,7 +222,6 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
recoilComponent.Kick(-angle.ToVec() * 0.15f);
}
// This section probably needs tweaking so there can be caseless hitscan etc.
if (projectile.TryGetComponent(out HitscanComponent? hitscan))
{
@@ -248,9 +249,9 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
throw new InvalidOperationException();
}
if (!string.IsNullOrEmpty(SoundGunshot))
if (SoundGunshot.TryGetSound(out var soundGunshot))
{
SoundSystem.Play(Filter.Broadcast(), SoundGunshot, Owner.Transform.Coordinates);
SoundSystem.Play(Filter.Broadcast(), soundGunshot, Owner.Transform.Coordinates);
}
_lastFire = _gameTiming.CurTime;
@@ -282,16 +283,10 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
entity.Transform.Coordinates = entity.Transform.Coordinates.Offset(offsetPos);
entity.Transform.LocalRotation = robustRandom.Pick(ejectDirections).ToAngle();
if (ammo.SoundCollectionEject == null || !playSound)
if (ammo.SoundCollectionEject.TryGetSound(out var ejectSounds) && playSound)
{
return;
}
prototypeManager ??= IoCManager.Resolve<IPrototypeManager>();
var soundCollection = prototypeManager.Index<SoundCollectionPrototype>(ammo.SoundCollectionEject);
var randomFile = robustRandom.Pick(soundCollection.PickFiles);
SoundSystem.Play(Filter.Broadcast(), randomFile, entity.Transform.Coordinates, AudioParams.Default.WithVolume(-1));
SoundSystem.Play(Filter.Broadcast(), ejectSounds, entity.Transform.Coordinates, AudioParams.Default.WithVolume(-1));
}
}
/// <summary>

View File

@@ -11,6 +11,7 @@ using Content.Shared.Damage.Components;
using Content.Shared.Hands;
using Content.Shared.Interaction.Events;
using Content.Shared.Notification.Managers;
using Content.Shared.Sound;
using Content.Shared.Weapons.Ranged.Components;
using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
@@ -48,6 +49,12 @@ namespace Content.Server.Weapon.Ranged
[DataField("canHotspot")]
private bool _canHotspot = true;
[DataField("clumsyWeaponHandlingSound")]
private SoundSpecifier _clumsyWeaponHandlingSound = new SoundPathSpecifier("/Audio/Items/bikehorn.ogg");
[DataField("clumsyWeaponShotSound")]
private SoundSpecifier _clumsyWeaponShotSound = new SoundPathSpecifier("/Audio/Weapons/Guns/Gunshots/bang.ogg");
public Func<bool>? WeaponCanFireHandler;
public Func<IEntity, bool>? UserCanFireHandler;
public Action<IEntity, Vector2>? FireHandler;
@@ -159,11 +166,13 @@ namespace Content.Server.Weapon.Ranged
if (ClumsyCheck && ClumsyComponent.TryRollClumsy(user, ClumsyExplodeChance))
{
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Items/bikehorn.ogg",
Owner.Transform.Coordinates, AudioParams.Default.WithMaxDistance(5));
if(_clumsyWeaponHandlingSound.TryGetSound(out var clumsyWeaponHandlingSound))
SoundSystem.Play(Filter.Pvs(Owner), clumsyWeaponHandlingSound,
Owner.Transform.Coordinates, AudioParams.Default.WithMaxDistance(5));
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Weapons/Guns/Gunshots/bang.ogg",
Owner.Transform.Coordinates, AudioParams.Default.WithMaxDistance(5));
if(_clumsyWeaponShotSound.TryGetSound(out var clumsyWeaponShotSound))
SoundSystem.Play(Filter.Pvs(Owner), clumsyWeaponShotSound,
Owner.Transform.Coordinates, AudioParams.Default.WithMaxDistance(5));
if (user.TryGetComponent(out IDamageableComponent? health))
{