While working on #5955 i noted that Commands::get_or_spawn had a strange implementation. I did some experiments and I found that the method can return EntityCommands for an invalid entity if the Entity passed as argument has been deleted replaced by a newer generation with the same id.
Bevy version:
main
.While working on #5955 i noted that
Commands::get_or_spawn
had a strange implementation. I did some experiments and I found that the method can returnEntityCommands
for an invalid entity if theEntity
passed as argument has been deletedreplaced by a newer generation with the same id.Code for reproduction
Possible solution
Return an
Option
just likeWorld::get_or_spawn
does.