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
+6 -4
View File
@@ -80,6 +80,8 @@ pistol = Weapon
, _itEffect = wpRecock
, _itInvDisplay = basicWeaponDisplay
, _itInvColor = white
, _itTargeting = Nothing
, _itWorldTrigger = Nothing
}
defaultAutoGun :: Item
defaultAutoGun = autoGun
@@ -260,13 +262,13 @@ tractorGun = defaultAutoGun
, _itEquipPict = pictureWeaponOnAim $ color blue $ pictures [polygon $ rectNESW 1.5 6 (-1.5) 0 ]
}
useTargetPos
:: (Point2 -> Creature -> World -> World)
:: (Maybe Point2 -> Creature -> World -> World)
-> Creature
-> World
-> World
useTargetPos f cr w = case cr ^? crInv . ix (_crInvSel cr) . itAttachment . _Just . itTargetPos of
useTargetPos f cr w = case cr ^? crInv . ix (_crInvSel cr) . itTargeting . _Just of
Nothing -> w
Just p -> f p cr w
Just (g,_) -> f (g w) cr w
bezierGun :: Item
bezierGun = defaultAutoGun
@@ -276,7 +278,7 @@ bezierGun = defaultAutoGun
. withMuzFlare
. withRecoil 40
. torqueBefore 0.05 -- I believe that this doesn't affect
$ shootBezier p -- <- the start point
$ shootBezier $ fromJust p -- <- the start point
, _itAttachment = Nothing
, _itScrollUp = removeItAttachment 0
, _itScrollDown = removeItAttachment 0