2020-12-16 18:18:27 +01:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
2019-04-15 21:11:38 -06:00
|
|
|
|
using Robust.Shared.Prototypes;
|
|
|
|
|
|
using Robust.Shared.Serialization;
|
|
|
|
|
|
using Robust.Shared.Utility;
|
2018-08-02 08:29:55 +02:00
|
|
|
|
using YamlDotNet.RepresentationModel;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Content.Shared.Construction
|
|
|
|
|
|
{
|
|
|
|
|
|
[Prototype("construction")]
|
|
|
|
|
|
public class ConstructionPrototype : IPrototype, IIndexedPrototype
|
|
|
|
|
|
{
|
2020-10-08 17:41:23 +02:00
|
|
|
|
private List<IConstructionCondition> _conditions;
|
2018-08-02 08:29:55 +02:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Friendly name displayed in the construction GUI.
|
|
|
|
|
|
/// </summary>
|
2020-10-08 17:41:23 +02:00
|
|
|
|
public string Name { get; private set; }
|
2018-08-02 08:29:55 +02:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// "Useful" description displayed in the construction GUI.
|
|
|
|
|
|
/// </summary>
|
2020-10-08 17:41:23 +02:00
|
|
|
|
public string Description { get; private set; }
|
2018-08-02 08:29:55 +02:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2020-10-08 17:41:23 +02:00
|
|
|
|
/// The <see cref="ConstructionGraphPrototype"/> this construction will be using.
|
2018-08-02 08:29:55 +02:00
|
|
|
|
/// </summary>
|
2020-10-08 17:41:23 +02:00
|
|
|
|
public string Graph { get; private set; }
|
2018-08-02 08:29:55 +02:00
|
|
|
|
|
2020-03-06 13:15:44 -06:00
|
|
|
|
/// <summary>
|
2020-10-08 17:41:23 +02:00
|
|
|
|
/// The target <see cref="ConstructionGraphNode"/> this construction will guide the user to.
|
2020-03-06 13:15:44 -06:00
|
|
|
|
/// </summary>
|
2020-10-08 17:41:23 +02:00
|
|
|
|
public string TargetNode { get; private set; }
|
2020-03-06 13:15:44 -06:00
|
|
|
|
|
2018-08-02 08:29:55 +02:00
|
|
|
|
/// <summary>
|
2020-10-08 17:41:23 +02:00
|
|
|
|
/// The starting <see cref="ConstructionGraphNode"/> this construction will start at.
|
2018-08-02 08:29:55 +02:00
|
|
|
|
/// </summary>
|
2020-10-08 17:41:23 +02:00
|
|
|
|
public string StartNode { get; private set; }
|
2018-08-02 08:29:55 +02:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2020-10-08 17:41:23 +02:00
|
|
|
|
/// Texture path inside the construction GUI.
|
2018-08-02 08:29:55 +02:00
|
|
|
|
/// </summary>
|
2020-10-08 17:41:23 +02:00
|
|
|
|
public SpriteSpecifier Icon { get; private set; }
|
2018-08-02 08:29:55 +02:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2020-10-08 17:41:23 +02:00
|
|
|
|
/// If you can start building or complete steps on impassable terrain.
|
2018-08-02 08:29:55 +02:00
|
|
|
|
/// </summary>
|
2020-10-08 17:41:23 +02:00
|
|
|
|
public bool CanBuildInImpassable { get; private set; }
|
2018-08-02 08:29:55 +02:00
|
|
|
|
|
2020-10-08 17:41:23 +02:00
|
|
|
|
public string Category { get; private set; }
|
2018-08-02 08:29:55 +02:00
|
|
|
|
|
2020-10-08 17:41:23 +02:00
|
|
|
|
public ConstructionType Type { get; private set; }
|
2018-08-02 08:29:55 +02:00
|
|
|
|
|
2020-10-08 17:41:23 +02:00
|
|
|
|
public string ID { get; private set; }
|
2018-08-02 08:29:55 +02:00
|
|
|
|
|
2020-10-08 17:41:23 +02:00
|
|
|
|
public string PlacementMode { get; private set; }
|
|
|
|
|
|
|
2020-10-12 14:22:31 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Whether this construction can be constructed rotated or not.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public bool CanRotate { get; private set; }
|
|
|
|
|
|
|
2020-10-08 17:41:23 +02:00
|
|
|
|
public IReadOnlyList<IConstructionCondition> Conditions => _conditions;
|
2018-08-02 08:29:55 +02:00
|
|
|
|
|
|
|
|
|
|
public void LoadFrom(YamlMappingNode mapping)
|
|
|
|
|
|
{
|
|
|
|
|
|
var ser = YamlObjectSerializer.NewReader(mapping);
|
2020-10-08 17:41:23 +02:00
|
|
|
|
Name = ser.ReadDataField<string>("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);
|
2020-10-12 14:22:31 +02:00
|
|
|
|
ser.DataField(this, x => x.CanRotate, "canRotate", true);
|
2020-10-08 17:41:23 +02:00
|
|
|
|
ser.DataField(ref _conditions, "conditions", new List<IConstructionCondition>());
|
2018-08-02 08:29:55 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public enum ConstructionType
|
|
|
|
|
|
{
|
|
|
|
|
|
Structure,
|
|
|
|
|
|
Item,
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|