SharedCriminalRecordsHackerSystem.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. using Content.Shared.CriminalRecords.Components;
  2. using Content.Shared.DoAfter;
  3. using Content.Shared.Interaction;
  4. using Content.Shared.Ninja.Systems;
  5. using Robust.Shared.Serialization;
  6. namespace Content.Shared.CriminalRecords.Systems;
  7. public abstract class SharedCriminalRecordsHackerSystem : EntitySystem
  8. {
  9. [Dependency] private readonly SharedDoAfterSystem _doAfter = default!;
  10. [Dependency] private readonly SharedNinjaGlovesSystem _gloves = default!;
  11. public override void Initialize()
  12. {
  13. base.Initialize();
  14. SubscribeLocalEvent<CriminalRecordsHackerComponent, BeforeInteractHandEvent>(OnBeforeInteractHand);
  15. }
  16. private void OnBeforeInteractHand(Entity<CriminalRecordsHackerComponent> ent, ref BeforeInteractHandEvent args)
  17. {
  18. // TODO: generic event
  19. if (args.Handled || !_gloves.AbilityCheck(ent, args, out var target))
  20. return;
  21. if (!HasComp<CriminalRecordsConsoleComponent>(target))
  22. return;
  23. var doAfterArgs = new DoAfterArgs(EntityManager, ent, ent.Comp.Delay, new CriminalRecordsHackDoAfterEvent(), target: target, used: ent, eventTarget: ent)
  24. {
  25. BreakOnDamage = true,
  26. BreakOnMove = true,
  27. MovementThreshold = 0.5f
  28. };
  29. _doAfter.TryStartDoAfter(doAfterArgs);
  30. args.Handled = true;
  31. }
  32. }
  33. /// <summary>
  34. /// Raised on the user when the doafter completes.
  35. /// </summary>
  36. [Serializable, NetSerializable]
  37. public sealed partial class CriminalRecordsHackDoAfterEvent : SimpleDoAfterEvent
  38. {
  39. }