Refactor shell movement, modularised in a tweakable way

This commit is contained in:
2021-05-26 03:35:30 +02:00
parent 7ca7a2f941
commit f05381be47
9 changed files with 170 additions and 112 deletions
+20
View File
@@ -0,0 +1,20 @@
module Dodge.Item.Weapon.Targeting
where
import Dodge.Data
import Control.Lens
import qualified Data.IntMap.Strict as IM
useTargetPos
:: (Maybe Point2 -> Creature -> World -> World)
-> Creature
-> World
-> World
useTargetPos f cr w = case cr ^? crInv . ix (_crInvSel cr) . itTargeting . _Just of
Nothing -> w
Just (g,_) -> f (g w) cr w
removeItTarget :: Int -> Int -> World -> World
removeItTarget i _ w = w & creatures . ix i . crInv . ix itRef . itTargeting .~ Nothing
where
cr = _creatures w IM.! i
itRef = _crInvSel cr