Files
OldThink/Content.Shared/Construction/ConstructionPrototype.cs
Visne 9b94d5c195 Added nullable to most Content.Shared files (#3238)
* Add nullable to some Content.Shared files.

* Use [NotNullWhen(true)]

* Undo adding now redundant !'s

* Forgot one

* Add a ton more nullable

* You can guess

* Fix some issues

* It actually compiles now

* Auto stash before merge of "null2" and "origin/master"

* I lied

* enable annotations -> enable

* Revert ActionBlockerSystem.cs to original

* Fix ActionBlockerSystem.cs

* More nullable

* Undo some added exclamation marks

* Fix issues

* Update Content.Shared/Maps/ContentTileDefinition.cs

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>

* Resolve some issues

* Remove unused method

* Fix more issues

* Fix more issues

* Fix more issues

* Fix more issues

* Fix issue, rollback SharedGhostComponent.cs

* Update submodule

* Fix issue, invert some if-statements to reduce nesting

* Revert RobustToolbox

* FIx things broken by merge

* Some fixes

- Replaced with string.Empty
- Remove some exclamation marks
- Revert file

* Some fixes

* Trivial #nullable enable

* Fix null ables

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
2021-02-27 14:12:09 +11:00

92 lines
3.5 KiB
C#

#nullable enable
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
{
private List<IConstructionCondition> _conditions = new();
/// <summary>
/// Friendly name displayed in the construction GUI.
/// </summary>
public string Name { get; private set; } = string.Empty;
/// <summary>
/// "Useful" description displayed in the construction GUI.
/// </summary>
public string Description { get; private set; } = string.Empty;
/// <summary>
/// The <see cref="ConstructionGraphPrototype"/> this construction will be using.
/// </summary>
public string Graph { get; private set; } = string.Empty;
/// <summary>
/// The target <see cref="ConstructionGraphNode"/> this construction will guide the user to.
/// </summary>
public string TargetNode { get; private set; } = string.Empty;
/// <summary>
/// The starting <see cref="ConstructionGraphNode"/> this construction will start at.
/// </summary>
public string StartNode { get; private set; } = string.Empty;
/// <summary>
/// Texture path inside the construction GUI.
/// </summary>
public SpriteSpecifier Icon { get; private set; } = SpriteSpecifier.Invalid;
/// <summary>
/// If you can start building or complete steps on impassable terrain.
/// </summary>
public bool CanBuildInImpassable { get; private set; }
public string Category { get; private set; } = string.Empty;
public ConstructionType Type { get; private set; } = ConstructionType.Structure;
public string ID { get; private set; } = string.Empty;
public string PlacementMode { get; private set; } = "PlaceFree";
/// <summary>
/// Whether this construction can be constructed rotated or not.
/// </summary>
public bool CanRotate { get; private set; }
public IReadOnlyList<IConstructionCondition> Conditions => _conditions;
public void LoadFrom(YamlMappingNode mapping)
{
var ser = YamlObjectSerializer.NewReader(mapping);
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);
ser.DataField(this, x => x.CanRotate, "canRotate", true);
ser.DataField(ref _conditions, "conditions", new List<IConstructionCondition>());
}
}
public enum ConstructionType
{
Structure,
Item,
}
}