using System; using System.Collections.Generic; using Robust.Shared.Prototypes; using Robust.Shared.Serialization; using Robust.Shared.Utility; using YamlDotNet.RepresentationModel; namespace Content.Shared.Construction { [Prototype("construction")] public class ConstructionPrototype : IPrototype, IIndexedPrototype { private List _conditions; /// /// Friendly name displayed in the construction GUI. /// public string Name { get; private set; } /// /// "Useful" description displayed in the construction GUI. /// public string Description { get; private set; } /// /// The this construction will be using. /// public string Graph { get; private set; } /// /// The target this construction will guide the user to. /// public string TargetNode { get; private set; } /// /// The starting this construction will start at. /// public string StartNode { get; private set; } /// /// Texture path inside the construction GUI. /// public SpriteSpecifier Icon { get; private set; } /// /// If you can start building or complete steps on impassable terrain. /// public bool CanBuildInImpassable { get; private set; } public string Category { get; private set; } public ConstructionType Type { get; private set; } public string ID { get; private set; } public string PlacementMode { get; private set; } /// /// Whether this construction can be constructed rotated or not. /// public bool CanRotate { get; private set; } public IReadOnlyList Conditions => _conditions; public void LoadFrom(YamlMappingNode mapping) { var ser = YamlObjectSerializer.NewReader(mapping); Name = ser.ReadDataField("name"); ser.DataField(this, x => x.ID, "id", string.Empty); ser.DataField(this, x => x.Graph, "graph", string.Empty); ser.DataField(this, x => x.TargetNode, "targetNode", string.Empty); ser.DataField(this, x => x.StartNode, "startNode", string.Empty); ser.DataField(this, x => x.Description, "description", string.Empty); ser.DataField(this, x => x.Icon, "icon", SpriteSpecifier.Invalid); ser.DataField(this, x => x.Type, "objectType", ConstructionType.Structure); ser.DataField(this, x => x.PlacementMode, "placementMode", "PlaceFree"); ser.DataField(this, x => x.CanBuildInImpassable, "canBuildInImpassable", false); ser.DataField(this, x => x.Category, "category", string.Empty); ser.DataField(this, x => x.CanRotate, "canRotate", true); ser.DataField(ref _conditions, "conditions", new List()); } } public enum ConstructionType { Structure, Item, } }