Misc replay related changes (#13250)
This commit is contained in:
@@ -3,6 +3,8 @@ using Content.Shared.Administration;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Replays;
|
||||
using Robust.Shared.Serialization.Markdown.Mapping;
|
||||
|
||||
namespace Content.Server.Administration;
|
||||
|
||||
@@ -11,6 +13,7 @@ namespace Content.Server.Administration;
|
||||
/// </summary>
|
||||
public sealed class GamePrototypeLoadManager : IGamePrototypeLoadManager
|
||||
{
|
||||
[Dependency] private readonly IReplayRecordingManager _replay = default!;
|
||||
[Dependency] private readonly IServerNetManager _netManager = default!;
|
||||
[Dependency] private readonly IAdminManager _adminManager = default!;
|
||||
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
||||
@@ -18,11 +21,22 @@ public sealed class GamePrototypeLoadManager : IGamePrototypeLoadManager
|
||||
[Dependency] private readonly ILocalizationManager _localizationManager = default!;
|
||||
|
||||
private readonly List<string> _loadedPrototypes = new();
|
||||
public IReadOnlyList<string> LoadedPrototypes => _loadedPrototypes;
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
_netManager.RegisterNetMessage<GamePrototypeLoadMessage>(ClientLoadsPrototype);
|
||||
_netManager.Connected += NetManagerOnConnected;
|
||||
_replay.OnRecordingStarted += OnStartReplayRecording;
|
||||
}
|
||||
|
||||
private void OnStartReplayRecording((MappingDataNode, List<object>) initReplayData)
|
||||
{
|
||||
// replays will need information about currently loaded prototypes
|
||||
foreach (var prototype in _loadedPrototypes)
|
||||
{
|
||||
initReplayData.Item2.Add(new ReplayPrototypeUploadMsg { PrototypeData = prototype });
|
||||
}
|
||||
}
|
||||
|
||||
public void SendGamePrototype(string prototype)
|
||||
@@ -47,6 +61,9 @@ public sealed class GamePrototypeLoadManager : IGamePrototypeLoadManager
|
||||
private void LoadPrototypeData(string prototypeData)
|
||||
{
|
||||
_loadedPrototypes.Add(prototypeData);
|
||||
|
||||
_replay.QueueReplayMessage(new ReplayPrototypeUploadMsg { PrototypeData = prototypeData });
|
||||
|
||||
var msg = new GamePrototypeLoadMessage
|
||||
{
|
||||
PrototypeData = prototypeData
|
||||
|
||||
Reference in New Issue
Block a user