Files
crystall-punk-14/Content.Shared/Maps/ContentTileDefinition.cs

83 lines
2.5 KiB
C#
Raw Normal View History

using System;
using System.Collections.Generic;
using System.Linq;
using JetBrains.Annotations;
using Robust.Shared.Interfaces.Map;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
2019-04-03 21:20:26 +02:00
using YamlDotNet.RepresentationModel;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization;
2019-04-03 21:20:26 +02:00
namespace Content.Shared.Maps
{
[UsedImplicitly]
[Prototype("tile")]
public sealed class ContentTileDefinition : IPrototype, IIndexedPrototype, ITileDefinition
{
string IIndexedPrototype.ID => Name;
public string Name { get; private set; }
public ushort TileId { get; private set; }
public string DisplayName { get; private set; }
public string SpriteName { get; private set; }
public bool IsSubFloor { get; private set; }
public List<string> BaseTurfs { get; private set; }
public bool CanCrowbar { get; private set; }
2019-04-05 02:04:34 +02:00
public string FootstepSounds { get; private set; }
2019-04-11 17:04:48 +02:00
public float Friction { get; set; }
public string ItemDropPrototypeName { get; private set; }
2019-04-03 21:20:26 +02:00
public void AssignTileId(ushort id)
{
TileId = id;
}
public void LoadFrom(YamlMappingNode mapping)
{
Name = mapping.GetNode("name").ToString();
DisplayName = mapping.GetNode("display_name").ToString();
SpriteName = mapping.GetNode("texture").ToString();
if (mapping.TryGetNode("is_subfloor", out var node))
{
IsSubFloor = node.AsBool();
}
if (mapping.TryGetNode("base_turfs", out YamlSequenceNode baseTurfNode))
BaseTurfs = baseTurfNode.Select(i => i.ToString()).ToList();
else
BaseTurfs = new List<string>();
if (mapping.TryGetNode("can_crowbar", out node))
{
CanCrowbar = node.AsBool();
}
2019-04-05 02:04:34 +02:00
if (mapping.TryGetNode("footstep_sounds", out node))
{
FootstepSounds = node.AsString();
}
2019-04-11 17:04:48 +02:00
if (mapping.TryGetNode("friction", out node))
{
Friction = node.AsFloat();
}
else
{
Friction = 0;
}
if (mapping.TryGetNode("item_drop", out node))
{
ItemDropPrototypeName = node.ToString();
}
else
{
ItemDropPrototypeName = "FloorTileItemSteel";
}
2019-04-03 21:20:26 +02:00
}
2019-04-03 21:20:26 +02:00
}
}