DoorWelded.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using Content.Shared.Construction;
  2. using Content.Shared.Doors.Components;
  3. using Content.Shared.Examine;
  4. using JetBrains.Annotations;
  5. namespace Content.Server.Construction.Conditions
  6. {
  7. [UsedImplicitly]
  8. [DataDefinition]
  9. public sealed partial class DoorWelded : IGraphCondition
  10. {
  11. [DataField("welded")]
  12. public bool Welded { get; private set; } = true;
  13. public bool Condition(EntityUid uid, IEntityManager entityManager)
  14. {
  15. if (!entityManager.TryGetComponent(uid, out DoorComponent? doorComponent))
  16. return false;
  17. return doorComponent.State == DoorState.Welded;
  18. }
  19. public bool DoExamine(ExaminedEvent args)
  20. {
  21. var entity = args.Examined;
  22. var entMan = IoCManager.Resolve<IEntityManager>();
  23. if (!entMan.TryGetComponent(entity, out DoorComponent? door)) return false;
  24. var isWelded = door.State == DoorState.Welded;
  25. if (isWelded != Welded)
  26. {
  27. if (Welded)
  28. args.PushMarkup(Loc.GetString("construction-examine-condition-door-weld", ("entityName", entMan.GetComponent<MetaDataComponent>(entity).EntityName)) + "\n");
  29. else
  30. args.PushMarkup(Loc.GetString("construction-examine-condition-door-unweld", ("entityName", entMan.GetComponent<MetaDataComponent>(entity).EntityName)) + "\n");
  31. return true;
  32. }
  33. return false;
  34. }
  35. public IEnumerable<ConstructionGuideEntry> GenerateGuideEntry()
  36. {
  37. yield return new ConstructionGuideEntry()
  38. {
  39. Localization = Welded
  40. ? "construction-guide-condition-door-weld"
  41. : "construction-guide-condition-door-unweld",
  42. };
  43. }
  44. }
  45. }