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:
committed by
GitHub
parent
6b94db0336
commit
e852ada6c8
@@ -123,12 +123,11 @@ namespace Content.Server.GameTicking
|
||||
|
||||
public void ToggleReady(IPlayerSession player, bool ready)
|
||||
{
|
||||
if (!_playersInLobby.ContainsKey(player)) return;
|
||||
|
||||
if (!_prefsManager.HavePreferencesLoaded(player))
|
||||
{
|
||||
if (!_playersInLobby.ContainsKey(player))
|
||||
return;
|
||||
|
||||
if (!_userDb.IsLoadComplete(player))
|
||||
return;
|
||||
}
|
||||
|
||||
var status = ready ? LobbyPlayerStatus.Ready : LobbyPlayerStatus.NotReady;
|
||||
_playersInLobby[player] = ready ? LobbyPlayerStatus.Ready : LobbyPlayerStatus.NotReady;
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace Content.Server.GameTicking
|
||||
|
||||
case SessionStatus.InGame:
|
||||
{
|
||||
_prefsManager.OnClientConnected(session);
|
||||
_userDb.ClientConnected(session);
|
||||
|
||||
var data = session.ContentData();
|
||||
|
||||
@@ -66,13 +66,13 @@ namespace Content.Server.GameTicking
|
||||
}
|
||||
|
||||
|
||||
SpawnWaitPrefs();
|
||||
SpawnWaitDb();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (data.Mind.CurrentEntity == null)
|
||||
{
|
||||
SpawnWaitPrefs();
|
||||
SpawnWaitDb();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -90,16 +90,16 @@ namespace Content.Server.GameTicking
|
||||
|
||||
_chatManager.SendAdminAnnouncement(Loc.GetString("player-leave-message", ("name", args.Session.Name)));
|
||||
|
||||
_prefsManager.OnClientDisconnected(session);
|
||||
_userDb.ClientDisconnected(session);
|
||||
break;
|
||||
}
|
||||
}
|
||||
//When the status of a player changes, update the server info text
|
||||
UpdateInfoText();
|
||||
|
||||
async void SpawnWaitPrefs()
|
||||
async void SpawnWaitDb()
|
||||
{
|
||||
await _prefsManager.WaitPreferencesLoaded(session);
|
||||
await _userDb.WaitLoadComplete(session);
|
||||
SpawnPlayer(session, EntityUid.Invalid);
|
||||
}
|
||||
|
||||
|
||||
@@ -177,6 +177,13 @@ namespace Content.Server.GameTicking
|
||||
readyPlayers = _playersInLobby.Keys.ToList();
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
foreach (var player in readyPlayers)
|
||||
{
|
||||
DebugTools.Assert(_userDb.IsLoadComplete(player), $"Player was readied up but didn't have user DB data loaded yet??");
|
||||
}
|
||||
#endif
|
||||
|
||||
readyPlayers.RemoveAll(p =>
|
||||
{
|
||||
if (_roleBanManager.GetRoleBans(p.UserId) != null)
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ using Content.Server.Chat.Systems;
|
||||
using Content.Server.Database;
|
||||
using Content.Server.Ghost;
|
||||
using Content.Server.Maps;
|
||||
using Content.Server.Players.PlayTimeTracking;
|
||||
using Content.Server.Preferences.Managers;
|
||||
using Content.Server.ServerUpdates;
|
||||
using Content.Server.Station.Systems;
|
||||
@@ -118,5 +119,7 @@ namespace Content.Server.GameTicking
|
||||
[Dependency] private readonly RoleBanManager _roleBanManager = default!;
|
||||
[Dependency] private readonly ChatSystem _chatSystem = default!;
|
||||
[Dependency] private readonly ServerUpdateManager _serverUpdates = default!;
|
||||
[Dependency] private readonly PlayTimeTrackingSystem _playTimeTrackings = default!;
|
||||
[Dependency] private readonly UserDbDataManager _userDb = default!;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user