Музыка: | VNV Nation - When is the Future? |
Entity Relations
Apparently the right way to implement relations is the by creating a relation table dynamically and adding there all ids satisfying the relation:
https://ajmmertens.medium.com/building-games-in-ecs-with-entity-relationships-657275ba2c6c
Basically we do
ComponentTables["[Relation] [What]"].[EntityId] != NULL
For example
ComponentTables["is mortal"].[Socrates] != NULL
In SQL people usually introduce secondary keys for that.
But yeah, that requires very efficient and adaptive hash table implementation, since we can have millions of relations, having just a few elements each. I.e. doing unordered_map<int,int> won't cut it.