bevyengine / bevy

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

Introduce `Populated` system param #15302

Closed MiniaczQ closed 1 month ago

MiniaczQ commented 1 month ago

What problem does this solve or what need does it fill?

There have been many requests to not run systems if there is nothing to process (in a query). The Populated system param would do exactly that.

What solution would you like?

Add Populated system param that fails validation if query is empty.

alice-i-cecile commented 1 month ago

I'm in favor of this existing: seems quite useful once #15276 is merged. This is a sibling to #15264.

I'd be interested in adding a NonEmptyEventReader as well, either in the same PR or in a separate one.

benfrankel commented 1 month ago

Bikeshedding, but would QueryNonEmpty be a better name? It'd be next to Query and QuerySingle alphabetically and in code-completion.

alice-i-cecile commented 1 month ago

I think that's a bit better, yeah.

MiniaczQ commented 1 month ago

I prefer proper spelling, all of them will show up when typing "Query" I'm fine either way

MiniaczQ commented 1 month ago

Second thoughts, maybe we should skip Query entirely, assuming we're moving more things to entities, this will naturally show up more so we don't need to be worried about awareness