refactor: Component rebalancing is now performed via a global queue (#2352)

This PR ensures that all component rebalancing operations are resolved from a single location, after the update stage but before the render stage (thus, components may get reordered during the update, and these changes will go into effect during the rendering step on the same game tick).

This also fixes the problem where the child changing the priorities of its parent would cause a ConcurrentModificationError.

A number of methods that were used to handle rebalancing are now marked as deprecated. From the user's perspective, the only API they should be using is the .priority setter.
This commit is contained in:
Pasha Stetsenko
2023-02-26 15:45:27 -08:00
committed by GitHub
parent 093a1abb07
commit 1ef518794c
9 changed files with 131 additions and 75 deletions

View File

@ -33,7 +33,7 @@ class Square extends RectangleComponent
bool onTapDown(TapDownInfo info) {
final topComponent = gameRef.children.last;
if (topComponent != this) {
gameRef.children.changePriority(this, topComponent.priority + 1);
priority = topComponent.priority + 1;
}
return false;
}