diff --git a/Sources/FirebladeECS/Activatable.swift b/Sources/FirebladeECS/Activatable.swift deleted file mode 100644 index c6628cd..0000000 --- a/Sources/FirebladeECS/Activatable.swift +++ /dev/null @@ -1,11 +0,0 @@ -// -// Activatable.swift -// FirebladeECSPackageDescription -// -// Created by Christian Treffs on 02.11.17. -// - -public protocol Activatable { - func activate() - func deactivate() -} diff --git a/Sources/FirebladeECS/Component.swift b/Sources/FirebladeECS/Component.swift index 50695b3..f7354c4 100644 --- a/Sources/FirebladeECS/Component.swift +++ b/Sources/FirebladeECS/Component.swift @@ -5,7 +5,7 @@ // Created by Christian Treffs on 08.10.17. // -public protocol Component: class, TypeIdentifiable, Activatable {} +public protocol Component: class, TypeIdentifiable {} extension Component { public var identifier: ComponentIdentifier { return typeObjectIdentifier } diff --git a/Sources/FirebladeECS/Entity.swift b/Sources/FirebladeECS/Entity.swift index b53f088..7812bae 100644 --- a/Sources/FirebladeECS/Entity.swift +++ b/Sources/FirebladeECS/Entity.swift @@ -20,16 +20,6 @@ public final class Entity: UniqueEntityIdentifiable { } -// MARK: - activatable protocol -extension Entity: Activatable { - public func activate() { - //TODO: nexus.activate(entity: self) - } - public func deactivate() { - //TODO: nexus.deactivate(entity: self) - } -} - // MARK: - Invalidate extension Entity { diff --git a/Sources/FirebladeECS/FamilyTraitSet.swift b/Sources/FirebladeECS/FamilyTraitSet.swift index 275fe08..bcbdb3e 100644 --- a/Sources/FirebladeECS/FamilyTraitSet.swift +++ b/Sources/FirebladeECS/FamilyTraitSet.swift @@ -83,17 +83,3 @@ extension FamilyTraitSet: Hashable { } } -// MARK: - description -/*extension FamilyTraits: CustomStringConvertible { - - public var description: String { - let all: String = hasAll.map { "\($0.self)" }.joined(separator: " AND ") - let any: String = hasAny.map { "\($0.self)" }.joined(separator: " OR ") - let none: String = hasNone.map { "!\($0.self)"}.joined(separator: " NOT ") - let out: String = ["\(all)", "\(any)", "\(none)"].joined(separator: " AND ") - //TODO: nicer - return "FamilyTraits(\(out))" - } - -} -*/ diff --git a/Sources/FirebladeECS/Timer.swift b/Sources/FirebladeECS/Timer.swift deleted file mode 100644 index 5f0486b..0000000 --- a/Sources/FirebladeECS/Timer.swift +++ /dev/null @@ -1,50 +0,0 @@ -// -// Timer.swift -// FirebladeECS -// -// Created by Christian Treffs on 28.10.17. -// - -import Darwin.Mach.mach_time - -public struct Timer { - private let numerator: UInt64 - private let denominator: UInt64 - private var startTime: UInt64 = 0 - private var stopTime: UInt64 = 0 - - public init() { - var timeBaseInfo = mach_timebase_info.init(numer: 0, denom: 0 ) - let success: kern_return_t = mach_timebase_info(&timeBaseInfo) - assert(KERN_SUCCESS == success) - numerator = UInt64(timeBaseInfo.numer) - denominator = UInt64(timeBaseInfo.denom) - } - - public mutating func start() { - startTime = mach_absolute_time() - } - public mutating func stop() { - stopTime = mach_absolute_time() - } - public mutating func reset() { - startTime = 0 - stopTime = 0 - } - - public var nanoSeconds: UInt64 { - return ((stopTime - startTime) * numerator) / denominator - } - - public var microSeconds: Double { - return Double(nanoSeconds) / 1.0e3 - } - - public var milliSeconds: Double { - return Double(nanoSeconds) / 1.0e6 - } - - public var seconds: Double { - return Double(nanoSeconds) / 1.0e9 - } -} diff --git a/Sources/FirebladeECS/UUID.swift b/Sources/FirebladeECS/UUID.swift deleted file mode 100644 index 110ee8d..0000000 --- a/Sources/FirebladeECS/UUID.swift +++ /dev/null @@ -1,122 +0,0 @@ -// -// UUID.swift -// FirebladeECSPackageDescription -// -// Created by Christian Treffs on 04.11.17. -// - -#if os(macOS) || os(iOS) || os(tvOS) - import Darwin.C.stdlib -#else - // TODO: support linux and other platforms -#endif - -public struct UUID { - public static let count: Int = 16 // https://tools.ietf.org/html/rfc4122#section-4.1 - private let bytes: ContiguousArray - - public init(_ bytes: ContiguousArray) { - assert(bytes.count == UUID.count, "An UUID must have a count of exactly \(UUID.count).") - self.bytes = bytes - } - public init() { - self.init(UUID.generateUUID()) - } - public init(_ bytes: [UInt8]) { - self.init(ContiguousArray(bytes)) - } - public init?(uuidString: String) { - guard uuidString.count == 2*UUID.count+4 else { - // "An UUID string must have a count of exactly 36." - return nil - } - - var uuid: ContiguousArray = ContiguousArray(repeating: 0, count: UUID.count) - let contiguousString: String = uuidString.split(separator: "-").joined() - guard contiguousString.count == 2*UUID.count else { - // An UUID string must have exactly 4 separators - return nil - } - var endIdx: String.Index = contiguousString.startIndex - for i in 0.. ContiguousArray { - var uuid: ContiguousArray = ContiguousArray(repeating: 0, count: UUID.count) - uuid.withUnsafeMutableBufferPointer { (uuidPtr: inout UnsafeMutableBufferPointer) -> Void in - // TODO: use /dev/urandom - arc4random_buf(uuidPtr.baseAddress, UUID.count) // TODO: linux - } - makeRFC4122compliant(uuid: &uuid) - return uuid - } - - private static func makeRFC4122compliant(uuid: inout ContiguousArray) { - uuid[6] = (uuid[6] & 0x0F) | 0x40 // version https://tools.ietf.org/html/rfc4122#section-4.1.3 - uuid[8] = (uuid[8] & 0x3f) | 0x80 // variant https://tools.ietf.org/html/rfc4122#section-4.1.1 - } -} - -extension UUID: Equatable { - public static func == (lhs: UUID, rhs: UUID) -> Bool { - return lhs.bytes == rhs.bytes - } -} - -extension UUID: Hashable { - /// One-at-a-Time hash - /// http://eternallyconfuzzled.com/tuts/algorithms/jsw_tut_hashing.aspx - private var oat_hash: Int { - var hash: Int = 0 - - for i: Int in 0..> 6) - } - - hash = hash &+ (hash << 3) - hash ^= (hash << 11) - hash = hash &+ (hash << 15) - return hash - } - public var hashValue: Int { return oat_hash } -} - -extension UUID: CustomStringConvertible, CustomDebugStringConvertible { - public var uuidString: String { - var out: String = String() - out.reserveCapacity(UUID.count) - let separatorLayout: [Int] = [0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0] - let separator: String = "-" - var idx: Int = 0 - for byte in bytes { - let char = String(byte, radix: UUID.count, uppercase: true) - switch char.count { - case 2: - out.append(char) - default: - out.append("0" + char) - } - if separatorLayout[idx] == 1 { - out.append(separator) - } - idx += 1 - } - - assert(idx == UUID.count) - assert(out.count == 36) - return out - } - public var description: String { return uuidString } - public var debugDescription: String { return uuidString } -}