Fix lathe queue bug (#7883)
This commit is contained in:
@@ -74,7 +74,7 @@ namespace Content.Server.Lathe
|
||||
}
|
||||
lathe.ProducingAccumulator = 0;
|
||||
|
||||
FinishProducing(lathe.ProducingRecipe, lathe);
|
||||
FinishProducing(lathe.ProducingRecipe, lathe, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,17 +156,26 @@ namespace Content.Server.Lathe
|
||||
/// This handles the checks to start producing an item, and
|
||||
/// starts up the sound and visuals
|
||||
/// </summary>
|
||||
private bool Produce(LatheComponent component, LatheRecipePrototype recipe, bool SkipCheck = false)
|
||||
private void Produce(LatheComponent component, LatheRecipePrototype recipe, bool SkipCheck = false)
|
||||
{
|
||||
if (!component.CanProduce(recipe)
|
||||
|| !TryComp(component.Owner, out MaterialStorageComponent? storage))
|
||||
return false;
|
||||
{
|
||||
FinishProducing(recipe, component, false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!SkipCheck && HasComp<LatheProducingComponent>(component.Owner))
|
||||
return false;
|
||||
{
|
||||
FinishProducing(recipe, component, false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (TryComp<ApcPowerReceiverComponent>(component.Owner, out var receiver) && !receiver.Powered)
|
||||
return false;
|
||||
{
|
||||
FinishProducing(recipe, component, false);
|
||||
return;
|
||||
}
|
||||
|
||||
component.UserInterface?.SendMessage(new LatheFullQueueMessage(GetIdQueue(component)));
|
||||
|
||||
@@ -185,16 +194,16 @@ namespace Content.Server.Lathe
|
||||
}
|
||||
UpdateRunningAppearance(component.Owner, true);
|
||||
ProducingAddQueue.Enqueue(component.Owner);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// After the production timer is up, this spawns the recipe and
|
||||
/// either cleans up or continues to the next item in the queue
|
||||
/// If we were able to produce the recipe,
|
||||
/// spawn it and cleanup. If we weren't, just do cleanup.
|
||||
/// </summary>
|
||||
private void FinishProducing(LatheRecipePrototype recipe, LatheComponent component)
|
||||
private void FinishProducing(LatheRecipePrototype recipe, LatheComponent component, bool productionSucceeded = true)
|
||||
{
|
||||
component.ProducingRecipe = null;
|
||||
if (productionSucceeded)
|
||||
EntityManager.SpawnEntity(recipe.Result, Comp<TransformComponent>(component.Owner).Coordinates);
|
||||
component.UserInterface?.SendMessage(new LatheStoppedProducingRecipeMessage());
|
||||
// Continue to next in queue if there are items left
|
||||
|
||||
Reference in New Issue
Block a user