EntityCoolSystem/README.md

69 lines
1.8 KiB
Markdown

# entity_cool_system
An ECS implementation in crystal
## Installation
1. Add the dependency to your `shard.yml`:
```yaml
dependencies:
entity_cool_system:
git: https://git.sceptique.eu/Sceptique/EntityCoolSystem
branch: master
```
2. Run `shards install`
## Usage
```crystal
require "entity_cool_system"
# init the world
world = ECS::World.new
# add custom systems
world << { name: "name_of_a_system", system: new MyScope::Systems::CustomSystem }
world["name_of_a_system"] << new MyScope::Entities::SomeKind("params1")
world["name_of_a_system"] << new MyScope::Entities::SomeKind("params2")
world["name_of_a_system"] << new MyScope::Entities::SomeKind("params3")
# call the systems #init methods
world.init
# maybe infinite loop
100.times do |i|
# call the systems #update methods
world.update
end
# call the systems #cleanup methods
world.cleanup
```
First you must define your systems and components.
Systems extend `ECS::System` and may provide `#init`, `#update`, `#cleanup` methods. To do so they also must implement `ECS::System::Init`, `ECS::System::Update`, `ECS::System::Cleanup`.
Components are extending `CS::Component` and they are initialized with an entity as first parameter. A macro `ECS::Components.generate_component` is provided in order to be able to generate new simple component initializer in one line.
You may provide entities generator if needed.
## Development
TODO: Write development instructions here
## Contributing
1. Fork it (<https://git.sceptique.eu/Sceptique/EntityCoolSystem>)
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request
## Contributors
- [Arthur Poulet](https://git.sceptique.eu/Sceptique - creator and maintainer