Adds the ability to assign equip sounds in ClothingComponent (#4485)
* Initial * Works (Kinda) * Polish * Reviews
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -520,14 +520,10 @@ namespace Content.Server.Inventory.Components
|
||||
var hands = Owner.GetComponent<HandsComponent>();
|
||||
var activeHand = hands.ActiveHand;
|
||||
var activeItem = hands.GetActiveHand;
|
||||
if (activeHand != null && activeItem != null && activeItem.Owner.TryGetComponent(out ItemComponent? clothing))
|
||||
if (activeHand != null && activeItem != null && activeItem.Owner.TryGetComponent(out ClothingComponent? clothing))
|
||||
{
|
||||
hands.TryDropNoInteraction();
|
||||
if (!Equip(msg.Inventoryslot, clothing, true, out var reason))
|
||||
{
|
||||
hands.PutInHand(clothing);
|
||||
Owner.PopupMessageCursor(reason);
|
||||
}
|
||||
clothing.TryEquip(this, msg.Inventoryslot, Owner);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
BIN
Resources/Audio/Items/belt_equip.ogg
Normal file
BIN
Resources/Audio/Items/belt_equip.ogg
Normal file
Binary file not shown.
BIN
Resources/Audio/Items/jumpsuit_equip.ogg
Normal file
BIN
Resources/Audio/Items/jumpsuit_equip.ogg
Normal file
Binary file not shown.
@@ -9,3 +9,5 @@
|
||||
Slots: [belt]
|
||||
size: 50
|
||||
QuickEquip: false
|
||||
EquipSound:
|
||||
path: /Audio/Items/belt_equip.ogg
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
state: icon
|
||||
- type: Clothing
|
||||
Slots: [innerclothing]
|
||||
EquipSound:
|
||||
path: /Audio/Items/jumpsuit_equip.ogg
|
||||
|
||||
- type: entity
|
||||
abstract: true
|
||||
@@ -18,3 +20,5 @@
|
||||
- type: Clothing
|
||||
Slots: [innerclothing]
|
||||
femaleMask: UniformTop
|
||||
EquipSound:
|
||||
path: /Audio/Items/jumpsuit_equip.ogg
|
||||
|
||||
Reference in New Issue
Block a user