ArtifactExamineTriggerSystem.cs 874 B

12345678910111213141516171819202122232425
  1. using Content.Server.Xenoarchaeology.XenoArtifacts.Triggers.Components;
  2. using Content.Shared.Examine;
  3. using Content.Shared.Ghost;
  4. namespace Content.Server.Xenoarchaeology.XenoArtifacts.Triggers.Systems;
  5. public sealed class ArtifactExamineTriggerSystem : EntitySystem
  6. {
  7. [Dependency] private readonly ArtifactSystem _artifact = default!;
  8. /// <inheritdoc/>
  9. public override void Initialize()
  10. {
  11. SubscribeLocalEvent<ArtifactExamineTriggerComponent, ExaminedEvent>(OnExamine);
  12. }
  13. private void OnExamine(EntityUid uid, ArtifactExamineTriggerComponent component, ExaminedEvent args)
  14. {
  15. // Prevent ghosts from activating this trigger unless they have CanGhostInteract
  16. if (TryComp<GhostComponent>(args.Examiner, out var ghost) && !ghost.CanGhostInteract)
  17. return;
  18. _artifact.TryActivateArtifact(uid);
  19. }
  20. }