Adds the ability to assign equip sounds in ClothingComponent (#4485)

* Initial

* Works (Kinda)

* Polish

* Reviews
This commit is contained in:
Swept
2021-08-19 21:22:23 -07:00
committed by GitHub
parent aa41db5a22
commit 45030b22a3
6 changed files with 20 additions and 7 deletions

View File

@@ -5,8 +5,11 @@ using Content.Shared.Clothing;
using Content.Shared.Interaction;
using Content.Shared.Item;
using Content.Shared.Notification.Managers;
using Content.Shared.Sound;
using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
using Robust.Shared.GameStates;
using Robust.Shared.Player;
using Robust.Shared.Players;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
@@ -32,6 +35,9 @@ namespace Content.Server.Clothing.Components
[DataField("HeatResistance")]
private int _heatResistance = 323;
[DataField("EquipSound")]
public SoundSpecifier? EquipSound { get; set; } = default!;
[ViewVariables(VVAccess.ReadWrite)]
public int HeatResistance => _heatResistance;
@@ -91,7 +97,7 @@ namespace Content.Server.Clothing.Components
return false;
}
private bool TryEquip(InventoryComponent inv, Slots slot, IEntity user)
public bool TryEquip(InventoryComponent inv, Slots slot, IEntity user)
{
if (!inv.Equip(slot, this, true, out var reason))
{
@@ -101,6 +107,11 @@ namespace Content.Server.Clothing.Components
return false;
}
if (EquipSound != null)
{
SoundSystem.Play(Filter.Pvs(Owner), EquipSound.GetSound(), Owner, AudioParams.Default.WithVolume(-2f));
}
return true;
}
}