Fix family iteration
This commit is contained in:
parent
2386fab4c3
commit
00bb739880
|
|
@ -5,55 +5,137 @@
|
||||||
// Created by Christian Treffs on 20.10.17.
|
// Created by Christian Treffs on 20.10.17.
|
||||||
//
|
//
|
||||||
|
|
||||||
public protocol FamilyIterable {
|
extension Family {
|
||||||
func forEachMember(_ applyToMember: (Entity) -> Void)
|
public func iterateMembers(_ apply: @escaping (EntityIdentifier, () -> Entity) -> Void) {
|
||||||
func forEachMember<A>(_ applyToMember: (Entity, A) -> Void) where A: Component
|
memberIds.forEach { (entityId: EntityIdentifier) -> Void in
|
||||||
func forEachMember<A, B>(_ applyToMember: (Entity, A, B) -> Void) where A: Component, B: Component
|
func getEntity() -> Entity {
|
||||||
func forEachMember<A, B, C>(_ applyToMember: (Entity, A, B, C) -> Void) where A: Component, B: Component, C: Component
|
return nexus.get(entity: entityId)
|
||||||
func forEachMember<A, B, C, D>(_ applyToMember: (Entity, A, B, C, D) -> Void) where A: Component, B: Component, C: Component, D: Component
|
}
|
||||||
func forEachMember<A, B, C, D, E>(_ applyToMember: (Entity, A, B, C, D, E) -> Void) where A: Component, B: Component, C: Component, D: Component, E: Component
|
apply(entityId, getEntity)
|
||||||
func forEachMember<A, B, C, D, E, F>(_ applyToMember: (Entity, A, B, C, D, E, F) -> Void) where A: Component, B: Component, C: Component, D: Component, E: Component, F: Component
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Family/*: FamilyIterable*/ {
|
extension Family {
|
||||||
public func forEachMember(_ applyToMember: (Entity) -> Void) {
|
|
||||||
members.forEach { applyToMember(nexus.get(entity: $0)!) }
|
|
||||||
}
|
|
||||||
|
|
||||||
public func forEachMember<A>(_ applyToMember: (Entity, () -> A?) -> Void) where A: Component {
|
public func iterate<A>(components _: A.Type, _ apply: @escaping (() -> Entity, () -> A?) -> Void)
|
||||||
forEachMember { (entity: Entity) in
|
where A: Component {
|
||||||
applyToMember(entity, entity.component())
|
iterateMembers { (entityId, getEntityInstance) in
|
||||||
|
func getComponent<Z>() -> Z? where Z: Component {
|
||||||
|
return self.nexus.get(component: Z.identifier, for: entityId) as? Z
|
||||||
|
}
|
||||||
|
apply(getEntityInstance, getComponent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func forEachMember<A, B>(_ applyToMember: (Entity, () -> A?, () -> B?) -> Void) where A: Component, B: Component {
|
public func iterate<A, B>(components _: A.Type, _: B.Type, _ apply: @escaping (() -> Entity, () -> A?, () -> B?) -> Void)
|
||||||
forEachMember { (entity: Entity) in
|
where A: Component, B: Component {
|
||||||
applyToMember(entity, entity.component(), entity.component())
|
iterateMembers { (entityId, getEntityInstance) in
|
||||||
|
func getComponent<Z>() -> Z? where Z: Component {
|
||||||
|
return self.nexus.get(component: Z.identifier, for: entityId) as? Z
|
||||||
|
}
|
||||||
|
apply(getEntityInstance, getComponent, getComponent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func forEachMember<A, B, C>(_ applyToMember: (Entity, () -> A?, () -> B?, () -> C?) -> Void) where A: Component, B: Component, C: Component {
|
public func iterate<A, B, C>(components _: A.Type, _: B.Type, _: C.Type, _ apply: @escaping (() -> Entity, () -> A?, () -> B?, () -> C?) -> Void)
|
||||||
forEachMember { (entity: Entity) in
|
where A: Component, B: Component, C: Component {
|
||||||
applyToMember(entity, entity.component(), entity.component(), entity.component())
|
iterateMembers { (entityId, getEntityInstance) in
|
||||||
|
func getComponent<Z>() -> Z? where Z: Component {
|
||||||
|
return self.nexus.get(component: Z.identifier, for: entityId) as? Z
|
||||||
|
}
|
||||||
|
apply(getEntityInstance, getComponent, getComponent, getComponent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func forEachMember<A, B, C, D>(_ applyToMember: (Entity, () -> A?, () -> B?, () -> C?, () -> D?) -> Void) where A: Component, B: Component, C: Component, D: Component {
|
public func iterate<A, B, C, D>(components _: A.Type, _: B.Type, _: C.Type, _: D.Type, _ apply: @escaping (() -> Entity, () -> A?, () -> B?, () -> C?, () -> D?) -> Void)
|
||||||
forEachMember { (entity: Entity) in
|
where A: Component, B: Component, C: Component, D: Component {
|
||||||
applyToMember(entity, entity.component(), entity.component(), entity.component(), entity.component())
|
iterateMembers { (entityId, getEntityInstance) in
|
||||||
|
func getComponent<Z>() -> Z? where Z: Component {
|
||||||
|
return self.nexus.get(component: Z.identifier, for: entityId) as? Z
|
||||||
|
}
|
||||||
|
apply(getEntityInstance, getComponent, getComponent, getComponent, getComponent)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public func iterate<A, B, C, D, E>(components _: A.Type, _: B.Type, _: C.Type, _: D.Type, _: E.Type, _ apply: @escaping (() -> Entity, () -> A?, () -> B?, () -> C?, () -> D?, () -> E?) -> Void)
|
||||||
|
where A: Component, B: Component, C: Component, D: Component, E: Component {
|
||||||
|
iterateMembers { (entityId, getEntityInstance) in
|
||||||
|
func getComponent<Z>() -> Z? where Z: Component {
|
||||||
|
return self.nexus.get(component: Z.identifier, for: entityId) as? Z
|
||||||
|
}
|
||||||
|
apply(getEntityInstance, getComponent, getComponent, getComponent, getComponent, getComponent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func forEachMember<A, B, C, D, E>(_ applyToMember: (Entity, () -> A?, () -> B?, () -> C?, () -> D?, () -> E?) -> Void) where A: Component, B: Component, C: Component, D: Component, E: Component {
|
public func iterate<A, B, C, D, E, F>(components _: A.Type, _: B.Type, _: C.Type, _: D.Type, _: E.Type, _: F.Type,
|
||||||
forEachMember { (entity: Entity) in
|
_ apply: @escaping (() -> Entity, () -> A?, () -> B?, () -> C?, () -> D?, () -> E?, () -> F?) -> Void)
|
||||||
applyToMember(entity, entity.component(), entity.component(), entity.component(), entity.component(), entity.component())
|
where A: Component, B: Component, C: Component, D: Component, E: Component, F: Component {
|
||||||
|
iterateMembers { (entityId, getEntityInstance) in
|
||||||
|
func getComponent<Z>() -> Z? where Z: Component {
|
||||||
|
return self.nexus.get(component: Z.identifier, for: entityId) as? Z
|
||||||
|
}
|
||||||
|
apply(getEntityInstance, getComponent, getComponent, getComponent, getComponent, getComponent, getComponent)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Family {
|
||||||
|
|
||||||
|
public func iterate<A>(_ apply: @escaping (() -> Entity, () -> A?) -> Void) where A: Component {
|
||||||
|
iterateMembers { (entityId, getEntityInstance) in
|
||||||
|
func getComponent<Z>() -> Z? where Z: Component {
|
||||||
|
return self.nexus.get(component: Z.identifier, for: entityId) as? Z
|
||||||
|
}
|
||||||
|
apply(getEntityInstance, getComponent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func forEachMember<A, B, C, D, E, F>(_ applyToMember: (Entity, () -> A?, () -> B?, () -> C?, () -> D?, () -> E?, () -> F?) -> Void) where A: Component, B: Component, C: Component, D: Component, E: Component, F: Component {
|
public func iterate<A, B>(_ apply: @escaping (() -> Entity, () -> A?, () -> B?) -> Void)
|
||||||
forEachMember { (entity: Entity) in
|
where A: Component, B: Component {
|
||||||
applyToMember(entity, entity.component(), entity.component(), entity.component(), entity.component(), entity.component(), entity.component())
|
iterateMembers { (entityId, getEntityInstance) in
|
||||||
|
func getComponent<Z>() -> Z? where Z: Component {
|
||||||
|
return self.nexus.get(component: Z.identifier, for: entityId) as? Z
|
||||||
|
}
|
||||||
|
apply(getEntityInstance, getComponent, getComponent)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public func iterate<A, B, C>(_ apply: @escaping (() -> Entity, () -> A?, () -> B?, () -> C?) -> Void)
|
||||||
|
where A: Component, B: Component, C: Component {
|
||||||
|
iterateMembers { (entityId, getEntityInstance) in
|
||||||
|
func getComponent<Z>() -> Z? where Z: Component {
|
||||||
|
return self.nexus.get(component: Z.identifier, for: entityId) as? Z
|
||||||
|
}
|
||||||
|
apply(getEntityInstance, getComponent, getComponent, getComponent)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public func iterate<A, B, C, D>(_ apply: @escaping (() -> Entity, () -> A?, () -> B?, () -> C?, () -> D?) -> Void)
|
||||||
|
where A: Component, B: Component, C: Component, D: Component {
|
||||||
|
iterateMembers { (entityId, getEntityInstance) in
|
||||||
|
func getComponent<Z>() -> Z? where Z: Component {
|
||||||
|
return self.nexus.get(component: Z.identifier, for: entityId) as? Z
|
||||||
|
}
|
||||||
|
apply(getEntityInstance, getComponent, getComponent, getComponent, getComponent)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public func iterate<A, B, C, D, E>(_ apply: @escaping (() -> Entity, () -> A?, () -> B?, () -> C?, () -> D?, () -> E?) -> Void)
|
||||||
|
where A: Component, B: Component, C: Component, D: Component, E: Component {
|
||||||
|
iterateMembers { (entityId, getEntityInstance) in
|
||||||
|
func getComponent<Z>() -> Z? where Z: Component {
|
||||||
|
return self.nexus.get(component: Z.identifier, for: entityId) as? Z
|
||||||
|
}
|
||||||
|
apply(getEntityInstance, getComponent, getComponent, getComponent, getComponent, getComponent)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public func iterate<A, B, C, D, E, F>(_ apply: @escaping (() -> Entity, () -> A?, () -> B?, () -> C?, () -> D?, () -> E?, () -> F?) -> Void) where A: Component, B: Component, C: Component, D: Component, E: Component, F: Component {
|
||||||
|
iterateMembers { (entityId, getEntityInstance) in
|
||||||
|
func getComponent<Z>() -> Z? where Z: Component {
|
||||||
|
return self.nexus.get(component: Z.identifier, for: entityId) as? Z
|
||||||
|
}
|
||||||
|
apply(getEntityInstance, getComponent, getComponent, getComponent, getComponent, getComponent, getComponent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,10 @@ extension Family {
|
||||||
return nexus.isMember(entity, in: self)
|
return nexus.isMember(entity, in: self)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal var members: EntitySet {
|
internal var members: LazyMapCollection<LazyFilterCollection<LazyMapCollection<EntityIdSet, Entity?>>, Entity> {
|
||||||
|
return nexus.members(of: self)
|
||||||
|
}
|
||||||
|
internal var memberIds: EntityIdSet {
|
||||||
return nexus.members(of: self)
|
return nexus.members(of: self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,13 @@ extension Nexus {
|
||||||
return get(hash)
|
return get(hash)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func get(component componentId: ComponentIdentifier, for entityId: EntityIdentifier) -> Component? {
|
||||||
|
let hash: EntityComponentHash = componentId.hashValue(using: entityId.index)
|
||||||
|
guard let componentIdx: ComponentIndex = componentIndexByEntityComponentHash[hash] else { return nil }
|
||||||
|
guard let uniformComponents: UniformComponents = componentsByType[componentId] else { return nil }
|
||||||
|
return uniformComponents[componentIdx]
|
||||||
|
}
|
||||||
|
|
||||||
fileprivate func get<C>(_ hash: EntityComponentHash) -> C? where C: Component {
|
fileprivate func get<C>(_ hash: EntityComponentHash) -> C? where C: Component {
|
||||||
Log.info("GETTING: \(C.self)")
|
Log.info("GETTING: \(C.self)")
|
||||||
let componentId: ComponentIdentifier = C.identifier
|
let componentId: ComponentIdentifier = C.identifier
|
||||||
|
|
|
||||||
|
|
@ -51,9 +51,7 @@ extension Nexus {
|
||||||
return isValid(entity: entityId)
|
return isValid(entity: entityId)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func get(entity entityId: EntityIdentifier) -> Entity? {
|
public func get(entity entityId: EntityIdentifier) -> Entity {
|
||||||
Log.info("GETTING ENTITY: \(entityId)")
|
|
||||||
guard has(entity: entityId) else { return nil }
|
|
||||||
return entities[entityId.index]
|
return entities[entityId.index]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,11 +33,15 @@ extension Nexus {
|
||||||
return family.traits.isMatch(components: componentSet)
|
return family.traits.isMatch(components: componentSet)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func members(of family: Family) -> EntitySet {
|
public func members(of family: Family) -> EntityIdSet {
|
||||||
let traitHash: FamilyTraitSetHash = family.traits.hashValue
|
let traitHash: FamilyTraitSetHash = family.traits.hashValue
|
||||||
return familyMembersByTraitHash[traitHash] ?? [] // FIXME: fail?
|
return familyMembersByTraitHash[traitHash] ?? [] // FIXME: fail?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func members(of family: Family) -> LazyMapCollection<LazyFilterCollection<LazyMapCollection<EntityIdSet, Entity?>>, Entity> {
|
||||||
|
return members(of: family).lazy.flatMap { self.get(entity: $0) }
|
||||||
|
}
|
||||||
|
|
||||||
public func isMember(_ entity: Entity, in family: Family) -> Bool {
|
public func isMember(_ entity: Entity, in family: Family) -> Bool {
|
||||||
let traitHash: FamilyTraitSetHash = family.traits.hashValue
|
let traitHash: FamilyTraitSetHash = family.traits.hashValue
|
||||||
let entityId = entity.identifier
|
let entityId = entity.identifier
|
||||||
|
|
@ -82,7 +86,7 @@ extension Nexus {
|
||||||
let (inserted, _) = familyMembersByTraitHash[traitHash]!.insert(entityId)
|
let (inserted, _) = familyMembersByTraitHash[traitHash]!.insert(entityId)
|
||||||
assert(inserted, "entity with id \(entityId) already in family")
|
assert(inserted, "entity with id \(entityId) already in family")
|
||||||
} else {
|
} else {
|
||||||
familyMembersByTraitHash[traitHash] = EntitySet(minimumCapacity: 2)
|
familyMembersByTraitHash[traitHash] = EntityIdSet(minimumCapacity: 2)
|
||||||
familyMembersByTraitHash[traitHash]!.insert(entityId)
|
familyMembersByTraitHash[traitHash]!.insert(entityId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ public typealias UniformComponents = ContiguousArray<Component>
|
||||||
public typealias ComponentIdentifiers = ContiguousArray<ComponentIdentifier>
|
public typealias ComponentIdentifiers = ContiguousArray<ComponentIdentifier>
|
||||||
public typealias ComponentSet = Set<ComponentIdentifier>
|
public typealias ComponentSet = Set<ComponentIdentifier>
|
||||||
public typealias Entities = ContiguousArray<Entity>
|
public typealias Entities = ContiguousArray<Entity>
|
||||||
public typealias EntitySet = Set<EntityIdentifier>
|
public typealias EntityIdSet = Set<EntityIdentifier>
|
||||||
public typealias FamilyTraitSetHash = Int
|
public typealias FamilyTraitSetHash = Int
|
||||||
|
|
||||||
public class Nexus {
|
public class Nexus {
|
||||||
|
|
@ -47,7 +47,7 @@ public class Nexus {
|
||||||
var freeEntities: ContiguousArray<EntityIdentifier>
|
var freeEntities: ContiguousArray<EntityIdentifier>
|
||||||
|
|
||||||
var familiyByTraitHash: [FamilyTraitSetHash: Family]
|
var familiyByTraitHash: [FamilyTraitSetHash: Family]
|
||||||
var familyMembersByTraitHash: [FamilyTraitSetHash: EntitySet]
|
var familyMembersByTraitHash: [FamilyTraitSetHash: EntityIdSet]
|
||||||
var componentIdsSetByEntity: [EntityIndex: ComponentSet]
|
var componentIdsSetByEntity: [EntityIndex: ComponentSet]
|
||||||
|
|
||||||
public init() {
|
public init() {
|
||||||
|
|
@ -67,7 +67,7 @@ public class Nexus {
|
||||||
extension Nexus {
|
extension Nexus {
|
||||||
|
|
||||||
func notify(_ event: Event) {
|
func notify(_ event: Event) {
|
||||||
Log.debug(event)
|
//Log.debug(event)
|
||||||
// TODO: implement
|
// TODO: implement
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -77,11 +77,12 @@ class FamilyTests: XCTestCase {
|
||||||
|
|
||||||
var index: Int = 0
|
var index: Int = 0
|
||||||
|
|
||||||
family.forEachMember { (e: Entity, p: () -> Position!, v: () -> Velocity!, n: () -> Name?) in
|
family.iterate { (e: () -> Entity, p: () -> Position!, v: () -> Velocity!, n: () -> Name?) in
|
||||||
|
|
||||||
p()!.x = 10
|
let pos: Position = p()
|
||||||
|
pos.x = 10
|
||||||
|
|
||||||
print(e, p(), n())
|
print(e(), pos, n())
|
||||||
if index == 0 {
|
if index == 0 {
|
||||||
print(v())
|
print(v())
|
||||||
}
|
}
|
||||||
|
|
@ -89,9 +90,19 @@ class FamilyTests: XCTestCase {
|
||||||
index += 1
|
index += 1
|
||||||
}
|
}
|
||||||
|
|
||||||
family.forEachMember { (e: Entity, p: () -> Position!, v: () -> Velocity!, n: () -> Name?) in
|
family.iterate(components: Position.self, Velocity.self, Name.self) { (_, pos, vel, nm) in
|
||||||
|
let position: Position = pos()!
|
||||||
|
let velocity: Velocity = vel()!
|
||||||
|
let name: Name? = nm()
|
||||||
|
|
||||||
print(e, p().x, n())
|
_ = position
|
||||||
|
_ = velocity
|
||||||
|
_ = name
|
||||||
|
}
|
||||||
|
|
||||||
|
family.iterate { (e: () -> Entity, p: () -> Position!, v: () -> Velocity!, n: () -> Name?) in
|
||||||
|
|
||||||
|
print(e(), p().x, n())
|
||||||
if index == 0 {
|
if index == 0 {
|
||||||
print(v())
|
print(v())
|
||||||
}
|
}
|
||||||
|
|
@ -101,4 +112,83 @@ class FamilyTests: XCTestCase {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func testMeasureFamilyIteration() {
|
||||||
|
let nexus = Nexus()
|
||||||
|
let number: Int = 10_000
|
||||||
|
|
||||||
|
for i in 0..<number {
|
||||||
|
nexus.create(entity: "\(i)").assign(Position(x: 1+i, y: 2+i), Name(name: "myName\(i)"), Velocity(a: 3.14), EmptyComponent())
|
||||||
|
}
|
||||||
|
|
||||||
|
let family = nexus.family(requiresAll: [Position.self, Velocity.self], excludesAll: [Party.self], needsAtLeastOne: [Name.self, EmptyComponent.self])
|
||||||
|
|
||||||
|
nexus.entities.forEach { nexus.update(membership: family, for: $0) }
|
||||||
|
|
||||||
|
XCTAssert(family.members.count == number)
|
||||||
|
XCTAssert(family.memberIds.count == number)
|
||||||
|
XCTAssert(nexus.entities.count == number)
|
||||||
|
|
||||||
|
measure {
|
||||||
|
family.iterate(components: Position.self, Velocity.self, Name.self) { (_, pos, vel, nm) in
|
||||||
|
let position: Position = pos()!
|
||||||
|
let velocity: Velocity = vel()!
|
||||||
|
let name: Name? = nm()
|
||||||
|
|
||||||
|
_ = position
|
||||||
|
_ = velocity
|
||||||
|
_ = name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func testMeasureFamilyIteration2() {
|
||||||
|
let nexus = Nexus()
|
||||||
|
let number: Int = 10_000
|
||||||
|
|
||||||
|
for i in 0..<number {
|
||||||
|
nexus.create(entity: "\(i)").assign(Position(x: 1+i, y: 2+i), Name(name: "myName\(i)"), Velocity(a: 3.14), EmptyComponent())
|
||||||
|
}
|
||||||
|
|
||||||
|
let family = nexus.family(requiresAll: [Position.self, Velocity.self], excludesAll: [Party.self], needsAtLeastOne: [Name.self, EmptyComponent.self])
|
||||||
|
|
||||||
|
nexus.entities.forEach { nexus.update(membership: family, for: $0) }
|
||||||
|
|
||||||
|
XCTAssert(family.members.count == number)
|
||||||
|
XCTAssert(family.memberIds.count == number)
|
||||||
|
XCTAssert(nexus.entities.count == number)
|
||||||
|
|
||||||
|
measure {
|
||||||
|
family.iterate { (_: () -> Entity, pos: () -> Position!, vel: () -> Velocity!, nm: () -> Name?) in
|
||||||
|
let name: Name? = nm()
|
||||||
|
let velocity: Velocity = vel()!
|
||||||
|
let position: Position = pos()!
|
||||||
|
|
||||||
|
_ = position
|
||||||
|
_ = velocity
|
||||||
|
_ = name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func testMeasureEntityIteration() {
|
||||||
|
let nexus = Nexus()
|
||||||
|
let number: Int = 10_000
|
||||||
|
|
||||||
|
for i in 0..<number {
|
||||||
|
nexus.create(entity: "\(i)").assign(Position(x: 1+i, y: 2+i), Name(name: "myName\(i)"), Velocity(a: 3.14), EmptyComponent())
|
||||||
|
}
|
||||||
|
|
||||||
|
let family = nexus.family(requiresAll: [Position.self, Velocity.self], excludesAll: [Party.self], needsAtLeastOne: [Name.self, EmptyComponent.self])
|
||||||
|
|
||||||
|
nexus.entities.forEach { nexus.update(membership: family, for: $0) }
|
||||||
|
|
||||||
|
measure {
|
||||||
|
family.memberIds.forEach { (e) in
|
||||||
|
_ = e
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ class NexusTests: XCTestCase {
|
||||||
XCTAssert(e0.name == nil)
|
XCTAssert(e0.name == nil)
|
||||||
XCTAssert(e1.name == "Named e1")
|
XCTAssert(e1.name == "Named e1")
|
||||||
|
|
||||||
let rE0 = nexus.get(entity: e0.identifier)!
|
let rE0 = nexus.get(entity: e0.identifier)
|
||||||
XCTAssert(rE0.name == e0.name)
|
XCTAssert(rE0.name == e0.name)
|
||||||
XCTAssert(rE0.identifier == e0.identifier)
|
XCTAssert(rE0.identifier == e0.identifier)
|
||||||
}
|
}
|
||||||
|
|
@ -109,7 +109,7 @@ class NexusTests: XCTestCase {
|
||||||
let nexus = Nexus()
|
let nexus = Nexus()
|
||||||
let identifier: EntityIdentifier = nexus.create(entity: "e0").identifier
|
let identifier: EntityIdentifier = nexus.create(entity: "e0").identifier
|
||||||
|
|
||||||
let e0 = nexus.get(entity: identifier)!
|
let e0 = nexus.get(entity: identifier)
|
||||||
|
|
||||||
XCTAssert(e0.numComponents == 0)
|
XCTAssert(e0.numComponents == 0)
|
||||||
e0.remove(Position.self)
|
e0.remove(Position.self)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue