require "common.class" ---@type AudioSample local exclusiveAudioSample = nil ---@class AudioSample ---@field path string ---@field exclusive boolean ---@field loop boolean local AudioSample = { __name = "AudioSample" } ---Create new AudioSample instance ---@param params AudioSample ---@return AudioSample function AudioSample.new(params) assert(params.path, "AudioSample.new() did not receive path to audio sample") params.exclusive = params.exclusive or false params.loop = params.loop or false game.LoadSkinSample(params.path) return CreateInstance(AudioSample, params) end function AudioSample:play() if not game.IsSamplePlaying(self.path) then if self.exclusive then if exclusiveAudioSample and self ~= exclusiveAudioSample then exclusiveAudioSample:stop() end exclusiveAudioSample = self end game.PlaySample(self.path) end end function AudioSample:stop() if game.IsSamplePlaying(self.path) then if self.exclusive and self == exclusiveAudioSample then exclusiveAudioSample = nil end game.StopSample(self.path) end end return AudioSample