https://github.com/jasonxudeveloper/easyecs
An Entity-Component-System library
https://github.com/jasonxudeveloper/easyecs
Last synced: 20 days ago
JSON representation
An Entity-Component-System library
- Host: GitHub
- URL: https://github.com/jasonxudeveloper/easyecs
- Owner: JasonXuDeveloper
- License: mit
- Created: 2025-01-19T10:08:08.000Z (5 months ago)
- Default Branch: master
- Last Pushed: 2025-06-01T10:40:47.000Z (about 1 month ago)
- Last Synced: 2025-06-01T12:09:30.223Z (about 1 month ago)
- Language: C#
- Size: 121 KB
- Stars: 6
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# EasyEcs

An Entity-Component-System library
## Why?
Sometimes we may want to remove bidirectional dependencies between our code, and ECS is a good way to do this.
This design pattern offers a clean way to separate the data from the logic, and it's also a good way to improve the performance.
## What is ECS?
E - Entity
C - Component
S - System
But what really is it?
Well, as a human, we (entities) live in the world (context), and we have some properties (components). Moreover, we have things to do based on our properties (systems).
## Concepts in EasyEcs
- A `Context` holds several `Entity` instances, some `System` instances and some `SingletonComponent` instances.
- Each `Entity` has some `Component` instances.
- Each `Component` (or `SingletonComponent`) has only data properties.
- Each `System` can filter lots of `Entity` instances in the same `Context` by their components and operate logics on them.## Why it removes bidirectional dependencies?
- Only `System` contains logics and none of them should reference on each other. But we allow one system depends on another by specifying `Priority`. (They should only depend on the filtered entities/components)
- `Component` only contains data properties and no logics. (Again, no way to have dependency)
- `Entity` only contains components. (It is really just a container)## Why is it fast?
- As a `System` can operate on a batch of entities with components, we can well utilize the cache of the MMU.
- We can also easily parallelize the systems to improve the performance, in a multi-core CPU environment.## Anything special in EasyEcs?
- We have **priority** for `System`, so you can control the order of systems.
- We have **frequency** for `System`, so you can control the frequency of systems being executed.
- We only allow **asynchronous** interfaces for `System` and `Context`, so our ECS should not block the thread (unless you screw up).
- We introduce built-in **parallelism** and/or **concurrency** for `System`, so you can easily parallelize your systems (for those who are in the same priority) and well utilize the multi-core CPU.
- We have a cool guy who is maintaining this library. (Just kidding)## Example
Just check out the `EasyEcs.UnitTest` project. I have comments there.
## Documentation
Believe me, one day I will make a website for this and document everything.