projectharmonia / bevy_replicon

Server-authoritative networking crate for the Bevy game engine.
https://crates.io/crates/bevy_replicon
Apache License 2.0
352 stars 31 forks source link

Use `EntityWorldMut::insert_by_ids` #332

Open Shatur opened 1 month ago

Shatur commented 1 month ago

Currently, we insert components one by one, which causes a lot of archetype moves and behaves somewhat unexpectedly with observers/hooks. To solve this, we could pass a special buffer for components instead of using Commands, and after all insertions, call EntityWorldMut::insert_by_ids.

UkoeHB commented 1 month ago

If bevy implements command batching, this would no longer be a perf issue (although observers might still run separately).