StorageWelded.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using Content.Server.Storage.Components;
  2. using Content.Shared.Construction;
  3. using Content.Shared.Examine;
  4. using Content.Shared.Tools.Systems;
  5. using JetBrains.Annotations;
  6. namespace Content.Server.Construction.Conditions
  7. {
  8. [UsedImplicitly]
  9. [DataDefinition]
  10. public sealed partial class StorageWelded : IGraphCondition
  11. {
  12. [DataField("welded")]
  13. public bool Welded { get; private set; } = true;
  14. public bool Condition(EntityUid uid, IEntityManager entityManager)
  15. {
  16. return entityManager.System<WeldableSystem>().IsWelded(uid) == Welded;
  17. }
  18. public bool DoExamine(ExaminedEvent args)
  19. {
  20. var entMan = IoCManager.Resolve<IEntityManager>();
  21. var entity = args.Examined;
  22. if (!entMan.HasComponent<EntityStorageComponent>(entity))
  23. return false;
  24. var metaData = entMan.GetComponent<MetaDataComponent>(entity);
  25. if (entMan.System<WeldableSystem>().IsWelded(entity) != Welded)
  26. {
  27. if (Welded)
  28. args.PushMarkup(Loc.GetString("construction-examine-condition-door-weld", ("entityName", metaData.EntityName)) + "\n");
  29. else
  30. args.PushMarkup(Loc.GetString("construction-examine-condition-door-unweld", ("entityName", metaData.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. }