Git Product home page Git Product logo

Comments (5)

sschmid avatar sschmid commented on April 28, 2024

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.

from entitas.

sschmid avatar sschmid commented on April 28, 2024

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 components count to store the components. To avoid creating large arrays for each entity, it can make sense to have multiple pools focusing on specific aspects like UI or Core Game, and therefore reducing the array capacity for the arrays in the entities. As a result, you run into the issue you described, since components from different pools always start with index 0.

from entitas.

 avatar commented on April 28, 2024

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.

from entitas.

sschmid avatar sschmid commented on April 28, 2024

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.

from entitas.

sschmid avatar sschmid commented on April 28, 2024

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 {}

from entitas.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.