Refactor bullet particles

This commit is contained in:
2021-05-19 13:46:19 +02:00
parent 44f239c673
commit 4463dc7716
29 changed files with 637 additions and 535 deletions
+5 -3
View File
@@ -199,11 +199,11 @@ moveBy
-> World
moveBy n v = over (creatures . ix n . crPos) (+.+ v)
reloadWeapon
startReloadingWeapon
:: Int -- ^ Creature id
-> World
-> Maybe World
reloadWeapon cid w =
startReloadingWeapon cid w =
let cr = _creatures w IM.! cid
it = _crInv cr IM.! _crInvSel cr
itRef = creatures . ix cid . crInv . ix (_crInvSel cr)
@@ -216,7 +216,8 @@ reloadWeapon cid w =
{- | Start reloading if clip is empty. -}
crAutoReload :: Creature -> Creature
crAutoReload cr = case cr ^? crInv . ix (_crInvSel cr) . wpLoadedAmmo of
Just 0 -> cr & crInv . ix (_crInvSel cr) . wpReloadState %~ (`fromMaybe` reloadT)
Just 0 | _posture (_crStance cr) /= Aiming
-> cr & crInv . ix (_crInvSel cr) . wpReloadState %~ (`fromMaybe` reloadT)
& crInv . ix (_crInvSel cr) . wpLoadedAmmo %~ (`fromMaybe` maxA)
_ -> cr
where
@@ -368,3 +369,4 @@ creatureTurnToward p turnSpeed cr
where
vToTarg = p -.- _crPos cr
dirToTarget = argV vToTarg