Play time tracking: Job timers 3: more titles: when the (#9978)

Co-authored-by: Veritius <veritiusgaming@gmail.com>
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
Pieter-Jan Briers
2022-08-07 08:00:42 +02:00
committed by GitHub
parent 6b94db0336
commit e852ada6c8
91 changed files with 5044 additions and 247 deletions

View File

@@ -3,7 +3,6 @@ using System.Linq;
using Content.Server.Ghost;
using Content.Server.Ghost.Components;
using Content.Server.Players;
using Content.Server.Roles;
using Content.Server.Spawners.Components;
using Content.Server.Speech.Components;
using Content.Server.Station.Components;
@@ -18,6 +17,7 @@ using Robust.Shared.Map;
using Robust.Shared.Network;
using Robust.Shared.Random;
using Robust.Shared.Utility;
using Job = Content.Server.Roles.Job;
namespace Content.Server.GameTicking
{
@@ -92,7 +92,10 @@ namespace Content.Server.GameTicking
var character = GetPlayerProfile(player);
var jobBans = _roleBanManager.GetJobBans(player.UserId);
if (jobBans == null || (jobId != null && jobBans.Contains(jobId)))
if (jobBans == null || jobId != null && jobBans.Contains(jobId))
return;
if (jobId != null && !_playTimeTrackings.IsAllowed(player, jobId))
return;
SpawnPlayer(player, character, station, jobId, lateJoin);
}
@@ -130,9 +133,18 @@ namespace Content.Server.GameTicking
return;
}
// Figure out job restrictions
var restrictedRoles = new HashSet<string>();
var getDisallowed = _playTimeTrackings.GetDisallowedJobs(player);
restrictedRoles.UnionWith(getDisallowed);
var jobBans = _roleBanManager.GetJobBans(player.UserId);
if(jobBans != null) restrictedRoles.UnionWith(jobBans);
// Pick best job best on prefs.
jobId ??= _stationJobs.PickBestAvailableJobWithPriority(station, character.JobPriorities, true,
_roleBanManager.GetJobBans(player.UserId));
restrictedRoles);
// If no job available, stay in lobby, or if no lobby spawn as observer
if (jobId is null)
{
@@ -161,6 +173,8 @@ namespace Content.Server.GameTicking
var job = new Job(newMind, jobPrototype);
newMind.AddRole(job);
_playTimeTrackings.PlayerRolesChanged(player);
if (lateJoin)
{
_chatSystem.DispatchStationAnnouncement(station,
@@ -217,12 +231,11 @@ namespace Content.Server.GameTicking
public void MakeJoinGame(IPlayerSession player, EntityUid station, string? jobId = null)
{
if (!_playersInLobby.ContainsKey(player)) return;
if (!_prefsManager.HavePreferencesLoaded(player))
{
if (!_playersInLobby.ContainsKey(player))
return;
if (!_userDb.IsLoadComplete(player))
return;
}
SpawnPlayer(player, station, jobId);
}