The entity component system (aka ECS, entity system) is an architectural pattern that represents game objects with entities (unique IDs - essentially just numbers) associated with various components (pure data that contain no behavior). Systems proper are free functions called each frame (or at some other frequency) that select all the entities fulfilling some criteria (e.g. all entities with both a Health
component and a Regeneration
component). For more details see:
- A Data-Driven Game Object System
- Evolve Your Hierarchy
- Entity Systems are the future of MMOG development
- Data-oriented design book
- ECS back and forth
Anatta is a library that integrates the ECS pattern into Roblox. Anatta aims to provide all that is reasonably necessary to use ECS to develop a Roblox game, but no more. Anatta provides infrastructure to:
- Represent game state with entities and components
- Define components with introspectable types and perform validation automatically
- Create expressive queries that can be used to iterate over entities and their components
- Handle temporarily connected
RBXSriptConnection
s and temporarily existingInstance
s - Convert entities and components between Roblox
Instance
attributes and their preferred representation
Anatta is not a framework. Structure your code however you'd like!
An entity component system for use on Roblox was originally motivated by the inadequacy of the DataModel
to elegantly solve problems with state and identity - particularly when Workspace.StreamingEnabled
is set, when uniquely replicating Instance
s via PlayerGui
(where each client in a typical setup has their own copy of the Instance
), or in other cases when there is not necessarily a one-to-one correspondence between an Instance
and a logical game object.