mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-11-06 02:48: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>
57 lines
1.7 KiB
C#
57 lines
1.7 KiB
C#
using Content.Shared.Actions.Components;
|
|
using Content.Shared.Inventory;
|
|
using Content.Shared.Whitelist;
|
|
|
|
namespace Content.Shared.Actions;
|
|
|
|
/// <summary>
|
|
/// <see cref="ActionGrantComponent"/>
|
|
/// </summary>
|
|
public sealed partial class ActionGrantSystem : EntitySystem
|
|
{
|
|
[Dependency] private SharedActionsSystem _actions = default!;
|
|
[Dependency] private EntityWhitelistSystem _whitelist = default!;
|
|
|
|
[SubscribeLocalEvent]
|
|
private void OnItemGet(Entity<ItemActionGrantComponent> ent, ref GetItemActionsEvent args)
|
|
{
|
|
if (!TryComp(ent.Owner, out ActionGrantComponent? grant))
|
|
return;
|
|
|
|
if (ent.Comp.ActiveIfWorn && (args.SlotFlags == null || args.SlotFlags == SlotFlags.POCKET))
|
|
return;
|
|
|
|
foreach (var action in grant.ActionEntities)
|
|
{
|
|
if (TryComp<ActionUserWhitelistComponent>(action, out var whitelist) &&
|
|
!_whitelist.IsWhitelistPass(whitelist.Whitelist, args.User))
|
|
{
|
|
continue;
|
|
}
|
|
|
|
args.AddAction(action);
|
|
}
|
|
}
|
|
|
|
[SubscribeLocalEvent]
|
|
private void OnMapInit(Entity<ActionGrantComponent> ent, ref MapInitEvent args)
|
|
{
|
|
foreach (var action in ent.Comp.Actions)
|
|
{
|
|
EntityUid? actionEnt = null;
|
|
_actions.AddAction(ent.Owner, ref actionEnt, action);
|
|
|
|
if (actionEnt != null)
|
|
ent.Comp.ActionEntities.Add(actionEnt.Value);
|
|
}
|
|
}
|
|
|
|
[SubscribeLocalEvent]
|
|
private void OnShutdown(Entity<ActionGrantComponent> ent, ref ComponentShutdown args)
|
|
{
|
|
foreach (var actionEnt in ent.Comp.ActionEntities)
|
|
{
|
|
_actions.RemoveAction(ent.Owner, actionEnt);
|
|
}
|
|
}
|
|
}
|