Add tag component and test (#2761)

* Add tag component and test

* Remove 0 capacity

* Add tag component extensions

* Change tags to be prototypes

Co-authored-by: Vera Aguilera Puerto <6766154+Zumorica@users.noreply.github.com>
This commit is contained in:
DrSmugleaf
2021-02-02 02:11:04 +01:00
committed by GitHub
parent 8dea532800
commit b0482dcb63
5 changed files with 751 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
#nullable enable
using JetBrains.Annotations;
using Robust.Shared.Interfaces.Serialization;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using YamlDotNet.RepresentationModel;
namespace Content.Shared.Prototypes.Tag
{
/// <summary>
/// Prototype representing a tag in YAML.
/// Meant to only have an ID property, as that is the only thing that
/// gets saved in TagComponent.
/// </summary>
[Prototype("Tag")]
public class TagPrototype : IPrototype, IIndexedPrototype, IExposeData
{
public string ID { get; [UsedImplicitly] private set; } = default!;
public void ExposeData(ObjectSerializer serializer)
{
serializer.DataField(this, x => x.ID, "id", "");
}
public void LoadFrom(YamlMappingNode mapping)
{
var serializer = YamlObjectSerializer.NewReader(mapping);
ExposeData(serializer);
}
}
}