mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-09-16 07:12:27 +02:00
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
50 lines
1.5 KiB
C#
50 lines
1.5 KiB
C#
using Robust.Shared.Serialization.Manager.Definition;
|
|
|
|
namespace Robust.Shared.Serialization.Manager.Result
|
|
{
|
|
public sealed class DeserializedFieldEntry
|
|
{
|
|
public DeserializedFieldEntry(bool mapped, InheritanceBehavior inheritanceBehavior, DeserializationResult? result = null)
|
|
{
|
|
Mapped = mapped;
|
|
Result = result;
|
|
InheritanceBehavior = inheritanceBehavior;
|
|
}
|
|
|
|
public bool Mapped { get; }
|
|
|
|
public InheritanceBehavior InheritanceBehavior { get; }
|
|
|
|
public DeserializationResult? Result { get; }
|
|
|
|
public DeserializedFieldEntry PushInheritanceFrom(DeserializedFieldEntry fieldEntry)
|
|
{
|
|
if (Mapped)
|
|
{
|
|
if (InheritanceBehavior == InheritanceBehavior.Always)
|
|
{
|
|
if (Result != null)
|
|
{
|
|
return fieldEntry.Result != null
|
|
? new DeserializedFieldEntry(Mapped, InheritanceBehavior, Result.PushInheritanceFrom(fieldEntry.Result))
|
|
: Copy();
|
|
}
|
|
else
|
|
{
|
|
return fieldEntry.Copy();
|
|
}
|
|
}
|
|
|
|
return Copy();
|
|
}
|
|
|
|
return InheritanceBehavior == InheritanceBehavior.Never ? Copy() : fieldEntry.Copy();
|
|
}
|
|
|
|
public DeserializedFieldEntry Copy()
|
|
{
|
|
return new(Mapped, InheritanceBehavior, Result?.Copy());
|
|
}
|
|
}
|
|
}
|