Fold in more ammo parameters, distinguish loadable and charging weapons
This commit is contained in:
@@ -123,17 +123,30 @@ invSideEff cr w = weaponReloadSounds cr $ IM.foldrWithKey f w (_crInv cr)
|
||||
Just g -> g (_itEffect it) cr i w'
|
||||
|
||||
weaponReloadSounds :: Creature -> World -> World
|
||||
weaponReloadSounds cr w = case _crInv cr IM.!? _crInvSel cr of
|
||||
Just Weapon{_wpReloadType = PassiveReload stype,_wpReloadTime=rt,_wpReloadState=rs}
|
||||
| rt == rs -> soundContinue (CrReloadSound 0) (_crPos cr) stype Nothing w
|
||||
| otherwise -> w
|
||||
Just Weapon{_wpReloadState = 0} -> w
|
||||
Just Weapon{_wpReloadState = 1} -> stopSoundFrom (CrReloadSound cid) w
|
||||
Just Weapon{} -> soundContinue (CrReloadSound cid) (_crPos cr) reloadS (Just 1) w
|
||||
_ -> w
|
||||
weaponReloadSounds cr w = case cr ^? crInv . ix (_crInvSel cr) . wpAmmo of
|
||||
Just am@LoadableAmmo{} -> case _wpReloadType am of
|
||||
PassiveReload stype |_wpReloadTime am ==_wpReloadState am
|
||||
-> soundContinue (CrReloadSound 0) (_crPos cr) stype Nothing w
|
||||
PassiveReload _ -> w
|
||||
ActiveReload | _wpReloadState am == 1 -> stopSoundFrom (CrReloadSound cid) w
|
||||
ActiveReload | _wpReloadState am == 0 -> w
|
||||
ActiveReload -> soundContinue (CrReloadSound cid) (_crPos cr) reloadS (Just 1) w
|
||||
Just ChargeableAmmo {} -> w
|
||||
Nothing -> w
|
||||
where
|
||||
cid = _crID cr
|
||||
|
||||
--weaponReloadSounds cr w = case _crInv cr IM.!? _crInvSel cr of
|
||||
-- Just Weapon{_wpAmmo=LoadableAmmo{_wpReloadType = PassiveReload stype,_wpReloadTime=rt,_wpReloadState=rs} }
|
||||
-- | rt == rs -> soundContinue (CrReloadSound 0) (_crPos cr) stype Nothing w
|
||||
-- | otherwise -> w
|
||||
-- Just Weapon{_wpAmmo=LoadableAmmo{_wpReloadState = 0}} -> w
|
||||
-- Just Weapon{_wpAmmo=LoadableAmmo{_wpReloadState = 1}} -> stopSoundFrom (CrReloadSound cid) w
|
||||
-- Just Weapon{} -> soundContinue (CrReloadSound cid) (_crPos cr) reloadS (Just 1) w
|
||||
-- _ -> w
|
||||
-- where
|
||||
-- cid = _crID cr
|
||||
|
||||
updateMovement :: Creature -> Creature
|
||||
updateMovement cr
|
||||
| isFrictionless cr = over crPos (+.+ momentum) $ setOldPos cr
|
||||
@@ -157,7 +170,7 @@ stepItemUseCooldown cr = cr & crInv . ix iSel %~
|
||||
iSel = _crInvSel cr
|
||||
|
||||
stepReloading :: Creature -> Creature
|
||||
stepReloading cr = over (crInv . ix iSel . wpReloadState) decreaseToZero cr
|
||||
stepReloading cr = over (crInv . ix iSel . wpAmmo . wpReloadState) decreaseToZero cr
|
||||
where
|
||||
iSel = _crInvSel cr
|
||||
|
||||
|
||||
Reference in New Issue
Block a user