Skip to content

Instantly share code, notes, and snippets.

@stanislaw
Created October 10, 2017 16:14
Show Gist options
  • Save stanislaw/f0c73974285fd3eee6df79e88e61d2ce to your computer and use it in GitHub Desktop.
Save stanislaw/f0c73974285fd3eee6df79e88e61d2ce to your computer and use it in GitHub Desktop.
SongTrainerAudioHandle
class SongTrainerAudioHandle {
weak manager: AudioManagerInternal
var requiresPrivilegedAccessToAudioFeatureX {
return true
}
func useAudioFeatureX {
if manager.allowsUseOfFeatureXAtThisTime {
} else {
notify Martin
}
}
setTempo() {
AudioManager.setTempo()
}
}
AudioManagerInternal {
var activeHandles: [ActiveHandle]
allowsUseOfFeatureXAtThisTime {
alreadyInUse = activeHandles.find { handle
handle.requiresPrivilegedAccessToAudioFeatureX
}
return alreadyInUse == false
}
}
AudioManager {
enum AudioAccessType {
case settings
case playSound
case songTrainer
}
func getHandle(accessType: AudioAccessType) {
let handle = SognTrainerHandle()
activeHandle.append(handle)
return handle
}
}
SongTrainerMinigameController {
private var audioHandle: SongTrainerAudioHandle
start() {
audioHandle.activateSound()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment