Cleanup and document family API

This commit is contained in:
Christian Treffs 2020-08-07 09:47:25 +02:00
parent 998ce2583c
commit 849110f8cc
No known key found for this signature in database
GPG Key ID: 49A4B4B460BE3ED4
1 changed files with 4 additions and 2 deletions

View File

@ -17,14 +17,16 @@ public struct Family<R> where R: FamilyRequirementsManaging {
nexus.onFamilyInit(traits: traits) nexus.onFamilyInit(traits: traits)
} }
@inlinable public var memberIds: UnorderedSparseSet<EntityIdentifier, EntityIdentifier.Idx> { @inlinable var memberIds: UnorderedSparseSet<EntityIdentifier, EntityIdentifier.Idx> {
nexus.members(withFamilyTraits: traits) nexus.members(withFamilyTraits: traits)
} }
/// Returns the number of family member entities.
@inlinable public var count: Int { @inlinable public var count: Int {
memberIds.count memberIds.count
} }
/// True if this family has no members; false otherwise.
@inlinable public var isEmpty: Bool { @inlinable public var isEmpty: Bool {
memberIds.isEmpty memberIds.isEmpty
} }
@ -55,7 +57,7 @@ extension Family: Equatable {
} }
extension Family: Sequence { extension Family: Sequence {
__consuming public func makeIterator() -> ComponentsIterator { public func makeIterator() -> ComponentsIterator {
ComponentsIterator(family: self) ComponentsIterator(family: self)
} }
} }