Skip to content
ctreffs edited this page Oct 7, 2020 · 6 revisions

Family

public struct Family<R> where R: FamilyRequirementsManaging

Inheritance

Equatable, Sequence

Initializers

init(nexus:requiresAll:excludesAll:)

public init(nexus: Nexus, requiresAll: @autoclosure () -> R.ComponentTypes, excludesAll: [Component.Type])

Properties

traits

let traits: FamilyTraitSet

count

Returns the number of family member entities.

var count: Int

isEmpty

True if this family has no members; false otherwise.

var isEmpty: Bool

entities

var entities: EntityIterator

entityAndComponents

var entityAndComponents: EntityComponentIterator

Methods

canBecomeMember(_:)

@inlinable public func canBecomeMember(_ entity: Entity) -> Bool

isMember(_:)

@inlinable public func isMember(_ entity: Entity) -> Bool

destroyMembers()

Destroy all member entities of this family.

@discardableResult public func destroyMembers() -> Bool

Returns

True if entities where destroyed, false otherwise.

createMember(using:)

Create a member entity with the given components assigned.

@discardableResult public func createMember(using builder: () -> R.Components) -> Entity

Parameters

  • builder: The family member builder.

Returns

The newly created member entity.

==(lhs:rhs:)

public static func ==(lhs: Family<R>, rhs: Family<R>) -> Bool

makeIterator()

public func makeIterator() -> ComponentsIterator

createMember(with:)

Create a new entity with components required by this family.

@discardableResult public func createMember(with components: R.Components) -> Entity

Since the created entity will meet the requirements of this family it will automatically become member of this family.

Parameters

  • components: The components required by this family.

Returns

The newly created entity.

Clone this wiki locally