using System.Text.Json.Serialization;
using Robust.Shared.Prototypes;
using Content.Server.Nutrition.Components;
namespace Content.Server.GuideGenerator;
public sealed class SliceRecipeEntry
{
///
/// Id of sliceable item
///
[JsonPropertyName("id")]
public string Id { get; }
///
/// Human-readable name of recipe.
/// Should automatically be localized by default
///
[JsonPropertyName("name")]
public string Name { get; }
///
/// Type of recipe
///
[JsonPropertyName("type")]
public string Type { get; }
///
/// Item that will be sliced into something
///
[JsonPropertyName("input")]
public string Input { get; }
///
/// Result of a recipe
///
[JsonPropertyName("result")]
public string Result { get; }
///
/// Count of result item
///
[JsonPropertyName("count")]
public int Count { get; }
public SliceRecipeEntry(EntityPrototype proto)
{
Id = proto.ID;
Name = TextTools.TextTools.CapitalizeString(proto.Name);
Type = "sliceableRecipes";
Input = proto.ID;
if (proto.Components.TryGetComponent("SliceableFood", out var comp))
{
var sliceable = (SliceableFoodComponent) comp;
Result = sliceable.Slice ?? "";
Count = sliceable.TotalCount;
}
else // just in case something will go wrong and we somehow will not get our component
{
Result = "";
Count = 0;
}
}
}