var jobs = new HashSet<ProtoId<JobPrototype>>(comp.SetupAvailableJobs.Keys);
var spawnPoints = entManager.EntityQuery<SpawnPointComponent>()
- .Where(x => x.SpawnType == SpawnPointType.Job)
- .Select(x => x.Job!.Value);
+ .Where(x => x.SpawnType == SpawnPointType.Job && x.Job != null)
+ .Select(x => x.Job.Value);
jobs.ExceptWith(spawnPoints);
spawnPoints = entManager.EntityQuery<ContainerSpawnPointComponent>()
- .Where(x => x.SpawnType == SpawnPointType.Job)
- .Select(x => x.Job!.Value);
+ .Where(x => x.SpawnType is SpawnPointType.Job or SpawnPointType.Unset && x.Job != null)
+ .Select(x => x.Job.Value);
jobs.ExceptWith(spawnPoints);
using Content.Server.Shuttles.Components;
using Content.Server.Shuttles.Events;
using Content.Server.Spawners.Components;
+using Content.Server.Spawners.EntitySystems;
using Content.Server.Station.Components;
using Content.Server.Station.Events;
using Content.Server.Station.Systems;
/// </summary>
public bool Enabled { get; private set; }
- /// <summary>
- /// Flags if all players must arrive via the Arrivals system, or if they can spawn in other ways.
- /// </summary>
- public bool Forced { get; private set; }
-
/// <summary>
/// Flags if all players spawning at the departure terminal have godmode until they leave the terminal.
/// </summary>
{
base.Initialize();
+ SubscribeLocalEvent<PlayerSpawningEvent>(HandlePlayerSpawning, before: new []{ typeof(ContainerSpawnPointSystem), typeof(SpawnPointSystem)});
+
SubscribeLocalEvent<StationArrivalsComponent, StationPostInitEvent>(OnStationPostInit);
SubscribeLocalEvent<ArrivalsShuttleComponent, ComponentStartup>(OnShuttleStartup);
// Don't invoke immediately as it will get set in the natural course of things.
Enabled = _cfgManager.GetCVar(CCVars.ArrivalsShuttles);
- Forced = _cfgManager.GetCVar(CCVars.ForceArrivals);
ArrivalsGodmode = _cfgManager.GetCVar(CCVars.GodmodeArrivals);
_cfgManager.OnValueChanged(CCVars.ArrivalsShuttles, SetArrivals);
- _cfgManager.OnValueChanged(CCVars.ForceArrivals, b => Forced = b);
_cfgManager.OnValueChanged(CCVars.GodmodeArrivals, b => ArrivalsGodmode = b);
// Command so admins can set these for funsies
return;
// Only works on latejoin even if enabled.
- if (!Enabled || !Forced && _ticker.RunLevel != GameRunLevel.InRound)
+ if (!Enabled || _ticker.RunLevel != GameRunLevel.InRound)
return;
if (!HasComp<StationArrivalsComponent>(ev.Station))
[Dependency] private readonly StationSystem _station = default!;
[Dependency] private readonly StationSpawningSystem _stationSpawning = default!;
+ public override void Initialize()
+ {
+ base.Initialize();
+ SubscribeLocalEvent<PlayerSpawningEvent>(HandlePlayerSpawning, before: new []{ typeof(SpawnPointSystem) });
+ }
+
public void HandlePlayerSpawning(PlayerSpawningEvent args)
{
if (args.SpawnResult != null)
private bool _randomizeCharacters;
- private Dictionary<SpawnPriorityPreference, Action<PlayerSpawningEvent>> _spawnerCallbacks = new();
-
/// <inheritdoc/>
public override void Initialize()
{
base.Initialize();
Subs.CVar(_configurationManager, CCVars.ICRandomCharacters, e => _randomizeCharacters = e, true);
-
- _spawnerCallbacks = new Dictionary<SpawnPriorityPreference, Action<PlayerSpawningEvent>>()
- {
- { SpawnPriorityPreference.Arrivals, _arrivalsSystem.HandlePlayerSpawning },
- {
- SpawnPriorityPreference.Cryosleep, ev =>
- {
- if (_arrivalsSystem.Forced)
- _arrivalsSystem.HandlePlayerSpawning(ev);
- else
- _containerSpawnPointSystem.HandlePlayerSpawning(ev);
- }
- }
- };
}
/// <summary>
var ev = new PlayerSpawningEvent(job, profile, station);
- if (station != null && profile != null)
- {
- // Try to call the character's preferred spawner first.
- if (_spawnerCallbacks.TryGetValue(profile.SpawnPriority, out var preferredSpawner))
- {
- preferredSpawner(ev);
-
- foreach (var (key, remainingSpawner) in _spawnerCallbacks)
- {
- if (key == profile.SpawnPriority)
- continue;
-
- remainingSpawner(ev);
- }
- }
- else
- {
- // Call all of them in the typical order.
- foreach (var typicalSpawner in _spawnerCallbacks.Values)
- {
- typicalSpawner(ev);
- }
- }
- }
-
RaiseLocalEvent(ev);
-
DebugTools.Assert(ev.SpawnResult is { Valid: true } or null);
return ev.SpawnResult;
public static readonly CVarDef<bool> ArrivalsReturns =
CVarDef.Create("shuttle.arrivals_returns", false, CVar.SERVERONLY);
- /// <summary>
- /// Should all players be forced to spawn at departures, even on roundstart, even if their loadout says they spawn in cryo?
- /// </summary>
- public static readonly CVarDef<bool> ForceArrivals =
- CVarDef.Create("shuttle.force_arrivals", false, CVar.SERVERONLY);
-
/// <summary>
/// Should all players who spawn at arrivals have godmode until they leave the map?
/// </summary>
suffix: Job spawn
components:
- type: ContainerSpawnPoint
- spawnType: Job
containerId: station_ai_mind_slot
job: StationAi
- type: Sprite