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.Interaction;
|
||||||
using Content.Shared.Item;
|
using Content.Shared.Item;
|
||||||
using Content.Shared.Notification.Managers;
|
using Content.Shared.Notification.Managers;
|
||||||
|
using Content.Shared.Sound;
|
||||||
|
using Robust.Shared.Audio;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.GameStates;
|
using Robust.Shared.GameStates;
|
||||||
|
using Robust.Shared.Player;
|
||||||
using Robust.Shared.Players;
|
using Robust.Shared.Players;
|
||||||
using Robust.Shared.Serialization.Manager.Attributes;
|
using Robust.Shared.Serialization.Manager.Attributes;
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
@@ -32,6 +35,9 @@ namespace Content.Server.Clothing.Components
|
|||||||
[DataField("HeatResistance")]
|
[DataField("HeatResistance")]
|
||||||
private int _heatResistance = 323;
|
private int _heatResistance = 323;
|
||||||
|
|
||||||
|
[DataField("EquipSound")]
|
||||||
|
public SoundSpecifier? EquipSound { get; set; } = default!;
|
||||||
|
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
public int HeatResistance => _heatResistance;
|
public int HeatResistance => _heatResistance;
|
||||||
|
|
||||||
@@ -91,7 +97,7 @@ namespace Content.Server.Clothing.Components
|
|||||||
return false;
|
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))
|
if (!inv.Equip(slot, this, true, out var reason))
|
||||||
{
|
{
|
||||||
@@ -101,6 +107,11 @@ namespace Content.Server.Clothing.Components
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (EquipSound != null)
|
||||||
|
{
|
||||||
|
SoundSystem.Play(Filter.Pvs(Owner), EquipSound.GetSound(), Owner, AudioParams.Default.WithVolume(-2f));
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -520,14 +520,10 @@ namespace Content.Server.Inventory.Components
|
|||||||
var hands = Owner.GetComponent<HandsComponent>();
|
var hands = Owner.GetComponent<HandsComponent>();
|
||||||
var activeHand = hands.ActiveHand;
|
var activeHand = hands.ActiveHand;
|
||||||
var activeItem = hands.GetActiveHand;
|
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();
|
hands.TryDropNoInteraction();
|
||||||
if (!Equip(msg.Inventoryslot, clothing, true, out var reason))
|
clothing.TryEquip(this, msg.Inventoryslot, Owner);
|
||||||
{
|
|
||||||
hands.PutInHand(clothing);
|
|
||||||
Owner.PopupMessageCursor(reason);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
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]
|
Slots: [belt]
|
||||||
size: 50
|
size: 50
|
||||||
QuickEquip: false
|
QuickEquip: false
|
||||||
|
EquipSound:
|
||||||
|
path: /Audio/Items/belt_equip.ogg
|
||||||
|
|||||||
@@ -7,6 +7,8 @@
|
|||||||
state: icon
|
state: icon
|
||||||
- type: Clothing
|
- type: Clothing
|
||||||
Slots: [innerclothing]
|
Slots: [innerclothing]
|
||||||
|
EquipSound:
|
||||||
|
path: /Audio/Items/jumpsuit_equip.ogg
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
abstract: true
|
abstract: true
|
||||||
@@ -18,3 +20,5 @@
|
|||||||
- type: Clothing
|
- type: Clothing
|
||||||
Slots: [innerclothing]
|
Slots: [innerclothing]
|
||||||
femaleMask: UniformTop
|
femaleMask: UniformTop
|
||||||
|
EquipSound:
|
||||||
|
path: /Audio/Items/jumpsuit_equip.ogg
|
||||||
|
|||||||
Reference in New Issue
Block a user