From be91805deec91fb640124a92f989663b5d03ba0a Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Wed, 22 Jun 2022 21:35:02 +0800 Subject: [PATCH] clsSFX // Add machine-gun farting / beeping effect. --- Source/Modules/SFX/clsSFX.swift | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Source/Modules/SFX/clsSFX.swift b/Source/Modules/SFX/clsSFX.swift index 6a6b4e04..d3b211fa 100644 --- a/Source/Modules/SFX/clsSFX.swift +++ b/Source/Modules/SFX/clsSFX.swift @@ -25,7 +25,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. import AVFoundation import Foundation -public class clsSFX { +public enum clsSFX { static func beep() { let filePath = Bundle.main.path(forResource: mgrPrefs.shouldNotFartInLieuOfBeep ? "Beep" : "Fart", ofType: "m4a")! let fileURL = URL(fileURLWithPath: filePath) @@ -33,4 +33,15 @@ public class clsSFX { AudioServicesCreateSystemSoundID(fileURL as CFURL, &soundID) AudioServicesPlaySystemSound(soundID) } + + static func beep(count: Int = 1) { + if count <= 1 { + clsSFX.beep() + return + } + for _ in 0...count { + clsSFX.beep() + usleep(500_000) + } + } }