mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
Expose more net serializer stuff to content (#3476)
This commit is contained in:
@@ -5,7 +5,6 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Reflection;
|
||||
@@ -13,11 +12,10 @@ using Robust.Shared.Utility;
|
||||
|
||||
namespace Robust.Shared.Serialization
|
||||
{
|
||||
|
||||
public sealed partial class RobustSerializer : IRobustSerializer
|
||||
internal abstract partial class RobustSerializer : IRobustSerializer
|
||||
{
|
||||
[Dependency] private readonly IReflectionManager _reflectionManager = default!;
|
||||
[Dependency] private readonly IRobustMappedStringSerializer _mappedStringSerializer = default!;
|
||||
[Dependency] protected readonly IRobustMappedStringSerializer MappedStringSerializer = default!;
|
||||
[Dependency] private readonly ILogManager _logManager = default!;
|
||||
|
||||
private readonly Dictionary<Type, Dictionary<string, Type?>> _cachedSerialized = new();
|
||||
@@ -78,11 +76,11 @@ namespace Robust.Shared.Serialization
|
||||
LogSzr = _logManager.GetSawmill("szr");
|
||||
types.AddRange(AlwaysNetSerializable);
|
||||
|
||||
_mappedStringSerializer.Initialize();
|
||||
MappedStringSerializer.Initialize();
|
||||
|
||||
var settings = new Settings
|
||||
{
|
||||
CustomTypeSerializers = new[] {_mappedStringSerializer.TypeSerializer}
|
||||
CustomTypeSerializers = new[] {MappedStringSerializer.TypeSerializer}
|
||||
};
|
||||
_serializer = new Serializer(types, settings);
|
||||
_serializableTypes = new HashSet<Type>(_serializer.GetTypeMap().Keys);
|
||||
@@ -95,6 +93,10 @@ namespace Robust.Shared.Serialization
|
||||
*/
|
||||
}
|
||||
|
||||
public byte[] GetSerializableTypesHash() => Convert.FromHexString(_serializer.GetSHA256());
|
||||
|
||||
public (byte[] Hash, byte[] Package) GetStringSerializerPackage() => MappedStringSerializer.GeneratePackage();
|
||||
|
||||
public void Serialize(Stream stream, object toSerialize)
|
||||
{
|
||||
var start = stream.Position;
|
||||
|
||||
Reference in New Issue
Block a user