Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions Sources/FirebladeECS/Family+Coding.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ public struct FamilyMemberContainer<each C: Component> {
}

/// Creates a new family member container from a sequence of components.
/// - Parameter component: A sequence of component tuples.
public init<S>(component: S) where S: Sequence, S.Element == (repeat each C) {
components = Array(component)
/// - Parameter components: A sequence of component tuples.
public init<S>(components sequence: S) where S: Sequence, S.Element == (repeat each C) {
components = Array(sequence)
}

/// Creates a new family member container from a family components iterator.
/// - Parameter components: The iterator providing component tuples.
public init(components: Family<repeat each C>.ComponentsIterator) {
self.components = Array(components)
public init(components iterator: Family<repeat each C>.ComponentsIterator) {
components = Array(iterator)
}
}

Expand Down Expand Up @@ -74,13 +74,13 @@ extension FamilyMemberContainer: Decodable where repeat each C: Decodable {
public init(from decoder: Decoder) throws {
let strategy = decoder.userInfo[CodingUserInfoKey.nexusCodingStrategy] as? CodingStrategy ?? DefaultCodingStrategy()
var familyContainer = try decoder.unkeyedContainer()
var componentsList: [(repeat each C)] = []
var decodedComponents: [(repeat each C)] = []
while !familyContainer.isAtEnd {
let container = try familyContainer.nestedContainer(keyedBy: DynamicCodingKey.self)
let memberComponents = try (repeat container.decode((each C).self, forKey: strategy.codingKey(for: (each C).self)))
componentsList.append(memberComponents)
decodedComponents.append(memberComponents)
}
components = componentsList
components = decodedComponents
}
}

Expand Down
6 changes: 3 additions & 3 deletions Sources/FirebladeECS/Nexus+Family.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,13 @@ extension Nexus {
/// - excludedComponents: All component types that must not be assigned to an entity in this family.
/// - Complexity: O(1) for existing families, O(N) where N is the number of entities for new families.
/// - Returns: The family of entities having 1 required components each.
public func family<Comp>(
public func family<Comp: Component>(
requires comp: Comp.Type,
excludesAll excludedComponents: Component.Type...
) -> Family<Comp> where Comp: Component {
) -> Family<Comp> {
Family<Comp>(
nexus: self,
requiresAll: (comp),
requiresAll: comp,
excludesAll: excludedComponents
)
}
Expand Down
Loading