using System;
using System.Collections.Generic;
using System.Linq;
using Robust.Shared.Localization;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
using YamlDotNet.RepresentationModel;
namespace Content.Shared.Jobs
{
///
/// Describes information for a single job on the station.
///
[Prototype("job")]
public class JobPrototype : IPrototype, IIndexedPrototype
{
public string ID { get; private set; }
///
/// The name of this job as displayed to players.
///
public string Name { get; private set; }
///
/// Whether this job is a head.
/// The job system will try to pick heads before other jobs on the same priority level.
///
public bool IsHead { get; private set; }
///
/// The total amount of people that can start with this job round-start.
///
public int SpawnPositions { get; private set; }
///
/// The total amount of positions available.
///
public int TotalPositions { get; private set; }
public string StartingGear { get; private set; }
public IReadOnlyCollection Department { get; private set; }
public IReadOnlyCollection Access { get; private set; }
public void LoadFrom(YamlMappingNode mapping)
{
ID = mapping.GetNode("id").AsString();
Name = Loc.GetString(mapping.GetNode("name").ToString());
StartingGear = mapping.GetNode("startingGear").ToString();
Department = mapping.GetNode("department").AllNodes.Select(i => i.ToString()).ToList();
TotalPositions = mapping.GetNode("positions").AsInt();
if (mapping.TryGetNode("spawnPositions", out var positionsNode))
{
SpawnPositions = positionsNode.AsInt();
}
else
{
SpawnPositions = TotalPositions;
}
if (mapping.TryGetNode("head", out var headNode))
{
IsHead = headNode.AsBool();
}
if (mapping.TryGetNode("access", out YamlSequenceNode accessNode))
{
Access = accessNode.Select(i => i.ToString()).ToList();
}
else
{
Access = Array.Empty();
}
}
}
}