Bugfix and cleanup

This commit is contained in:
2022-05-21 22:14:50 +01:00
parent f555a4bf05
commit 14de40e0bf
2 changed files with 11 additions and 22 deletions
+1 -1
View File
@@ -18,7 +18,7 @@ medkit i = defaultConsumable
, _itUse = ConsumeUse
{_cUse = \_ cr w -> w & creatures . ix (_crID cr) . crHP +~ i
}
, _itEquipPict = pictureItem $ (,) emptySH $ color blue $ circleSolid 3
, _itEquipPict = pictureWeaponAim $ const $ (,) emptySH $ color blue $ circleSolid 3
, _itID = Nothing
}
+10 -21
View File
@@ -23,14 +23,13 @@ itSPic it = _dimSPic (_itDimension it) it
pictureWeaponAim
:: (Item -> SPic)
-> Creature
-> Item -- ^ Position of item in inventory
-> Item
-> SPic
pictureWeaponAim = const
--pictureWeaponAim f cr itm = pictureWeaponOnAimItem pic cr i
-- where
-- pic = f itm
-- i = fromJust $ _itInvPos itm
--pic = f (_crInv cr IM.! i)
pictureWeaponAim f cr itm = case _itInvPos itm of
Just i -> pictureWeaponOnAimItem pic cr i
Nothing -> mempty
where
pic = f itm
{- | Places an item picture onto a creature when the item is selected. -}
pictureWeaponOnAimItem
@@ -66,6 +65,7 @@ pictureWeaponOnAimItem p' cr posInInv
x <- theIt ^? itDimension . dimPortage . handlePos
return $translateSPf (-x) 0 p'
isOneHand = theIt ^? itUseAimStance == Just OneHand
|| isNothing (theIt ^? itUseAimStance)
isTwoHandFlat = theIt ^? itUseAimStance == Just TwoHandFlat
itUseAimStance = itUse . useAim . aimStance
f i = 0.1 * fromIntegral (sLen - i) / fromIntegral sLen
@@ -74,23 +74,12 @@ pictureWeaponOnAimItem p' cr posInInv
strideRot :: Creature -> Float
strideRot cr = case cr ^? crStance . carriage of
Just (Walking x LeftForward) -> f x
Just (Walking x RightForward) -> - f x
_ -> 0
Just (Walking x LeftForward) -> f x
Just (Walking x RightForward) -> - f x
_ -> 0
where
f i = 0.1 * fromIntegral (sLen - i) / fromIntegral sLen
sLen = _strideLength $ _crStance cr
twoFlatHRot :: Creature -> Float
twoFlatHRot cr = 2*strideRot cr
pictureItem
:: SPic
-> Creature
-> Item -- ^ Position of item in inventory
-> SPic
pictureItem p cr itm = case _itInvPos itm of
Just posInInv | _crInvSel cr == posInInv -> drawnWep
_ -> emptyBlank
where
drawnWep = translateSPf (_crRad cr) 0 p