junkdog / artemis-odb

A continuation of the popular Artemis ECS framework
BSD 2-Clause "Simplified" License
777 stars 112 forks source link

[Question] Is withTag very expensive? Example: E player = E.withTag("player"); #624

Closed bryanbrunt closed 3 years ago

bryanbrunt commented 3 years ago

For example, you have a couple components that you reference frequently in your systems. Things like:

game player current location

I'm using E.withTag() to access those. However, I don't know how that's going to scale if I have thousands of components.

Is there an alternative?

I have found that there's possible bug with Singleton components. They don't deserialize. So I can't use singleton components for these commonly accessed items.

So potentially, using a singleton component that stores the entity ids of these components, I could set the id for those entities on the singleton, and make retrieval of the components much faster if withTag is expensive.

Anyone dealt with this problem? Or is it not a problem?