Extend nexus with naive entity with component collection creation

This commit is contained in:
Christian Treffs 2020-07-30 15:33:28 +02:00
parent 9f95889439
commit 09bfa595c3
No known key found for this signature in database
GPG Key ID: 49A4B4B460BE3ED4
1 changed files with 7 additions and 0 deletions

View File

@ -21,6 +21,13 @@ extension Nexus {
return newEntity
}
@discardableResult
public func createEntity<C>(with components: C) -> Entity where C: Collection, C.Element == Component {
let entity = self.createEntity()
components.forEach { entity.assign($0) }
return entity
}
/// Number of entities in nexus.
public var numEntities: Int {
entityStorage.count