Files
tbd-station-14/Content.Shared/ChangeNameInContainer/ChangeNameInContainerSystem.cs
beck-thompson 327466a6e2 Plushies can now have pAIs stuffed into them (v2)! (#30805)
* First commit

* I forgot silly me

* Actually added comments

* spellin

* fixes

* more blacklists

* Minor fixes

* Speech Verb also changes now

* Simple name stuff

* Other fixes

* remove one line of whitespace

---------

Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
2024-10-09 20:01:32 +02:00

31 lines
1.1 KiB
C#

using Content.Shared.Chat;
using Robust.Shared.Containers;
using Content.Shared.Whitelist;
using Content.Shared.Speech;
namespace Content.Shared.ChangeNameInContainer;
public sealed partial class ChangeNameInContainerSystem : EntitySystem
{
[Dependency] private readonly SharedContainerSystem _container = default!;
[Dependency] private readonly EntityWhitelistSystem _whitelist = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<ChangeVoiceInContainerComponent, TransformSpeakerNameEvent>(OnTransformSpeakerName);
}
private void OnTransformSpeakerName(Entity<ChangeVoiceInContainerComponent> ent, ref TransformSpeakerNameEvent args)
{
if (!_container.TryGetContainingContainer((ent, null, null), out var container)
|| _whitelist.IsWhitelistFail(ent.Comp.Whitelist, container.Owner))
return;
args.VoiceName = Name(container.Owner);
if (TryComp<SpeechComponent>(container.Owner, out var speechComp))
args.SpeechVerb = speechComp.SpeechVerb;
}
}