mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 18:31:17 +03:00
* 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.
34 lines
1.1 KiB
C#
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;
|
|
}
|
|
|
|
}
|