diff --git a/Sources/FirebladeECS/TypedFamily.swift b/Sources/FirebladeECS/TypedFamily.swift
index ed44732..5bf286b 100644
--- a/Sources/FirebladeECS/TypedFamily.swift
+++ b/Sources/FirebladeECS/TypedFamily.swift
@@ -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 {
diff --git a/Sources/FirebladeECS/TypedFamily1.swift b/Sources/FirebladeECS/TypedFamily1.swift
index 6657555..ca40f59 100644
--- a/Sources/FirebladeECS/TypedFamily1.swift
+++ b/Sources/FirebladeECS/TypedFamily1.swift
@@ -40,12 +40,11 @@ public struct ComponentIterator1: 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) {
self.nexus = nexus
memberIds = family.memberIds
- index = memberIds.index(before: memberIds.startIndex)
}
public mutating func next() -> A? {
diff --git a/Sources/FirebladeECS/TypedFamily2.swift b/Sources/FirebladeECS/TypedFamily2.swift
index 8a22134..7ca7d94 100644
--- a/Sources/FirebladeECS/TypedFamily2.swift
+++ b/Sources/FirebladeECS/TypedFamily2.swift
@@ -40,12 +40,11 @@ public struct ComponentIterator2: 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) {
self.nexus = nexus
memberIds = family.memberIds
- index = memberIds.index(before: memberIds.startIndex)
}
public mutating func next() -> (A, B)? {
diff --git a/Sources/FirebladeECS/TypedFamily3.swift b/Sources/FirebladeECS/TypedFamily3.swift
index da76dae..654ae3e 100644
--- a/Sources/FirebladeECS/TypedFamily3.swift
+++ b/Sources/FirebladeECS/TypedFamily3.swift
@@ -41,12 +41,11 @@ public struct ComponentIterator3: 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) {
self.nexus = nexus
memberIds = family.memberIds
- index = memberIds.index(before: memberIds.startIndex)
}
public mutating func next() -> (A, B, C)? {
diff --git a/Sources/FirebladeECS/TypedFamily4.swift b/Sources/FirebladeECS/TypedFamily4.swift
index 38ef944..4a54fdd 100644
--- a/Sources/FirebladeECS/TypedFamily4.swift
+++ b/Sources/FirebladeECS/TypedFamily4.swift
@@ -41,12 +41,11 @@ public struct ComponentIterator4: 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) {
self.nexus = nexus
memberIds = family.memberIds
- index = memberIds.index(before: memberIds.startIndex)
}
public mutating func next() -> (A, B, C, D)? {
diff --git a/Sources/FirebladeECS/TypedFamily5.swift b/Sources/FirebladeECS/TypedFamily5.swift
index ea8a21b..812ccf0 100644
--- a/Sources/FirebladeECS/TypedFamily5.swift
+++ b/Sources/FirebladeECS/TypedFamily5.swift
@@ -41,12 +41,11 @@ public struct ComponentIterator5: 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) {
self.nexus = nexus
memberIds = family.memberIds
- index = memberIds.index(before: memberIds.startIndex)
}
public mutating func next() -> (A, B, C, D, E)? {