-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Conflict when IComponents from different pools assigned to a single entity #12
Comments
Yes, that is completely true. You mustn't add components from different pool to the same entity. Different pools have a specific set of components, depending how you attribute your components (e.g. [A] or [B]). When you create an entity with pool A, you can only add components of set A. Personally, I have a pool for UI, Meta Game and the Core Game. Adding Core Game Components to a UI Entity doesn't work, and doesn't really make sense. The different pools work on specific aspects in your application and do not mix. |
The introduction of multiple pools originally was a part of performance optimizations when the amount of components grow. Each created entity will have a array of capacity |
It makes sense performance wise but I wish there was a mechanism at compile time to formally link entity and pool. In the current state, I would have to remember which component belongs to which pool in order to not mix them up in the same entity and introduce a bug. This mechanism should be inexpensive, otherwise it defeats the purpose of separating the pools. I'll give it some thought and come back to you if I come up with a good solution. |
I already had a few discussions about this topic. In the future the might be some safety mechanisms to address this issue, e.g. generating pools and entities based on the specified pool names. Like: APool and BPool and AEntity and BEntity, only offering code completion for their supported components. |
Fyi, the next release will have support for components with multiple PoolAttributes. Regarding your example of adding AComponent and BComponent to entities in different pools, you can now do this by attributing the components with all the pools they should be supported in [A, B]
public class AComponent : IComponent {}
[A, B]
public class BComponent : IComponent {} |
Let's say I have 2 pools named A and B, with 1 component each.
Code generation creates two arrays, one for each Pool. AComponent will be assigned at index 0 of his pool, BComponent will also be assigned to index 0 in his own pool's array:
Therefore, it results in conflicts when we want to group by AComponent and BComponent.
entity is incorrectly considered as both A and B.
The text was updated successfully, but these errors were encountered: