Add entity creation convenience to Entity

This commit is contained in:
Christian Treffs 2020-10-20 14:39:15 +02:00
parent c4d48202be
commit 788c6f75ea
No known key found for this signature in database
GPG Key ID: 49A4B4B460BE3ED4
1 changed files with 15 additions and 0 deletions

View File

@ -27,6 +27,21 @@ public struct Entity {
nexus.count(components: identifier) nexus.count(components: identifier)
} }
@discardableResult
public func createEntity() -> Entity {
nexus.createEntity()
}
@discardableResult
public func createEntity(with components: Component...) -> Entity {
createEntity(with: components)
}
@discardableResult
public func createEntity<C>(with components: C) -> Entity where C: Collection, C.Element == Component {
nexus.createEntity(with: components)
}
/// Checks if a component with given type is assigned to this entity. /// Checks if a component with given type is assigned to this entity.
/// - Parameter type: the component type. /// - Parameter type: the component type.
public func has<C>(_ type: C.Type) -> Bool where C: Component { public func has<C>(_ type: C.Type) -> Bool where C: Component {