//Made by Lumaa import Foundation import CoreHaptics struct Haptic: Hashable { var intensity: CGFloat var sharpness: CGFloat var interval: CGFloat static let tap: [Haptic] = [Haptic(intensity: 0.5, sharpness: 0.8, interval: 0.0)] static let success: [Haptic] = [ Haptic(intensity: 0.5, sharpness: 1.0, interval: 0.0), Haptic(intensity: 0.9, sharpness: 0.5, interval: 0.2) ] static let error: [Haptic] = [ Haptic(intensity: 1.0, sharpness: 0.7, interval: 0.0), Haptic(intensity: 1.0, sharpness: 0.3, interval: 0.2) ] } class HapticManager { private static var supportsHaptics: Bool = false private static var engine: CHHapticEngine? static func playHaptics(haptics: [Haptic]) { guard supportsHaptics else { return } var events = [CHHapticEvent]() let hapticIntensity: [CGFloat] = haptics.map { $0.intensity } let hapticSharpness: [CGFloat] = haptics.map { $0.sharpness } let intervals: [CGFloat] = haptics.map({ $0.interval }) for index in 0..