-
-
Notifications
You must be signed in to change notification settings - Fork 892
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
Allow entities and components of specific entities to be disabled/enabled #888
Comments
I suggest you look into exclusion. eg:
|
That would exclude all "renderable". This is about disabling specific components on specific entities. I updated the original text to hopefully be more clear. |
Added a bit about optionally allowing |
I think this goes without saying because of the implementation I've in mind. |
We have almost the same use case and would love to see this feature. Right now we use tags to enable / disable rendering, transform updates and collision handling. |
It would be super helpful to be able to disable either an entity or a specific component on an entity, both without actually deleting entity or component. The entity or component continues to exist, does not get overwritten by entt during creation (retains its id and version), and might be re-enabled later.
What
get<T>
andtry_get<T>
should not return componentT
if it has been disabled for the given entity.get<T>
andtry_get<T>
should not return an enabled componentT
if the given entity is disabled.Imagine two entities exist with components:
Entity A
-TransformComponent
-RenderComponent
-CollisionComponent
Entity B
-TransformComponent
-RenderComponent
-CollisionComponent
If I disable Entity A, it should not be returned if I create a view on
CollisionComponent
.If I disable
CollisionComponent
on Entity B, only Entity A should be returned if I create a view onCollisionComponent
.(Why you would disable
CollisionComponent
I have no idea. This is just to demonstrate that disabling a component applies to a specific entity, not all components of that type.)Nice to Have
view
that returns all entities, enabled or not.How
I'm purposefully not suggesting how an entity or component might be enabled or disabled.
Why
Presumably entt's own check would be far faster/efficient than the method I employed to do this. All of my components derive from a
Component
class, which has anenabled
member. All entities get aGeneralComponent
on creation. Among other thingsGeneralComponent
does, itsenabled
is treated specially: to determine if the entity itself is considered enabled.Background
I was working on a pathing system that has three pieces: FollowComponent, WanderComponent, and PathingComponent (and the corresponding systems). The problem is simple: the first two components must stop all work for any entities involved in cutscene scripting (unless a script specifically turns them back on). I can't simply disable the systems because they should continue to process other entities not involved in the script. I need to disable FollowComponent and WanderComponent on the entities involved in the cutscene.
Another practical usage scenario is undo/redo in a level editor. Deleting an entity could simply disable it, and then upon save all disabled entities are ignored. Undo'ing a delete would simply re-enable said entity (presumably the undo/redo list stores the entity). The major benefit of this approach is preserving the original state of the entity after the user requests an undo. Redo would simply disable the entity again.
The text was updated successfully, but these errors were encountered: