Commit before improving item targeting
This commit is contained in:
@@ -1,11 +1,33 @@
|
||||
module Dodge.Item.Weapon.Remote
|
||||
( pointToItem
|
||||
, retireRemoteProj
|
||||
) where
|
||||
import Dodge.Data
|
||||
import Geometry
|
||||
|
||||
import qualified Data.IntMap.Strict as IM
|
||||
import Control.Lens
|
||||
import Data.Maybe
|
||||
|
||||
pointToItem :: Applicative f =>
|
||||
ItemPos -> (Item -> f Item) -> World -> f World
|
||||
pointToItem (InInv cid invid) = creatures . ix cid . crInv . ix invid
|
||||
pointToItem (OnFloor flid) = floorItems . ix flid . flIt
|
||||
|
||||
retireRemoteProj :: (Item -> Creature -> World -> World)
|
||||
-> Int -> Int -> Int -> World -> World
|
||||
retireRemoteProj resetFire itid 0 pjid w = w
|
||||
& pointToItem (_itemPositions w IM.! itid) %~
|
||||
( (itScope . scopePos .~ V2 0 0)
|
||||
. (itUse . rUse .~ resetFire)
|
||||
)
|
||||
& props %~ IM.delete pjid
|
||||
retireRemoteProj resetFire itid t pjid w = setScope w
|
||||
& props . ix pjid . pjUpdate .~ (\_ -> retireRemoteProj resetFire itid (t-1) pjid)
|
||||
where
|
||||
setScope w' = case _itemPositions w' IM.! itid of
|
||||
InInv cid invid -> w'
|
||||
& creatures . ix cid . crInv . ix invid . itScope
|
||||
. scopePos .~ (pos -.- _crPos (_creatures w' IM.! cid))
|
||||
_ -> w'
|
||||
pos = fromMaybe (V2 0 0) $ w ^? props . ix pjid . pjPos
|
||||
|
||||
Reference in New Issue
Block a user