Perform-ecs is a tiny and efficient TypeScript based Component-Entity-System framework. It was originally written for Open Stronghold - open source clone of Stronghold/Stronghold Crusader engine.
Why Entity Component System?
ECS is an architectural pattern used mostly in game development. An ECS follows the Composition over Inheritance principle to allow for greater flexibility when defining entities by building out of individual parts that can be mixed-and-matched. This eliminates the ambiguity problems of long inheritance chains and promotes clean design.
You can read more here Evolve your hierarchy or here Entity Systems Wiki
Features
- Swift and efficient. The main principle is 'pay for what you use', so iterating over entities is really fast and you pay only when remove/add entities/components.
- Easy to use API
- Full TypeScript support when composing entities from components
Install
npm install perform-ecs --save
TS types inside.
Example
// create component // create system // prepare;;ecs.registerSystempositionSystem; // create entity; // create entity with arguments ; assertentity.x === 10;assertentity.y === 5;assertentity2.x === 20;assertentity2.y === 10; // system 'update' methods will be calledecs.update;
Docs
Coming soon
ToDo
- Documentation
- Benchmarks
- More valuable tests
- Check support for vanilla JS
- Clean codebase
- Multiple system views types, suitable for different cases, eg. when entities are removed/added very often.
License
This project is licensed under the MIT License - see the LICENSE.md file for details