diff --git a/Content.Client/Administration/UI/Tabs/ObjectsTab/ObjectsTab.xaml.cs b/Content.Client/Administration/UI/Tabs/ObjectsTab/ObjectsTab.xaml.cs index 59e0e6040b..de9ccbbf50 100644 --- a/Content.Client/Administration/UI/Tabs/ObjectsTab/ObjectsTab.xaml.cs +++ b/Content.Client/Administration/UI/Tabs/ObjectsTab/ObjectsTab.xaml.cs @@ -76,7 +76,7 @@ public sealed partial class ObjectsTab : Control switch (selection) { case ObjectsTabSelection.Stations: - entities.AddRange(_entityManager.EntitySysManager.GetEntitySystem().Stations); + entities.AddRange(_entityManager.EntitySysManager.GetEntitySystem().GetStationNames()); break; case ObjectsTabSelection.Grids: { diff --git a/Content.Client/Station/StationSystem.cs b/Content.Client/Station/StationSystem.cs index 5a4a1853d2..e1ccd14d7b 100644 --- a/Content.Client/Station/StationSystem.cs +++ b/Content.Client/Station/StationSystem.cs @@ -2,34 +2,5 @@ namespace Content.Client.Station; -/// -/// This handles letting the client know stations are a thing. Only really used by an admin menu. -/// -public sealed partial class StationSystem : SharedStationSystem -{ - private readonly List<(string Name, NetEntity Entity)> _stations = new(); - - /// - /// All stations that currently exist. - /// - /// - /// I'd have this just invoke an entity query, but we're on the client and the client barely knows about stations. - /// - // TODO: Stations have a global PVS override now, this can probably be changed into a query. - public IReadOnlyList<(string Name, NetEntity Entity)> Stations => _stations; - - /// - public override void Initialize() - { - base.Initialize(); - - SubscribeNetworkEvent(StationsUpdated); - } - - private void StationsUpdated(StationsUpdatedEvent ev) - { - _stations.Clear(); - // TODO this needs to be done in component states and with the Ensure() methods - _stations.AddRange(ev.Stations); - } -} +/// +public sealed partial class StationSystem : SharedStationSystem; diff --git a/Content.IntegrationTests/Tests/Station/EvacShuttleTest.cs b/Content.IntegrationTests/Tests/Station/EvacShuttleTest.cs index 9e925a451a..02552669f7 100644 --- a/Content.IntegrationTests/Tests/Station/EvacShuttleTest.cs +++ b/Content.IntegrationTests/Tests/Station/EvacShuttleTest.cs @@ -2,9 +2,9 @@ using System.Linq; using Content.Server.GameTicking; using Content.Server.Shuttles.Components; using Content.Server.Shuttles.Systems; -using Content.Server.Station.Components; using Content.Shared.CCVar; using Content.Shared.Shuttles.Components; +using Content.Shared.Station.Components; using Robust.Shared.GameObjects; using Robust.Shared.Map.Components; diff --git a/Content.Server/Administration/Systems/AdminVerbSystem.Tools.cs b/Content.Server/Administration/Systems/AdminVerbSystem.Tools.cs index 6e88d59be6..44795d1fb2 100644 --- a/Content.Server/Administration/Systems/AdminVerbSystem.Tools.cs +++ b/Content.Server/Administration/Systems/AdminVerbSystem.Tools.cs @@ -2,15 +2,12 @@ using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Numerics; using Content.Server.Administration.Components; -using Content.Server.Atmos; -using Content.Server.Atmos.Components; using Content.Server.Cargo.Components; using Content.Server.Doors.Systems; using Content.Server.Hands.Systems; using Content.Server.Power.Components; using Content.Server.Power.EntitySystems; using Content.Server.Stack; -using Content.Server.Station.Components; using Content.Server.Station.Systems; using Content.Server.Weapons.Ranged.Systems; using Content.Shared.Access; @@ -28,6 +25,7 @@ using Content.Shared.Hands.Components; using Content.Shared.Inventory; using Content.Shared.PDA; using Content.Shared.Stacks; +using Content.Shared.Station.Components; using Content.Shared.Verbs; using Content.Shared.Weapons.Ranged.Components; using Robust.Server.Physics; diff --git a/Content.Server/Anomaly/AnomalySystem.Generator.cs b/Content.Server/Anomaly/AnomalySystem.Generator.cs index 1b88429204..46ad9278f8 100644 --- a/Content.Server/Anomaly/AnomalySystem.Generator.cs +++ b/Content.Server/Anomaly/AnomalySystem.Generator.cs @@ -1,6 +1,5 @@ using Content.Server.Anomaly.Components; using Content.Server.Power.EntitySystems; -using Content.Server.Station.Components; using Content.Shared.Anomaly; using Content.Shared.CCVar; using Content.Shared.Materials; @@ -164,8 +163,7 @@ public sealed partial class AnomalySystem var xform = Transform(uid); if (_station.GetStationInMap(xform.MapID) is not { } station || - !TryComp(station, out var data) || - _station.GetLargestGrid(data) is not { } grid) + _station.GetLargestGrid(station) is not { } grid) { if (xform.GridUid == null) return; diff --git a/Content.Server/Cargo/Components/StationCargoOrderDatabaseComponent.cs b/Content.Server/Cargo/Components/StationCargoOrderDatabaseComponent.cs index 37d0f5b7d1..56401602b3 100644 --- a/Content.Server/Cargo/Components/StationCargoOrderDatabaseComponent.cs +++ b/Content.Server/Cargo/Components/StationCargoOrderDatabaseComponent.cs @@ -1,8 +1,8 @@ using System.Linq; -using Content.Server.Station.Components; using Content.Shared.Cargo; using Content.Shared.Cargo.Components; using Content.Shared.Cargo.Prototypes; +using Content.Shared.Station.Components; using Robust.Shared.Prototypes; namespace Content.Server.Cargo.Components; diff --git a/Content.Server/Cargo/Systems/CargoSystem.Orders.cs b/Content.Server/Cargo/Systems/CargoSystem.Orders.cs index 862bf1f096..febe093d98 100644 --- a/Content.Server/Cargo/Systems/CargoSystem.Orders.cs +++ b/Content.Server/Cargo/Systems/CargoSystem.Orders.cs @@ -1,7 +1,6 @@ using System.Diagnostics.CodeAnalysis; using System.Linq; using Content.Server.Cargo.Components; -using Content.Server.Station.Components; using Content.Shared.Cargo; using Content.Shared.Cargo.BUI; using Content.Shared.Cargo.Components; @@ -13,8 +12,8 @@ using Content.Shared.IdentityManagement; using Content.Shared.Interaction; using Content.Shared.Labels.Components; using Content.Shared.Paper; +using Content.Shared.Station.Components; using JetBrains.Annotations; -using Robust.Shared.Audio; using Robust.Shared.Map; using Robust.Shared.Prototypes; using Robust.Shared.Timing; diff --git a/Content.Server/Cargo/Systems/CargoSystem.Telepad.cs b/Content.Server/Cargo/Systems/CargoSystem.Telepad.cs index 25fb514db6..9e5c20e8c9 100644 --- a/Content.Server/Cargo/Systems/CargoSystem.Telepad.cs +++ b/Content.Server/Cargo/Systems/CargoSystem.Telepad.cs @@ -3,11 +3,11 @@ using System.Linq; using Content.Server.Cargo.Components; using Content.Server.Power.Components; using Content.Server.Power.EntitySystems; -using Content.Server.Station.Components; using Content.Shared.Cargo; using Content.Shared.Cargo.Components; using Content.Shared.DeviceLinking; using Content.Shared.Power; +using Content.Shared.Station.Components; using Robust.Shared.Audio; using Robust.Shared.Random; using Robust.Shared.Utility; diff --git a/Content.Server/Chat/Systems/ChatSystem.cs b/Content.Server/Chat/Systems/ChatSystem.cs index d49da57801..7ff12595d1 100644 --- a/Content.Server/Chat/Systems/ChatSystem.cs +++ b/Content.Server/Chat/Systems/ChatSystem.cs @@ -7,7 +7,6 @@ using Content.Server.Chat.Managers; using Content.Server.GameTicking; using Content.Server.Speech.EntitySystems; using Content.Server.Speech.Prototypes; -using Content.Server.Station.Components; using Content.Server.Station.Systems; using Content.Shared.ActionBlocker; using Content.Shared.Administration; @@ -21,6 +20,7 @@ using Content.Shared.Mobs.Systems; using Content.Shared.Players; using Content.Shared.Players.RateLimiting; using Content.Shared.Radio; +using Content.Shared.Station.Components; using Content.Shared.Whitelist; using Robust.Server.Player; using Robust.Shared.Audio; diff --git a/Content.Server/Commands/ContentCompletionHelper.cs b/Content.Server/Commands/ContentCompletionHelper.cs index f843d84a62..bc80b28762 100644 --- a/Content.Server/Commands/ContentCompletionHelper.cs +++ b/Content.Server/Commands/ContentCompletionHelper.cs @@ -1,4 +1,4 @@ -using Content.Server.Station.Components; +using Content.Shared.Station.Components; using Robust.Shared.Console; namespace Content.Server.Commands; diff --git a/Content.Server/CrewManifest/CrewManifestSystem.cs b/Content.Server/CrewManifest/CrewManifestSystem.cs index d8e0858ce0..448e2fff20 100644 --- a/Content.Server/CrewManifest/CrewManifestSystem.cs +++ b/Content.Server/CrewManifest/CrewManifestSystem.cs @@ -1,7 +1,6 @@ using System.Linq; using Content.Server.Administration; using Content.Server.EUI; -using Content.Server.Station.Components; using Content.Server.Station.Systems; using Content.Server.StationRecords; using Content.Server.StationRecords.Systems; @@ -10,12 +9,12 @@ using Content.Shared.CCVar; using Content.Shared.CrewManifest; using Content.Shared.GameTicking; using Content.Shared.Roles; +using Content.Shared.Station.Components; using Content.Shared.StationRecords; using Robust.Shared.Configuration; using Robust.Shared.Console; using Robust.Shared.Player; using Robust.Shared.Prototypes; -using Robust.Shared.Utility; namespace Content.Server.CrewManifest; diff --git a/Content.Server/GameTicking/Rules/DragonRuleSystem.cs b/Content.Server/GameTicking/Rules/DragonRuleSystem.cs index de13218568..964b248beb 100644 --- a/Content.Server/GameTicking/Rules/DragonRuleSystem.cs +++ b/Content.Server/GameTicking/Rules/DragonRuleSystem.cs @@ -1,11 +1,8 @@ using Content.Server.Antag; -using Content.Server.Dragon; using Content.Server.GameTicking.Rules.Components; using Content.Server.Mind; using Content.Server.Roles; -using Content.Server.Station.Components; using Content.Server.Station.Systems; -using Content.Shared.CharacterInfo; using Content.Shared.Localizations; using Robust.Server.GameObjects; @@ -56,10 +53,9 @@ public sealed class DragonRuleSystem : GameRuleSystem var dragonXform = Transform(dragon); - var station = _station.GetStationInMap(dragonXform.MapID); EntityUid? stationGrid = null; - if (TryComp(station, out var stationData)) - stationGrid = _station.GetLargestGrid(stationData); + if (_station.GetStationInMap(dragonXform.MapID) is { } station) + stationGrid = _station.GetLargestGrid(station); if (stationGrid is not null) { diff --git a/Content.Server/GameTicking/Rules/GameRuleSystem.Utility.cs b/Content.Server/GameTicking/Rules/GameRuleSystem.Utility.cs index 33ee91f8a5..cd93eae502 100644 --- a/Content.Server/GameTicking/Rules/GameRuleSystem.Utility.cs +++ b/Content.Server/GameTicking/Rules/GameRuleSystem.Utility.cs @@ -1,14 +1,12 @@ using System.Diagnostics.CodeAnalysis; using System.Linq; -using Content.Server.GameTicking.Rules.Components; using Content.Server.Station.Components; using Content.Shared.GameTicking.Components; using Content.Shared.Random.Helpers; -using Robust.Server.GameObjects; +using Content.Shared.Station.Components; using Robust.Shared.Collections; using Robust.Shared.Map; using Robust.Shared.Map.Components; -using Robust.Shared.Random; namespace Content.Server.GameTicking.Rules; diff --git a/Content.Server/GameTicking/Rules/NukeopsRuleSystem.cs b/Content.Server/GameTicking/Rules/NukeopsRuleSystem.cs index f687c9dcc7..17d9e4c847 100644 --- a/Content.Server/GameTicking/Rules/NukeopsRuleSystem.cs +++ b/Content.Server/GameTicking/Rules/NukeopsRuleSystem.cs @@ -24,6 +24,7 @@ using Robust.Shared.Map; using Robust.Shared.Random; using Robust.Shared.Utility; using System.Linq; +using Content.Shared.Station.Components; using Content.Shared.Store.Components; using Robust.Shared.Prototypes; diff --git a/Content.Server/GameTicking/Rules/RoundstartStationVariationRuleSystem.cs b/Content.Server/GameTicking/Rules/RoundstartStationVariationRuleSystem.cs index 570889155b..66f0d1f22c 100644 --- a/Content.Server/GameTicking/Rules/RoundstartStationVariationRuleSystem.cs +++ b/Content.Server/GameTicking/Rules/RoundstartStationVariationRuleSystem.cs @@ -1,11 +1,10 @@ -using System.Linq; -using Content.Server.GameTicking.Rules.Components; +using Content.Server.GameTicking.Rules.Components; using Content.Server.Shuttles.Systems; using Content.Server.Station.Components; using Content.Server.Station.Events; using Content.Shared.GameTicking.Components; +using Content.Shared.Station.Components; using Content.Shared.Storage; -using Robust.Shared.Prototypes; using Robust.Shared.Random; namespace Content.Server.GameTicking.Rules; diff --git a/Content.Server/GameTicking/Rules/VariationPass/BaseEntityReplaceVariationPassSystem.cs b/Content.Server/GameTicking/Rules/VariationPass/BaseEntityReplaceVariationPassSystem.cs index 00b2546e78..1a5b97c327 100644 --- a/Content.Server/GameTicking/Rules/VariationPass/BaseEntityReplaceVariationPassSystem.cs +++ b/Content.Server/GameTicking/Rules/VariationPass/BaseEntityReplaceVariationPassSystem.cs @@ -58,7 +58,7 @@ public abstract class BaseEntityReplaceVariationPassSystem ent, List replacements) diff --git a/Content.Server/GameTicking/Rules/VariationPass/EntitySpawnVariationPassSystem.cs b/Content.Server/GameTicking/Rules/VariationPass/EntitySpawnVariationPassSystem.cs index 7247bd98aa..462c89e016 100644 --- a/Content.Server/GameTicking/Rules/VariationPass/EntitySpawnVariationPassSystem.cs +++ b/Content.Server/GameTicking/Rules/VariationPass/EntitySpawnVariationPassSystem.cs @@ -9,7 +9,7 @@ public sealed class EntitySpawnVariationPassSystem : VariationPassSystem ent, ref StationVariationPassEvent args) { - var totalTiles = Stations.GetTileCount(args.Station); + var totalTiles = Stations.GetTileCount(args.Station.AsNullable()); var dirtyMod = Random.NextGaussian(ent.Comp.TilesPerEntityAverage, ent.Comp.TilesPerEntityStdDev); var trashTiles = Math.Max((int) (totalTiles * (1 / dirtyMod)), 0); diff --git a/Content.Server/GameTicking/Rules/VariationPass/PuddleMessVariationPassSystem.cs b/Content.Server/GameTicking/Rules/VariationPass/PuddleMessVariationPassSystem.cs index 41cdbd87f8..2895416a7f 100644 --- a/Content.Server/GameTicking/Rules/VariationPass/PuddleMessVariationPassSystem.cs +++ b/Content.Server/GameTicking/Rules/VariationPass/PuddleMessVariationPassSystem.cs @@ -15,7 +15,7 @@ public sealed class PuddleMessVariationPassSystem : VariationPassSystem ent, ref StationVariationPassEvent args) { - var totalTiles = Stations.GetTileCount(args.Station); + var totalTiles = Stations.GetTileCount(args.Station.AsNullable()); if (!_proto.TryIndex(ent.Comp.RandomPuddleSolutionFill, out var proto)) return; diff --git a/Content.Server/GameTicking/Rules/ZombieRuleSystem.cs b/Content.Server/GameTicking/Rules/ZombieRuleSystem.cs index a38940c667..9fab98446a 100644 --- a/Content.Server/GameTicking/Rules/ZombieRuleSystem.cs +++ b/Content.Server/GameTicking/Rules/ZombieRuleSystem.cs @@ -4,7 +4,6 @@ using Content.Server.GameTicking.Rules.Components; using Content.Server.Popups; using Content.Server.Roles; using Content.Server.RoundEnd; -using Content.Server.Station.Components; using Content.Server.Station.Systems; using Content.Server.Zombies; using Content.Shared.GameTicking.Components; @@ -190,7 +189,7 @@ public sealed class ZombieRuleSystem : GameRuleSystem { foreach (var station in _station.GetStationsSet()) { - if (TryComp(station, out var data) && _station.GetLargestGrid(data) is { } grid) + if (_station.GetLargestGrid(station) is { } grid) stationGrids.Add(grid); } } diff --git a/Content.Server/Maps/GameMapPrototype.cs b/Content.Server/Maps/GameMapPrototype.cs index f0f40fe06d..df9046652b 100644 --- a/Content.Server/Maps/GameMapPrototype.cs +++ b/Content.Server/Maps/GameMapPrototype.cs @@ -1,9 +1,8 @@ -using Content.Server.Station; using JetBrains.Annotations; using Robust.Shared.Prototypes; using Robust.Shared.Utility; using System.Diagnostics; -using System.Numerics; +using Content.Shared.Station; namespace Content.Server.Maps; diff --git a/Content.Server/Nuke/Commands/SendNukeCodesCommand.cs b/Content.Server/Nuke/Commands/SendNukeCodesCommand.cs index 8ac4f95a97..e44811a835 100644 --- a/Content.Server/Nuke/Commands/SendNukeCodesCommand.cs +++ b/Content.Server/Nuke/Commands/SendNukeCodesCommand.cs @@ -1,6 +1,6 @@ using Content.Server.Administration; -using Content.Server.Station.Components; using Content.Shared.Administration; +using Content.Shared.Station.Components; using Robust.Shared.Console; namespace Content.Server.Nuke.Commands; diff --git a/Content.Server/Nuke/NukeCodePaperSystem.cs b/Content.Server/Nuke/NukeCodePaperSystem.cs index aac2d2361d..af6751ed71 100644 --- a/Content.Server/Nuke/NukeCodePaperSystem.cs +++ b/Content.Server/Nuke/NukeCodePaperSystem.cs @@ -2,9 +2,9 @@ using System.Diagnostics.CodeAnalysis; using Content.Server.Chat.Systems; using Content.Server.Fax; using Content.Shared.Fax.Components; -using Content.Server.Station.Components; using Content.Server.Station.Systems; using Content.Shared.Paper; +using Content.Shared.Station.Components; using Robust.Shared.Random; using Robust.Shared.Utility; diff --git a/Content.Server/RoundEnd/RoundEndSystem.cs b/Content.Server/RoundEnd/RoundEndSystem.cs index 2d4f582bfc..a464796a74 100644 --- a/Content.Server/RoundEnd/RoundEndSystem.cs +++ b/Content.Server/RoundEnd/RoundEndSystem.cs @@ -9,7 +9,6 @@ using Content.Server.GameTicking; using Content.Server.Screens.Components; using Content.Server.Shuttles.Components; using Content.Server.Shuttles.Systems; -using Content.Server.Station.Components; using Content.Server.Station.Systems; using Content.Shared.Database; using Content.Shared.DeviceNetwork; @@ -20,6 +19,7 @@ using Robust.Shared.Player; using Robust.Shared.Prototypes; using Robust.Shared.Timing; using Content.Shared.DeviceNetwork.Components; +using Content.Shared.Station.Components; using Timer = Robust.Shared.Timing.Timer; namespace Content.Server.RoundEnd @@ -97,10 +97,10 @@ namespace Content.Server.RoundEnd /// public EntityUid? GetStation() { - AllEntityQuery().MoveNext(out _, out _, out var data); + AllEntityQuery().MoveNext(out var uid, out _, out var data); if (data == null) return null; - var targetGrid = _stationSystem.GetLargestGrid(data); + var targetGrid = _stationSystem.GetLargestGrid((uid, data)); return targetGrid == null ? null : Transform(targetGrid.Value).MapUid; } diff --git a/Content.Server/Salvage/SalvageSystem.Runner.cs b/Content.Server/Salvage/SalvageSystem.Runner.cs index 9050db3971..ceee9c3784 100644 --- a/Content.Server/Salvage/SalvageSystem.Runner.cs +++ b/Content.Server/Salvage/SalvageSystem.Runner.cs @@ -2,7 +2,6 @@ using System.Numerics; using Content.Server.Salvage.Expeditions; using Content.Server.Shuttles.Components; using Content.Server.Shuttles.Events; -using Content.Server.Station.Components; using Content.Shared.Chat; using Content.Shared.Humanoid; using Content.Shared.Mobs.Components; @@ -10,6 +9,7 @@ using Content.Shared.Mobs.Systems; using Content.Shared.Salvage.Expeditions; using Content.Shared.Shuttles.Components; using Content.Shared.Localizations; +using Content.Shared.Station.Components; using Robust.Shared.Map.Components; using Robust.Shared.Player; diff --git a/Content.Server/Shuttles/Systems/ArrivalsSystem.cs b/Content.Server/Shuttles/Systems/ArrivalsSystem.cs index aa1c2e6dff..20976ca019 100644 --- a/Content.Server/Shuttles/Systems/ArrivalsSystem.cs +++ b/Content.Server/Shuttles/Systems/ArrivalsSystem.cs @@ -11,7 +11,6 @@ using Content.Server.Shuttles.Components; using Content.Server.Shuttles.Events; using Content.Server.Spawners.Components; using Content.Server.Spawners.EntitySystems; -using Content.Server.Station.Components; using Content.Server.Station.Events; using Content.Server.Station.Systems; using Content.Shared.Administration; @@ -224,7 +223,7 @@ public sealed class ArrivalsSystem : EntitySystem if (component.FirstRun) { - var station = _station.GetLargestGrid(Comp(component.Station)); + var station = _station.GetLargestGrid(component.Station); sourceMap = station == null ? null : Transform(station.Value)?.MapUid; arrivalsDelay += RoundStartFTLDuration; component.FirstRun = false; @@ -470,7 +469,7 @@ public sealed class ArrivalsSystem : EntitySystem { while (query.MoveNext(out var uid, out var comp, out var shuttle, out var xform)) { - if (comp.NextTransfer > curTime || !TryComp(comp.Station, out var data)) + if (comp.NextTransfer > curTime) continue; var tripTime = _shuttles.DefaultTravelTime + _shuttles.DefaultStartupTime; @@ -486,7 +485,7 @@ public sealed class ArrivalsSystem : EntitySystem // Go to station else { - var targetGrid = _station.GetLargestGrid(data); + var targetGrid = _station.GetLargestGrid(comp.Station); if (targetGrid != null) _shuttles.FTLToDock(uid, shuttle, targetGrid.Value); diff --git a/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.cs b/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.cs index 9eff1455f9..53714c846a 100644 --- a/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.cs +++ b/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.cs @@ -14,7 +14,6 @@ using Content.Server.RoundEnd; using Content.Server.Screens.Components; using Content.Server.Shuttles.Components; using Content.Server.Shuttles.Events; -using Content.Server.Station.Components; using Content.Server.Station.Events; using Content.Server.Station.Systems; using Content.Shared.Access.Systems; @@ -181,7 +180,7 @@ public sealed partial class EmergencyShuttleSystem : EntitySystem return; } - var targetGrid = _station.GetLargestGrid(Comp(station.Value)); + var targetGrid = _station.GetLargestGrid(station.Value); if (targetGrid == null) return; @@ -270,7 +269,7 @@ public sealed partial class EmergencyShuttleSystem : EntitySystem return null; } - var targetGrid = _station.GetLargestGrid(Comp(stationUid)); + var targetGrid = _station.GetLargestGrid(stationUid); // UHH GOOD LUCK if (targetGrid == null) diff --git a/Content.Server/Shuttles/Systems/ShuttleSystem.GridFill.cs b/Content.Server/Shuttles/Systems/ShuttleSystem.GridFill.cs index a794ee0104..2e6ebe396c 100644 --- a/Content.Server/Shuttles/Systems/ShuttleSystem.GridFill.cs +++ b/Content.Server/Shuttles/Systems/ShuttleSystem.GridFill.cs @@ -1,9 +1,7 @@ using System.Numerics; using Content.Server.Shuttles.Components; -using Content.Server.Station.Components; using Content.Server.Station.Events; using Content.Shared.CCVar; -using Content.Shared.Salvage; using Content.Shared.Shuttles.Components; using Content.Shared.Station.Components; using Robust.Shared.Collections; @@ -62,10 +60,7 @@ public sealed partial class ShuttleSystem if (!_cfg.GetCVar(CCVars.GridFill)) return; - if (!TryComp(uid, out StationDataComponent? dataComp)) - return; - - var targetGrid = _station.GetLargestGrid(dataComp); + var targetGrid = _station.GetLargestGrid(uid); if (targetGrid == null) return; @@ -165,12 +160,7 @@ public sealed partial class ShuttleSystem if (!_cfg.GetCVar(CCVars.GridFill)) return; - if (!TryComp(uid, out var data)) - { - return; - } - - var targetGrid = _station.GetLargestGrid(data); + var targetGrid = _station.GetLargestGrid(uid); if (targetGrid == null) return; diff --git a/Content.Server/Singularity/EntitySystems/EventHorizonSystem.cs b/Content.Server/Singularity/EntitySystems/EventHorizonSystem.cs index 9c69422797..7090ca77ef 100644 --- a/Content.Server/Singularity/EntitySystems/EventHorizonSystem.cs +++ b/Content.Server/Singularity/EntitySystems/EventHorizonSystem.cs @@ -1,15 +1,13 @@ using System.Numerics; using Content.Server.Administration.Logs; using Content.Server.Singularity.Events; -using Content.Server.Station.Components; using Content.Shared.Database; -using Content.Shared.Ghost; using Content.Shared.Mind.Components; using Content.Shared.Singularity.Components; using Content.Shared.Singularity.EntitySystems; +using Content.Shared.Station.Components; using Content.Shared.Tag; using Robust.Shared.Containers; -using Robust.Shared.GameObjects; using Robust.Shared.Map; using Robust.Shared.Map.Components; using Robust.Shared.Physics.Components; diff --git a/Content.Server/Station/Commands/StationCommand.cs b/Content.Server/Station/Commands/StationCommand.cs index 8fe8c67646..f9dcb83d93 100644 --- a/Content.Server/Station/Commands/StationCommand.cs +++ b/Content.Server/Station/Commands/StationCommand.cs @@ -2,12 +2,12 @@ using System.Diagnostics; using System.Linq; using Content.Server.Administration; using Content.Server.Cargo.Systems; -using Content.Server.Station.Components; using Content.Server.Station.Systems; using Content.Shared.Administration; +using Content.Shared.Station; +using Content.Shared.Station.Components; using Robust.Shared.Toolshed; using Robust.Shared.Toolshed.Errors; -using Robust.Shared.Toolshed.Syntax; using Robust.Shared.Utility; namespace Content.Server.Station.Commands; @@ -54,7 +54,7 @@ public sealed class StationsCommand : ToolshedCommand public EntityUid? LargestGrid([PipedArgument] EntityUid input) { _station ??= GetSys(); - return _station.GetLargestGrid(Comp(input)); + return _station.GetLargestGrid(input); } [CommandImplementation("largestgrid")] diff --git a/Content.Server/Station/Events/StationPostInitEvent.cs b/Content.Server/Station/Events/StationPostInitEvent.cs index 54b8eeeb31..934d482bf2 100644 --- a/Content.Server/Station/Events/StationPostInitEvent.cs +++ b/Content.Server/Station/Events/StationPostInitEvent.cs @@ -1,4 +1,4 @@ -using Content.Server.Station.Components; +using Content.Shared.Station.Components; namespace Content.Server.Station.Events; diff --git a/Content.Server/Station/Systems/StationBiomeSystem.cs b/Content.Server/Station/Systems/StationBiomeSystem.cs index c12e2f47e4..61bc70794a 100644 --- a/Content.Server/Station/Systems/StationBiomeSystem.cs +++ b/Content.Server/Station/Systems/StationBiomeSystem.cs @@ -20,12 +20,10 @@ public sealed partial class StationBiomeSystem : EntitySystem private void OnStationPostInit(Entity map, ref StationPostInitEvent args) { - if (!TryComp(map, out StationDataComponent? dataComp)) + var station = _station.GetLargestGrid(map.Owner); + if (station == null) return; - var station = _station.GetLargestGrid(dataComp); - if (station == null) return; - var mapId = Transform(station.Value).MapID; var mapUid = _map.GetMapOrInvalid(mapId); diff --git a/Content.Server/Station/Systems/StationNameSystem.cs b/Content.Server/Station/Systems/StationNameSystem.cs index fbbf690465..ea17830a47 100644 --- a/Content.Server/Station/Systems/StationNameSystem.cs +++ b/Content.Server/Station/Systems/StationNameSystem.cs @@ -1,4 +1,5 @@ using Content.Server.Station.Components; +using Content.Shared.Station.Components; namespace Content.Server.Station.Systems; diff --git a/Content.Server/Station/Systems/StationSystem.cs b/Content.Server/Station/Systems/StationSystem.cs index 456d3c6b80..7100c6144f 100644 --- a/Content.Server/Station/Systems/StationSystem.cs +++ b/Content.Server/Station/Systems/StationSystem.cs @@ -3,20 +3,16 @@ using Content.Server.Chat.Systems; using Content.Server.GameTicking; using Content.Server.Station.Components; using Content.Server.Station.Events; -using Content.Shared.CCVar; using Content.Shared.Station; using Content.Shared.Station.Components; using JetBrains.Annotations; -using Robust.Server.GameObjects; using Robust.Server.GameStates; using Robust.Server.Player; using Robust.Shared.Collections; -using Robust.Shared.Configuration; using Robust.Shared.Enums; using Robust.Shared.Map; using Robust.Shared.Map.Components; using Robust.Shared.Player; -using Robust.Shared.Random; using Robust.Shared.Utility; namespace Content.Server.Station.Systems; @@ -34,7 +30,6 @@ public sealed partial class StationSystem : SharedStationSystem [Dependency] private readonly ChatSystem _chatSystem = default!; [Dependency] private readonly SharedTransformSystem _transform = default!; [Dependency] private readonly MetaDataSystem _metaData = default!; - [Dependency] private readonly MapSystem _map = default!; [Dependency] private readonly PvsOverrideSystem _pvsOverride = default!; private ISawmill _sawmill = default!; @@ -42,8 +37,8 @@ public sealed partial class StationSystem : SharedStationSystem private EntityQuery _gridQuery; private EntityQuery _xformQuery; - private ValueList _mapIds = new(); - private ValueList<(Box2Rotated Bounds, MapId MapId)> _gridBounds = new(); + private ValueList _mapIds; + private ValueList<(Box2Rotated Bounds, MapId MapId)> _gridBounds; /// public override void Initialize() @@ -79,6 +74,7 @@ public sealed partial class StationSystem : SharedStationSystem return; stationData.Grids.Remove(uid); + Dirty(uid, component); } public override void Shutdown() @@ -193,44 +189,6 @@ public sealed partial class StationSystem : SharedStationSystem #endregion Event handlers - /// - /// Gets the largest member grid from a station. - /// - public EntityUid? GetLargestGrid(StationDataComponent component) - { - EntityUid? largestGrid = null; - Box2 largestBounds = new Box2(); - - foreach (var gridUid in component.Grids) - { - if (!TryComp(gridUid, out var grid) || - grid.LocalAABB.Size.LengthSquared() < largestBounds.Size.LengthSquared()) - continue; - - largestBounds = grid.LocalAABB; - largestGrid = gridUid; - } - - return largestGrid; - } - - /// - /// Returns the total number of tiles contained in the station's grids. - /// - public int GetTileCount(StationDataComponent component) - { - var count = 0; - foreach (var gridUid in component.Grids) - { - if (!TryComp(gridUid, out var grid)) - continue; - - count += _map.GetAllTiles(gridUid, grid).Count(); - } - - return count; - } - /// /// Tries to retrieve a filter for everything in the station the source is on. /// @@ -384,6 +342,7 @@ public sealed partial class StationSystem : SharedStationSystem var stationMember = EnsureComp(mapGrid); stationMember.Station = station; stationData.Grids.Add(mapGrid); + Dirty(station, stationData); RaiseLocalEvent(station, new StationGridAddedEvent(mapGrid, station, false), true); @@ -407,6 +366,7 @@ public sealed partial class StationSystem : SharedStationSystem RemComp(mapGrid); stationData.Grids.Remove(mapGrid); + Dirty(station, stationData); RaiseLocalEvent(station, new StationGridRemovedEvent(mapGrid, station), true); _sawmill.Info($"Removing grid {mapGrid} from station {Name(station)} ({station})"); @@ -450,110 +410,6 @@ public sealed partial class StationSystem : SharedStationSystem QueueDel(station); } - - public EntityUid? GetOwningStation(EntityUid? entity, TransformComponent? xform = null) - { - if (entity == null) - return null; - - return GetOwningStation(entity.Value, xform); - } - - /// - /// Gets the station that "owns" the given entity (essentially, the station the grid it's on is attached to) - /// - /// Entity to find the owner of. - /// Resolve pattern, transform of the entity. - /// The owning station, if any. - /// - /// This does not remember what station an entity started on, it simply checks where it is currently located. - /// - public EntityUid? GetOwningStation(EntityUid entity, TransformComponent? xform = null) - { - if (!Resolve(entity, ref xform)) - throw new ArgumentException("Tried to use an abstract entity!", nameof(entity)); - - if (TryComp(entity, out _)) - { - // We are the station, just return ourselves. - return entity; - } - - if (TryComp(entity, out _)) - { - // We are the station, just check ourselves. - return CompOrNull(entity)?.Station; - } - - if (xform.GridUid == EntityUid.Invalid) - { - Log.Debug("Unable to get owning station - GridUid invalid."); - return null; - } - - return CompOrNull(xform.GridUid)?.Station; - } - - public List GetStations() - { - var stations = new List(); - var query = EntityQueryEnumerator(); - while (query.MoveNext(out var uid, out _)) - { - stations.Add(uid); - } - - return stations; - } - - public HashSet GetStationsSet() - { - var stations = new HashSet(); - var query = EntityQueryEnumerator(); - while (query.MoveNext(out var uid, out _)) - { - stations.Add(uid); - } - - return stations; - } - - public List<(string Name, NetEntity Entity)> GetStationNames() - { - var stations = GetStationsSet(); - var stats = new List<(string Name, NetEntity Station)>(); - - foreach (var weh in stations) - { - stats.Add((MetaData(weh).EntityName, GetNetEntity(weh))); - } - - return stats; - } - - /// - /// Returns the first station that has a grid in a certain map. - /// If the map has no stations, null is returned instead. - /// - /// - /// If there are multiple stations on a map it is probably arbitrary which one is returned. - /// - public EntityUid? GetStationInMap(MapId map) - { - var query = EntityQueryEnumerator(); - while (query.MoveNext(out var uid, out var data)) - { - foreach (var gridUid in data.Grids) - { - if (Transform(gridUid).MapID == map) - { - return uid; - } - } - } - - return null; - } } /// diff --git a/Content.Server/StationEvents/Events/AnomalySpawnRule.cs b/Content.Server/StationEvents/Events/AnomalySpawnRule.cs index 06da91e256..4c9cfd87ea 100644 --- a/Content.Server/StationEvents/Events/AnomalySpawnRule.cs +++ b/Content.Server/StationEvents/Events/AnomalySpawnRule.cs @@ -1,7 +1,7 @@ using Content.Server.Anomaly; -using Content.Server.Station.Components; using Content.Server.StationEvents.Components; -using Content.Shared.GameTicking.Components; +using Content.Shared.GameTicking.Components; +using Content.Shared.Station.Components; namespace Content.Server.StationEvents.Events; @@ -31,7 +31,7 @@ public sealed class AnomalySpawnRule : StationEventSystem(chosenStation, out var stationData)) return; - var grid = StationSystem.GetLargestGrid(stationData); + var grid = StationSystem.GetLargestGrid((chosenStation.Value, stationData)); if (grid is null) return; diff --git a/Content.Server/StationEvents/Events/CargoGiftsRule.cs b/Content.Server/StationEvents/Events/CargoGiftsRule.cs index 91baf2ecad..d38de1e0d8 100644 --- a/Content.Server/StationEvents/Events/CargoGiftsRule.cs +++ b/Content.Server/StationEvents/Events/CargoGiftsRule.cs @@ -2,9 +2,9 @@ using System.Linq; using Content.Server.Cargo.Components; using Content.Server.Cargo.Systems; using Content.Server.GameTicking; -using Content.Server.Station.Components; using Content.Server.StationEvents.Components; using Content.Shared.GameTicking.Components; +using Content.Shared.Station.Components; using Robust.Shared.Prototypes; namespace Content.Server.StationEvents.Events; diff --git a/Content.Server/StationEvents/Events/MeteorSwarmSystem.cs b/Content.Server/StationEvents/Events/MeteorSwarmSystem.cs index 948fedf6fc..e1987789b6 100644 --- a/Content.Server/StationEvents/Events/MeteorSwarmSystem.cs +++ b/Content.Server/StationEvents/Events/MeteorSwarmSystem.cs @@ -1,7 +1,6 @@ using System.Numerics; using Content.Server.Chat.Systems; using Content.Server.GameTicking.Rules; -using Content.Server.Station.Components; using Content.Server.Station.Systems; using Content.Server.StationEvents.Components; using Content.Shared.GameTicking.Components; @@ -49,7 +48,7 @@ public sealed class MeteorSwarmSystem : GameRuleSystem return; var station = RobustRandom.Pick(_station.GetStations()); - if (_station.GetLargestGrid(Comp(station)) is not { } grid) + if (_station.GetLargestGrid(station) is not { } grid) return; var mapId = Transform(grid).MapID; diff --git a/Content.Server/StationEvents/Events/SpaceSpawnRule.cs b/Content.Server/StationEvents/Events/SpaceSpawnRule.cs index 6fccaaa5cf..08e43b4c68 100644 --- a/Content.Server/StationEvents/Events/SpaceSpawnRule.cs +++ b/Content.Server/StationEvents/Events/SpaceSpawnRule.cs @@ -1,6 +1,4 @@ using Content.Server.Antag; -using Content.Server.GameTicking.Rules.Components; -using Content.Server.Station.Components; using Content.Server.StationEvents.Components; using Content.Shared.GameTicking.Components; using Robust.Shared.Map; @@ -32,10 +30,8 @@ public sealed class SpaceSpawnRule : StationEventSystem return; } - var stationData = Comp(station.Value); - // find a station grid - var gridUid = StationSystem.GetLargestGrid(stationData); + var gridUid = StationSystem.GetLargestGrid(station.Value); if (gridUid == null || !TryComp(gridUid, out var grid)) { Sawmill.Warning("Chosen station has no grids, cannot pick location for {ToPrettyString(uid):rule}"); diff --git a/Content.Server/Station/Components/StationDataComponent.cs b/Content.Shared/Station/Components/StationDataComponent.cs similarity index 55% rename from Content.Server/Station/Components/StationDataComponent.cs rename to Content.Shared/Station/Components/StationDataComponent.cs index d154c6936d..ef01525d31 100644 --- a/Content.Server/Station/Components/StationDataComponent.cs +++ b/Content.Shared/Station/Components/StationDataComponent.cs @@ -1,26 +1,23 @@ -using Content.Server.Shuttles.Systems; -using Content.Server.Station.Systems; -using Robust.Shared.Serialization.TypeSerializers.Implementations; -using Robust.Shared.Utility; +using Robust.Shared.GameStates; -namespace Content.Server.Station.Components; +namespace Content.Shared.Station.Components; /// /// Stores core information about a station, namely its config and associated grids. /// All station entities will have this component. /// -[RegisterComponent, Access(typeof(StationSystem))] +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState, Access(typeof(SharedStationSystem))] public sealed partial class StationDataComponent : Component { /// /// The game map prototype, if any, associated with this station. /// - [DataField("stationConfig")] - public StationConfig? StationConfig = null; + [DataField] + public StationConfig? StationConfig; /// /// List of all grids this station is part of. /// - [DataField("grids")] + [DataField, AutoNetworkedField] public HashSet Grids = new(); } diff --git a/Content.Shared/Station/SharedStationSystem.Tracker.cs b/Content.Shared/Station/SharedStationSystem.Tracker.cs new file mode 100644 index 0000000000..770420d47e --- /dev/null +++ b/Content.Shared/Station/SharedStationSystem.Tracker.cs @@ -0,0 +1,88 @@ +using Content.Shared.Station.Components; +using JetBrains.Annotations; +using Robust.Shared.Map; + +namespace Content.Shared.Station; + +public abstract partial class SharedStationSystem +{ + private void InitializeTracker() + { + SubscribeLocalEvent(OnTrackerMapInit); + SubscribeLocalEvent(OnTrackerRemove); + SubscribeLocalEvent(OnTrackerGridChanged); + SubscribeLocalEvent(OnMetaFlagRemoveAttempt); + } + + private void OnTrackerMapInit(Entity ent, ref MapInitEvent args) + { + _meta.AddFlag(ent, MetaDataFlags.ExtraTransformEvents); + UpdateStationTracker(ent.AsNullable()); + } + + private void OnTrackerRemove(Entity ent, ref ComponentRemove args) + { + _meta.RemoveFlag(ent, MetaDataFlags.ExtraTransformEvents); + } + + private void OnTrackerGridChanged(Entity ent, ref GridUidChangedEvent args) + { + UpdateStationTracker((ent, ent.Comp, args.Transform)); + } + + private void OnMetaFlagRemoveAttempt(Entity ent, ref MetaFlagRemoveAttemptEvent args) + { + if ((args.ToRemove & MetaDataFlags.ExtraTransformEvents) != 0 && + ent.Comp.LifeStage <= ComponentLifeStage.Running) + { + args.ToRemove &= ~MetaDataFlags.ExtraTransformEvents; + } + } + + /// + /// Updates the station tracker component based on entity's current location. + /// + [PublicAPI] + public void UpdateStationTracker(Entity ent) + { + if (!Resolve(ent, ref ent.Comp1)) + return; + + var xform = ent.Comp2; + + if (!_xformQuery.Resolve(ent, ref xform)) + return; + + // Entity is in nullspace or not on a grid + if (xform.MapID == MapId.Nullspace || xform.GridUid == null) + { + SetStation(ent, null); + return; + } + + // Check if the grid is part of a station + if (!_stationMemberQuery.TryGetComponent(xform.GridUid.Value, out var stationMember)) + { + SetStation(ent, null); + return; + } + + SetStation(ent, stationMember.Station); + } + + /// + /// Sets the station for a StationTrackerComponent. + /// + [PublicAPI] + public void SetStation(Entity ent, EntityUid? station) + { + if (!Resolve(ent, ref ent.Comp)) + return; + + if (ent.Comp.Station == station) + return; + + ent.Comp.Station = station; + Dirty(ent); + } +} diff --git a/Content.Shared/Station/SharedStationSystem.cs b/Content.Shared/Station/SharedStationSystem.cs index c067af610d..afd2e77258 100644 --- a/Content.Shared/Station/SharedStationSystem.cs +++ b/Content.Shared/Station/SharedStationSystem.cs @@ -1,11 +1,14 @@ +using System.Linq; using Content.Shared.Station.Components; using JetBrains.Annotations; using Robust.Shared.Map; +using Robust.Shared.Map.Components; namespace Content.Shared.Station; public abstract partial class SharedStationSystem : EntitySystem { + [Dependency] private readonly SharedMapSystem _map = default!; [Dependency] private readonly MetaDataSystem _meta = default!; private EntityQuery _xformQuery; @@ -16,96 +19,164 @@ public abstract partial class SharedStationSystem : EntitySystem { base.Initialize(); + InitializeTracker(); + _xformQuery = GetEntityQuery(); _stationMemberQuery = GetEntityQuery(); - - SubscribeLocalEvent(OnTrackerMapInit); - SubscribeLocalEvent(OnTrackerRemove); - SubscribeLocalEvent(OnTrackerGridChanged); - SubscribeLocalEvent(OnMetaFlagRemoveAttempt); - } - - private void OnTrackerMapInit(Entity ent, ref MapInitEvent args) - { - _meta.AddFlag(ent, MetaDataFlags.ExtraTransformEvents); - UpdateStationTracker(ent.AsNullable()); - } - - private void OnTrackerRemove(Entity ent, ref ComponentRemove args) - { - _meta.RemoveFlag(ent, MetaDataFlags.ExtraTransformEvents); - } - - private void OnTrackerGridChanged(Entity ent, ref GridUidChangedEvent args) - { - UpdateStationTracker((ent, ent.Comp, args.Transform)); - } - - private void OnMetaFlagRemoveAttempt(Entity ent, ref MetaFlagRemoveAttemptEvent args) - { - if ((args.ToRemove & MetaDataFlags.ExtraTransformEvents) != 0 && - ent.Comp.LifeStage <= ComponentLifeStage.Running) - { - args.ToRemove &= ~MetaDataFlags.ExtraTransformEvents; - } } /// - /// Updates the station tracker component based on entity's current location. + /// Gets the largest member grid from a station. /// - [PublicAPI] - public void UpdateStationTracker(Entity ent) - { - if (!Resolve(ent, ref ent.Comp1)) - return; - - var xform = ent.Comp2; - - if (!_xformQuery.Resolve(ent, ref xform)) - return; - - // Entity is in nullspace or not on a grid - if (xform.MapID == MapId.Nullspace || xform.GridUid == null) - { - SetStation(ent, null); - return; - } - - // Check if the grid is part of a station - if (!_stationMemberQuery.TryGetComponent(xform.GridUid.Value, out var stationMember)) - { - SetStation(ent, null); - return; - } - - SetStation(ent, stationMember.Station); - } - - /// - /// Sets the station for a StationTrackerComponent. - /// - [PublicAPI] - public void SetStation(Entity ent, EntityUid? station) + public EntityUid? GetLargestGrid(Entity ent) { if (!Resolve(ent, ref ent.Comp)) - return; + return null; - if (ent.Comp.Station == station) - return; + EntityUid? largestGrid = null; + Box2 largestBounds = new Box2(); - ent.Comp.Station = station; - Dirty(ent); + foreach (var gridUid in ent.Comp.Grids) + { + if (!TryComp(gridUid, out var grid) || + grid.LocalAABB.Size.LengthSquared() < largestBounds.Size.LengthSquared()) + continue; + + largestBounds = grid.LocalAABB; + largestGrid = gridUid; + } + + return largestGrid; } /// - /// Gets the station an entity is currently on, if any. + /// Returns the total number of tiles contained in the station's grids. /// - [PublicAPI] - public EntityUid? GetCurrentStation(Entity ent) + public int GetTileCount(Entity ent) { - if (!Resolve(ent, ref ent.Comp, logMissing: false)) + if (!Resolve(ent, ref ent.Comp)) + return 0; + + var count = 0; + foreach (var gridUid in ent.Comp.Grids) + { + if (!TryComp(gridUid, out var grid)) + continue; + + count += _map.GetAllTiles(gridUid, grid).Count(); + } + + return count; + } + + [PublicAPI] + public EntityUid? GetOwningStation(EntityUid? entity, TransformComponent? xform = null) + { + if (entity == null) return null; - return ent.Comp.Station; + return GetOwningStation(entity.Value, xform); + } + + /// + /// Gets the station that "owns" the given entity (essentially, the station the grid it's on is attached to) + /// + /// Entity to find the owner of. + /// Resolve pattern, transform of the entity. + /// The owning station, if any. + /// + /// This does not remember what station an entity started on, it simply checks where it is currently located. + /// + public EntityUid? GetOwningStation(EntityUid entity, TransformComponent? xform = null) + { + if (!Resolve(entity, ref xform)) + throw new ArgumentException("Tried to use an abstract entity!", nameof(entity)); + + if (TryComp(entity, out var stationTracker)) + { + // We have a specific station we are tracking and are tethered to. + return stationTracker.Station; + } + + if (HasComp(entity)) + { + // We are the station, just return ourselves. + return entity; + } + + if (HasComp(entity)) + { + // We are the station, just check ourselves. + return CompOrNull(entity)?.Station; + } + + if (xform.GridUid == EntityUid.Invalid) + { + Log.Debug("Unable to get owning station - GridUid invalid."); + return null; + } + + return CompOrNull(xform.GridUid)?.Station; + } + + public List GetStations() + { + var stations = new List(); + var query = EntityQueryEnumerator(); + while (query.MoveNext(out var uid, out _)) + { + stations.Add(uid); + } + + return stations; + } + + public HashSet GetStationsSet() + { + var stations = new HashSet(); + var query = EntityQueryEnumerator(); + while (query.MoveNext(out var uid, out _)) + { + stations.Add(uid); + } + + return stations; + } + + public List<(string Name, NetEntity Entity)> GetStationNames() + { + var stations = GetStationsSet(); + var stats = new List<(string Name, NetEntity Station)>(); + + foreach (var weh in stations) + { + stats.Add((MetaData(weh).EntityName, GetNetEntity(weh))); + } + + return stats; + } + + /// + /// Returns the first station that has a grid in a certain map. + /// If the map has no stations, null is returned instead. + /// + /// + /// If there are multiple stations on a map it is probably arbitrary which one is returned. + /// + public EntityUid? GetStationInMap(MapId map) + { + var query = EntityQueryEnumerator(); + while (query.MoveNext(out var uid, out var data)) + { + foreach (var gridUid in data.Grids) + { + if (Transform(gridUid).MapID == map) + { + return uid; + } + } + } + + return null; } } diff --git a/Content.Server/Station/StationConfig.cs b/Content.Shared/Station/StationConfig.cs similarity index 59% rename from Content.Server/Station/StationConfig.cs rename to Content.Shared/Station/StationConfig.cs index 8bc0caf1aa..5bdbf77422 100644 --- a/Content.Server/Station/StationConfig.cs +++ b/Content.Shared/Station/StationConfig.cs @@ -1,17 +1,15 @@ -using Content.Server.Maps.NameGenerators; -using JetBrains.Annotations; -using Robust.Shared.Prototypes; +using Robust.Shared.Prototypes; -namespace Content.Server.Station; +namespace Content.Shared.Station; /// /// A config for a station. Specifies name and component modifications. /// -[DataDefinition, PublicAPI] +[DataDefinition] public sealed partial class StationConfig { [DataField("stationProto", required: true)] - public string StationPrototype = default!; + public EntProtoId StationPrototype; [DataField("components", required: true)] public ComponentRegistry StationComponentOverrides = default!;