Disable Arrivals message for Cryosleep (#30888)

* Disable arrivals message for cryosleep late arrivals

* Provide silent to PlayerSpawnCompleteEvent

* Fix typo

* Move message to event and into arrivals system
This commit is contained in:
Thomas
2024-08-27 10:02:21 -05:00
committed by GitHub
parent 4b91f1f50b
commit d304123ef7
2 changed files with 22 additions and 17 deletions

View File

@@ -104,6 +104,8 @@ public sealed class ArrivalsSystem : EntitySystem
SubscribeLocalEvent<ArrivalsShuttleComponent, FTLStartedEvent>(OnArrivalsFTL);
SubscribeLocalEvent<ArrivalsShuttleComponent, FTLCompletedEvent>(OnArrivalsDocked);
SubscribeLocalEvent<PlayerSpawnCompleteEvent>(SendDirections);
_pendingQuery = GetEntityQuery<PendingClockInComponent>();
_blacklistQuery = GetEntityQuery<ArrivalsBlacklistComponent>();
_mobQuery = GetEntityQuery<MobStateComponent>();
@@ -378,6 +380,20 @@ public sealed class ArrivalsSystem : EntitySystem
EnsureComp<GodmodeComponent>(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))