Refactor creature draw, pass World to function

This commit is contained in:
2021-05-25 21:44:25 +02:00
parent 28386ec8b9
commit d4a15a2416
10 changed files with 48 additions and 37 deletions
+12 -4
View File
@@ -8,7 +8,7 @@ import Dodge.Data
import Dodge.Base
import Dodge.Item.Weapon.Decoration
import Dodge.Item.Weapon.UseEffect
import Dodge.Item.Attachment.Data
--import Dodge.Item.Attachment.Data
import Dodge.WorldEvent.Flash
import Dodge.WorldEvent.ThingsHit
import Picture
@@ -109,7 +109,15 @@ rbSetTarget = ItInvEffect
setTarg _ cr invid w
| _crInvSel cr /= invid = w
| SDL.ButtonRight `S.member` _mouseButtons w = w
& creatures . ix (_crID cr) . crInv . ix invid . itAttachment
%~ maybe (Just $ ItTargetPos $ mouseWorldPos w) Just
| otherwise = w & creatures . ix (_crID cr) . crInv . ix invid . itAttachment .~ Nothing
& creatures . ix (_crID cr) . crInv . ix invid . itTargeting
%~ maybe (Just $ targetCurrentMousePos w) Just
| otherwise = w & creatures . ix (_crID cr) . crInv . ix invid . itTargeting .~ Nothing
targetCurrentMousePos
:: World
-> (World -> Maybe Point2, Item -> Int -> Creature -> World -> Picture)
targetCurrentMousePos w = (f, \_ _ _ _ -> cursorPic)
where
f _ = Just mwp
mwp = mouseWorldPos w
cursorPic = line [mwp +.+ (5,5), mwp -.- (5,5)]