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