Remove dead code

This commit is contained in:
Christian Treffs 2018-05-10 16:07:35 +02:00
parent 585252b218
commit 32cf2383d6
2 changed files with 8 additions and 96 deletions

View File

@ -13,41 +13,15 @@ public extension Component {
static var identifier: ComponentIdentifier { return typeObjectIdentifier }
}
// MARK: - entity component hashable
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
static func hashValue(using entityIdx: EntityIndex) -> EntityComponentHash {
return Self.identifier.hashValue(using: entityIdx)
}
/// 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
func hashValue(using entityIdx: EntityIndex) -> EntityComponentHash {
return Self.hashValue(using: entityIdx)
}
/// TypeIdentifiable
/// Identifies an object by it's meta type.
public protocol TypeIdentifiable {
static var typeObjectIdentifier: ObjectIdentifier { get }
var typeObjectIdentifier: ObjectIdentifier { get }
}
// MARK: - component identifier hashable
extension ComponentIdentifier {
public extension TypeIdentifiable {
static var typeObjectIdentifier: ObjectIdentifier { return ObjectIdentifier(Self.self) }
/// 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
func hashValue(using entityIdx: EntityIndex) -> EntityComponentHash {
return hashValue(using: entityIdx.identifier)
}
func hashValue(using entityId: EntityIdentifier) -> EntityComponentHash {
return EntityComponentHash.compose(entityId: entityId, componentTypeHash: hashValue)
}
var typeObjectIdentifier: ObjectIdentifier { return Self.typeObjectIdentifier }
}

View File

@ -1,62 +0,0 @@
//
// Hashable.swift
// FirebladeECS
//
// Created by Christian Treffs on 04.11.17.
//
/// TypeIdentifiable
/// Identifies an object by it's meta type.
public protocol TypeIdentifiable {
static var typeObjectIdentifier: ObjectIdentifier { get }
var typeObjectIdentifier: ObjectIdentifier { get }
}
/// TypeHashable
/// Identifies an object by it's meta type and conforms to Hashable.
/// This introduces a Self type requirement.
public protocol TypeHashable: TypeIdentifiable, Hashable {
static var hashValue: Int { get }
}
/// InstanceHashable
/// Identifies an object instance by it's object identifier and conforms to Hashable
public protocol InstanceHashable: class, Hashable {
var instanceObjectIdentifier: ObjectIdentifier { get }
}
/// TypeInstanceHashable
/// Identifies an object by instance and meta type and conforms to Hashable
public typealias TypeInstanceHashable = TypeHashable & InstanceHashable
public extension InstanceHashable {
var instanceObjectIdentifier: ObjectIdentifier { return ObjectIdentifier(self) }
static func == (lhs: Self, rhs: Self) -> Bool { return lhs.hashValue == rhs.hashValue }
var hashValue: Int { return instanceObjectIdentifier.hashValue }
}
public extension TypeIdentifiable {
static var typeObjectIdentifier: ObjectIdentifier { return ObjectIdentifier(Self.self) }
var typeObjectIdentifier: ObjectIdentifier { return Self.typeObjectIdentifier }
}
public extension TypeHashable {
static func == (lhs: Self, rhs: Self) -> Bool { return lhs.hashValue == rhs.hashValue }
var hashValue: Int { return typeObjectIdentifier.hashValue }
static var hashValue: Int { return typeObjectIdentifier.hashValue }
}
public extension TypeHashable where Self: InstanceHashable {
static func == (lhs: Self, rhs: Self) -> Bool {
return lhs.typeObjectIdentifier == rhs.typeObjectIdentifier &&
lhs.instanceObjectIdentifier == rhs.instanceObjectIdentifier
}
var hashValue: Int {
return hash(combine: typeObjectIdentifier.hashValue, instanceObjectIdentifier.hashValue)
}
}