Update to new storage
This commit is contained in:
parent
5a33f1d19c
commit
64aea76a8e
|
|
@ -22,6 +22,7 @@ extension ComponentIdentifier {
|
|||
ObjectIdentifier(componentType).hashValue
|
||||
}
|
||||
|
||||
typealias StableId = UInt64
|
||||
internal static func makeStableTypeHash(component: Component) -> StableId {
|
||||
let componentTypeString = String(describing: type(of: component))
|
||||
return StringHashing.singer_djb2(componentTypeString)
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ extension Nexus {
|
|||
var componentInstances: [ComponentIdentifier.StableId: SComponent<SNexus>] = [:]
|
||||
var entityComponentsMap: [EntityIdentifier: Set<ComponentIdentifier.StableId>] = [:]
|
||||
|
||||
for entitId in self.entityStorage {
|
||||
for entitId in self.componentIdsByEntity.keys {
|
||||
entityComponentsMap[entitId] = []
|
||||
let componentIds = self.get(components: entitId) ?? []
|
||||
|
||||
|
|
@ -36,8 +36,7 @@ extension Nexus {
|
|||
let entityIds = sNexus.entities.map { $0.key }.reversed()
|
||||
|
||||
// FIXME: this does not respect the generator of the target nexus!
|
||||
self.init(entityStorage: UnorderedSparseSet(),
|
||||
componentsByType: [:],
|
||||
self.init(componentsByType: [:],
|
||||
componentsByEntity: [:],
|
||||
entityIdGenerator: DefaultEntityIdGenerator(startProviding: entityIds),
|
||||
familyMembersByTraits: [:],
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ public final class SerializationTests: XCTestCase {
|
|||
let decoder = JSONDecoder()
|
||||
let nexus2: Nexus = try decoder.decode(Nexus.self, from: data)
|
||||
|
||||
let firstEntity2 = nexus2.get(entity: firstEntity.identifier)!
|
||||
let firstEntity2 = nexus2.entity(from: firstEntity.identifier)
|
||||
XCTAssertEqual(firstEntity2.identifier, firstEntity.identifier)
|
||||
XCTAssertTrue(firstEntity2.has(Name.self))
|
||||
XCTAssertTrue(firstEntity2.has(Position.self))
|
||||
|
|
@ -62,7 +62,7 @@ public final class SerializationTests: XCTestCase {
|
|||
XCTAssertEqual(firstEntity2.get(component: Position.self)?.x, 1)
|
||||
XCTAssertEqual(firstEntity2.get(component: Position.self)?.y, 2)
|
||||
|
||||
let secondEntity2 = nexus2.get(entity: secondEntity.identifier)!
|
||||
let secondEntity2 = nexus2.entity(from: secondEntity.identifier)
|
||||
XCTAssertEqual(secondEntity2.identifier, secondEntity.identifier)
|
||||
XCTAssertTrue(secondEntity2.has(Velocity.self))
|
||||
XCTAssertTrue(secondEntity2.has(Party.self))
|
||||
|
|
|
|||
Loading…
Reference in New Issue