Mid-game prototype loading for game admins (#5675)

This commit is contained in:
Moony
2021-12-11 17:28:16 -06:00
committed by GitHub
parent 5abb3cdc36
commit caad34eecb
12 changed files with 186 additions and 4 deletions

View File

@@ -0,0 +1,25 @@
using System;
using Lidgren.Network;
using Robust.Shared.Network;
using Robust.Shared.Serialization;
namespace Content.Shared.Administration;
[NetSerializable]
[Serializable]
public class GamePrototypeLoadMessage : NetMessage
{
public override MsgGroups MsgGroup => MsgGroups.String;
public string PrototypeData { get; set; } = string.Empty;
public override void ReadFromBuffer(NetIncomingMessage buffer)
{
PrototypeData = buffer.ReadString();
}
public override void WriteToBuffer(NetOutgoingMessage buffer)
{
buffer.Write(PrototypeData);
}
}

View File

@@ -0,0 +1,11 @@
using System;
namespace Content.Shared.Administration;
public interface IGamePrototypeLoadManager
{
public void Initialize();
public void SendGamePrototype(string prototype);
event Action GamePrototypeLoaded;
}

View File

@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using Content.Shared.Administration;
using Content.Shared.Administration.Logs;
using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.Reagent;
@@ -24,6 +25,7 @@ namespace Content.Shared.Chemistry.Reaction
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] protected readonly SharedAdminLogSystem _logSystem = default!;
[Dependency] private readonly IGamePrototypeLoadManager _gamePrototypeLoadManager = default!;
/// <summary>
/// A cache of all existant chemical reactions indexed by one of their
@@ -37,6 +39,7 @@ namespace Content.Shared.Chemistry.Reaction
InitializeReactionCache();
_prototypeManager.PrototypesReloaded += OnPrototypesReloaded;
_gamePrototypeLoadManager.GamePrototypeLoaded += InitializeReactionCache;
}
/// <summary>