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:
31
Content.Shared/Prototypes/Tag/TagPrototype.cs
Normal file
31
Content.Shared/Prototypes/Tag/TagPrototype.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user