Component for entity visibility
As requested by @kevzettler - a way (likely a component) to show or hide an entire entity.
Open design questions:
- Is this clientside only?
- If it's on the serverside as well, should it disable physics for that entity as well?
- Is this recursive? Does hiding an entity hide all of its children too? (#299 potentially relevant - maybe we should add
entity::[set/add]_component_recursive?)
-
Not sure what the state of rendering is in general, but there are plenty of server-side rendering components like
color(), so allowing this on the server side seems consistent to me unless long-term we are considering moving all those other rendering components to be clientside only. -
I think we already have a way to disable physics - remove
physics_controlled- and it could create extra confusion to add another way an object's physics might be toggled. Maybe this is alluding to some kind ofentity_disabledcomponent, but I think that raises a lot of other weird questions. I'd prefer to use a Concept for disabling multiple otherwise-unrelated components at once, or to just despawn entities that we want to 'not exist' for a while. -
Left a comment in that issue about this topic
Re. recursive case; we need a solution for that in general, but the tricky thing is that the sub-tree can change, so just setting it once won't work (hence the outlines_recursive etc.).
2. I think we already have a way to disable physics - remove
physics_controlled- and it could create extra confusion to add another way an object's physics might be toggled.
Is removing/readding physics_controlled a quick operation? If so, then yeah, that should be fine. (might need to better document it)
Re. recursive case; we need a solution for that in general, but the tricky thing is that the sub-tree can change, so just setting it once won't work (hence the outlines_recursive etc.).
Mm yeah, it seems likely we'll need something more advanced like the two-entity queries @droqen suggested or a more specific solution (like an entity::add_component_to_hierarchy that does the necessary bookkeeping to apply that to the hierarchy, even as the hierarchy changes)
This would also be nice for something I've run into - storing templates in the ECS. Right now, these template entities show up in the world - it would be ideal to hide them entirely, and only show them when they're instantiated for real.
@philpax You can also remove the main_scene component from all the entities to hide them. The renderer will only render things with main_scene or ui_scene on them.