module Dodge.WorldEvent.Sound
    ( mkSoundBreakGlass
    , mkSoundSplinterGlass
    , mkSoundSplinterBlock
    , originIDsAt 
    )
  where
import Dodge.Data
import Dodge.SoundLogic
import Sound.Data
import Geometry.Data
import Dodge.RandomHelp

import Control.Lens
import Control.Monad.State.Lazy

originIDsAt :: SoundOrigin -> [SoundID] -> Point2 -> World -> World
originIDsAt so sids p w = soundStart so p sid Nothing $ set randGen g w
  where
    (sid,g) = _randGen w & runState (takeOne sids)

mkSoundBreakGlass :: Point2 -> World -> World
mkSoundBreakGlass = originIDsAt (GlassBreakSound 0) [glassShat1S,glassShat2S,glassShat3S,glassShat4S]

mkSoundSplinterGlass :: Point2 -> World -> World
mkSoundSplinterGlass = originIDsAt (GlassBreakSound 1) [smallGlass1S,smallGlass2S,smallGlass3S,smallGlass4S]

mkSoundSplinterBlock :: Point2 -> World -> World
mkSoundSplinterBlock = originIDsAt (BlockDegradeSound 1) [impact1S,impact2S,impact3S,impact4S]
