Cleanup
This commit is contained in:
+3
-3
@@ -14,9 +14,9 @@ import qualified IntMapHelp as IM
|
|||||||
unshadowBlock :: World -> Int -> World
|
unshadowBlock :: World -> Int -> World
|
||||||
unshadowBlock w wlid = w & cWorld . lWorld . walls . ix wlid . wlUnshadowed .~ True
|
unshadowBlock w wlid = w & cWorld . lWorld . walls . ix wlid . wlUnshadowed .~ True
|
||||||
|
|
||||||
destroyBlock :: S.Set Int2 -> Block -> World -> (S.Set Int2,World)
|
destroyBlock :: Block -> World -> (S.Set Int2,World)
|
||||||
destroyBlock is bl w =
|
destroyBlock bl w =
|
||||||
(js<>is,w
|
(js,w
|
||||||
& flip (foldl' unshadowBlock) (_blShadows bl)
|
& flip (foldl' unshadowBlock) (_blShadows bl)
|
||||||
& makeBlockDebris bl
|
& makeBlockDebris bl
|
||||||
& deleteWallIDs wlids
|
& deleteWallIDs wlids
|
||||||
|
|||||||
@@ -253,18 +253,10 @@ drawInspectWalls w = concat $ do
|
|||||||
)
|
)
|
||||||
|
|
||||||
drawInspectWall :: World -> Wall -> Picture
|
drawInspectWall :: World -> Wall -> Picture
|
||||||
drawInspectWall _ wl =
|
drawInspectWall _ wl = setLayer DebugLayer $ color rose (thickLine 3 [a, b])
|
||||||
setLayer DebugLayer $
|
|
||||||
color rose (thickLine 3 [a, b])
|
|
||||||
-- <> foldMap (drawDoorPaths w) (wl ^? wlStructure . wsDoor)
|
|
||||||
where
|
where
|
||||||
(a, b) = _wlLine wl
|
(a, b) = _wlLine wl
|
||||||
|
|
||||||
--drawDoorPaths :: World -> Int -> Picture
|
|
||||||
--drawDoorPaths w drid = concat $ do
|
|
||||||
-- paths <- w ^? cWorld . lWorld . doors . ix drid . drObstructs
|
|
||||||
-- return $ foldMap' (drawPathEdge . (^. penPathEdge)) paths
|
|
||||||
|
|
||||||
drawPathEdge :: Point2 -> Point2 -> S.Set EdgeObstacle -> Picture
|
drawPathEdge :: Point2 -> Point2 -> S.Set EdgeObstacle -> Picture
|
||||||
drawPathEdge x y pe = setLayer DebugLayer $ multiArrow x y green (S.map obstacleColor pe)
|
drawPathEdge x y pe = setLayer DebugLayer $ multiArrow x y green (S.map obstacleColor pe)
|
||||||
|
|
||||||
|
|||||||
+13
-15
@@ -25,31 +25,29 @@ import qualified Data.Set as S
|
|||||||
-- maybeDestroyDoor should rather happen during the door mechanism update
|
-- maybeDestroyDoor should rather happen during the door mechanism update
|
||||||
damageWall :: Damage -> Wall -> (S.Set Int2,World) -> (S.Set Int2,World)
|
damageWall :: Damage -> Wall -> (S.Set Int2,World) -> (S.Set Int2,World)
|
||||||
damageWall dt wl (is,w) = case _wlStructure wl of
|
damageWall dt wl (is,w) = case _wlStructure wl of
|
||||||
MachinePart mcid -> f $ w' & cWorld . lWorld . machines . ix mcid . mcDamage .:~ dt
|
MachinePart mcid -> (,) is $ w' & cWorld . lWorld . machines . ix mcid . mcDamage .:~ dt
|
||||||
BlockPart blid ->
|
BlockPart blid ->
|
||||||
w' & cWorld . lWorld . blocks . ix blid . blHP -~ dmam
|
w' & cWorld . lWorld . blocks . ix blid . blHP -~ dmam
|
||||||
& maybeDestroyBlock is blid
|
& maybeDestroyBlock blid
|
||||||
|
& _1 <>~ is
|
||||||
DoorPart drid _ ->
|
DoorPart drid _ ->
|
||||||
w' & cWorld . lWorld . doors . ix drid . drHP -~ dmam
|
w' & cWorld . lWorld . doors . ix drid . drHP -~ dmam
|
||||||
& maybeDestroyDoor is drid
|
& maybeDestroyDoor drid
|
||||||
_ -> f w'
|
& _1 <>~ is
|
||||||
|
_ -> (is, w')
|
||||||
where
|
where
|
||||||
f = (,) is
|
|
||||||
-- x = case dt of
|
|
||||||
-- Explosive y _ -> y * 100
|
|
||||||
-- _ -> dt ^. dmAmount
|
|
||||||
(dmam,w') = damMatSideEffect dt (_wlMaterial wl) (Right wl) w
|
(dmam,w') = damMatSideEffect dt (_wlMaterial wl) (Right wl) w
|
||||||
|
|
||||||
-- block destruction is convoluted...
|
-- block destruction is convoluted...
|
||||||
maybeDestroyBlock :: S.Set Int2 -> Int -> World -> (S.Set Int2,World)
|
maybeDestroyBlock :: Int -> World -> (S.Set Int2,World)
|
||||||
maybeDestroyBlock is blid w = case w ^? cWorld . lWorld . blocks . ix blid of
|
maybeDestroyBlock blid w = case w ^? cWorld . lWorld . blocks . ix blid of
|
||||||
Just bl | _blHP bl < 1 -> destroyBlock is bl w
|
Just bl | _blHP bl < 1 -> destroyBlock bl w
|
||||||
_ -> (is,w)
|
_ -> (mempty,w)
|
||||||
|
|
||||||
maybeDestroyDoor :: S.Set Int2 -> Int -> World -> (S.Set Int2, World)
|
maybeDestroyDoor :: Int -> World -> (S.Set Int2, World)
|
||||||
maybeDestroyDoor is drid w = case w ^? cWorld . lWorld . doors . ix drid of
|
maybeDestroyDoor drid w = case w ^? cWorld . lWorld . doors . ix drid of
|
||||||
Just dr | _drHP dr < 1 -> destroyDoor dr w
|
Just dr | _drHP dr < 1 -> destroyDoor dr w
|
||||||
_ -> (is,w)
|
_ -> (mempty,w)
|
||||||
|
|
||||||
destroyDoor :: Door -> World -> (S.Set Int2, World)
|
destroyDoor :: Door -> World -> (S.Set Int2, World)
|
||||||
destroyDoor dr w =
|
destroyDoor dr w =
|
||||||
|
|||||||
Reference in New Issue
Block a user