In ECS, entities are just an identifier which components will be attached to, usually just an integer.
Rather than just a typedef for Int, I decided to make Entity a struct to provide a bit more type safety. I’m trusting in the swift compiler to make this reasonably efficient.
Unique ids need to be assigned to each new entity. In addition, when entities are created, we’re going to need to usually add components to them. So there’s an EntityBuilder class that will create and assign ids to new entities.
Also, when entities are destroyed, we’ll want to reclaim those ids and notify anyone interested that the entities are gone.
We’ll come back to EntityBuilder to help us add components to an entity
The protocol for EntityContainer is fairly straight forward
So we end up with an entity builder that can create entities and destroy them, then notify anything interested when entities are destroyed (purely for cleaning up any resources).
Components and component containers
All posts about the development of SwiftECS can be found here