Fix typos and cleanup
This commit is contained in:
parent
84d3419dfd
commit
09dd6d2645
|
|
@ -94,7 +94,7 @@ public struct Entity {
|
|||
|
||||
/// Remove all components from this entity.
|
||||
public func removeAll() {
|
||||
nexus.removeAll(componentes: identifier)
|
||||
nexus.removeAll(components: identifier)
|
||||
}
|
||||
|
||||
/// Destroy this entity.
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ public struct Family<R> where R: FamilyRequirementsManaging {
|
|||
@usableFromInline unowned let nexus: Nexus
|
||||
public let traits: FamilyTraitSet
|
||||
|
||||
public init(nexus: Nexus, requiresAll: @autoclosure () -> (R.ComponentTypes), excludesAll: [Component.Type]) {
|
||||
public init(nexus: Nexus, requiresAll: @autoclosure () -> R.ComponentTypes, excludesAll: [Component.Type]) {
|
||||
let required = R(requiresAll())
|
||||
self.nexus = nexus
|
||||
let traits = FamilyTraitSet(requiresAll: required.componentTypes, excludesAll: excludesAll)
|
||||
|
|
|
|||
|
|
@ -10,11 +10,11 @@ public typealias Family1<A: Component> = Family<Requires1<A>>
|
|||
public struct Requires1<A>: FamilyRequirementsManaging where A: Component {
|
||||
public let componentTypes: [Component.Type]
|
||||
|
||||
public init(_ components: (A.Type)) {
|
||||
public init(_ components: A.Type) {
|
||||
componentTypes = [A.self]
|
||||
}
|
||||
|
||||
public static func components(nexus: Nexus, entityId: EntityIdentifier) -> (A) {
|
||||
public static func components(nexus: Nexus, entityId: EntityIdentifier) -> A {
|
||||
let compA: A = nexus.get(unsafeComponentFor: entityId)
|
||||
return (compA)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,16 +51,16 @@ public func hash(combine seed: Int, _ value: Int) -> Int {
|
|||
/// - Returns: combined hash value.
|
||||
public func hash<S: Sequence>(combine hashValues: S) -> Int where S.Element == Int {
|
||||
/// http://www.boost.org/doc/libs/1_65_1/doc/html/hash/reference.html#boost.hash_range_idp517643120
|
||||
return hashValues.reduce(0) { hash(combine: $0, $1) }
|
||||
hashValues.reduce(0) { hash(combine: $0, $1) }
|
||||
}
|
||||
|
||||
/// Calculates the combined hash value of the elements. This implementation is based on boost::hash_range.
|
||||
/// Is sensitive to the order of the elements.
|
||||
/// - Parameter hashValues: sequence of hash values to combine.
|
||||
/// - Returns: combined hash value.
|
||||
public func hash<H: Sequence>(combine hashables: H) -> Int where H.Element: Hashable {
|
||||
public func hash<H: Sequence>(combine hashValues: H) -> Int where H.Element: Hashable {
|
||||
/// http://www.boost.org/doc/libs/1_65_1/doc/html/hash/reference.html#boost.hash_range_idp517643120
|
||||
return hashables.reduce(0) { hash(combine: $0, $1.hashValue) }
|
||||
hashValues.reduce(0) { hash(combine: $0, $1.hashValue) }
|
||||
}
|
||||
|
||||
// MARK: - entity component hash
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ extension Nexus {
|
|||
@inlinable
|
||||
public final func get<C>(unsafeComponentFor entityId: EntityIdentifier) -> C where C: Component {
|
||||
let component: Component = get(unsafeComponent: C.identifier, for: entityId)
|
||||
// components are guaranteed to be reference tyes so unsafeDowncast is applicable here
|
||||
// components are guaranteed to be reference types so unsafeDowncast is applicable here
|
||||
return unsafeDowncast(component, to: C.self)
|
||||
}
|
||||
|
||||
|
|
@ -89,7 +89,7 @@ extension Nexus {
|
|||
public final func remove(component componentId: ComponentIdentifier, from entityId: EntityIdentifier) -> Bool {
|
||||
// delete component instance
|
||||
componentsByType[componentId]?.remove(at: entityId.id)
|
||||
// unasign component from entity
|
||||
// un-assign component from entity
|
||||
componentIdsByEntity[entityId]?.remove(componentId)
|
||||
|
||||
update(familyMembership: entityId)
|
||||
|
|
@ -99,7 +99,7 @@ extension Nexus {
|
|||
}
|
||||
|
||||
@discardableResult
|
||||
public final func removeAll(componentes entityId: EntityIdentifier) -> Bool {
|
||||
public final func removeAll(components entityId: EntityIdentifier) -> Bool {
|
||||
guard let allComponents = get(components: entityId) else {
|
||||
delegate?.nexusNonFatalError("clearing components form entity \(entityId) with no components")
|
||||
return false
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ extension Nexus {
|
|||
|
||||
removeAllChildren(from: entityId)
|
||||
|
||||
if removeAll(componentes: entityId) {
|
||||
if removeAll(components: entityId) {
|
||||
update(familyMembership: entityId)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,8 +41,8 @@ extension Single where A: SingleComponent {
|
|||
@inlinable public var component: A {
|
||||
// Since we guarantee that the component will always be present by managing the complete lifecycle of the entity
|
||||
// and component assignment we may unsafelyUnwrap here.
|
||||
// Since components will allways be of reference type (class) we may use unsafeDowncast here for performance reasons.
|
||||
return nexus.get(unsafeComponentFor: entityId)
|
||||
// Since components will always be of reference type (class) we may use unsafeDowncast here for performance reasons.
|
||||
nexus.get(unsafeComponentFor: entityId)
|
||||
}
|
||||
|
||||
public var entity: Entity {
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ public struct UnorderedSparseSet<Element> {
|
|||
dense.removeAll(keepingCapacity: keepingCapacity)
|
||||
}
|
||||
|
||||
/// Removes an element from the set and retuns it in O(1).
|
||||
/// Removes an element from the set and returns it in O(1).
|
||||
/// The removed element is replaced with the last element of the set.
|
||||
///
|
||||
/// - Parameter denseIndex: the dense index
|
||||
|
|
|
|||
Loading…
Reference in New Issue