using Content.Server.Station.Systems;
using Content.Shared.Administration;
using Content.Shared.CCVar;
+using Content.Shared.Damage.Components;
using Content.Shared.DeviceNetwork;
using Content.Shared.Mobs.Components;
using Content.Shared.Movement.Components;
/// </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>
+ public bool ArrivalsGodmode { get; private set; }
+
/// <summary>
/// The first arrival is a little early, to save everyone 10s
/// </summary>
// Don't invoke immediately as it will get set in the natural course of things.
Enabled = _cfgManager.GetCVar(CCVars.ArrivalsShuttles);
- Subs.CVar(_cfgManager, CCVars.ArrivalsShuttles, SetArrivals);
+ 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
_console.RegisterCommand("arrivals", ArrivalsCommand, ArrivalsCompletion);
// The player has successfully left arrivals and is also not on the shuttle. Remove their warp coupon.
RemCompDeferred<PendingClockInComponent>(pUid);
RemCompDeferred<AutoOrientComponent>(pUid);
+
+ if (ArrivalsGodmode)
+ RemCompDeferred<GodmodeComponent>(pUid);
}
}
return;
// Only works on latejoin even if enabled.
- if (!Enabled || _ticker.RunLevel != GameRunLevel.InRound)
+ if (!Enabled || !Forced && _ticker.RunLevel != GameRunLevel.InRound)
return;
if (!HasComp<StationArrivalsComponent>(ev.Station))
TryGetArrivals(out var arrivals);
- if (TryComp(arrivals, out TransformComponent? arrivalsXform))
- {
- var mapId = arrivalsXform.MapID;
+ if (!TryComp(arrivals, out TransformComponent? arrivalsXform))
+ return;
- var points = EntityQueryEnumerator<SpawnPointComponent, TransformComponent>();
- var possiblePositions = new List<EntityCoordinates>();
- while (points.MoveNext(out var uid, out var spawnPoint, out var xform))
- {
- if (spawnPoint.SpawnType != SpawnPointType.LateJoin || xform.MapID != mapId)
- continue;
+ var mapId = arrivalsXform.MapID;
- possiblePositions.Add(xform.Coordinates);
- }
+ var points = EntityQueryEnumerator<SpawnPointComponent, TransformComponent>();
+ var possiblePositions = new List<EntityCoordinates>();
+ while (points.MoveNext(out var uid, out var spawnPoint, out var xform))
+ {
+ if (spawnPoint.SpawnType != SpawnPointType.LateJoin || xform.MapID != mapId)
+ continue;
- if (possiblePositions.Count > 0)
- {
- var spawnLoc = _random.Pick(possiblePositions);
- ev.SpawnResult = _stationSpawning.SpawnPlayerMob(
- spawnLoc,
- ev.Job,
- ev.HumanoidCharacterProfile,
- ev.Station);
-
- EnsureComp<PendingClockInComponent>(ev.SpawnResult.Value);
- EnsureComp<AutoOrientComponent>(ev.SpawnResult.Value);
- }
+ possiblePositions.Add(xform.Coordinates);
}
+
+ if (possiblePositions.Count <= 0)
+ return;
+
+ var spawnLoc = _random.Pick(possiblePositions);
+ ev.SpawnResult = _stationSpawning.SpawnPlayerMob(
+ spawnLoc,
+ ev.Job,
+ ev.HumanoidCharacterProfile,
+ ev.Station);
+
+ EnsureComp<PendingClockInComponent>(ev.SpawnResult.Value);
+ EnsureComp<AutoOrientComponent>(ev.SpawnResult.Value);
+
+ // If you're forced to spawn, you're invincible until you leave wherever you were forced to spawn.
+ if (ArrivalsGodmode)
+ EnsureComp<GodmodeComponent>(ev.SpawnResult.Value);
}
private bool TryTeleportToMapSpawn(EntityUid player, EntityUid stationId, TransformComponent? transform = null)