Skip to content

Commit

Permalink
Bring back the prisoner role (DeltaV-Station#511)
Browse files Browse the repository at this point in the history
* Revert "Removes Prisoner selection from maps (#262)"

This reverts commit d73f485.

* Fix alwaysUseSpawner, add DesiredSpawnPointType

Prisoners are now forced to spawn in the prison again.

* Updated map prototypes for prisoner

Yaaay, we love confinement!

* Update asterisk.yml

Add a drain to the cell area :trollface:

---------

Co-authored-by: Colin-Tel <[email protected]>
(cherry picked from commit 003f262)
  • Loading branch information
luringens authored and DebugOk committed Jan 20, 2024
1 parent 271af17 commit 9bd9369
Show file tree
Hide file tree
Showing 15 changed files with 126 additions and 78 deletions.
10 changes: 9 additions & 1 deletion Content.Server/GameTicking/GameTicker.Spawning.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,15 @@ private void SpawnPlayer(ICommonSession player, HumanoidCharacterProfile charact

_playTimeTrackings.PlayerRolesChanged(player);

var mobMaybe = _stationSpawning.SpawnPlayerCharacterOnStation(station, job, character);
// Delta-V: Add AlwaysUseSpawner.
var spawnPointType = SpawnPointType.Unset;
if (jobPrototype.AlwaysUseSpawner)
{
lateJoin = false;
spawnPointType = SpawnPointType.Job;
}

var mobMaybe = _stationSpawning.SpawnPlayerCharacterOnStation(station, job, character, spawnPointType: spawnPointType);
DebugTools.AssertNotNull(mobMaybe);
var mob = mobMaybe!.Value;

Expand Down
20 changes: 19 additions & 1 deletion Content.Server/Spawners/EntitySystems/SpawnPointSystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Content.Server.GameTicking;
using Content.Server.GameTicking;
using Content.Server.Spawners.Components;
using Content.Server.Station.Systems;
using Robust.Shared.Map;
Expand Down Expand Up @@ -32,6 +32,24 @@ private void OnSpawnPlayer(PlayerSpawningEvent args)
if (args.Station != null && _stationSystem.GetOwningStation(uid, xform) != args.Station)
continue;

// Delta-V: Allow setting a desired SpawnPointType
if (args.DesiredSpawnPointType != SpawnPointType.Unset)
{
var isMatchingJob = spawnPoint.SpawnType == SpawnPointType.Job &&
(args.Job == null || spawnPoint.Job?.ID == args.Job.Prototype);

switch (args.DesiredSpawnPointType)
{
case SpawnPointType.Job when isMatchingJob:
case SpawnPointType.LateJoin when spawnPoint.SpawnType == SpawnPointType.LateJoin:
case SpawnPointType.Observer when spawnPoint.SpawnType == SpawnPointType.Observer:
possiblePositions.Add(xform.Coordinates);
break;
default:
continue;
}
}

if (_gameTicker.RunLevel == GameRunLevel.InRound && spawnPoint.SpawnType == SpawnPointType.LateJoin)
{
possiblePositions.Add(xform.Coordinates);
Expand Down
14 changes: 11 additions & 3 deletions Content.Server/Station/Systems/StationSpawningSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Content.Server.IdentityManagement;
using Content.Server.Mind.Commands;
using Content.Server.PDA;
using Content.Server.Spawners.Components;
using Content.Server.Station.Components;
using Content.Shared.Access.Components;
using Content.Shared.Access.Systems;
Expand Down Expand Up @@ -59,17 +60,19 @@ public override void Initialize()
/// <param name="job">The job to assign, if any.</param>
/// <param name="profile">The character profile to use, if any.</param>
/// <param name="stationSpawning">Resolve pattern, the station spawning component for the station.</param>
/// <param name="spawnPointType">Delta-V: Set desired spawn point type.</param>
/// <returns>The resulting player character, if any.</returns>
/// <exception cref="ArgumentException">Thrown when the given station is not a station.</exception>
/// <remarks>
/// This only spawns the character, and does none of the mind-related setup you'd need for it to be playable.
/// </remarks>
public EntityUid? SpawnPlayerCharacterOnStation(EntityUid? station, JobComponent? job, HumanoidCharacterProfile? profile, StationSpawningComponent? stationSpawning = null)
public EntityUid? SpawnPlayerCharacterOnStation(EntityUid? station, JobComponent? job, HumanoidCharacterProfile? profile, StationSpawningComponent? stationSpawning = null, SpawnPointType spawnPointType = SpawnPointType.Unset)
{
if (station != null && !Resolve(station.Value, ref stationSpawning))
throw new ArgumentException("Tried to use a non-station entity as a station!", nameof(station));

var ev = new PlayerSpawningEvent(job, profile, station);
// Delta-V: Set desired spawn point type.
var ev = new PlayerSpawningEvent(job, profile, station, spawnPointType);
RaiseLocalEvent(ev);

DebugTools.Assert(ev.SpawnResult is { Valid: true } or null);
Expand Down Expand Up @@ -235,11 +238,16 @@ public sealed class PlayerSpawningEvent : EntityEventArgs
/// The target station, if any.
/// </summary>
public readonly EntityUid? Station;
/// <summary>
/// Delta-V: Desired SpawnPointType, if any.
/// </summary>
public readonly SpawnPointType DesiredSpawnPointType;

public PlayerSpawningEvent(JobComponent? job, HumanoidCharacterProfile? humanoidCharacterProfile, EntityUid? station)
public PlayerSpawningEvent(JobComponent? job, HumanoidCharacterProfile? humanoidCharacterProfile, EntityUid? station, SpawnPointType spawnPointType = SpawnPointType.Unset)
{
Job = job;
HumanoidCharacterProfile = humanoidCharacterProfile;
Station = station;
DesiredSpawnPointType = spawnPointType;
}
}
6 changes: 6 additions & 0 deletions Content.Shared/Roles/JobPrototype.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ public sealed partial class JobPrototype : IPrototype
[DataField("canBeAntag")]
public bool CanBeAntag { get; private set; } = true;

/// <summary>
/// Nyano/DV: For e.g. prisoners, they'll never use their latejoin spawner.
/// </summary>
[DataField("alwaysUseSpawner")]
public bool AlwaysUseSpawner { get; } = false;

/// <summary>
/// Whether this job is a head.
/// The job system will try to pick heads before other jobs on the same priority level.
Expand Down
Loading

0 comments on commit 9bd9369

Please sign in to comment.