Fix start index for component iterators
This commit is contained in:
parent
c64495b4a9
commit
f6f8f5e5a2
|
|
@ -12,12 +12,18 @@ public protocol TypedFamilyProtocol: AnyObject {
|
|||
var nexus: Nexus? { get }
|
||||
var memberIds: UniformEntityIdentifiers { get }
|
||||
var members: Members { get set }
|
||||
|
||||
var count: Int { get }
|
||||
}
|
||||
|
||||
public extension TypedFamilyProtocol {
|
||||
var memberIds: UniformEntityIdentifiers {
|
||||
return nexus?.members(withFamilyTraits: traits) ?? UniformEntityIdentifiers()
|
||||
}
|
||||
|
||||
var count: Int {
|
||||
return memberIds.count
|
||||
}
|
||||
}
|
||||
|
||||
public protocol FamilyMembersProtocol: LazySequenceProtocol {
|
||||
|
|
|
|||
|
|
@ -40,12 +40,11 @@ public struct ComponentIterator1<A>: ComponentIteratorProtocol where A: Componen
|
|||
|
||||
public private(set) weak var nexus: Nexus?
|
||||
public let memberIds: UniformEntityIdentifiers
|
||||
public var index: Int
|
||||
public var index: Int = -1
|
||||
|
||||
public init(_ nexus: Nexus?, _ family: TypedFamily1<A>) {
|
||||
self.nexus = nexus
|
||||
memberIds = family.memberIds
|
||||
index = memberIds.index(before: memberIds.startIndex)
|
||||
}
|
||||
|
||||
public mutating func next() -> A? {
|
||||
|
|
|
|||
|
|
@ -40,12 +40,11 @@ public struct ComponentIterator2<A, B>: ComponentIteratorProtocol where A: Compo
|
|||
|
||||
public private(set) weak var nexus: Nexus?
|
||||
public let memberIds: UniformEntityIdentifiers
|
||||
public var index: Int
|
||||
public var index: Int = -1
|
||||
|
||||
public init(_ nexus: Nexus?, _ family: TypedFamily2<A, B>) {
|
||||
self.nexus = nexus
|
||||
memberIds = family.memberIds
|
||||
index = memberIds.index(before: memberIds.startIndex)
|
||||
}
|
||||
|
||||
public mutating func next() -> (A, B)? {
|
||||
|
|
|
|||
|
|
@ -41,12 +41,11 @@ public struct ComponentIterator3<A, B, C>: ComponentIteratorProtocol where A: Co
|
|||
|
||||
public private(set) weak var nexus: Nexus?
|
||||
public let memberIds: UniformEntityIdentifiers
|
||||
public var index: Int
|
||||
public var index: Int = -1
|
||||
|
||||
public init(_ nexus: Nexus?, _ family: TypedFamily3<A, B, C>) {
|
||||
self.nexus = nexus
|
||||
memberIds = family.memberIds
|
||||
index = memberIds.index(before: memberIds.startIndex)
|
||||
}
|
||||
|
||||
public mutating func next() -> (A, B, C)? {
|
||||
|
|
|
|||
|
|
@ -41,12 +41,11 @@ public struct ComponentIterator4<A, B, C, D>: ComponentIteratorProtocol where A:
|
|||
|
||||
public private(set) weak var nexus: Nexus?
|
||||
public let memberIds: UniformEntityIdentifiers
|
||||
public var index: Int
|
||||
public var index: Int = -1
|
||||
|
||||
public init(_ nexus: Nexus?, _ family: TypedFamily4<A, B, C, D>) {
|
||||
self.nexus = nexus
|
||||
memberIds = family.memberIds
|
||||
index = memberIds.index(before: memberIds.startIndex)
|
||||
}
|
||||
|
||||
public mutating func next() -> (A, B, C, D)? {
|
||||
|
|
|
|||
|
|
@ -41,12 +41,11 @@ public struct ComponentIterator5<A, B, C, D, E>: ComponentIteratorProtocol where
|
|||
|
||||
public private(set) weak var nexus: Nexus?
|
||||
public let memberIds: UniformEntityIdentifiers
|
||||
public var index: Int
|
||||
public var index: Int = -1
|
||||
|
||||
public init(_ nexus: Nexus?, _ family: TypedFamily5<A, B, C, D, E>) {
|
||||
self.nexus = nexus
|
||||
memberIds = family.memberIds
|
||||
index = memberIds.index(before: memberIds.startIndex)
|
||||
}
|
||||
|
||||
public mutating func next() -> (A, B, C, D, E)? {
|
||||
|
|
|
|||
Loading…
Reference in New Issue