Open
Description
@chescock in #19519 (comment)_ says:
With this change, every branch in this hook (after the RelationshipHookMode
check) is guaranteed to run a command, right? It might make sense as a follow-up PR to wrap the entire method in world.commands.queue(|world| {...})
. That would avoid having to look up target_entity
twice, which would also avoid the possibility of it getting despawned in between.
Huh, and it also looks like EntityEntryCommands::or_insert_with
just invokes the closure immediately. If we work with world
instead of commands
then I think we can avoid allocating a new RelationshipTarget
if it already exists. Also, I'm going to create an issue for or_insert_with
, because that behavior is surprising ... #19884.