Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If you spawn an entity with a parent component, it takes two ticks right now for that entity to get added to the list of children of its new parent. In the first tick, missing_previous_parent_system adds a PreviousParent(None) to the entity, which will be added after parent_update_system has run. Since parent_update_system queries for entities with a previous parent, the child list of the new parent is not yet updated. In the second tick, parent_update_system picks the entity up and updates the child list of the parent.
This caused a panic for me when I tried to despawn the parent recursively one tick after the creation of its new child (parent_update_system then tries to insert a new child list for an entity that just got despawned). Merging the two systems fixes that and allows to get rid of the Optional in the PreviousParent struct.