CatStation/Content.Shared/Actions/ActionRestrictionsSystem.cs
AndrewFenriz dd46064672
Unify blink and katana dash teleportation (also removed EnergyKatana system/component) (#45041)
* ActionRestrictions

* katana use ActionGrant/ItemActionGrant

* TeleportAction

* no more DashAbility

* no more TeleportSpell

* no more EnergyKatana

* cleanup

* fix whitelist and popup

* docs

* display recharge cooldown

* refactor: whitespace consistency!111

* Revert "display recharge cooldown"

This reverts commit 3b93b179

* popup for limited charges

* maybe fix

* no more CanUseCharge

* upd

* better?

* refactor: using _SharedPhysicsSystem for TeleportActionSystem collision detection + small refactoring

* refactor: xml-doc

---------

Co-authored-by: Fildrance <fildrance@gmail.com>
2026-08-09 12:27:08 +00:00

44 lines
1.4 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, 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, ref args);
}
private void CancelAttempt(EntityUid user, LocId? popup, ref ActionAttemptEvent args)
{
if (popup != null)
_popup.PopupEntity(Loc.GetString(popup.Value), user, user);
args.Cancelled = true;
}
}