Cleanups
This commit is contained in:
parent
532741b126
commit
8174315fd3
|
|
@ -37,8 +37,6 @@ private protocol FamilyMemberComponentsGetterProtocol {
|
|||
func components<A, B, C, D, E>(_ entityId: EntityIdentifier) -> (A?, B?, C?, D?, E?) where A: Component, B: Component, C: Component, D: Component, E: Component
|
||||
}
|
||||
|
||||
// TODO: lazy get entity instead of entity identifier
|
||||
|
||||
extension Family: FamilyMemberIterable {
|
||||
|
||||
public final func iterate<A>(_ apply: @escaping (A?) -> Void) where A: Component {
|
||||
|
|
|
|||
|
|
@ -34,11 +34,11 @@ public final class Family: Equatable {
|
|||
}
|
||||
|
||||
public final var memberIds: UniformEntityIdentifiers {
|
||||
return nexus?.members(of: self) ?? UniformEntityIdentifiers()
|
||||
return nexus?.members(of: traits) ?? UniformEntityIdentifiers()
|
||||
}
|
||||
|
||||
public final var count: Int {
|
||||
return nexus?.members(of: self)?.count ?? 0
|
||||
return nexus?.members(of: traits)?.count ?? 0
|
||||
}
|
||||
|
||||
public final func canBecomeMember(_ entity: Entity) -> Bool {
|
||||
|
|
@ -55,7 +55,6 @@ public final class Family: Equatable {
|
|||
|
||||
// MARK: Equatable
|
||||
public static func == (lhs: Family, rhs: Family) -> Bool {
|
||||
// TODO: maybe this is not enough for equality
|
||||
return lhs.traits == rhs.traits && lhs.nexus == rhs.nexus
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ public class ManagedContiguousArray<Element>: UniformStorage {
|
|||
chunkSize = minCount
|
||||
store = ContiguousArray<Element?>(repeating: nil, count: minCount)
|
||||
}
|
||||
|
||||
deinit {
|
||||
clear()
|
||||
}
|
||||
|
|
@ -100,5 +101,3 @@ extension ManagedContiguousArray: Equatable where ManagedContiguousArray.Element
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
public typealias ContiguousEntityIdArray = ManagedContiguousArray<EntityIdentifier>
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
extension Nexus {
|
||||
|
||||
public var numComponents: Int {
|
||||
var numComponents: Int {
|
||||
return componentsByType.reduce(0) { return $0 + $1.value.count }
|
||||
}
|
||||
|
||||
|
|
@ -101,7 +101,7 @@ extension Nexus {
|
|||
public func clear(componentes entityId: EntityIdentifier) -> Bool {
|
||||
guard let allComponents: SparseComponentIdentifierSet = get(components: entityId) else {
|
||||
report("clearing components form entity \(entityId) with no components")
|
||||
return true
|
||||
return false
|
||||
}
|
||||
let removedAll: Bool = allComponents.reduce(true) { $0 && remove(component: $1, from: entityId) }
|
||||
return removedAll
|
||||
|
|
|
|||
|
|
@ -47,12 +47,11 @@ extension Nexus {
|
|||
return false
|
||||
}
|
||||
|
||||
let cleared: Bool = clear(componentes: entityId)
|
||||
assert(cleared, "Could not clear all components form entity \(entityId)")
|
||||
if clear(componentes: entityId) {
|
||||
update(familyMembership: entityId)
|
||||
}
|
||||
|
||||
freeEntities.append(entityId)
|
||||
|
||||
update(familyMembership: entityId)
|
||||
freeEntities.append(entityId)
|
||||
|
||||
notify(EntityDestroyed(entityId: entityId))
|
||||
return true
|
||||
|
|
|
|||
|
|
@ -33,11 +33,6 @@ public extension Nexus {
|
|||
return family.traits.isMatch(components: componentSet)
|
||||
}
|
||||
|
||||
func members(of family: Family) -> UniformEntityIdentifiers? {
|
||||
let traits: FamilyTraitSet = family.traits
|
||||
return members(of: traits)
|
||||
}
|
||||
|
||||
func members(of traits: FamilyTraitSet) -> UniformEntityIdentifiers? {
|
||||
return familyMembersByTraits[traits]
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue