Refine ComponentIdentifier
This commit is contained in:
parent
e351de9fb3
commit
37618d5b4f
|
|
@ -7,22 +7,18 @@
|
|||
|
||||
/// Identifies a component by it's meta type
|
||||
public struct ComponentIdentifier {
|
||||
@usableFromInline
|
||||
typealias Hash = Int
|
||||
@usableFromInline
|
||||
typealias StableId = UInt64
|
||||
|
||||
@usableFromInline let hash: Hash
|
||||
public typealias Identifier = Int
|
||||
public let id: Identifier
|
||||
}
|
||||
|
||||
extension ComponentIdentifier {
|
||||
@usableFromInline
|
||||
init<C>(_ componentType: C.Type) where C: Component {
|
||||
self.hash = Self.makeRuntimeHash(componentType)
|
||||
self.id = Self.makeRuntimeHash(componentType)
|
||||
}
|
||||
|
||||
/// object identifier hash (only stable during runtime) - arbitrary hash is ok.
|
||||
internal static func makeRuntimeHash<C>(_ componentType: C.Type) -> Hash where C: Component {
|
||||
internal static func makeRuntimeHash<C>(_ componentType: C.Type) -> Identifier where C: Component {
|
||||
ObjectIdentifier(componentType).hashValue
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue