Add destroyMembers method to family

This commit is contained in:
Christian Treffs 2020-08-07 09:46:55 +02:00
parent d9c477e48a
commit 2a33e98118
No known key found for this signature in database
GPG Key ID: 49A4B4B460BE3ED4
1 changed files with 7 additions and 0 deletions

View File

@ -38,6 +38,13 @@ public struct Family<R> where R: FamilyRequirementsManaging {
public func isMember(_ entity: Entity) -> Bool {
nexus.isMember(entity, in: traits)
}
/// Destroy all member entities of this family.
/// - Returns: True if entities where destroyed successfully, false otherwise.
@discardableResult
public func destroyMembers() -> Bool {
entities.reduce(!isEmpty) { $0 && nexus.destroy(entity: $1) }
}
}
extension Family: Equatable {