ArtifactInteractionTriggerSystem.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using Content.Server.Xenoarchaeology.XenoArtifacts.Triggers.Components;
  2. using Content.Shared.Interaction;
  3. using Content.Shared.Movement.Pulling.Events;
  4. using Content.Shared.Weapons.Melee.Events;
  5. namespace Content.Server.Xenoarchaeology.XenoArtifacts.Triggers.Systems;
  6. public sealed class ArtifactInteractionTriggerSystem : EntitySystem
  7. {
  8. [Dependency] private readonly ArtifactSystem _artifactSystem = default!;
  9. public override void Initialize()
  10. {
  11. base.Initialize();
  12. SubscribeLocalEvent<ArtifactInteractionTriggerComponent, PullStartedMessage>(OnPull);
  13. SubscribeLocalEvent<ArtifactInteractionTriggerComponent, AttackedEvent>(OnAttack);
  14. SubscribeLocalEvent<ArtifactInteractionTriggerComponent, InteractHandEvent>(OnInteract);
  15. }
  16. private void OnPull(EntityUid uid, ArtifactInteractionTriggerComponent component, PullStartedMessage args)
  17. {
  18. if (!component.PullActivation)
  19. return;
  20. _artifactSystem.TryActivateArtifact(uid, args.PullerUid);
  21. }
  22. private void OnAttack(EntityUid uid, ArtifactInteractionTriggerComponent component, AttackedEvent args)
  23. {
  24. if (!component.AttackActivation)
  25. return;
  26. _artifactSystem.TryActivateArtifact(uid, args.User);
  27. }
  28. private void OnInteract(EntityUid uid, ArtifactInteractionTriggerComponent component, InteractHandEvent args)
  29. {
  30. if (args.Handled)
  31. return;
  32. if (!component.EmptyHandActivation)
  33. return;
  34. args.Handled = _artifactSystem.TryActivateArtifact(uid, args.User);
  35. }
  36. }