Mid-game prototype loading for game admins (#5675)
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using Content.Shared.Administration;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Client.Administration.Managers;
|
||||
|
||||
public class GamePrototypeLoadManager : IGamePrototypeLoadManager
|
||||
{
|
||||
[Dependency] private readonly IClientNetManager _netManager = default!;
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
[Dependency] private readonly ILocalizationManager _localizationManager = default!;
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
_netManager.RegisterNetMessage<GamePrototypeLoadMessage>(LoadGamePrototype);
|
||||
}
|
||||
|
||||
private void LoadGamePrototype(GamePrototypeLoadMessage message)
|
||||
{
|
||||
_prototypeManager.LoadString(message.PrototypeData);
|
||||
_prototypeManager.Resync();
|
||||
_localizationManager.ReloadLocalizations();
|
||||
GamePrototypeLoaded?.Invoke();
|
||||
Logger.InfoS("adminbus", "Loaded adminbus prototype data.");
|
||||
}
|
||||
|
||||
public void SendGamePrototype(string prototype)
|
||||
{
|
||||
var msg = _netManager.CreateNetMessage<GamePrototypeLoadMessage>();
|
||||
msg.PrototypeData = prototype;
|
||||
_netManager.ClientSendMessage(msg);
|
||||
}
|
||||
|
||||
public event Action? GamePrototypeLoaded;
|
||||
}
|
||||
Reference in New Issue
Block a user