bevyengine / bevy

A refreshingly simple data-driven game engine built in Rust
https://bevyengine.org
Apache License 2.0
36.46k stars 3.6k forks source link

Support for `get_many` and `get_many_mut` functions for `Assets<T>` #16334

Open Rajveer100 opened 2 weeks ago

Rajveer100 commented 2 weeks ago

Part of #16244

Objective

Add functions for Assets<T> to retrieve multiple references similar to Query<...>

Solution

The Query type has the get_many and get_many_mut methods to get around this limitation, allowing multiple Entities to be looked up at once, with a dynamic check to prevent the same entity from being accessed multiple times. A similar pattern can be followed here.

Rajveer100 commented 2 weeks ago

For retrieving mutable references, what do you think is an appropriate way?