Refactor stacks to use prototypes (#3387)
* Refactor stacks to use prototypes * Fix not assigned warning * Add names to stacks * Make machine baords and material constructions use the name as well * Remove defaulting stacks to prototype id * Fix tests Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
33
Content.Shared/Stacks/StackPrototype.cs
Normal file
33
Content.Shared/Stacks/StackPrototype.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
#nullable enable
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Utility;
|
||||
using YamlDotNet.RepresentationModel;
|
||||
|
||||
namespace Content.Shared.Stacks
|
||||
{
|
||||
[Prototype("stack")]
|
||||
public class StackPrototype : IPrototype
|
||||
{
|
||||
public string ID { get; private set; } = string.Empty;
|
||||
|
||||
public string Name { get; private set; } = string.Empty;
|
||||
|
||||
public SpriteSpecifier? Icon { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The entity id that will be spawned by default from this stack.
|
||||
/// </summary>
|
||||
public string? Spawn { get; private set; }
|
||||
|
||||
public void LoadFrom(YamlMappingNode mapping)
|
||||
{
|
||||
var reader = YamlObjectSerializer.NewReader(mapping);
|
||||
|
||||
reader.DataField(this, x => x.ID, "id", string.Empty);
|
||||
reader.DataField(this, x => x.Name, "name", string.Empty);
|
||||
reader.DataField(this, x => x.Icon, "icon", null);
|
||||
reader.DataField(this, x => x.Spawn, "spawn", null);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user