diff --git a/Content.Server/GameTicking/GameTicker.Spawning.cs b/Content.Server/GameTicking/GameTicker.Spawning.cs index 5e2ef0c02c..3ca62e561d 100644 --- a/Content.Server/GameTicking/GameTicker.Spawning.cs +++ b/Content.Server/GameTicking/GameTicker.Spawning.cs @@ -4,6 +4,7 @@ using System.Numerics; using Content.Server.Administration.Managers; using Content.Server.GameTicking.Events; using Content.Server.Ghost; +using Content.Server.Shuttles.Components; using Content.Server.Spawners.Components; using Content.Server.Speech.Components; using Content.Server.Station.Components; @@ -274,28 +275,13 @@ namespace Content.Server.GameTicking Loc.GetString("job-greet-station-name", ("stationName", metaData.EntityName))); } - // Arrivals is unable to do this during spawning as no actor is attached yet. - // We also want this message last. - if (!silent && lateJoin && _arrivals.Enabled) - { - var arrival = _arrivals.NextShuttleArrival(); - if (arrival == null) - { - _chatManager.DispatchServerMessage(player, Loc.GetString("latejoin-arrivals-direction")); - } - else - { - _chatManager.DispatchServerMessage(player, - Loc.GetString("latejoin-arrivals-direction-time", ("time", $"{arrival:mm\\:ss}"))); - } - } - // We raise this event directed to the mob, but also broadcast it so game rules can do something now. PlayersJoinedRoundNormally++; var aev = new PlayerSpawnCompleteEvent(mob, player, jobId, lateJoin, + silent, PlayersJoinedRoundNormally, station, character); @@ -314,7 +300,7 @@ namespace Content.Server.GameTicking } /// - /// Makes a player join into the game and spawn on a staiton. + /// Makes a player join into the game and spawn on a station. /// /// The player joining /// The station they're spawning on @@ -494,6 +480,7 @@ namespace Content.Server.GameTicking public ICommonSession Player { get; } public string? JobId { get; } public bool LateJoin { get; } + public bool Silent { get; } public EntityUid Station { get; } public HumanoidCharacterProfile Profile { get; } @@ -504,6 +491,7 @@ namespace Content.Server.GameTicking ICommonSession player, string? jobId, bool lateJoin, + bool silent, int joinOrder, EntityUid station, HumanoidCharacterProfile profile) @@ -512,6 +500,7 @@ namespace Content.Server.GameTicking Player = player; JobId = jobId; LateJoin = lateJoin; + Silent = silent; Station = station; Profile = profile; JoinOrder = joinOrder; diff --git a/Content.Server/Shuttles/Systems/ArrivalsSystem.cs b/Content.Server/Shuttles/Systems/ArrivalsSystem.cs index e921590e39..0b86383faa 100644 --- a/Content.Server/Shuttles/Systems/ArrivalsSystem.cs +++ b/Content.Server/Shuttles/Systems/ArrivalsSystem.cs @@ -104,6 +104,8 @@ public sealed class ArrivalsSystem : EntitySystem SubscribeLocalEvent(OnArrivalsFTL); SubscribeLocalEvent(OnArrivalsDocked); + SubscribeLocalEvent(SendDirections); + _pendingQuery = GetEntityQuery(); _blacklistQuery = GetEntityQuery(); _mobQuery = GetEntityQuery(); @@ -378,6 +380,20 @@ public sealed class ArrivalsSystem : EntitySystem EnsureComp(ev.SpawnResult.Value); } + private void SendDirections(PlayerSpawnCompleteEvent ev) + { + if (!Enabled || !ev.LateJoin || ev.Silent || !_pendingQuery.HasComp(ev.Mob)) + return; + + var arrival = NextShuttleArrival(); + + var message = arrival is not null + ? Loc.GetString("latejoin-arrivals-direction-time", ("time", $"{arrival:mm\\:ss}")) + : Loc.GetString("latejoin-arrivals-direction"); + + _chat.DispatchServerMessage(ev.Player, message); + } + private bool TryTeleportToMapSpawn(EntityUid player, EntityUid stationId, TransformComponent? transform = null) { if (!Resolve(player, ref transform))