-
Notifications
You must be signed in to change notification settings - Fork 1
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 toggling of components. #24
Comments
Ideas on how to implement that:
Would that work for you? |
The first approach sounds like a good solution but I assume that it would be extremely complex to implement given that dynamic entities need to be special-cased in lots of places, for example Tagging components as dynamic also sounds good (and more doable) but I don't see the need to give up support for dependencies and inheritance for that. Dynamic components could have a bool that's initialized as false as well as HandleEnable and HandleDisable handlers for entity's Enable/Disable methods. Non-dynamic components would just have the same bool initialized as true and not react to Enable/Disable in any way. This allows us to otherwise treat dynamic and non-dynamic components identically except for evaluating the value of said bool where appropriate (ForAll, Get and message dispatching would consider a Component with the bool set to false as non-existing). |
Not needed as badly anymore due to changes in my design. |
Allow components to be enabled and disabled.
Entity::Get<>()
should return anullptr
andForAll<>()
should skip an entity if a required component is disabled. Messages shouldn't be handled by disabled components. A component should provide handler methods (HandleEnable
andHandleDisable
) so that it can react to a state change.Here's a usage example from Unvanquished:
One problem that could occur is that if you have a reference to a component and then that component gets disabled, you could still call its methods. I think we can/have to live with that though.
The text was updated successfully, but these errors were encountered: