Replies: 3 comments 1 reply
-
Empty components are "not iterable" as in "you can't get instances of those components". So you can create a view over an empty component and iterate all the entities having this component assigned. |
Beta Was this translation helpful? Give feedback.
-
Can I ask you where this is mentioned? Probably I should review that part and make it clear that the view is definitely iterable.
On the other side, if
In a multi-component view, you've that non-empty types are returned while empty types are not:
So, you can definitely use empty types in your views and they are treated as all other types, but for the fact that they aren't returned because they don't exist (literally!). If you don't like this model, you can disable it as a whole with the |
Beta Was this translation helpful? Give feedback.
-
All right, that sounds just like i'd want it to work! I was referring to this part: There doesn't exist a way to iterate empty types. Views and groups will never return instances of empty types But lower down, a line mentions how iterations are faster because only the entities to which the type is assigned are considered. I guess knowing the context, it's more clear, but i want to understand the phrase "iterating over a type" as "iterating over a list of all entities with a given type", and in that case, the first sentence makes it sound as if this is not possible. I think adding your example along with some introduction to the utility of empty types would improve that part of the documentation. Thank you for taking your time to reply! |
Beta Was this translation helpful? Give feedback.
-
I browsed through the documentation and noticed a mention of empty types, stating that these are not iterable through views. Having empty components (or similar functionality) is something that would be quite useful, as sometimes you just want to tag an entity and iterate over all entities with this tag (like, say, a "Static" tag). Technically, you can add a component with a single bool, but storing a value is not interesting since you just want a view into all entities with this component. This is a concept which Unity allows in their ECS system. Is there any way of doing this in entt?
Beta Was this translation helpful? Give feedback.
All reactions