Replace some foldr with foldl'
This commit is contained in:
+7
-7
@@ -23,7 +23,7 @@ import RandomHelp
|
||||
|
||||
splinterBlock :: Block -> World -> World
|
||||
splinterBlock bl w =
|
||||
foldr unshadowBlock w (_blShadows bl) -- foldr shiftTowardCen w (_blWallIDs bl)
|
||||
foldl' unshadowBlock w (_blShadows bl) -- foldr shiftTowardCen w (_blWallIDs bl)
|
||||
& originsIDsAt
|
||||
[MaterialSound bm 0, MaterialSound bm 1, MaterialSound bm 2]
|
||||
(weakenMatS bm)
|
||||
@@ -34,8 +34,8 @@ splinterBlock bl w =
|
||||
(wlid, _) <- IS.minView wlids
|
||||
w ^? cWorld . walls . ix wlid . wlMaterial
|
||||
|
||||
unshadowBlock :: Int -> World -> World
|
||||
unshadowBlock wlid w = case w ^? cWorld . walls . ix wlid of
|
||||
unshadowBlock :: World -> Int -> World
|
||||
unshadowBlock w wlid = case w ^? cWorld . walls . ix wlid of
|
||||
Just wl ->
|
||||
w
|
||||
& cWorld . walls . ix wlid . wlUnshadowed .~ True
|
||||
@@ -50,13 +50,13 @@ checkBlockHP bl
|
||||
destroyBlock :: Block -> World -> World
|
||||
destroyBlock bl w =
|
||||
w
|
||||
& flip (foldr unshadowBlock) (_blShadows bl)
|
||||
& flip (foldl' unshadowBlock) (_blShadows bl)
|
||||
& makeBlockDebris bl
|
||||
& deleteWallIDs wlids
|
||||
& maybeClearPaths (_blObstructs bl) -- must happen after the walls are deleted
|
||||
& cWorld . blocks %~ IM.delete (_blID bl)
|
||||
-- & matDesSound (_blMaterial bl) pos
|
||||
& flip (foldr (wlDustAt awl)) (map (pos +.+) ps)
|
||||
& flip (foldl' $ flip (wlDustAt awl)) (map (pos +.+) ps)
|
||||
where
|
||||
wlids = _blWallIDs bl
|
||||
awl = _walls (_cWorld w) IM.! IS.findMin wlids
|
||||
@@ -79,7 +79,7 @@ destroyDoor dr w =
|
||||
& doDrWdWd (_drDeath dr) dr
|
||||
& deleteWallIDs wlids
|
||||
& cWorld . doors %~ IM.delete (_drID dr)
|
||||
& flip (foldr (wlDustAt awl)) (map (pos +.+) ps)
|
||||
& flip (foldl' (flip $ wlDustAt awl)) (map (pos +.+) ps)
|
||||
& stopPushing (_drPushes dr)
|
||||
& destroyMounts (_drMounts dr)
|
||||
where
|
||||
@@ -89,7 +89,7 @@ destroyDoor dr w =
|
||||
ps = replicateM 25 (randInCirc 20) & evalState $ _randGen w
|
||||
|
||||
destroyMounts :: [MountedObject] -> World -> World
|
||||
destroyMounts mos w = foldr destroyMount w mos
|
||||
destroyMounts mos w = foldl' (flip destroyMount) w mos
|
||||
|
||||
destroyMount :: MountedObject -> World -> World
|
||||
destroyMount mo = case mo of
|
||||
|
||||
Reference in New Issue
Block a user