Call reload protoypes on admin changes (#13160)

* Call reload protoypes on admin changes

Fixes NPCs not working after engine change.

* Also chems

* other fixes
This commit is contained in:
metalgearsloth
2022-12-25 08:31:11 +11:00
committed by GitHub
parent a5f17a590f
commit 455939afc1
5 changed files with 30 additions and 28 deletions

View File

@@ -17,7 +17,7 @@ public sealed class GamePrototypeLoadManager : IGamePrototypeLoadManager
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly ILocalizationManager _localizationManager = default!;
private readonly List<string> LoadedPrototypes = new();
private readonly List<string> _loadedPrototypes = new();
public void Initialize()
{
@@ -30,8 +30,6 @@ public sealed class GamePrototypeLoadManager : IGamePrototypeLoadManager
}
public event Action? GamePrototypeLoaded;
private void ClientLoadsPrototype(GamePrototypeLoadMessage message)
{
var player = _playerManager.GetSessionByChannel(message.MsgChannel);
@@ -48,23 +46,28 @@ public sealed class GamePrototypeLoadManager : IGamePrototypeLoadManager
private void LoadPrototypeData(string prototypeData)
{
LoadedPrototypes.Add(prototypeData);
var msg = new GamePrototypeLoadMessage();
msg.PrototypeData = prototypeData;
_loadedPrototypes.Add(prototypeData);
var msg = new GamePrototypeLoadMessage
{
PrototypeData = prototypeData
};
_netManager.ServerSendToAll(msg); // everyone load it up!
_prototypeManager.LoadString(prototypeData, true); // server needs it too.
var changed = new Dictionary<Type, HashSet<string>>();
_prototypeManager.LoadString(prototypeData, true, changed); // server needs it too.
_prototypeManager.ResolveResults();
_prototypeManager.ReloadPrototypes(changed);
_localizationManager.ReloadLocalizations();
GamePrototypeLoaded?.Invoke();
}
private void NetManagerOnConnected(object? sender, NetChannelArgs e)
{
// Just dump all the prototypes on connect, before them missing could be an issue.
foreach (var prototype in LoadedPrototypes)
foreach (var prototype in _loadedPrototypes)
{
var msg = new GamePrototypeLoadMessage();
msg.PrototypeData = prototype;
var msg = new GamePrototypeLoadMessage
{
PrototypeData = prototype
};
e.Channel.SendMessage(msg);
}
}