mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-11-06 10:58:36 +03:00
* 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>
44 lines
1.4 KiB
C#
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;
|
|
}
|
|
}
|