What's the point in bundling components if bundles can't be entities? For example, what's the point of making a "PlayerBundle" bundle to ensure players get all of the proper components, when I'd have to create a whole separate marker component for filtering, say "PlayerMarker" to query any of those components and know I'm getting the right one? How am I supposed to identify anything without creating a bunch of marker structs that are useful for nothing but filtering?
#Can someone make Bevy's Bundles make sense?
20 messages · Page 1 of 1 (latest)
Bundles are effectively "suggestions of components that go well together"
They're primarily a documentation / learning / ergonomics thing
I also see them as a form of basic code deduplication
Yeah, definining constructors on them is really handy to help with that further
What's wrong with using marker components that make you want to avoid it?
As for querying specific things, marker components are really handy. For the most part though, I tend to find myself thinking about broad classes of things, and systems that operate on entities regardless of the exact details of what type of object they are
(althoug Player often gets special treatment)
An entity can be conceptualized as a particular set of components, so if only Players have a particular set, querying for only and exactly those will in effect get all of the Players, no marker necessary
I'm just trying to figure out the clean way to handle entity component enforcement. Is there not really a good way to enforce that entities receive components other than making a commands.spawn() wrapper?
You enforce it by writing the code that does it
You can use an injector pattern based on observers, if you'd like
gotcha.
I'm super new to the enforced ecs thing, I came from Godot a couple months ago
Listen for a marker component being added, and then subsequently inject all other components you want
You'll like the required components pattern that Cart's been proposing over in #1264881140007702558 I suspect
This is a hand-rolled version of that 🙂
The required components proposal is a game changer for the ergonomics
Can't wait to see it in
That looks very useful. Looking forward to it.