Update readme
This commit is contained in:
parent
b211cab2ed
commit
38c3f7078f
42
README.md
42
README.md
|
|
@ -47,12 +47,52 @@ let package = Package(
|
||||||
|
|
||||||
<!--Show what the library does as concisely as possible, developers should be able to figure out **how** your project solves their problem by looking at the code example. Make sure the API you are showing off is obvious, and that your code is short and concise.-->
|
<!--Show what the library does as concisely as possible, developers should be able to figure out **how** your project solves their problem by looking at the code example. Make sure the API you are showing off is obvious, and that your code is short and concise.-->
|
||||||
|
|
||||||
A core element in the Fireblade-ECS is the [Nexus](https://en.wiktionary.org/wiki/nexus#Noun). It acts as a centralized way to store, access and manage entities and their components.
|
A core element in the Fireblade-ECS is the [Nexus](https://en.wiktionary.org/wiki/nexus#Noun). It acts as a centralized way to store, access and manage entities and their components. You may use more than one nexus at the same time.
|
||||||
|
|
||||||
|
Initialize a nexus with
|
||||||
|
|
||||||
```swift
|
```swift
|
||||||
let nexus = Nexus()
|
let nexus = Nexus()
|
||||||
```
|
```
|
||||||
|
|
||||||
|
then create entities by generating them with the nexus.
|
||||||
|
|
||||||
|
```swift
|
||||||
|
let myEntity = nexus.create(entity: "myEntity")
|
||||||
|
```
|
||||||
|
|
||||||
|
You create components like this
|
||||||
|
|
||||||
|
```swift
|
||||||
|
class Movement: Component {
|
||||||
|
var position: (x: Double, y: Double) = (0.0, 1.0)
|
||||||
|
var velocity: Double = 0.1
|
||||||
|
}
|
||||||
|
```
|
||||||
|
and assign them to an entity with
|
||||||
|
|
||||||
|
```swift
|
||||||
|
myEntity.assign(Movement())
|
||||||
|
```
|
||||||
|
|
||||||
|
```swift
|
||||||
|
class PlayerMovementSystem {
|
||||||
|
let family = nexus.family(requiresAll: [Movement.self, PlayerInput.self], excludesAll: [])
|
||||||
|
|
||||||
|
func update() {
|
||||||
|
family.iterate { (_, mov: Movement!, input: PlayerInput!) in
|
||||||
|
|
||||||
|
mov.position
|
||||||
|
mov.velocity
|
||||||
|
...
|
||||||
|
|
||||||
|
input.command
|
||||||
|
...
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
<!--## Contributing
|
<!--## Contributing
|
||||||
|
|
||||||
Please read [CONTRIBUTING.md](https://gist.github.com/PurpleBooth/b24679402957c63ec426) for details on our code of conduct, and the process for submitting pull requests to us.-->
|
Please read [CONTRIBUTING.md](https://gist.github.com/PurpleBooth/b24679402957c63ec426) for details on our code of conduct, and the process for submitting pull requests to us.-->
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue