mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
Shared String Dictionary ctd. (#1126)
This commit is contained in:
@@ -39,6 +39,8 @@ namespace Robust.Server.Maps
|
||||
[Dependency] private readonly IComponentManager _componentManager = default!;
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
|
||||
public event Action<YamlStream, string>? LoadedMapData;
|
||||
|
||||
/// <inheritdoc />
|
||||
public void SaveBlueprint(GridId gridId, string yamlPath)
|
||||
{
|
||||
@@ -99,6 +101,8 @@ namespace Robust.Server.Maps
|
||||
|
||||
var data = new MapData(reader);
|
||||
|
||||
LoadedMapData?.Invoke(data.Stream, resPath.ToString());
|
||||
|
||||
if (data.GridCount != 1)
|
||||
{
|
||||
throw new InvalidDataException("Cannot instance map with multiple grids as blueprint.");
|
||||
@@ -182,6 +186,8 @@ namespace Robust.Server.Maps
|
||||
|
||||
var data = new MapData(reader);
|
||||
|
||||
LoadedMapData?.Invoke(data.Stream, resPath.ToString());
|
||||
|
||||
var context = new MapContext(_mapManager, _tileDefinitionManager, _serverEntityManager, _pauseManager, _componentManager, _prototypeManager, (YamlMappingNode)data.RootNode, mapId);
|
||||
context.Deserialize();
|
||||
|
||||
@@ -849,7 +855,9 @@ namespace Robust.Server.Maps
|
||||
/// </summary>
|
||||
private class MapData
|
||||
{
|
||||
public YamlNode RootNode { get; }
|
||||
public YamlStream Stream { get; }
|
||||
|
||||
public YamlNode RootNode => Stream.Documents[0].RootNode;
|
||||
public int GridCount { get; }
|
||||
|
||||
public MapData(TextReader reader)
|
||||
@@ -869,9 +877,8 @@ namespace Robust.Server.Maps
|
||||
throw new InvalidDataException("Stream too many YAML documents. Map files store exactly one.");
|
||||
}
|
||||
|
||||
RootNode = stream.Documents[0].RootNode;
|
||||
Stream = stream;
|
||||
GridCount = ((YamlSequenceNode)RootNode["grids"]).Children.Count;
|
||||
RobustSerializer.MappedStringSerializer.AddStrings(stream, "anonymous map YAML stream");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user