Fix bug where new sounds didn't overplay old sounds
This commit is contained in:
@@ -12,6 +12,13 @@ basicBullet = BulletAmmo
|
||||
, _amBulWth = 2
|
||||
, _amBulVel = V2 50 0
|
||||
}
|
||||
ltBullet :: Ammo
|
||||
ltBullet = BulletAmmo
|
||||
{ _amString = "LTBULLET"
|
||||
, _amBulEff = destroyOnImpact bulHitCr bulHitWall' bulHitFF'
|
||||
, _amBulWth = 2
|
||||
, _amBulVel = V2 40 0
|
||||
}
|
||||
hvBullet :: Ammo
|
||||
hvBullet = BulletAmmo
|
||||
{ _amString = "HVBULLET"
|
||||
|
||||
@@ -89,25 +89,23 @@ withWarmUp
|
||||
-> Creature
|
||||
-> World
|
||||
-> World
|
||||
withWarmUp t f cr w
|
||||
withWarmUp t f cr w
|
||||
| reloadCondition = fromMaybe w $ startReloadingWeapon cr w
|
||||
| _wpReloadState item /= 0 = w
|
||||
| fState == 0 = w
|
||||
& pointerToItem %~ ( (itUse .~ (\_ -> withWarmUp 100 f)) . (itUseTime .~ 2) )
|
||||
| t > 2 = w
|
||||
& pointerToItem %~ ( (itUse .~ (\_ -> withWarmUp (t-1) f)) . (itUseTime .~ 2) )
|
||||
| curWarmUp < maxWarmUp = w
|
||||
& pointerToItem . wpCurWarmUp +~ 2
|
||||
& soundFrom (CrWeaponSound cid) 26 2 0
|
||||
| t > 0 = w
|
||||
& pointerToItem %~ ( (itUse .~ (\_ -> withWarmUp (t-1) f)) . (itUseTime .~ 2) )
|
||||
| otherwise = w
|
||||
& pointerToItem %~ ( (itUse .~ (\_ -> withWarmUp 1 f)) . (wpLoadedAmmo -~ 1) . (itUseTime .~ 2) )
|
||||
| otherwise = w
|
||||
& pointerToItem . wpCurWarmUp .~ maxWarmUp
|
||||
& f cr
|
||||
& soundFrom (CrWeaponSound cid) 28 2 0
|
||||
-- & soundFrom (CrWeaponSound cid) 28 2 0
|
||||
where
|
||||
cid = _crID cr
|
||||
itRef = _crInvSel cr
|
||||
item = _crInv cr IM.! itRef
|
||||
pointerToItem = creatures . ix cid . crInv . ix itRef
|
||||
curWarmUp = _wpCurWarmUp item
|
||||
maxWarmUp = _wpMaxWarmUp item
|
||||
fState = _itUseTime item
|
||||
reloadCondition = _wpLoadedAmmo item == 0
|
||||
{- | Adds a sound to a creature based world effect.
|
||||
@@ -133,11 +131,13 @@ withRecoil recoilAmount eff cr = eff cr . over (creatures . ix cid) pushback
|
||||
Applied before the underlying effect. -}
|
||||
withSidePushI
|
||||
:: Float -- ^ Maximal possible side push amount
|
||||
-> (Creature -> World -> World)
|
||||
-- ^ Underlying world effect, takes creature id as input
|
||||
-> (Item -> Creature -> World -> World)
|
||||
-- ^ Underlying world effect
|
||||
-> Item
|
||||
-> Creature
|
||||
-> World -> World
|
||||
withSidePushI maxSide eff cr w = eff cr . over (creatures . ix cid) push $ w
|
||||
withSidePushI maxSide eff item cr w = eff item cr $
|
||||
w & creatures . ix cid %~ push
|
||||
where
|
||||
cid = _crID cr
|
||||
push = over crPos (+.+ rotateV (_crDir cr) (V2 0 (pushAmount / _crMass cr)))
|
||||
@@ -170,6 +170,32 @@ withSidePushAfter maxSide eff cr w = over (creatures . ix cid) push . eff cr $ w
|
||||
push = over crPos (+.+ rotateV (_crDir cr) (V2 0 (pushAmount / _crMass cr)))
|
||||
(pushAmount, _) = randomR (-maxSide,maxSide) $ _randGen w
|
||||
{- | Applies a world effect and sound effect after an ammo check. -}
|
||||
shootWithSoundFor
|
||||
:: Int -- ^ Sound identifier
|
||||
-> Int -- ^ Frames to play
|
||||
-> (Creature -> World -> World)
|
||||
-- ^ Shoot effect, takes creature id as input
|
||||
-> Creature
|
||||
-> World
|
||||
-> World
|
||||
shootWithSoundFor soundid playTime f cr w
|
||||
| fireCondition = over (pointerToItem . wpLoadedAmmo) (\ammo -> ammo-1)
|
||||
$ soundFromPos (CrWeaponSound cid) cpos soundid playTime 0
|
||||
$ set (pointerToItem . itUseTime) (_itUseRate item)
|
||||
$ f cr w
|
||||
| reloadCondition = fromMaybe w $ startReloadingWeapon cr w
|
||||
| otherwise = w
|
||||
where
|
||||
cid = _crID cr
|
||||
cpos = _crPos cr
|
||||
itRef = _crInvSel cr
|
||||
item = _crInv cr IM.! itRef
|
||||
pointerToItem = creatures . ix cid . crInv . ix itRef
|
||||
fireCondition = _wpReloadState item == 0
|
||||
&& _itUseTime item == 0
|
||||
&& _wpLoadedAmmo item > 0
|
||||
reloadCondition = _wpLoadedAmmo item == 0
|
||||
{- | Applies a world effect and sound effect after an ammo check. -}
|
||||
shootWithSound
|
||||
:: Int -- ^ Sound identifier
|
||||
-> (Creature -> World -> World)
|
||||
|
||||
Reference in New Issue
Block a user