Files
tbd-station-14/Content.Shared/Trigger/Systems/PopupOnTriggerSystem.cs
Princess Cheeseballs c01ec294d0 Reduce Triggers Boilerplate. (#41086)
* Push 1

* cleanup + master merge

* launchontrigger

* A crumb of cleanup

---------

Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com>
2025-10-25 00:00:55 +00:00

55 lines
1.6 KiB
C#

using Content.Shared.Popups;
using Content.Shared.Trigger.Components.Effects;
namespace Content.Shared.Trigger.Systems;
/// <summary>
/// This handles <see cref="PopupOnTriggerComponent"/>
/// </summary>
public sealed class PopupOnTriggerSystem : XOnTriggerSystem<PopupOnTriggerComponent>
{
[Dependency] private readonly SharedPopupSystem _popup = default!;
protected override void OnTrigger(Entity<PopupOnTriggerComponent> ent, EntityUid target, ref TriggerEvent args)
{
// Popups only play for one entity
if (ent.Comp.Quiet)
{
if (ent.Comp.Predicted)
{
_popup.PopupClient(Loc.GetString(ent.Comp.Text),
target,
ent.Comp.UserIsRecipient ? args.User : ent.Owner,
ent.Comp.PopupType);
}
else if (args.User != null)
{
_popup.PopupEntity(Loc.GetString(ent.Comp.OtherText ?? ent.Comp.Text),
target,
args.User.Value,
ent.Comp.PopupType);
}
return;
}
// Popups play for all entities
if (ent.Comp.Predicted)
{
_popup.PopupPredicted(Loc.GetString(ent.Comp.Text),
Loc.GetString(ent.Comp.OtherText ?? ent.Comp.Text),
target,
ent.Comp.UserIsRecipient ? args.User : ent.Owner,
ent.Comp.PopupType);
}
else
{
_popup.PopupEntity(Loc.GetString(ent.Comp.OtherText ?? ent.Comp.Text),
target,
ent.Comp.PopupType);
}
}
}