Refactor sounds
This commit is contained in:
@@ -31,5 +31,8 @@ heal25 :: Int -> World -> Maybe World
|
||||
heal25 = heal 25
|
||||
heal :: Int -> Int -> World -> Maybe World
|
||||
heal hp n w | _crHP (_creatures w IM.! n) >= 10000 = Nothing
|
||||
| otherwise = Just $ soundOnce healSound w & creatures . ix n . crHP %~ min 10000 . (+ hp)
|
||||
| otherwise = Just $ soundFrom (CrSound $ _crID cr) (_crPos cr) healSound Nothing w
|
||||
& creatures . ix n . crHP %~ min 10000 . (+ hp)
|
||||
where
|
||||
cr = _creatures w IM.! n
|
||||
|
||||
|
||||
@@ -751,10 +751,10 @@ moveRemoteBomb itid time pID w
|
||||
$ set (projectiles .ix pID.pjUpdate) (\_ -> moveRemoteBomb itid (f time) pID)
|
||||
w
|
||||
| time < 2 = case hitWl of
|
||||
Just _ -> soundOnce tapQuiet $ halfV updatedWorld
|
||||
Just (p,_) -> soundFrom (Tap 0) p tapQuiet Nothing $ halfV updatedWorld
|
||||
_ -> halfV updatedWorld
|
||||
| otherwise = case hitWl of
|
||||
Just _ -> soundOnce tapQuiet updatedWorld
|
||||
Just (p,_) -> soundFrom (Tap 0) p tapQuiet Nothing updatedWorld
|
||||
_ -> updatedWorld
|
||||
where
|
||||
updatedWorld
|
||||
@@ -768,7 +768,7 @@ moveRemoteBomb itid time pID w
|
||||
-- this is hacky, should use a version of collidePointWalls' that collides
|
||||
-- circles and walls
|
||||
invShift x = x -.- 5 *.* normalizeV (_pjVel pj)
|
||||
hitWl = collideCircWalls' oldPos newPos 4 $ wallsNearPoint newPos w
|
||||
hitWl = collideCircWalls oldPos newPos 4 $ wallsNearPoint newPos w
|
||||
finalPos = maybe newPos (invShift . fst) hitWl
|
||||
setV v = set (projectiles . ix pID . pjVel) v
|
||||
updateV = maybe id (setV . snd) hitWl
|
||||
@@ -874,7 +874,7 @@ fireRemoteLauncher :: Creature -> World -> World
|
||||
fireRemoteLauncher cr w = setLocation
|
||||
$ resetFire
|
||||
$ resetName
|
||||
$ soundOnce launcherSound
|
||||
$ soundFrom (CrWeaponSound cid) pos launcherSound Nothing
|
||||
$ over projectiles addRemRocket w
|
||||
where
|
||||
i = IM.newKey $ _projectiles w
|
||||
@@ -922,7 +922,7 @@ moveRemoteShell cid itid pj w
|
||||
( ( pjVel %~ ( (accel +.+) . (frict *.*) ) )
|
||||
. ( pjDir .~ newdir )
|
||||
)
|
||||
& soundFromPos (ShellSound i) newPos smokeTrailSound 1 250
|
||||
& soundFrom (ShellSound i) newPos smokeTrailSound (Just 1)
|
||||
& smokeGen
|
||||
& makeFlameletTimed oldPos 20 (0.5 *.* rotateV (pi+sparkD) accel) Nothing 3 10
|
||||
| time > -200 = case thingHit of
|
||||
@@ -944,7 +944,7 @@ moveRemoteShell cid itid pj w
|
||||
(frict,g) = randomR (0.6,0.9) $ _randGen w
|
||||
(sparkD,_) = randomR (-0.5,0.5) $ _randGen w
|
||||
hitCr = fst <$> collideCircCrsPoint oldPos newPos 4 w
|
||||
hitWl = fst <$> collideCircWalls' oldPos newPos 2 (wallsNearPoint newPos w)
|
||||
hitWl = fst <$> collideCircWalls oldPos newPos 2 (wallsNearPoint newPos w)
|
||||
thingHit = hitCr <|> hitWl
|
||||
r1 = _randGen w & evalState (randInCirc 10)
|
||||
smokeGen = makeSmokeCloudAt $ addZ 20 $ oldPos +.+ r1 +.+ 30 *.* normalizeV (oldPos -.- newPos)
|
||||
|
||||
@@ -31,7 +31,7 @@ moveGrenade 0 _ pID w = over projectiles (IM.delete pID)
|
||||
pj = _projectiles w IM.! pID
|
||||
explosion = _pjPayload pj
|
||||
moveGrenade time dir pID w = case hitWl of
|
||||
Just _ -> soundOnce tapQuiet updatedWorld
|
||||
Just (p,_) -> soundFrom (Tap 0) p tapQuiet Nothing updatedWorld
|
||||
_ -> updatedWorld
|
||||
where
|
||||
updatedWorld = updateV $ set (projectiles . ix pID . pjPos) finalPos
|
||||
@@ -42,7 +42,7 @@ moveGrenade time dir pID w = case hitWl of
|
||||
pj = _projectiles w IM.! pID
|
||||
oldPos = _pjPos pj
|
||||
newPos = _pjVel pj +.+ oldPos
|
||||
hitWl = collideCircWalls' oldPos newPos 4 $ wallsNearPoint newPos w
|
||||
hitWl = collideCircWalls oldPos newPos 4 $ wallsNearPoint newPos w
|
||||
finalPos = maybe newPos fst hitWl
|
||||
setV v = set (projectiles .ix pID.pjVel) v
|
||||
updateV = maybe id (setV . snd) hitWl
|
||||
|
||||
@@ -106,7 +106,7 @@ doThrust :: Projectile -> World -> World
|
||||
doThrust pj w = w
|
||||
& randGen .~ g
|
||||
& projectiles . ix i . pjVel %~ (\v -> accel +.+ frict *.* v)
|
||||
& soundFromPos (ShellSound i) newPos smokeTrailSound 1 250
|
||||
& soundFrom (ShellSound i) newPos smokeTrailSound (Just 1)
|
||||
& makeFlameletTimed (oldPos -.- vel) 0 (vel +.+ rotateV (pi+sparkD) accel) Nothing 3 10
|
||||
& smokeGen
|
||||
where
|
||||
@@ -174,7 +174,7 @@ moveShell pj w
|
||||
projectileExplosion = _pjPayload pj
|
||||
newPos = oldPos +.+ vel
|
||||
hitCr = fst <$> collideCircCrsPoint oldPos newPos 4 w
|
||||
hitWl = fst <$> collideCircWalls' oldPos newPos 2 (wallsNearPoint newPos w)
|
||||
hitWl = fst <$> collideCircWalls oldPos newPos 2 (wallsNearPoint newPos w)
|
||||
thingHit = hitCr <|> hitWl
|
||||
|
||||
reduceSpinBy :: Float -> Projectile -> World -> World
|
||||
|
||||
@@ -126,7 +126,7 @@ withWarmUpI soundID f item cr w
|
||||
| _wpReloadState item /= 0 = w
|
||||
| curWarmUp < maxWarmUp = w
|
||||
& pointerToItem . wpCurWarmUp +~ 2
|
||||
& soundFrom (CrWeaponSound cid) soundID 2 0
|
||||
& soundFrom (CrWeaponSound cid) (_crPos cr) soundID (Just 2)
|
||||
| otherwise = w
|
||||
& pointerToItem . wpCurWarmUp .~ maxWarmUp
|
||||
& f item cr
|
||||
@@ -141,7 +141,11 @@ The sound is emitted from the creature's position. -}
|
||||
withSoundI
|
||||
:: Int -- ^ Sound id
|
||||
-> ChainEffect
|
||||
withSoundI soundid f item cr = soundOncePos soundid (_crPos cr) . f item cr
|
||||
withSoundI soundid f item cr
|
||||
= soundFrom (CrWeaponSound cid) (_crPos cr) soundid Nothing
|
||||
. f item cr
|
||||
where
|
||||
cid = _crID cr
|
||||
|
||||
{- | Adds a sound to a creature based world effect.
|
||||
The sound is emitted from the creature's position. -}
|
||||
@@ -150,7 +154,7 @@ withSoundForI
|
||||
-> Int -- ^ Frames to play
|
||||
-> ChainEffect
|
||||
withSoundForI soundid playTime f item cr
|
||||
= soundFromPos (CrWeaponSound (_crID cr)) (_crPos cr) soundid playTime 0
|
||||
= soundFrom (CrWeaponSound (_crID cr)) (_crPos cr) soundid (Just playTime)
|
||||
. f item cr
|
||||
|
||||
afterRecoil
|
||||
|
||||
Reference in New Issue
Block a user