The hot new1 thing in software architecture for games is entity component systems (ECS). While the rest of the software architecture world is admiring their shiny containers, edge computing, and cloud-native architecture, game developers are off in the corner creating new ECS-based architectures and pushing the boundaries of architecture with this runtime-flexible, highly compatible, safe, and easily composable approach to software.
An entity-component-system involves three components: an entity (a general purpose object); a component (the parameters for one facet of the object); and the system (something that runs continuously and performs actions on every entity that has a component of the same facet the system manages). ECS makes for the safe management of dependencies; the system can check entities for the components and perform logic as needed. Nothing is dependent on anything else in a strongly coupled way.
ECS also makes for easily “composable” software. There’s no complex inheritance tree, since every entity has little more than an ID and a list of the components—its facets. Any object necessary can be created by composing an entity with the needed facets. Features from one type of entity can be added to another by including the necessary components.
In game design, the use is obvious: a physics engine in a game can iterate through all the physics simulation components present, performing any necessary calculations without caring how the entity is drawn. Or health point components can be attached to a play entity but not to other entities in the game world, and the health management system would know how to deduct health from entities that have health point components when a collision that would cause a loss of health occurs.
Intersystem and intercomponent communication can be a problem in this architecture, but there are a number of solutions, including use of the observer pattern.
This architecture is not just for games. Paris Buttfield-Addison, Mars Geldard, and Tim Nugent explain why. You’ll learn how to apply the lessons from decades of ECS use in game development to the wider software development and software architecture world and see how ECS is related to existing similar architectures. (ECS is kind of microservices, combined with functional programming, on some levels, but isn’t quite the same.) ECS isn’t for every software problem, but you can learn a lot from it even if you don’t use it.
1. ECS debuted in 1998.
Paris Buttfield-Addison is cofounder of Secret Lab, a game development studio based in beautiful Hobart, Australia. Secret Lab builds games and game development tools, including the multi-award-winning ABC Play School iPad games, Night in the Woods, the Qantas airlines Joey Playbox games, and the Yarn Spinner narrative game framework. Previously, Paris was mobile product manager for Meebo (acquired by Google). Paris particularly enjoys game design, statistics, the blockchain, machine learning, and human-centered technology research and writes technical books on mobile and game development (more than 20 so far) for O’Reilly Media. He holds a degree in medieval history and a PhD in computing.
Marina Rose Geldard, more commonly known as Mars, is a final-year computing student from Down Under in Tasmania. Entering the world of technology relatively late as a mature-age student, she has found her place in the world: an industry where she can apply her lifelong love of mathematics and optimization. When she is not busy being the most annoyingly eager student ever, she compulsively volunteers at industry events, dabbles in research, and serves on the executive committee for her state’s branch of the Australian Computer Society (ACS). She’s currently writing “Practical AI with Swift” for O’Reilly Media.
Tim Nugent pretends to be a mobile app developer, game designer, tools builder, researcher, and tech author. When he isn’t busy avoiding being found out as a fraud, Tim spends most of his time designing and creating little apps and games he won’t let anyone see. He also spent a disproportionately long time writing this tiny little bio, most of which was taken up trying to stick a witty sci-fi reference in. . .before he simply gave up.
Comments on this page are now closed.
©2019, O'Reilly Media, Inc. • (800) 889-8969 or (707) 827-7019 • Monday-Friday 7:30am-5pm PT • All trademarks and registered trademarks appearing on oreilly.com are the property of their respective owners. • firstname.lastname@example.org