Replies: 2 comments 2 replies
-
#5602 adds the methods To do that the PR also splits the |
Beta Was this translation helpful? Give feedback.
-
Your belief that struct CustomComponent<T> {
/// The ID of the component to insert
component_id: ComponentId,
/// The component data
data: T,
} Could implement The design of the Bundle trait is (currently) such that the style of API you suggest cannot work; each |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm trying to understand how to insert a custom component I've registered with
world.init_component_with_descriptor()
.All component insertions are handled through the
Bundle
trait now, and I see new docs on Bevymain
branch that say you should not implementBundle
( like ever, is the impression I get from the wording ).A lot of the other APIs that might be used for insertion are private, so that leaves the only way I can see to insert a custom component to be implementing the
Bundle
trait.But it also feels like there should be much easier ways to do certain things like, for instance, removing a component from an entity by passing the
ComponentId
. I think that function could be 100% safe, and actually useful in scenarios where you want to remove all the components from an entity.Inserting custom components wouldn't be safe in any way I don't think, but there should still be a way to do it, and probably without implementing
Bundle
.Maybe we can create a
CustomComponent
struct that implementsBundle
and is something like this:We could make it's constructor
unsafe
and then implementBundle
on it.The unsafety of the constructor would be centered around the fact that
T
much match the underlying layout that the component with the givenComponentId
was registered, if I'm getting that right.Anyway, any thoughts?
Beta Was this translation helpful? Give feedback.
All reactions