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;
[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;
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.
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;
}
}
if (entity == null)
return true;
- if (HasComp<PendingClockInComponent>(entity))
+ if (_arrivals.IsOnArrivals((entity.Value, null)))
return false;
if (!def.AllowNonHumans && !HasComp<HumanoidAppearanceComponent>(entity))
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;
[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;
if (ArrivalsGodmode)
RemCompDeferred<GodmodeComponent>(pUid);
+
+ if (_actor.TryGetSession(pUid, out var session) && session is not null)
+ _antag.TryMakeLateJoinAntag(session);
}
}
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>();