Files
OldThink/Content.Server/VoiceMask/VoiceMaskSystem.Equip.cs
rhailrake ea4f7595a2 [feat] TTS
# Conflicts:
#	Content.Client/Options/UI/Tabs/AudioTab.xaml.cs
#	Content.Client/Preferences/UI/HumanoidProfileEditor.xaml
#	Content.Client/Preferences/UI/HumanoidProfileEditor.xaml.cs
#	Content.Server/Database/ServerDbBase.cs
#	Content.Server/Entry/EntryPoint.cs
#	Content.Server/Humanoid/Systems/HumanoidAppearanceSystem.cs
#	Content.Server/IoC/ServerContentIoC.cs
#	Content.Server/VoiceMask/VoiceMaskSystem.cs
#	Resources/Prototypes/Entities/Mobs/Species/base.yml
2024-01-10 23:56:07 +07:00

47 lines
1.6 KiB
C#

using Content.Server.Actions;
using Content.Shared.Inventory;
using Content.Shared.Inventory.Events;
namespace Content.Server.VoiceMask;
// This partial deals with equipment, i.e., the syndicate voice mask.
public sealed partial class VoiceMaskSystem
{
[Dependency] private readonly InventorySystem _inventory = default!;
[Dependency] private readonly ActionsSystem _actions = default!;
private const string MaskSlot = "mask";
private void OnEquip(EntityUid uid, VoiceMaskerComponent component, GotEquippedEvent args)
{
var user = args.Equipee;
// have to be wearing the mask to use it, duh.
if (!_inventory.TryGetSlotEntity(user, MaskSlot, out var maskEntity) || maskEntity != uid)
return;
var comp = EnsureComp<VoiceMaskComponent>(user);
comp.VoiceName = component.LastSetName;
if (component.LastSetVoice != null)
comp.VoiceId = component.LastSetVoice;
_actions.AddAction(user, ref component.ActionEntity, component.Action, uid);
}
private void OnUnequip(EntityUid uid, VoiceMaskerComponent compnent, GotUnequippedEvent args)
{
RemComp<VoiceMaskComponent>(args.Equipee);
}
private void TrySetLastKnownName(EntityUid maskWearer, string lastName)
{
if (!HasComp<VoiceMaskComponent>(maskWearer)
|| !_inventory.TryGetSlotEntity(maskWearer, MaskSlot, out var maskEntity)
|| !TryComp<VoiceMaskerComponent>(maskEntity, out var maskComp))
{
return;
}
maskComp.LastSetName = lastName;
}
}