From 32cf2383d6de56e53114f5ff258a185fe6a06a24 Mon Sep 17 00:00:00 2001 From: Christian Treffs Date: Thu, 10 May 2018 16:07:35 +0200 Subject: [PATCH] Remove dead code --- Sources/FirebladeECS/Component.swift | 42 ++++--------------- Sources/FirebladeECS/Hashable.swift | 62 ---------------------------- 2 files changed, 8 insertions(+), 96 deletions(-) delete mode 100644 Sources/FirebladeECS/Hashable.swift diff --git a/Sources/FirebladeECS/Component.swift b/Sources/FirebladeECS/Component.swift index 21ffc2f..b707e36 100644 --- a/Sources/FirebladeECS/Component.swift +++ b/Sources/FirebladeECS/Component.swift @@ -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 } } diff --git a/Sources/FirebladeECS/Hashable.swift b/Sources/FirebladeECS/Hashable.swift deleted file mode 100644 index 5d02a48..0000000 --- a/Sources/FirebladeECS/Hashable.swift +++ /dev/null @@ -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) - } -}