diff --git a/Content.Server/GameTicking/GameTicker.Spawning.cs b/Content.Server/GameTicking/GameTicker.Spawning.cs index 30bb8f347b..a4d00dc1e1 100644 --- a/Content.Server/GameTicking/GameTicker.Spawning.cs +++ b/Content.Server/GameTicking/GameTicker.Spawning.cs @@ -231,13 +231,15 @@ namespace Content.Server.GameTicking var arrivals = true; + // Все появляются в прибытии в начале раунда. Зачем? А мне нравится эта бегающаа орящая толпа. + var spawnPointType = SpawnPointType.Arrivals; if (jobPrototype.AlwaysUseSpawner) { lateJoin = false; - arrivals = false; + spawnPointType = SpawnPointType.Job; } - var mobMaybe = _stationSpawning.SpawnPlayerCharacterOnStation(station, job, character, arrivals: arrivals); + var mobMaybe = _stationSpawning.SpawnPlayerCharacterOnStation(station, job, character, arrivals: arrivals, spawnPointType: spawnPointType); DebugTools.AssertNotNull(mobMaybe); var mob = mobMaybe!.Value; diff --git a/Content.Server/Shuttles/Systems/ArrivalsSystem.cs b/Content.Server/Shuttles/Systems/ArrivalsSystem.cs index e65b5d0ba4..c60ae941e6 100644 --- a/Content.Server/Shuttles/Systems/ArrivalsSystem.cs +++ b/Content.Server/Shuttles/Systems/ArrivalsSystem.cs @@ -4,7 +4,6 @@ using Content.Server.Administration; using Content.Server.DeviceNetwork.Components; using Content.Server.DeviceNetwork.Systems; using Content.Server.GameTicking; -using Content.Server.GameTicking.Events; using Content.Server.Parallax; using Content.Server.Screens.Components; using Content.Server.Shuttles.Components; @@ -19,9 +18,6 @@ using Content.Shared.DeviceNetwork; using Content.Shared.Mobs.Components; using Content.Shared.Movement.Components; using Content.Shared.Parallax.Biomes; -using Content.Shared.Preferences; -using Content.Shared.Roles.Jobs; -using Content.Shared.Salvage; using Content.Shared.Shuttles.Components; using Content.Shared.Tiles; using Robust.Server.GameObjects; @@ -304,16 +300,39 @@ public sealed class ArrivalsSystem : EntitySystem } } + public List GetArrivalsSpawnPoints() + { + TryGetArrivalsSource(out var arrivals); + var possiblePositions = new List(); + + if (TryComp(arrivals, out TransformComponent? arrivalsXform)) + { + var mapId = arrivalsXform.MapID; + + var points = EntityQueryEnumerator(); + + while (points.MoveNext(out var uid, out var spawnPoint, out var xform)) + { + if (spawnPoint.SpawnType != SpawnPointType.LateJoin || xform.MapID != mapId) + continue; + + possiblePositions.Add(xform.Coordinates); + } + } + + return possiblePositions; + } + public void HandlePlayerSpawning(PlayerSpawningEvent ev) { if (ev.SpawnResult != null) return; // Only works on latejoin even if enabled. - if (!Enabled || !ev.Arrivals) + if (!Enabled || _ticker.RunLevel != GameRunLevel.InRound) return; - if (!HasComp(ev.Station) && !ev.Arrivals) + if (!HasComp(ev.Station)) return; TryGetArrivalsSource(out var arrivals); diff --git a/Content.Server/Spawners/Components/SpawnPointComponent.cs b/Content.Server/Spawners/Components/SpawnPointComponent.cs index c6d14dfeb3..4dbfe64bbc 100644 --- a/Content.Server/Spawners/Components/SpawnPointComponent.cs +++ b/Content.Server/Spawners/Components/SpawnPointComponent.cs @@ -27,4 +27,5 @@ public enum SpawnPointType LateJoin, Job, Observer, + Arrivals } diff --git a/Content.Server/Spawners/EntitySystems/SpawnPointSystem.cs b/Content.Server/Spawners/EntitySystems/SpawnPointSystem.cs index be555dd54a..261b11a6e9 100644 --- a/Content.Server/Spawners/EntitySystems/SpawnPointSystem.cs +++ b/Content.Server/Spawners/EntitySystems/SpawnPointSystem.cs @@ -1,4 +1,5 @@ using Content.Server.GameTicking; +using Content.Server.Shuttles.Systems; using Content.Server.Spawners.Components; using Content.Server.Station.Systems; using Robust.Shared.Map; @@ -12,6 +13,7 @@ public sealed class SpawnPointSystem : EntitySystem [Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly StationSystem _stationSystem = default!; [Dependency] private readonly StationSpawningSystem _stationSpawning = default!; + [Dependency] private readonly ArrivalsSystem _arrivals = default!; public override void Initialize() { @@ -27,11 +29,29 @@ public sealed class SpawnPointSystem : EntitySystem var points = EntityQueryEnumerator(); var possiblePositions = new List(); - while ( points.MoveNext(out var uid, out var spawnPoint, out var xform)) + while (points.MoveNext(out var uid, out var spawnPoint, out var xform)) { if (args.Station != null && _stationSystem.GetOwningStation(uid, xform) != args.Station) continue; + // Delta-V: Allow setting a desired SpawnPointType + if (args.DesiredSpawnPointType != SpawnPointType.Unset) + { + var isMatchingJob = spawnPoint.SpawnType == SpawnPointType.Job && + (args.Job == null || spawnPoint.Job == args.Job.Prototype); + + switch (args.DesiredSpawnPointType) + { + case SpawnPointType.Job when isMatchingJob: + case SpawnPointType.LateJoin when spawnPoint.SpawnType == SpawnPointType.LateJoin: + case SpawnPointType.Observer when spawnPoint.SpawnType == SpawnPointType.Observer: + possiblePositions.Add(xform.Coordinates); + break; + default: + continue; + } + } + if (_gameTicker.RunLevel == GameRunLevel.InRound && spawnPoint.SpawnType == SpawnPointType.LateJoin) { possiblePositions.Add(xform.Coordinates); @@ -45,6 +65,11 @@ public sealed class SpawnPointSystem : EntitySystem } } + if (args.DesiredSpawnPointType == SpawnPointType.Arrivals) + { + possiblePositions = _arrivals.GetArrivalsSpawnPoints(); + } + if (possiblePositions.Count == 0) { // Ok we've still not returned, but we need to put them /somewhere/. diff --git a/Content.Server/Station/Systems/StationSpawningSystem.cs b/Content.Server/Station/Systems/StationSpawningSystem.cs index 4d0b2363bb..4b575d7460 100644 --- a/Content.Server/Station/Systems/StationSpawningSystem.cs +++ b/Content.Server/Station/Systems/StationSpawningSystem.cs @@ -6,6 +6,7 @@ using Content.Server.IdentityManagement; using Content.Server.Mind.Commands; using Content.Server.PDA; using Content.Server.Shuttles.Systems; +using Content.Server.Spawners.Components; using Content.Server.Spawners.EntitySystems; using Content.Server.Station.Components; using Content.Shared.Access.Components; @@ -81,12 +82,12 @@ public sealed class StationSpawningSystem : SharedStationSpawningSystem /// /// This only spawns the character, and does none of the mind-related setup you'd need for it to be playable. /// - public EntityUid? SpawnPlayerCharacterOnStation(EntityUid? station, JobComponent? job, HumanoidCharacterProfile? profile, bool arrivals, StationSpawningComponent? stationSpawning = null) + public EntityUid? SpawnPlayerCharacterOnStation(EntityUid? station, JobComponent? job, HumanoidCharacterProfile? profile, bool arrivals, StationSpawningComponent? stationSpawning = null, SpawnPointType spawnPointType = SpawnPointType.Unset) { if (station != null && !Resolve(station.Value, ref stationSpawning)) throw new ArgumentException("Tried to use a non-station entity as a station!", nameof(station)); - var ev = new PlayerSpawningEvent(job, profile, station, arrivals); + var ev = new PlayerSpawningEvent(job, profile, station, spawnPointType); if (station != null && profile != null) { @@ -307,13 +308,16 @@ public sealed class PlayerSpawningEvent : EntityEventArgs /// The target station, if any. /// public readonly EntityUid? Station; - public readonly bool Arrivals; + /// + /// Delta-V: Desired SpawnPointType, if any. + /// + public readonly SpawnPointType DesiredSpawnPointType; - public PlayerSpawningEvent(JobComponent? job, HumanoidCharacterProfile? humanoidCharacterProfile, EntityUid? station, bool arrivals) + public PlayerSpawningEvent(JobComponent? job, HumanoidCharacterProfile? humanoidCharacterProfile, EntityUid? station, SpawnPointType spawnPointType = SpawnPointType.Unset) { Job = job; HumanoidCharacterProfile = humanoidCharacterProfile; Station = station; - Arrivals = arrivals; + DesiredSpawnPointType = spawnPointType; } }