Fix stuck lathe queue (#10311)
This commit is contained in:
@@ -187,12 +187,16 @@ namespace Content.Server.Lathe
|
|||||||
component.Queue.RemoveAt(0);
|
component.Queue.RemoveAt(0);
|
||||||
return TryStartProducing(uid, prodComp, component);
|
return TryStartProducing(uid, prodComp, component);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!component.CanProduce(recipe) || !TryComp(uid, out MaterialStorageComponent? storage))
|
if (!component.CanProduce(recipe) || !TryComp(uid, out MaterialStorageComponent? storage))
|
||||||
|
{
|
||||||
|
component.Queue.RemoveAt(0);
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
prodComp ??= EnsureComp<LatheProducingComponent>(uid);
|
prodComp ??= EnsureComp<LatheProducingComponent>(uid);
|
||||||
|
|
||||||
|
// Do nothing if the lathe is already producing something.
|
||||||
if (prodComp.Recipe != null)
|
if (prodComp.Recipe != null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -203,6 +207,7 @@ namespace Content.Server.Lathe
|
|||||||
foreach (var (material, amount) in recipe.RequiredMaterials)
|
foreach (var (material, amount) in recipe.RequiredMaterials)
|
||||||
{
|
{
|
||||||
// This should always return true, otherwise CanProduce fucked up.
|
// This should always return true, otherwise CanProduce fucked up.
|
||||||
|
// TODO just remove materials when first queuing, to avoid queuing more items than can actually be produced.
|
||||||
storage.RemoveMaterial(material, amount);
|
storage.RemoveMaterial(material, amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -278,6 +283,7 @@ namespace Content.Server.Lathe
|
|||||||
{
|
{
|
||||||
for (var i = 0; i < args.Quantity; i++)
|
for (var i = 0; i < args.Quantity; i++)
|
||||||
{
|
{
|
||||||
|
// TODO check required materials exist and make materials unavailable.
|
||||||
component.Queue.Add(recipe.ID);
|
component.Queue.Add(recipe.ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user