Allow late join from arrivals to be considered for antagonist. (#39837)

* Allow late join from arrivals to be considered for antagonist.

* Don't use `PendingClockInComponent` to block late join antag selection, instead do an arrivals grid transform check with new helper function `IsOnArrivals`.

* Minor formatting fixes

* missing using

---------

Co-authored-by: SlamBamActionman <slambamactionman@gmail.com>
This commit is contained in:
Quantum-cross
2026-01-12 17:17:27 -05:00
committed by GitHub
parent 7f4bc8f7d1
commit d06b18a8f0
2 changed files with 38 additions and 3 deletions

View File

@@ -13,7 +13,7 @@ using Content.Server.Players.PlayTimeTracking;
using Content.Server.Preferences.Managers;
using Content.Server.Roles;
using Content.Server.Roles.Jobs;
using Content.Server.Shuttles.Components;
using Content.Server.Shuttles.Systems;
using Content.Shared.Administration.Logs;
using Content.Shared.Antag;
using Content.Shared.Clothing;
@@ -54,6 +54,7 @@ public sealed partial class AntagSelectionSystem : GameRuleSystem<AntagSelection
[Dependency] private readonly TransformSystem _transform = default!;
[Dependency] private readonly EntityWhitelistSystem _whitelist = default!;
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
[Dependency] private readonly ArrivalsSystem _arrivals = default!;
// arbitrary random number to give late joining some mild interest.
public const float LateJoinRandomChance = 0.5f;
@@ -168,6 +169,15 @@ public sealed partial class AntagSelectionSystem : GameRuleSystem<AntagSelection
if (!args.LateJoin)
return;
TryMakeLateJoinAntag(args.Player);
}
/// <summary>
/// Attempt to make this player be a late-join antag.
/// </summary>
/// <param name="session">The session to attempt to make antag.</param>
public void TryMakeLateJoinAntag(ICommonSession session)
{
// TODO: this really doesn't handle multiple latejoin definitions well
// eventually this should probably store the players per definition with some kind of unique identifier.
// something to figure out later.
@@ -197,7 +207,7 @@ public sealed partial class AntagSelectionSystem : GameRuleSystem<AntagSelection
if (!TryGetNextAvailableDefinition((uid, antag), out var def, players))
continue;
if (TryMakeAntag((uid, antag), args.Player, def.Value))
if (TryMakeAntag((uid, antag), session, def.Value))
break;
}
}
@@ -572,7 +582,7 @@ public sealed partial class AntagSelectionSystem : GameRuleSystem<AntagSelection
if (entity == null)
return true;
if (HasComp<PendingClockInComponent>(entity))
if (_arrivals.IsOnArrivals((entity.Value, null)))
return false;
if (!def.AllowNonHumans && !HasComp<HumanoidAppearanceComponent>(entity))

View File

@@ -1,6 +1,7 @@
using System.Linq;
using System.Numerics;
using Content.Server.Administration;
using Content.Server.Antag;
using Content.Server.Chat.Managers;
using Content.Server.DeviceNetwork.Systems;
using Content.Server.GameTicking;
@@ -61,6 +62,7 @@ public sealed class ArrivalsSystem : EntitySystem
[Dependency] private readonly ShuttleSystem _shuttles = default!;
[Dependency] private readonly StationSpawningSystem _stationSpawning = default!;
[Dependency] private readonly StationSystem _station = default!;
[Dependency] private readonly AntagSelectionSystem _antag = default!;
private EntityQuery<PendingClockInComponent> _pendingQuery;
private EntityQuery<ArrivalsBlacklistComponent> _blacklistQuery;
@@ -273,6 +275,9 @@ public sealed class ArrivalsSystem : EntitySystem
if (ArrivalsGodmode)
RemCompDeferred<GodmodeComponent>(pUid);
if (_actor.TryGetSession(pUid, out var session) && session is not null)
_antag.TryMakeLateJoinAntag(session);
}
}
@@ -443,6 +448,26 @@ public sealed class ArrivalsSystem : EntitySystem
return false;
}
/// <summary>
/// Check if an entity is on the arrivals grid.
/// </summary>
/// <param name="entity">Entity to check.</param>
/// <returns>True if the entity is on the arrivals grid. Returns false if not on arrivals, or there is no arrivals grid.</returns>
public bool IsOnArrivals(Entity<TransformComponent?> entity)
{
if (!Resolve(entity, ref entity.Comp))
return false;
if (!TryGetArrivals(out var arrivals))
return false;
var arrivalsGridUid = Transform(arrivals).GridUid;
if (!arrivalsGridUid.HasValue)
return false;
return entity.Comp.GridUid == Transform(arrivals).GridUid;
}
public TimeSpan? NextShuttleArrival()
{
var query = EntityQueryEnumerator<ArrivalsShuttleComponent>();