This is my first project using ECS design and I come from a RDMS background for reference.
I'm building a ecology simulation that spans multiple planets, with the following ECS structure:
Entities & Components
- Planet (Components: Year)
- Biome (Components: Planet (Link to planet this biome is in))
- Species (Components: Population, Growth Rate, Biome (Link to biome they reside in))
Systems
- TimeSystem (Adds +1 to the year component every N ticks)
- PopulationGrowthSystem (Updates the Population component for each species if a year has passed on the planet)
Question:
I'm struggling with how the PopulationGrowthSystem should filter which Species Populations to update on each iteration.
Iterating through each Population component requires me to do a Species Entity->Biome Component->Planet Component lookup to check the year, which is terribly inefficient.
I've considered de-normalizing by putting something like year_last_updated in the Population Component, but it doesn't feel clean.
I've also considered just updating Population components every N-ticks, but Year needs to always be updated before the population is updated, and to my reading on proper ECS design, I shouldn't depend on the Systems being run in order.
I feel like I'm missing something obvious in how I'm approaching this.