mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-17 05:27:38 +03:00
Removed all unused variables i could find, built and tested on a simple upstart and clicking trough most systems. Change Loc references to localization. <!-- This is default collapsed, readers click to expand it and see all your media The PR media section can get very large at times, so this is a good way to keep it clean The title is written using HTML tags The title must be within the <summary> tags or you won't see it --> <details><summary><h1>Media</h1></summary> <p> "using Robust.Shared.Prototypes;" to "" "[dependency] private readonly ISpriteComponent" to "" </p> </details> --- No CL this isn't player facing. --------- Co-authored-by: ilmenwe <no@mail.com>
64 lines
2.1 KiB
C#
64 lines
2.1 KiB
C#
using Content.Shared.Administration.Logs;
|
|
using Content.Shared.Database;
|
|
using Content.Shared.Emag.Systems;
|
|
using Content.Shared.Interaction;
|
|
using Content.Shared.Ninja.Components;
|
|
using Content.Shared.Tag;
|
|
using Content.Shared.Whitelist;
|
|
|
|
namespace Content.Shared.Ninja.Systems;
|
|
|
|
/// <summary>
|
|
/// Handles emagging whitelisted objects when clicked.
|
|
/// </summary>
|
|
public sealed class EmagProviderSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly EmagSystem _emag = default!;
|
|
[Dependency] private readonly EntityWhitelistSystem _whitelist = default!;
|
|
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
|
|
[Dependency] private readonly SharedNinjaGlovesSystem _gloves = default!;
|
|
[Dependency] private readonly TagSystem _tag = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<EmagProviderComponent, BeforeInteractHandEvent>(OnBeforeInteractHand);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Emag clicked entities that are on the whitelist.
|
|
/// </summary>
|
|
private void OnBeforeInteractHand(Entity<EmagProviderComponent> ent, ref BeforeInteractHandEvent args)
|
|
{
|
|
// TODO: change this into a generic check event thing
|
|
if (args.Handled || !_gloves.AbilityCheck(ent, args, out var target))
|
|
return;
|
|
|
|
var (uid, comp) = ent;
|
|
|
|
// only allowed to emag entities on the whitelist
|
|
if (_whitelist.IsWhitelistFail(comp.Whitelist, target))
|
|
return;
|
|
|
|
// only allowed to emag non-immune entities
|
|
if (_tag.HasTag(target, comp.EmagImmuneTag))
|
|
return;
|
|
|
|
var handled = _emag.DoEmagEffect(uid, target);
|
|
if (!handled)
|
|
return;
|
|
|
|
_adminLogger.Add(LogType.Emag, LogImpact.High, $"{ToPrettyString(uid):player} emagged {ToPrettyString(target):target}");
|
|
var ev = new EmaggedSomethingEvent(target);
|
|
RaiseLocalEvent(uid, ref ev);
|
|
args.Handled = true;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Raised on the player when emagging something.
|
|
/// </summary>
|
|
[ByRefEvent]
|
|
public record struct EmaggedSomethingEvent(EntityUid Target);
|