HasTag.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using Content.Shared.Construction;
  2. using JetBrains.Annotations;
  3. using Content.Shared.Doors.Components;
  4. using Content.Shared.Examine;
  5. using YamlDotNet.Core.Tokens;
  6. using Content.Shared.Tag;
  7. namespace Content.Server.Construction.Conditions
  8. {
  9. /// <summary>
  10. /// This condition checks whether if an entity with the <see cref="TagComponent"/> possesses a specific tag
  11. /// </summary>
  12. [UsedImplicitly]
  13. [DataDefinition]
  14. public sealed partial class HasTag : IGraphCondition
  15. {
  16. /// <summary>
  17. /// The tag the entity is being checked for
  18. /// </summary>
  19. [DataField("tag")]
  20. public string Tag { get; private set; }
  21. public bool Condition(EntityUid uid, IEntityManager entityManager)
  22. {
  23. if (!entityManager.TrySystem<TagSystem>(out var tagSystem))
  24. return false;
  25. return tagSystem.HasTag(uid, Tag);
  26. }
  27. public bool DoExamine(ExaminedEvent args)
  28. {
  29. return false;
  30. }
  31. public IEnumerable<ConstructionGuideEntry> GenerateGuideEntry()
  32. {
  33. yield return new ConstructionGuideEntry()
  34. {
  35. };
  36. }
  37. }
  38. }