Update README
This commit is contained in:
parent
a0e6f05edc
commit
c4de78e6d0
24
README.md
24
README.md
|
|
@ -34,7 +34,7 @@ import PackageDescription
|
||||||
let package = Package(
|
let package = Package(
|
||||||
name: "YourPackageName",
|
name: "YourPackageName",
|
||||||
dependencies: [
|
dependencies: [
|
||||||
.package(url: "https://github.com/fireblade-engine/ecs.git", from: "0.12.2")
|
.package(url: "https://github.com/fireblade-engine/ecs.git", from: "0.13.0")
|
||||||
],
|
],
|
||||||
targets: [
|
targets: [
|
||||||
.target(
|
.target(
|
||||||
|
|
@ -216,6 +216,28 @@ nexus.family(requires: Position.self)
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### 🔗 Serialization
|
||||||
|
|
||||||
|
|
||||||
|
To serialize/deserialize entities you must conform their assigned components to the `Codable` protocol.
|
||||||
|
Conforming components can then be serialized per family like this:
|
||||||
|
|
||||||
|
```swift
|
||||||
|
// MyComponent and YourComponent both conform to Component and Codable protocols.
|
||||||
|
let nexus = Nexus()
|
||||||
|
let family = nexus.family(requiresAll: MyComponent.self, YourComponent.self)
|
||||||
|
|
||||||
|
// JSON encode entities from given family.
|
||||||
|
var jsonEncoder = JSONEncoder()
|
||||||
|
let encodedData = try family.encodeMembers(using: &jsonEncoder)
|
||||||
|
|
||||||
|
// Decode entities into given family from JSON.
|
||||||
|
// The decoded entities will be added to the nexus.
|
||||||
|
var jsonDecoder = JSONDecoder()
|
||||||
|
let newEntities = try family.decodeMembers(from: jsonData, using: &jsonDecoder)
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
## 🧪 Demo
|
## 🧪 Demo
|
||||||
|
|
||||||
See the [Fireblade ECS Demo App](https://github.com/fireblade-engine/ecs-demo) to get started.
|
See the [Fireblade ECS Demo App](https://github.com/fireblade-engine/ecs-demo) to get started.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue