type-safe entity component api generation via reflection-based code generation
Entitas uses a code generator (Jenny) that introspects component class definitions marked with IComponent interface and automatically generates type-safe fluent APIs (e.g., entity.AddPosition() instead of generic entity.AddComponent<Position>()). The generator creates context-specific entity classes, matcher factories, and component accessors by parsing C# source files and emitting boilerplate code, eliminating manual repetition while maintaining compile-time safety and IDE autocomplete support.
Unique: Uses attribute-driven code generation with Jenny generator that introspects IComponent implementations and emits context-specific entity classes with typed accessors, rather than relying on runtime reflection or manual interface implementation like traditional ECS frameworks
vs alternatives: Generates more type-safe and IDE-friendly APIs than reflection-based ECS frameworks (e.g., Arch, Flecs) while maintaining zero runtime overhead compared to hand-written code
multi-context entity lifecycle management with domain separation
Entitas provides a Context abstraction that acts as a container and lifecycle manager for entities belonging to a specific domain (e.g., GameContext, InputContext, UIContext). Each context maintains its own entity pool, component index, and group cache, allowing developers to logically partition game state and systems. Contexts expose fluent APIs for entity creation, destruction, and querying via matchers, with automatic group updates when entities gain or lose components.
Unique: Implements multi-context architecture where each context maintains independent entity pools, component indices, and group caches, enabling logical domain separation without shared mutable state between contexts
vs alternatives: Provides cleaner domain separation than single-context ECS frameworks (e.g., Arch) while maintaining better performance than inheritance-based approaches through composition and pooling
component attribute-driven code generation with custom generation rules
Entitas uses a Jenny code generator that parses component class definitions and their attributes ([Event], [Unique], [ForeignKey], [PrimaryKey], etc.) to generate specialized code. Attributes control code generation behavior, allowing developers to declare component properties without writing boilerplate. The generator supports custom generation rules via plugins, enabling teams to extend code generation for domain-specific needs (e.g., network serialization, UI binding).
Unique: Implements attribute-driven code generation with pluggable custom generation rules, allowing teams to extend code generation for domain-specific needs beyond standard ECS boilerplate
vs alternatives: More extensible than fixed code generation and more declarative than manual code writing, with plugin architecture enabling custom generation without modifying core framework
fluent entity api with method chaining for component operations
Entitas provides a fluent API for entity manipulation where component operations (add, remove, replace) can be chained together in a single expression. The generated entity classes expose typed methods like entity.AddPosition(x, y).AddVelocity(vx, vy).IsMoving(true) that return the entity instance, enabling readable, chainable code. This fluent pattern reduces boilerplate and improves code readability compared to imperative component management.
Unique: Implements fluent API for entity component operations via generated typed methods that return the entity instance, enabling readable method chaining for entity initialization
vs alternatives: More readable than imperative component management and more efficient than builder patterns, with generated methods providing compile-time type safety
reactive system execution with component change event subscriptions
Entitas implements reactive systems that automatically trigger when entities gain, lose, or replace specific components. Systems subscribe to component change events (OnComponentAdded, OnComponentRemoved, OnComponentReplaced) via matcher-based predicates, and the framework batches these events and executes reactive systems in response. This eliminates manual polling and enables event-driven architecture where systems only run when relevant state changes occur.
Unique: Implements reactive systems via component change event subscriptions with automatic batching and frame-synchronized execution, rather than requiring manual polling or observer pattern implementation
vs alternatives: More efficient than polling-based systems (e.g., traditional Update() loops) and more declarative than manual observer patterns, reducing boilerplate while improving frame-time consistency
component matcher-based group querying with automatic cache invalidation
Entitas provides a Matcher class that defines entity query criteria using fluent AllOf/AnyOf/NoneOf predicates, which are compiled into efficient group collections. Groups automatically track entities matching the matcher criteria and update their membership when entities gain or lose components. The framework caches groups by matcher hash to avoid redundant queries, and invalidates caches when component changes occur, ensuring queries always return correct results without manual refresh.
Unique: Implements matcher-based group caching with automatic invalidation on component changes, using hash-based matcher compilation to enable efficient reuse of complex queries without manual refresh
vs alternatives: More efficient than manual filtering loops and more flexible than pre-defined query types, with automatic cache management eliminating stale query results
entity pooling and memory management with garbage collection optimization
Entitas implements object pooling for entities and components to minimize garbage collection pressure in Unity's managed environment. When entities are destroyed, they are returned to a pool rather than deallocated, and component instances are reused across entity lifecycle. The framework pre-allocates entity pools based on expected capacity and resets component state on reuse, reducing GC.Alloc calls and frame-time spikes from garbage collection.
Unique: Implements entity and component pooling with automatic state reset on reuse, pre-allocation based on capacity hints, and integration with Unity's garbage collection to minimize GC.Alloc calls
vs alternatives: Reduces garbage collection pressure more effectively than allocation-per-frame approaches, with explicit pooling control compared to implicit GC-based frameworks
entity index-based fast lookup by component field values
Entitas provides entity indexing capabilities that create hash-based indices on specific component fields (e.g., index entities by their ID or position). Indices are automatically maintained as entities gain/lose components or component values change, enabling O(1) lookups by field value instead of O(n) group iteration. Developers declare indices via attributes on components, and the code generator creates index management code.
Unique: Implements automatic entity indexing on component fields with hash-based O(1) lookups and automatic index maintenance on component changes, declared via code generation attributes
vs alternatives: Faster than group iteration for single-value lookups and more automatic than manual dictionary management, with compile-time index declaration preventing runtime errors
+4 more capabilities