Entity Component System (ECS) - Kazzymodus/Spark GitHub Wiki

ECS System

The Entity-Component-System system (no, that's not a tautology) is the basis for gameplay within the Spark Engine. It's primary purpose is performance, consistency and avoiding the pitfalls associated with Object Oriented Design.

The way ECS works is that game object (or Entity) behaviour, rather than codified in one huge monolithic class, is segmented into individual, independent Components. All components are then batch processed by a System every frame.

There are some clear benefits to this technique: first and foremost, it allows you to create complex objects from individual pieces from behaviour, rather than having to lump everything into one class, avoiding code blobs and/or duplication. Secondly, it can be easily optimised to run very efficiently, saving memory and avoiding cache misses. And finally, it allows you to create discrete systems that don't thread through the entire update loop, keeping the code flow nice and simple.

Entities

The most interesting thing about entities is that, at least in Spark, they don't actually exist: there is no class called Entity, nor are entities ever referenced in components or systems. As far as the code is concerned, they are purely conceptual.