Cleanups
This commit is contained in:
parent
a42918501d
commit
4c48aab814
|
|
@ -22,14 +22,14 @@ extension Component {
|
|||
}
|
||||
|
||||
// MARK: - entity component hashable
|
||||
internal extension Component {
|
||||
extension Component {
|
||||
|
||||
/// Provides XOR hash value from component identifier (aka type) and entity index.
|
||||
/// Is only stable for app runtime.
|
||||
///
|
||||
/// - Parameter entityIdx: entity index
|
||||
/// - Returns: combinded entity component hash
|
||||
internal static func hashValue(using entityIdx: EntityIndex) -> EntityComponentHash {
|
||||
static func hashValue(using entityIdx: EntityIndex) -> EntityComponentHash {
|
||||
return Self.identifier.hashValue(using: entityIdx)
|
||||
}
|
||||
|
||||
|
|
@ -38,7 +38,7 @@ internal extension Component {
|
|||
///
|
||||
/// - Parameter entityIdx: entity index
|
||||
/// - Returns: combinded entity component hash
|
||||
internal func hashValue(using entityIdx: EntityIndex) -> EntityComponentHash {
|
||||
func hashValue(using entityIdx: EntityIndex) -> EntityComponentHash {
|
||||
return Self.hashValue(using: entityIdx)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,18 +13,18 @@ public protocol UniqueComponentIdentifiable {
|
|||
var identifier: ComponentIdentifier { get }
|
||||
}
|
||||
|
||||
internal extension ComponentIdentifier {
|
||||
extension ComponentIdentifier {
|
||||
|
||||
/// Provides XOR hash value from component identifier (aka type) and entity index.
|
||||
/// Is only stable for app runtime.
|
||||
///
|
||||
/// - Parameter entityIdx: entity index
|
||||
/// - Returns: combinded entity component hash
|
||||
internal func hashValue(using entityIdx: EntityIndex) -> EntityComponentHash {
|
||||
func hashValue(using entityIdx: EntityIndex) -> EntityComponentHash {
|
||||
return hashValue(using: entityIdx.identifier)
|
||||
}
|
||||
|
||||
internal func hashValue(using entityId: EntityIdentifier) -> EntityComponentHash {
|
||||
func hashValue(using entityId: EntityIdentifier) -> EntityComponentHash {
|
||||
return EntityComponentHash.compose(entityId: entityId, componentTypeHash: hashValue)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ extension Entity {
|
|||
return nexus.isValid(entity: self)
|
||||
}
|
||||
|
||||
internal func invalidate() {
|
||||
func invalidate() {
|
||||
identifier = EntityIdentifier.invalid
|
||||
name = nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ extension Family {
|
|||
return nexus?.isMember(entityId, in: self) ?? false
|
||||
}
|
||||
|
||||
internal var memberIds: UniformEntityIdentifiers {
|
||||
var memberIds: UniformEntityIdentifiers {
|
||||
return nexus!.members(of: self)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,11 +68,11 @@ public class ManagedContiguousArray: UniformStorage {
|
|||
_store.removeAll(keepingCapacity: keepingCapacity)
|
||||
}
|
||||
|
||||
internal func needsToGrow(_ index: Index) -> Bool {
|
||||
func needsToGrow(_ index: Index) -> Bool {
|
||||
return index > _store.count - 1
|
||||
}
|
||||
|
||||
internal func grow(including index: Index) {
|
||||
func grow(including index: Index) {
|
||||
let newCapacity: Int = nearest(to: index)
|
||||
let newCount: Int = newCapacity-_store.count
|
||||
for _ in 0..<newCount {
|
||||
|
|
@ -80,7 +80,7 @@ public class ManagedContiguousArray: UniformStorage {
|
|||
}
|
||||
}
|
||||
|
||||
internal func nearest(to index: Index) -> Int {
|
||||
func nearest(to index: Index) -> Int {
|
||||
let delta = Float(index) / Float(ManagedContiguousArray.chunkSize)
|
||||
let multiplier = Int(delta) + 1
|
||||
return multiplier * ManagedContiguousArray.chunkSize
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@ extension Nexus {
|
|||
assert(false, "no component set defined for entity: \(entity)")
|
||||
return false
|
||||
}
|
||||
// FIXME: may be a bottle neck
|
||||
let componentSet: ComponentSet = ComponentSet.init(componentIds)
|
||||
return family.traits.isMatch(components: componentSet)
|
||||
}
|
||||
|
|
@ -73,14 +72,14 @@ extension Nexus {
|
|||
}
|
||||
|
||||
/// will be called on family init defer
|
||||
internal func onFamilyInit(family: Family) {
|
||||
func onFamilyInit(family: Family) {
|
||||
// FIXME: this is costly for many entities
|
||||
for entity: Entity in entityStorage {
|
||||
update(membership: family, for: entity.identifier)
|
||||
}
|
||||
}
|
||||
|
||||
internal func onFamilyDeinit(traitHash: FamilyTraitSetHash) {
|
||||
func onFamilyDeinit(traitHash: FamilyTraitSetHash) {
|
||||
for member in members(of: traitHash) {
|
||||
remove(from: traitHash, entityId: member, entityIdx: member.index)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +0,0 @@
|
|||
//
|
||||
// Profiler.swift
|
||||
// FirebladeECS
|
||||
//
|
||||
// Created by Christian Treffs on 28.10.17.
|
||||
//
|
||||
|
||||
struct Profiler {
|
||||
|
||||
}
|
||||
|
|
@ -23,8 +23,8 @@ public class SparseSet<Element>: UniformStorage, Sequence {
|
|||
}
|
||||
|
||||
public var count: Int { return size }
|
||||
internal var capacitySparse: Int { return sparse.capacity }
|
||||
internal var capacityDense: Int { return dense.capacity }
|
||||
var capacitySparse: Int { return sparse.capacity }
|
||||
var capacityDense: Int { return dense.capacity }
|
||||
|
||||
public func has(_ index: Index) -> Bool {
|
||||
return sparse[index] ?? Int.max < count &&
|
||||
|
|
|
|||
Loading…
Reference in New Issue