StationSystem.cs 1015 B

1234567891011121314151617181920212223242526272829303132
  1. using Content.Shared.Station;
  2. namespace Content.Client.Station;
  3. /// <summary>
  4. /// This handles letting the client know stations are a thing. Only really used by an admin menu.
  5. /// </summary>
  6. public sealed class StationSystem : EntitySystem
  7. {
  8. private readonly List<(string Name, NetEntity Entity)> _stations = new();
  9. /// <summary>
  10. /// All stations that currently exist.
  11. /// </summary>
  12. /// <remarks>
  13. /// I'd have this just invoke an entity query, but we're on the client and the client barely knows about stations.
  14. /// </remarks>
  15. public IReadOnlyList<(string Name, NetEntity Entity)> Stations => _stations;
  16. /// <inheritdoc/>
  17. public override void Initialize()
  18. {
  19. SubscribeNetworkEvent<StationsUpdatedEvent>(StationsUpdated);
  20. }
  21. private void StationsUpdated(StationsUpdatedEvent ev)
  22. {
  23. _stations.Clear();
  24. // TODO this needs to be done in component states and with the Ensure() methods
  25. _stations.AddRange(ev.Stations);
  26. }
  27. }