Storing components for an ECS in java

380 views Asked by At

I'm creating a networked game in java using ECS(Entity Component System) and this is my first time using ECS. I'm not sure how I should store the components though. I do want to use an Entity class where I'll store components for that specific entity but how? Should I have all components be extended from a base class and store them in an arraylist? Should I use collections? I'm basically just asking if anyone has any recommendations on how to do this? Thanks.

1

There are 1 answers

0
Sam On

You might want to look at how Unity does it. Here's a little vocabulary to help you in your research.

Unity uses chunks to store archetypes of components. The components are stored in memory aligned arrays inside those chunks for better cache performance. You could also look into Unity's source code for ECS (stored in their "Entity" package), this could show you how they store and access component data.