Is there a specific order in which the update
method is called for components added in Flame? For example, in Unity, the LateUpdate
method is available to ensure certain updates, like the camera update, are executed last.
Is it called in the order it was added? Or is the order random?
The order of update is decided depending on the priority
of the component, and if two components have the same priority they are updated in the order that they were added. But, this only applies to sibling components, the component tree updates start in the root and then it traverses down to the leaf components in a DFS manner.
/// This method traverses the component tree and calls [update] on all its
/// children according to their [priority] order, relative to the
/// priority of the direct siblings, not the children or the ancestors.
void updateTree(double dt) {
update(dt);
_children?.forEach((c) => c.updateTree(dt));
}