StationMapBoundUserInterface.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using Content.Shared.Pinpointer;
  2. using Robust.Client.UserInterface;
  3. namespace Content.Client.Pinpointer.UI;
  4. public sealed class StationMapBoundUserInterface : BoundUserInterface
  5. {
  6. [ViewVariables]
  7. private StationMapWindow? _window;
  8. public StationMapBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
  9. {
  10. }
  11. protected override void Open()
  12. {
  13. base.Open();
  14. EntityUid? gridUid = null;
  15. if (EntMan.TryGetComponent<TransformComponent>(Owner, out var xform))
  16. {
  17. gridUid = xform.GridUid;
  18. }
  19. _window = this.CreateWindow<StationMapWindow>();
  20. _window.Title = EntMan.GetComponent<MetaDataComponent>(Owner).EntityName;
  21. string stationName = string.Empty;
  22. if(EntMan.TryGetComponent<MetaDataComponent>(gridUid, out var gridMetaData))
  23. {
  24. stationName = gridMetaData.EntityName;
  25. }
  26. if (EntMan.TryGetComponent<StationMapComponent>(Owner, out var comp) && comp.ShowLocation)
  27. _window.Set(stationName, gridUid, Owner);
  28. else
  29. _window.Set(stationName, gridUid, null);
  30. }
  31. }