* Partial work on StationSystem refactor. * WIP station jobs API. * forgor to fire off grid events. * Partial implementation of StationSpawningSystem * whoops infinite loop. * Spawners should work now. * it compiles. * tfw * Vestigial code cleanup. * fix station deletion. * attempt to make tests go brr * add latejoin spawnpoints to test maps. * make sure the station still exists while destructing spawners. * forgot an exists check. * destruction order check. * hopefully fix final test. * fail-safe radstorm. * Deep-clean job code further. This is bugged!!!!! * Fix job bug. (init order moment) * whooo cleanup * New job selection algorithm that tries to distribute fairly across stations. * small nitpicks * Give the heads their weights to replace the head field. * make overflow assign take a station list. * moment * Fixes and test #1 of many. * please fix nullspace * AssignJobs should no longer even consider showing up on a trace. * add comment. * Introduce station configs, praying i didn't miss something. * in one small change stations are now fully serializable. * Further doc comments. * whoops. * Solve bug where assignjobs didn't account for roundstart. * Fix spawning, improve the API. Caught an oversight in stationsystem that should've broke everything but didn't, whoops. * Goodbye JobController. * minor fix.. * fix test fail, remove debug logs. * quick serialization fixes. * fixes.. * sus * partialing * Update Content.Server/Station/Systems/StationJobsSystem.Roundstart.cs Co-authored-by: Kara <lunarautomaton6@gmail.com> * Use dirtying to avoid rebuilding the list 2,100 times. * add a bajillion more lines of docs (mostly in AssignJobs so i don't ever forget how it works) * Update Content.IntegrationTests/Tests/Station/StationJobsTest.cs Co-authored-by: Kara <lunarautomaton6@gmail.com> * Add the Mysteriously Missing Captain Check. * Put maprender back the way it belongs. * I love addressing reviews. * Update Content.Server/Station/Systems/StationJobsSystem.cs Co-authored-by: Kara <lunarautomaton6@gmail.com> * doc cleanup. * Fix bureaucratic error, add job slot tests. * zero cost abstractions when * cri * saner error. * Fix spawning failing certain tests due to gameticker not handling falliability correctly. Can't fix this until I refactor the rest of spawning code. * submodule gaming * Packedenger. * Documentation consistency. Co-authored-by: Kara <lunarautomaton6@gmail.com>
129 lines
5.1 KiB
C#
129 lines
5.1 KiB
C#
using Content.Client.Lobby;
|
|
using Content.Client.RoundEnd;
|
|
using Content.Client.Viewport;
|
|
using Content.Shared.GameTicking;
|
|
using Content.Shared.GameWindow;
|
|
using JetBrains.Annotations;
|
|
using Robust.Client.Graphics;
|
|
using Robust.Client.State;
|
|
using Robust.Shared.Network;
|
|
using Robust.Shared.Utility;
|
|
|
|
namespace Content.Client.GameTicking.Managers
|
|
{
|
|
[UsedImplicitly]
|
|
public sealed class ClientGameTicker : SharedGameTicker
|
|
{
|
|
[Dependency] private readonly IStateManager _stateManager = default!;
|
|
[ViewVariables] private bool _initialized;
|
|
private Dictionary<EntityUid, Dictionary<string, uint?>> _jobsAvailable = new();
|
|
private Dictionary<EntityUid, string> _stationNames = new();
|
|
|
|
[ViewVariables] public bool AreWeReady { get; private set; }
|
|
[ViewVariables] public bool IsGameStarted { get; private set; }
|
|
[ViewVariables] public string? LobbySong { get; private set; }
|
|
[ViewVariables] public string? LobbyBackground { get; private set; }
|
|
[ViewVariables] public bool DisallowedLateJoin { get; private set; }
|
|
[ViewVariables] public string? ServerInfoBlob { get; private set; }
|
|
[ViewVariables] public TimeSpan StartTime { get; private set; }
|
|
[ViewVariables] public new bool Paused { get; private set; }
|
|
[ViewVariables] public Dictionary<NetUserId, LobbyPlayerStatus> Status { get; private set; } = new();
|
|
[ViewVariables] public IReadOnlyDictionary<EntityUid, Dictionary<string, uint?>> JobsAvailable => _jobsAvailable;
|
|
[ViewVariables] public IReadOnlyDictionary<EntityUid, string> StationNames => _stationNames;
|
|
|
|
public event Action? InfoBlobUpdated;
|
|
public event Action? LobbyStatusUpdated;
|
|
public event Action? LobbyReadyUpdated;
|
|
public event Action? LobbyLateJoinStatusUpdated;
|
|
public event Action<IReadOnlyDictionary<EntityUid, Dictionary<string, uint?>>>? LobbyJobsAvailableUpdated;
|
|
|
|
public override void Initialize()
|
|
{
|
|
DebugTools.Assert(!_initialized);
|
|
|
|
SubscribeNetworkEvent<TickerJoinLobbyEvent>(JoinLobby);
|
|
SubscribeNetworkEvent<TickerJoinGameEvent>(JoinGame);
|
|
SubscribeNetworkEvent<TickerLobbyStatusEvent>(LobbyStatus);
|
|
SubscribeNetworkEvent<TickerLobbyInfoEvent>(LobbyInfo);
|
|
SubscribeNetworkEvent<TickerLobbyCountdownEvent>(LobbyCountdown);
|
|
SubscribeNetworkEvent<TickerLobbyReadyEvent>(LobbyReady);
|
|
SubscribeNetworkEvent<RoundEndMessageEvent>(RoundEnd);
|
|
SubscribeNetworkEvent<RequestWindowAttentionEvent>(msg =>
|
|
{
|
|
IoCManager.Resolve<IClyde>().RequestWindowAttention();
|
|
});
|
|
SubscribeNetworkEvent<TickerLateJoinStatusEvent>(LateJoinStatus);
|
|
SubscribeNetworkEvent<TickerJobsAvailableEvent>(UpdateJobsAvailable);
|
|
|
|
Status = new Dictionary<NetUserId, LobbyPlayerStatus>();
|
|
_initialized = true;
|
|
}
|
|
|
|
private void LateJoinStatus(TickerLateJoinStatusEvent message)
|
|
{
|
|
DisallowedLateJoin = message.Disallowed;
|
|
LobbyLateJoinStatusUpdated?.Invoke();
|
|
}
|
|
|
|
private void UpdateJobsAvailable(TickerJobsAvailableEvent message)
|
|
{
|
|
_jobsAvailable = message.JobsAvailableByStation;
|
|
_stationNames = message.StationNames;
|
|
LobbyJobsAvailableUpdated?.Invoke(JobsAvailable);
|
|
}
|
|
|
|
private void JoinLobby(TickerJoinLobbyEvent message)
|
|
{
|
|
_stateManager.RequestStateChange<LobbyState>();
|
|
}
|
|
|
|
private void LobbyStatus(TickerLobbyStatusEvent message)
|
|
{
|
|
StartTime = message.StartTime;
|
|
IsGameStarted = message.IsRoundStarted;
|
|
AreWeReady = message.YouAreReady;
|
|
LobbySong = message.LobbySong;
|
|
LobbyBackground = message.LobbyBackground;
|
|
Paused = message.Paused;
|
|
if (IsGameStarted)
|
|
Status.Clear();
|
|
|
|
LobbyStatusUpdated?.Invoke();
|
|
}
|
|
|
|
private void LobbyInfo(TickerLobbyInfoEvent message)
|
|
{
|
|
ServerInfoBlob = message.TextBlob;
|
|
|
|
InfoBlobUpdated?.Invoke();
|
|
}
|
|
|
|
private void JoinGame(TickerJoinGameEvent message)
|
|
{
|
|
_stateManager.RequestStateChange<GameScreen>();
|
|
}
|
|
|
|
private void LobbyCountdown(TickerLobbyCountdownEvent message)
|
|
{
|
|
StartTime = message.StartTime;
|
|
Paused = message.Paused;
|
|
}
|
|
|
|
private void LobbyReady(TickerLobbyReadyEvent message)
|
|
{
|
|
// Merge the Dictionaries
|
|
foreach (var p in message.Status)
|
|
{
|
|
Status[p.Key] = p.Value;
|
|
}
|
|
LobbyReadyUpdated?.Invoke();
|
|
}
|
|
|
|
private void RoundEnd(RoundEndMessageEvent message)
|
|
{
|
|
//This is not ideal at all, but I don't see an immediately better fit anywhere else.
|
|
var roundEnd = new RoundEndSummaryWindow(message.GamemodeTitle, message.RoundEndText, message.RoundDuration, message.RoundId, message.AllPlayersEndInfo);
|
|
}
|
|
}
|
|
}
|