Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some Late Join Fixing #1154

Merged
merged 3 commits into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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.Server.Containers;
Expand All @@ -20,6 +20,10 @@ public void HandlePlayerSpawning(PlayerSpawningEvent args)
if (args.SpawnResult != null)
return;

// DeltaV - Ignore these two desired spawn types
if (args.DesiredSpawnPointType is SpawnPointType.Observer or SpawnPointType.LateJoin)
return;

var query = EntityQueryEnumerator<ContainerSpawnPointComponent, ContainerManagerComponent, TransformComponent>();
var possibleContainers = new List<Entity<ContainerSpawnPointComponent, ContainerManagerComponent, TransformComponent>>();

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 OnPlayerSpawning(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 @@ -26,6 +26,7 @@
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Utility;
using Content.Server.Spawners.Components; // DeltaV

namespace Content.Server.Station.Systems;

Expand Down Expand Up @@ -72,17 +73,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);

if (station != null && profile != null)
{
Expand Down Expand Up @@ -276,11 +279,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 @@ -67,6 +67,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
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
name: job-name-mail-carrier
description: job-name-mail-carrier
startingGear: MailCarrierGear
alwaysUseSpawner: true
playTimeTracker: JobMailCarrier
requirements:
- !type:OverallPlaytimeRequirement
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- !type:OverallPlaytimeRequirement
time: 10800
startingGear: ValetGear
alwaysUseSpawner: true
icon: "JobIconServiceWorker"
supervisors: job-supervisors-everyone
access:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
requirements:
- !type:WhitelistRequirement
startingGear: PrisonerGear
# alwaysUseSpawner: true
canBeAntag: false
whitelistRequired: true
icon: "JobIconPrisoner"
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Roles/Jobs/Civilian/janitor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- !type:OverallPlaytimeRequirement
time: 10800
startingGear: JanitorGear
alwaysUseSpawner: true
icon: "JobIconJanitor"
supervisors: job-supervisors-hop
access:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- !type:WhitelistRequirement
weight: 20
startingGear: HoPGear
alwaysUseSpawner: true
icon: "JobIconHeadOfPersonnel"
requireAdminNotify: true
supervisors: job-supervisors-centcom # Frontier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
# time: 108000 # 30 hrs
weight: 10
startingGear: HoSGear
alwaysUseSpawner: true
icon: "JobIconHeadOfSecurity"
requireAdminNotify: true
supervisors: job-supervisors-hop # Frontier
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/_NF/Roles/Jobs/Command/stc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
description: job-description-stc
playTimeTracker: JobStc
startingGear: StcGear
alwaysUseSpawner: true
requirements:
- !type:OverallPlaytimeRequirement
time: 72000 # 20 hrs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- !type:OverallPlaytimeRequirement
time: 36000 # Frontier - 10 hrs
startingGear: SecurityGuardGear
alwaysUseSpawner: true
icon: "JobIconSecurityGuard"
supervisors: job-supervisors-hop # not hos
canBeAntag: false
Expand Down
Loading