Comments (5)
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.
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.
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.
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.
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)
- Add/Replace/Remove vs Set/Unset HOT 5
- Boolean in setttings for unique components to actually be unique
- A component with multiple contexts +events, only make event listeners for 1 context
- Could not resolve type with token ... expected class System.Threading.CancellationToken HOT 10
- How to generate codes in a project which has several csproj files? HOT 1
- Update on Entitas 2.0-beta and my situation HOT 4
- [1.14.1]code gen twice and compile error HOT 1
- there is a Error, on click Tools/Jenny/Gennerate, how can I do? HOT 4
- _group.GetEntities().AsParallel().ForAll(Execute);这段语句有GC HOT 2
- Is it feasible to use Entitas in the backend? HOT 7
- Entity Behaviour in Unity inspector not visible HOT 2
- Removal of crucial SearchPaths when executing the wiz command
- How to get all group in some context, without reflection。
- GUI Null ref when trying to view entity in inspector HOT 1
- generator issues HOT 1
- Error running dotnet Jenny/Jenny.Generator.Cli.dll gen -v command - System.IO.FileNotFoundException HOT 1
- Bro i want remove this how i remove
- Generate error
- Visual debugging. Coloring components not working properly. HOT 2
- Fixed Point HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from entitas.