Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable Arrivals message for Cryosleep #30888

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 6 additions & 17 deletions Content.Server/GameTicking/GameTicker.Spawning.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
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;
Expand Down Expand Up @@ -274,28 +275,13 @@ private void SpawnPlayer(ICommonSession player,
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);
Expand All @@ -314,7 +300,7 @@ public void Respawn(ICommonSession player)
}

/// <summary>
/// Makes a player join into the game and spawn on a staiton.
/// Makes a player join into the game and spawn on a station.
/// </summary>
/// <param name="player">The player joining</param>
/// <param name="station">The station they're spawning on</param>
Expand Down Expand Up @@ -494,6 +480,7 @@ public sealed class PlayerSpawnCompleteEvent : EntityEventArgs
public ICommonSession Player { get; }
public string? JobId { get; }
public bool LateJoin { get; }
public bool Silent { get; }
public EntityUid Station { get; }
public HumanoidCharacterProfile Profile { get; }

Expand All @@ -504,6 +491,7 @@ public PlayerSpawnCompleteEvent(EntityUid mob,
ICommonSession player,
string? jobId,
bool lateJoin,
bool silent,
int joinOrder,
EntityUid station,
HumanoidCharacterProfile profile)
Expand All @@ -512,6 +500,7 @@ public PlayerSpawnCompleteEvent(EntityUid mob,
Player = player;
JobId = jobId;
LateJoin = lateJoin;
Silent = silent;
Station = station;
Profile = profile;
JoinOrder = joinOrder;
Expand Down
16 changes: 16 additions & 0 deletions Content.Server/Shuttles/Systems/ArrivalsSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ public override void Initialize()
SubscribeLocalEvent<ArrivalsShuttleComponent, FTLStartedEvent>(OnArrivalsFTL);
SubscribeLocalEvent<ArrivalsShuttleComponent, FTLCompletedEvent>(OnArrivalsDocked);

SubscribeLocalEvent<PlayerSpawnCompleteEvent>(SendDirections);

_pendingQuery = GetEntityQuery<PendingClockInComponent>();
_blacklistQuery = GetEntityQuery<ArrivalsBlacklistComponent>();
_mobQuery = GetEntityQuery<MobStateComponent>();
Expand Down Expand Up @@ -377,6 +379,20 @@ public void HandlePlayerSpawning(PlayerSpawningEvent ev)
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))
Expand Down
Loading