refactor: pass creature to weapon use function, as opposed to just id

This commit is contained in:
2021-05-23 22:07:46 +02:00
parent 3ae454acf4
commit cda035b1d1
11 changed files with 235 additions and 219 deletions
+6 -5
View File
@@ -30,11 +30,11 @@ import System.Random
--import qualified Data.Map as M
startReloadingWeapon
:: Int -- ^ Creature id
:: Creature
-> World
-> Maybe World
startReloadingWeapon cid w =
let cr = _creatures w IM.! cid
startReloadingWeapon cr w =
let cid = _crID cr
it = _crInv cr IM.! _crInvSel cr
itRef = creatures . ix cid . crInv . ix (_crInvSel cr)
in case it of
@@ -54,15 +54,16 @@ crAutoReload cr = case cr ^? crInv . ix (_crInvSel cr) . wpLoadedAmmo of
maxA = cr ^? crInv . ix (_crInvSel cr) . wpMaxAmmo
{- | Teleport a creature to the mouse position -}
blinkAction
:: Int -- ^ Creature id
:: Creature
-> World
-> World
blinkAction n w
blinkAction cr w
= soundOnce teleSound
. set (creatures . ix n . crPos) p3
. blinkShockwave n p3
$ inverseShockwaveAt cp 40 2 2 2 w
where
n = _crID cr
p1 = _cameraCenter w +.+ (1 / _cameraZoom w) *.* rotateV (_cameraRot w) (_mousePos w)
cp = _crPos $ _creatures w IM.! n
p2 = reflectPointWalls cp p1 $ wallsAlongLine cp p1 w