WirePanel.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using Content.Shared.Construction;
  2. using Content.Shared.Examine;
  3. using Content.Shared.Wires;
  4. using JetBrains.Annotations;
  5. namespace Content.Server.Construction.Conditions
  6. {
  7. [UsedImplicitly]
  8. [DataDefinition]
  9. public sealed partial class WirePanel : IGraphCondition
  10. {
  11. [DataField("open")] public bool Open { get; private set; } = true;
  12. public bool Condition(EntityUid uid, IEntityManager entityManager)
  13. {
  14. //if it doesn't have a wire panel, then just let it work.
  15. if (!entityManager.TryGetComponent<WiresPanelComponent>(uid, out var wires))
  16. return true;
  17. return wires.Open == Open;
  18. }
  19. public bool DoExamine(ExaminedEvent args)
  20. {
  21. var entity = args.Examined;
  22. if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<WiresPanelComponent>(entity, out var panel)) return false;
  23. switch (Open)
  24. {
  25. case true when !panel.Open:
  26. args.PushMarkup(Loc.GetString("construction-examine-condition-wire-panel-open"));
  27. return true;
  28. case false when panel.Open:
  29. args.PushMarkup(Loc.GetString("construction-examine-condition-wire-panel-close"));
  30. return true;
  31. }
  32. return false;
  33. }
  34. public IEnumerable<ConstructionGuideEntry> GenerateGuideEntry()
  35. {
  36. yield return new ConstructionGuideEntry()
  37. {
  38. Localization = Open
  39. ? "construction-step-condition-wire-panel-open"
  40. : "construction-step-condition-wire-panel-close"
  41. };
  42. }
  43. }
  44. }