Improve debris
This commit is contained in:
@@ -55,15 +55,21 @@ blColor :: Block -> Color
|
||||
blColor _ = orange
|
||||
|
||||
makeBlockDebris :: Block -> World -> World
|
||||
makeBlockDebris bl w = foldl' (flip $ makeDebris (BlockDebris $ blColor bl) mt) w ps
|
||||
makeBlockDebris bl w = foldl' (flip $ makeDebris (blockDebrisType mwl bl) mt) w ps
|
||||
where
|
||||
dsize = debrisSize mt
|
||||
ps = gridInPolygon dsize $ shrinkPolyOnEdges dsize $ reverse (_blFootprint bl)
|
||||
mt = fromMaybe Stone $ do
|
||||
mt = fromMaybe Stone $ mwl ^? _Just . wlMaterial
|
||||
mwl = do
|
||||
wlids <- w ^? cWorld . lWorld . blocks . ix (_blID bl) . blWallIDs
|
||||
(wlid, _) <- IS.minView wlids
|
||||
wl <- w ^? cWorld . lWorld . walls . ix wlid
|
||||
return $ _wlMaterial wl
|
||||
w ^? cWorld . lWorld . walls . ix wlid
|
||||
|
||||
blockDebrisType :: Maybe Wall -> Block -> DebrisType
|
||||
blockDebrisType wl bl = case wl ^? _Just . wlMaterial of
|
||||
Just Glass -> GlassDebris
|
||||
Just Metal -> MetalDebris red
|
||||
_ -> BlockDebris $ blColor bl
|
||||
|
||||
-- makeDebris :: Material -> Color -> Point2 -> World -> World
|
||||
makeDebris :: DebrisType -> Material -> Point2 -> World -> World
|
||||
|
||||
Reference in New Issue
Block a user