Fix tile rendering

This commit is contained in:
2021-09-07 10:53:39 +01:00
parent 6ecd739d6f
commit 45bbf9b005
14 changed files with 66 additions and 100 deletions
+22 -42
View File
@@ -1,8 +1,7 @@
module Dodge.Item.Attachment
( charFiringStratI
, scrollCharMode
, decreaseFuse
, increaseFuse
, changeFuse
)
where
import Dodge.Data
@@ -18,27 +17,25 @@ import qualified Data.IntMap.Strict as IM
scrollCharMode
:: Float -- ^ Amount scrolled
-> Creature
-> World
-> World
scrollCharMode x cr
| x > 0 = incCharMode (_crInvSel cr)
| x < 0 = decCharMode (_crInvSel cr)
-> Item
-> Item
scrollCharMode x _
| x > 0 = incCharMode
| x < 0 = decCharMode
| otherwise = id
incCharMode
:: Int -- ^ Inventory selection
-> World
-> World
incCharMode i = creatures . ix 0 . crInv . ix i . itAttachment . itCharMode %~ cycleL
:: Item
-> Item
incCharMode = itAttachment . itCharMode %~ cycleL
where
cycleL (x :<| xs) = xs |> x
cycleL xs = xs
decCharMode
:: Int -- ^ Inventory selection
-> World
-> World
decCharMode i = creatures . ix 0 . crInv . ix i . itAttachment . itCharMode %~ cycleR
:: Item
-> Item
decCharMode = itAttachment . itCharMode %~ cycleR
where
cycleR (xs :|> x) = x <| xs
cycleR xs = xs
@@ -59,32 +56,15 @@ charFiringStratI strats eff item cr w = case w ^? creatures . ix cid . crInv
where
cid = _crID cr
increaseFuse
:: Int -- ^ Old fuse time
-> Int -- ^ Inventory item reference (I believe)
-> World
-> World
increaseFuse fuse itid w = w
& creatures . ix 0 . crInv . ix itid %~
( itScrollUp .~ decreaseFuse newTime )
. (itScrollDown .~ increaseFuse newTime )
. ( itAttachment .~ ItFuse newTime )
. ( itAimZoom .~ defaultItZoom{_itZoomMax = zm, _itZoomMin = zm} )
changeFuse
:: Float -- ^ Old fuse time
-> Creature -- ^ Inventory item reference (I believe)
-> Item
-> Item
changeFuse scrollAmount _ it = it
& ( itAttachment .~ ItFuse newTime )
& ( itAimZoom .~ defaultItZoom{_itZoomMax = zm, _itZoomMin = zm} )
where
newTime = min (fuse + 5) 90
zm = 50 / fromIntegral newTime
decreaseFuse
:: Int -- ^ Old fuse time
-> Int -- ^ Inventory item reference (I believe)
-> World
-> World
decreaseFuse fuse itid w = w
& creatures . ix 0 . crInv . ix itid %~
( itScrollUp .~ decreaseFuse newTime )
. ( itScrollDown .~ increaseFuse newTime )
. ( itAttachment .~ ItFuse newTime )
. ( itAimZoom .~ defaultItZoom {_itZoomMax = zm, _itZoomMin = zm} )
where
newTime = max (fuse - 5) 20
oldTime = _itFuseTime $ _itAttachment it
newTime = min 90 $ max 20 $ oldTime - round (5 * scrollAmount)
zm = 50 / fromIntegral newTime