Fix bug with chemical reactions which cause other reactions (#475)
SolutionComponent.CheckForReaction only checks for a reaction once, meaning that if a reaction generates reagents that create a solution that's valid for another reaction, that second reaction doesn't occur. This fixes that by repeatedly checking for a reaction until no more occur.
This commit is contained in:
committed by
Pieter-Jan Briers
parent
6df5028d7a
commit
4cf8e18d1f
@@ -192,14 +192,27 @@ namespace Content.Server.GameObjects.Components.Chemistry
|
|||||||
|
|
||||||
private void CheckForReaction()
|
private void CheckForReaction()
|
||||||
{
|
{
|
||||||
//Check the solution for every reaction
|
bool checkForNewReaction = false;
|
||||||
foreach (var reaction in _reactions)
|
while (true)
|
||||||
{
|
{
|
||||||
if (SolutionValidReaction(reaction, out int unitReactions))
|
//Check the solution for every reaction
|
||||||
|
foreach (var reaction in _reactions)
|
||||||
{
|
{
|
||||||
PerformReaction(reaction, unitReactions);
|
if (SolutionValidReaction(reaction, out int unitReactions))
|
||||||
break; //Only perform one reaction per solution per update.
|
{
|
||||||
|
PerformReaction(reaction, unitReactions);
|
||||||
|
checkForNewReaction = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Check for a new reaction if a reaction occurs, run loop again.
|
||||||
|
if (checkForNewReaction)
|
||||||
|
{
|
||||||
|
checkForNewReaction = false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user