Refactor shell movement, modularised in a tweakable way
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user