-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Add simple Disabled marker #17514
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add simple Disabled marker #17514
Conversation
I think that this should close that issue. Would you mind fixing the description? :) |
|
||
let disabled = self.register_component::<Disabled>(); | ||
let mut filters = DefaultQueryFilters::default(); | ||
filters.set_disabled(disabled); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit worried that users might do a
app.init_resource::<DefaultQueryFilters>()
and lose the Disabled
functionality inadvertently..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
init_resource
doesn't overwrite existing resources. You'd have to explicitly call .insert_resource(DefaultQueryFilters::default())
which is probably verbose enough to make it obvious what will happen. Currently it is intended that you can opt-out of entity disabling, but as the feature matures we could consider making it so that it is always there.
|
||
/// A marker component for disabled entities. See [the module docs] for more info. | ||
/// | ||
/// [the module docs]: crate::entity_disabling |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we update the module docs to mention that the Disabled
component is disabled in the default DefaultQueryFilters
? Right now they talk about it as a hypothetical.
let original_world_dqf_id = self | ||
.original_world | ||
.components() | ||
.get_resource_id(TypeId::of::<DefaultQueryFilters>()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will be nice when resources-as-components lets us use default query filters to exclude the default query filters resource from our resource query :).
# Objective We have default query filters now, but there is no first-party marker for entity disabling yet Fixes bevyengine#17458 ## Solution Add the marker, cool recursive features and/or potential hook changes should be follow up work ## Testing Added a unit test to check that the new marker is enabled by default
# Objective We have default query filters now, but there is no first-party marker for entity disabling yet Fixes bevyengine#17458 ## Solution Add the marker, cool recursive features and/or potential hook changes should be follow up work ## Testing Added a unit test to check that the new marker is enabled by default
# Objective The entity disabling / default query filter work added in #17514 and #13120 is neat, but we don't teach users how it works! We should fix that before 0.16. ## Solution Write a simple example to teach the basics of entity disabling! ## Testing `cargo run --example entity_disabling` ## Showcase  --------- Co-authored-by: Zachary Harrold <[email protected]>
…y filters (#17768) # Objective Currently, default query filters, as added in #13120 / #17514 are hardcoded to only use a single query filter. This is limiting, as multiple distinct disabling components can serve important distinct roles. I ran into this limitation when experimenting with a workflow for prefabs, which don't represent the same state as "an entity which is temporarily nonfunctional". ## Solution 1. Change `DefaultQueryFilters` to store a SmallVec of ComponentId, rather than an Option. 2. Expose methods on `DefaultQueryFilters`, `World` and `App` to actually configure this. 3. While we're here, improve the docs, write some tests, make use of FromWorld and make some method names more descriptive. ## Follow-up I'm not convinced that supporting sparse set disabling components is useful, given the hit to iteration performance and runtime checks incurred. That's disjoint from this PR though, so I'm not doing it here. The existing warnings are fine for now. ## Testing I've added both a doc test and an mid-level unit test to verify that this works!
# Objective The entity disabling / default query filter work added in bevyengine#17514 and bevyengine#13120 is neat, but we don't teach users how it works! We should fix that before 0.16. ## Solution Write a simple example to teach the basics of entity disabling! ## Testing `cargo run --example entity_disabling` ## Showcase  --------- Co-authored-by: Zachary Harrold <[email protected]>
Objective
We have default query filters now, but there is no first-party marker for entity disabling yet
Fixes #17458
Solution
Add the marker, cool recursive features and/or potential hook changes should be follow up work
Testing
Added a unit test to check that the new marker is enabled by default