/// Populates the build queue list with all queued items
/// </summary>
/// <param name="queue"></param>
- public void PopulateQueueList(List<LatheRecipePrototype> queue)
+ public void PopulateQueueList(IReadOnlyCollection<ProtoId<LatheRecipePrototype>> queue)
{
QueueList.DisposeAllChildren();
var idx = 1;
- foreach (var recipe in queue)
+ foreach (var recipeProto in queue)
{
+ var recipe = _prototypeManager.Index(recipeProto);
var queuedRecipeBox = new BoxContainer();
queuedRecipeBox.Orientation = BoxContainer.LayoutOrientation.Horizontal;
}
}
- public void SetQueueInfo(LatheRecipePrototype? recipe)
+ public void SetQueueInfo(ProtoId<LatheRecipePrototype>? recipeProto)
{
- FabricatingContainer.Visible = recipe != null;
- if (recipe == null)
+ FabricatingContainer.Visible = recipeProto != null;
+ if (recipeProto == null)
return;
+ var recipe = _prototypeManager.Index(recipeProto.Value);
+
FabricatingDisplayContainer.Children.Clear();
FabricatingDisplayContainer.AddChild(GetRecipeDisplayControl(recipe));
_materialStorage.TryChangeMaterialAmount(uid, mat, adjustedAmount);
}
- component.Queue.Add(recipe);
+ component.Queue.Enqueue(recipe);
return true;
}
if (component.CurrentRecipe != null || component.Queue.Count <= 0 || !this.IsPowered(uid, EntityManager))
return false;
- var recipe = component.Queue.First();
- component.Queue.RemoveAt(0);
+ var recipeProto = component.Queue.Dequeue();
+ var recipe = _proto.Index(recipeProto);
var time = _reagentSpeed.ApplySpeed(uid, recipe.CompleteTime) * component.TimeMultiplier;
if (comp.CurrentRecipe != null)
{
- if (comp.CurrentRecipe.Result is { } resultProto)
+ var currentRecipe = _proto.Index(comp.CurrentRecipe.Value);
+ if (currentRecipe.Result is { } resultProto)
{
var result = Spawn(resultProto, Transform(uid).Coordinates);
_stack.TryMergeToContacts(result);
}
- if (comp.CurrentRecipe.ResultReagents is { } resultReagents &&
+ if (currentRecipe.ResultReagents is { } resultReagents &&
comp.ReagentOutputSlotId is { } slotId)
{
var toAdd = new Solution(
if (!Resolve(uid, ref component))
return;
- var producing = component.CurrentRecipe ?? component.Queue.FirstOrDefault();
+ var producing = component.CurrentRecipe;
+ if (producing == null && component.Queue.TryPeek(out var next))
+ producing = next;
- var state = new LatheUpdateState(GetAvailableRecipes(uid, component), component.Queue, producing);
+ var state = new LatheUpdateState(GetAvailableRecipes(uid, component), component.Queue.ToArray(), producing);
_uiSys.SetUiState(uid, LatheUiKey.Key, state);
}
/// The lathe's construction queue
/// </summary>
[DataField]
- public List<LatheRecipePrototype> Queue = new();
+ public Queue<ProtoId<LatheRecipePrototype>> Queue = new();
/// <summary>
/// The sound that plays when the lathe is producing an item, if any
/// The recipe the lathe is currently producing
/// </summary>
[ViewVariables]
- public LatheRecipePrototype? CurrentRecipe;
+ public ProtoId<LatheRecipePrototype>? CurrentRecipe;
#region MachineUpgrading
/// <summary>
using Content.Shared.Research.Prototypes;
+using NetSerializer;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
{
public List<ProtoId<LatheRecipePrototype>> Recipes;
- public List<LatheRecipePrototype> Queue;
+ public ProtoId<LatheRecipePrototype>[] Queue;
- public LatheRecipePrototype? CurrentlyProducing;
+ public ProtoId<LatheRecipePrototype>? CurrentlyProducing;
- public LatheUpdateState(List<ProtoId<LatheRecipePrototype>> recipes, List<LatheRecipePrototype> queue, LatheRecipePrototype? currentlyProducing = null)
+ public LatheUpdateState(List<ProtoId<LatheRecipePrototype>> recipes, ProtoId<LatheRecipePrototype>[] queue, ProtoId<LatheRecipePrototype>? currentlyProducing = null)
{
Recipes = recipes;
Queue = queue;
using Content.Shared.Lathe.Prototypes;
using Content.Shared.Materials;
using Robust.Shared.Prototypes;
-using Robust.Shared.Serialization;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Array;
using Robust.Shared.Utility;
namespace Content.Shared.Research.Prototypes
{
- [NetSerializable, Serializable, Prototype]
+ [Prototype]
public sealed partial class LatheRecipePrototype : IPrototype, IInheritingPrototype
{
[ViewVariables]