Swiftlint done for now
This commit is contained in:
parent
cb1ad79ff4
commit
34a75014ab
|
|
@ -58,7 +58,7 @@ file_header:
|
|||
\/\/ FirebladeECS
|
||||
\/\/
|
||||
\/\/ Created by .*? on \d{1,2}\/\d{1,2}\/\d{2}\.
|
||||
\/\/ Copyright © \d{4} Realm\. All rights reserved\.
|
||||
\/\/ Copyright © \d{4} Christian Treffs\. All rights reserved\.
|
||||
\/\/
|
||||
identifier_name:
|
||||
excluded:
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ public final class Family {
|
|||
}
|
||||
|
||||
var memberIds: UniformEntityIdentifiers {
|
||||
return nexus!.members(of: self)
|
||||
return nexus?.members(of: self) ?? UniformEntityIdentifiers()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,12 +43,12 @@ extension Nexus {
|
|||
if componentsByType[componentId] == nil {
|
||||
componentsByType[componentId] = UniformComponents()
|
||||
}
|
||||
componentsByType[componentId]!.add(component, at: entityIdx)
|
||||
componentsByType[componentId]?.add(component, at: entityIdx)
|
||||
|
||||
// assigns the component id to the entity id
|
||||
if componentIdsByEntity[entityIdx] != nil {
|
||||
let endIndex: Int = componentIdsByEntity[entityIdx]!.count
|
||||
componentIdsByEntity[entityIdx]!.append(componentId) // Amortized O(1)
|
||||
if let compIds = componentIdsByEntity[entityIdx] {
|
||||
let endIndex: Int = compIds.count
|
||||
componentIdsByEntity[entityIdx]?.append(componentId) // Amortized O(1)
|
||||
componentIdsByEntityLookup[hash] = endIndex
|
||||
} else {
|
||||
componentIdsByEntity[entityIdx] = ComponentIdentifiers(arrayLiteral: componentId)
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ private extension Nexus {
|
|||
if familyMembersByTraitHash[traitHash] == nil {
|
||||
familyMembersByTraitHash[traitHash] = UniformEntityIdentifiers()
|
||||
}
|
||||
familyMembersByTraitHash[traitHash]!.add(entityId, at: entityIdx)
|
||||
familyMembersByTraitHash[traitHash]?.add(entityId, at: entityIdx)
|
||||
}
|
||||
|
||||
func remove(from traitHash: FamilyTraitSetHash, entityId: EntityIdentifier, entityIdx: EntityIndex) {
|
||||
|
|
|
|||
|
|
@ -46,20 +46,27 @@ public class SparseSet<Element>: UniformStorage, Sequence {
|
|||
guard has(index) else {
|
||||
return nil
|
||||
}
|
||||
return dense[sparse[index]!]!.value
|
||||
guard let sIdx = sparse[index] else {
|
||||
return nil
|
||||
}
|
||||
return dense[sIdx]?.value
|
||||
}
|
||||
|
||||
public func remove(at index: Index) {
|
||||
guard has(index) else {
|
||||
return
|
||||
}
|
||||
let removeIdx: DenseIndex = sparse[index]!
|
||||
guard let removeIdx: DenseIndex = sparse[index] else {
|
||||
return
|
||||
}
|
||||
let lastIdx: DenseIndex = count - 1
|
||||
dense.swapAt(removeIdx, lastIdx)
|
||||
sparse[index] = nil
|
||||
let swapped: Pair = dense[removeIdx]!
|
||||
guard let swapped: Pair = dense[removeIdx] else {
|
||||
return
|
||||
}
|
||||
sparse[swapped.key] = removeIdx
|
||||
_ = dense.popLast()!!
|
||||
dense.removeLast()
|
||||
size -= 1
|
||||
if size == 0 {
|
||||
clear(keepingCapacity: false)
|
||||
|
|
|
|||
Loading…
Reference in New Issue