SuppressArtifactContainerSystem.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. using Content.Server.Xenoarchaeology.Equipment.Components;
  2. using Content.Server.Xenoarchaeology.XenoArtifacts;
  3. using Robust.Shared.Containers;
  4. namespace Content.Server.Xenoarchaeology.Equipment.Systems;
  5. public sealed class SuppressArtifactContainerSystem : EntitySystem
  6. {
  7. [Dependency] private readonly ArtifactSystem _artifact = default!;
  8. public override void Initialize()
  9. {
  10. base.Initialize();
  11. SubscribeLocalEvent<SuppressArtifactContainerComponent, EntInsertedIntoContainerMessage>(OnInserted);
  12. SubscribeLocalEvent<SuppressArtifactContainerComponent, EntRemovedFromContainerMessage>(OnRemoved);
  13. }
  14. private void OnInserted(EntityUid uid, SuppressArtifactContainerComponent component, EntInsertedIntoContainerMessage args)
  15. {
  16. if (!TryComp<ArtifactComponent>(args.Entity, out var artifact))
  17. return;
  18. _artifact.SetIsSuppressed(args.Entity, true, artifact);
  19. }
  20. private void OnRemoved(EntityUid uid, SuppressArtifactContainerComponent component, EntRemovedFromContainerMessage args)
  21. {
  22. if (!TryComp<ArtifactComponent>(args.Entity, out var artifact))
  23. return;
  24. _artifact.SetIsSuppressed(args.Entity, false, artifact);
  25. }
  26. }