CatStation/Content.Shared/Actions/DangerousActionSystem.cs
Ewanderer d2f4a5ec5a
Prevent a Microbomb Implant Action while pacified. (#44198)
* adding a dangerous action system to allow pacified to interject with harmful action. making the microbomb explosion a dangerous action, to stop pacified syndicats from being able to blow up themselves.

* simplified code.

* cleaning  up comments, making some slight adjustments based on feedback to performance.
2026-07-11 21:54:48 +00:00

34 lines
1.1 KiB
C#

using Content.Shared.Actions.Components;
using Content.Shared.Actions.Events;
using Content.Shared.CombatMode.Pacification;
using Content.Shared.Popups;
namespace Content.Shared.Actions;
/// <summary>
/// Just the system to realize Dangerous Action Component.
/// <seealso cref="DangerousActionComponent"/>
/// </summary>
public sealed partial class DangerousActionSystem : EntitySystem
{
[Dependency] private SharedPopupSystem _popup = default!;
[Dependency] private EntityQuery<PacifiedComponent> _pacifiedQuery = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<DangerousActionComponent, ActionAttemptEvent>(OnAttempt);
}
private void OnAttempt(Entity<DangerousActionComponent> ent, ref ActionAttemptEvent args)
{
if (args.Cancelled)
return;
//query for pacification
if (!_pacifiedQuery.HasComp(args.User))
return;
//if found popup message and cancel
_popup.PopupClient(Loc.GetString(ent.Comp.PacificationMessage),args.User,args.User,PopupType.Small);
args.Cancelled = true;
}
}