CatStation/Content.Shared/Actions/ActionRestrictionsSystem.cs
ScarKy0 091180655d
Changeling Chemicals (#45239)
* initially works i think

* yeah

* pulled these numbers outta my ass

* text

* silly

* fixy fix

* fix

* This sure is a videogame

* init test fuck everything

* sprites

* fix dirty

* query

* another query

* craftable changeling sting

* remove todo

* \n

* doc
2026-08-19 19:25:16 +00:00

44 lines
1.5 KiB
C#

using Content.Shared.Actions.Components;
using Content.Shared.Actions.Events;
using Content.Shared.Hands.EntitySystems;
using Content.Shared.Popups;
using Content.Shared.Whitelist;
namespace Content.Shared.Actions;
public sealed partial class ActionRestrictionsSystem : EntitySystem
{
[Dependency] private SharedHandsSystem _hands = default!;
[Dependency] private SharedPopupSystem _popup = default!;
[Dependency] private EntityWhitelistSystem _whitelist = default!;
[SubscribeLocalEvent]
private void OnWhitelistAttempt(Entity<ActionUserWhitelistComponent> ent, ref ActionAttemptEvent args)
{
if (args.Cancelled || _whitelist.IsWhitelistPass(ent.Comp.Whitelist, args.User))
return;
CancelAttempt(args.User, ent.Comp.OnFailPopup, ent.Comp.OnFailPopupType, ref args);
}
[SubscribeLocalEvent]
private void OnProviderHeldAttempt(Entity<ActionProviderHeldComponent> ent, ref ActionAttemptEvent args)
{
if (args.Cancelled)
return;
var provider = Comp<ActionComponent>(ent).Container;
if (_hands.IsHolding(args.User, provider))
return;
CancelAttempt(args.User, ent.Comp.OnFailPopup, ent.Comp.OnFailPopupType, ref args);
}
private void CancelAttempt(EntityUid user, LocId? popup, PopupType type, ref ActionAttemptEvent args)
{
if (popup != null)
_popup.PopupEntity(Loc.GetString(popup.Value), user, user, type);
args.Cancelled = true;
}
}