Update README
This commit is contained in:
parent
99d08c5139
commit
3d6fd06841
37
README.md
37
README.md
|
|
@ -1,9 +1,9 @@
|
|||
# Fireblade ECS (Entity-Component-System)
|
||||
[](https://travis-ci.com/fireblade-engine/ecs)
|
||||
[](releases/tag/v0.9.1)
|
||||
[](LICENSE)
|
||||
[](#)
|
||||
[](#)
|
||||
[](#)
|
||||
[](#)
|
||||
[](#)
|
||||
|
||||
This is a **dependency free**, **lightweight**, **fast** and **easy to use** [Entity-Component-System](https://en.wikipedia.org/wiki/Entity–component–system) implementation in Swift. It is developed and maintained as part of the [Fireblade Game Engine project](https://github.com/fireblade-engine).
|
||||
|
||||
|
|
@ -184,6 +184,37 @@ class GameLogicSystem {
|
|||
|
||||
```
|
||||
|
||||
### 👫 Relatives
|
||||
|
||||
This ECS implementation provides an integrated way of creating a [directed acyclic graph (DAG)](https://en.wikipedia.org/wiki/Directed_acyclic_graph) hierarchy of entities by forming parent-child relationships. Entities can become children of a parent entity. In family terms they become **relatives**. Families provide iteration over these relationships.
|
||||
The entity hierachy implementation does not use an additional component therefore keeping the hierarchy intact over different component-families.
|
||||
This feature is especially useful for implenting a [scene graph](https://en.wikipedia.org/wiki/Scene_graph).
|
||||
|
||||
```swift
|
||||
// create entities with 0 to n components
|
||||
let parent: Entity = nexus.createEntity(with: Position(x: 1, y: 1), SomeOtherComponent(...))
|
||||
let child: Entity = nexus.createEntity(with: Position(x: 2, y: 2))
|
||||
let child2: Entity = nexus.createEntity(with: Position(x: 3, y: 3), MySpecialComponent(...))
|
||||
|
||||
// create relationships between entities
|
||||
parent.addChild(child)
|
||||
child.addChild(child2)
|
||||
// or remove them
|
||||
// parent.removeChild(child)
|
||||
|
||||
// iterate over component families descending the graph
|
||||
nexus.family(requires: Position.self)
|
||||
.descendRelatives(from: parent) // provide the start entity (aka root "node")
|
||||
.forEach { (parent: Position, child: Position) in
|
||||
// parent: the current parent component
|
||||
// child: the current child component
|
||||
|
||||
// update you components hierarchically
|
||||
child.x += parent.x
|
||||
child.y += parent.y
|
||||
}
|
||||
```
|
||||
|
||||
## 🧪 Demo
|
||||
|
||||
See the [Fireblade ECS Demo App](https://github.com/fireblade-engine/ecs-demo) to get started.
|
||||
|
|
|
|||
Loading…
Reference in New Issue