mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-10 10:51:14 +03:00
# Conflicts: # .github/CODEOWNERS # Content.IntegrationTests/Tests/Preferences/ServerDbSqliteTests.cs # Content.Server/VoiceMask/VoiceMaskSystem.cs # Resources/Prototypes/Datasets/verbs.yml # Resources/Prototypes/Entities/Mobs/NPCs/silicon.yml # Resources/Prototypes/Entities/Mobs/Player/admin_ghost.yml # Resources/Prototypes/Maps/aspid.yml # Resources/Prototypes/Maps/barratry.yml # Resources/Prototypes/Maps/cluster.yml # Resources/Prototypes/Maps/kettle.yml # Resources/Prototypes/Maps/origin.yml # Resources/ServerInfo/Guidebook/Cargo/Salvage.xml # Resources/Textures/Structures/Furniture/chairs.rsi/meta.json
48 lines
1.6 KiB
C#
48 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;
|
|
// Corvax-TTS-Start
|
|
if (component.LastSetVoice != null)
|
|
comp.VoiceId = component.LastSetVoice;
|
|
// Corvax-TTS-End
|
|
|
|
_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;
|
|
}
|
|
}
|