Files
space-station-14/Content.Shared/Implants/SharedSubdermalImplantSystem.Relays.cs
alexalexmax 4ff7411fb7 Voice mask effects are toggleable and hide your accent (#41965)
* apply negate accents system

* add toggle to voice mask ui

* roll negateaccents into voice mask system, delete negate accents comp&system, update yml entries

* convert button to ToggleButton and some cleanup

* retry for heisenfail

* accent toggle

* update names and add mask active check for accent hiding
2025-12-26 02:47:05 +00:00

56 lines
1.9 KiB
C#

using Content.Shared.Chat;
using Content.Shared.IdentityManagement.Components;
using Content.Shared.Implants.Components;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Events;
using Content.Shared.Mobs;
namespace Content.Shared.Implants;
public abstract partial class SharedSubdermalImplantSystem
{
public void InitializeRelay()
{
SubscribeLocalEvent<ImplantedComponent, MobStateChangedEvent>(RelayToImplantEvent);
SubscribeLocalEvent<ImplantedComponent, AfterInteractUsingEvent>(RelayToImplantEvent);
SubscribeLocalEvent<ImplantedComponent, SuicideEvent>(RelayToImplantEvent);
SubscribeLocalEvent<ImplantedComponent, TransformSpeakerNameEvent>(RelayToImplantEvent);
SubscribeLocalEvent<ImplantedComponent, TransformSpeechEvent>(RelayToImplantEvent);
SubscribeLocalEvent<ImplantedComponent, SeeIdentityAttemptEvent>(RelayToImplantEvent);
}
/// <summary>
/// Relays events from the implanted to the implant.
/// </summary>
private void RelayToImplantEvent<T>(EntityUid uid, ImplantedComponent component, T args) where T : notnull
{
if (!_container.TryGetContainer(uid, ImplanterComponent.ImplantSlotId, out var implantContainer))
return;
var relayEv = new ImplantRelayEvent<T>(args, uid);
foreach (var implant in implantContainer.ContainedEntities)
{
if (args is HandledEntityEventArgs { Handled: true })
return;
RaiseLocalEvent(implant, relayEv);
}
}
}
/// <summary>
/// Wrapper for relaying events from an implanted entity to their implants.
/// </summary>
public sealed class ImplantRelayEvent<T> where T : notnull
{
public readonly T Event;
public readonly EntityUid ImplantedEntity;
public ImplantRelayEvent(T ev, EntityUid implantedEntity)
{
Event = ev;
ImplantedEntity = implantedEntity;
}
}