Separate out concrete part of world
This commit is contained in:
@@ -23,7 +23,7 @@ plBlock
|
||||
-> (Int,World)
|
||||
plBlock [] _ _ _ = error "Trying to add a block with incomplete polygon"
|
||||
plBlock (p:ps) bl wl w = (,) blid $ w
|
||||
& blocks . at blid ?~ bl
|
||||
& cWorld . blocks . at blid ?~ bl
|
||||
{ _blID = blid
|
||||
, _blWallIDs = IS.fromList is
|
||||
, _blShadows = []
|
||||
@@ -31,9 +31,9 @@ plBlock (p:ps) bl wl w = (,) blid $ w
|
||||
}
|
||||
& insertWalls blid wls
|
||||
where
|
||||
blid = IM.newKey $ _blocks w
|
||||
blid = IM.newKey $ _blocks (_cWorld w)
|
||||
lns = zip (p:ps) (ps ++ [p])
|
||||
i = IM.newKey $ _walls w
|
||||
i = IM.newKey $ _walls (_cWorld w)
|
||||
is = [i.. i + length lns-1]
|
||||
wls = zipWith
|
||||
(\j ln -> wl & wlLine .~ ln & wlID .~ j & wlStructure .~ BlockPart blid)
|
||||
@@ -62,11 +62,11 @@ plLineBlock basePane blwidth a b gw = ( 0
|
||||
cornerPoints = reverse $ rectWH halfBlockWidth depth -- goes clockwise around the block
|
||||
cornersAt p = fmap ( (p +.+) . rotateV (argV (b -.- a)) ) cornerPoints
|
||||
linesAt p = loopPairs $ cornersAt p
|
||||
wlid = IM.newKey $ _walls gw
|
||||
blid = IM.newKey $ _blocks gw
|
||||
wlid = IM.newKey $ _walls (_cWorld gw)
|
||||
blid = IM.newKey $ _blocks (_cWorld gw)
|
||||
insertBlock (i,p) =
|
||||
insertWalls (i + blid) (makeWallAt p i)
|
||||
. over blocks (IM.insert (i+blid) Block
|
||||
. over (cWorld . blocks) (IM.insert (i+blid) Block
|
||||
{ _blID = i + blid, _blWallIDs = IS.fromList $ ksAtI i
|
||||
, _blHP = 1000, _blShadows = shadowsAt i
|
||||
, _blDir = 0 -- THIS IS NOT SENSIBLE. TODO rethink block positioning
|
||||
@@ -96,10 +96,10 @@ plLineBlock basePane blwidth a b gw = ( 0
|
||||
|
||||
-- | Must be done after inserting the block
|
||||
insertWalls :: Int -> [Wall] -> World -> World
|
||||
insertWalls blid wls w = w' & blocks . ix blid . blObstructs .~ concat paths
|
||||
insertWalls blid wls w = w' & cWorld . blocks . ix blid . blObstructs .~ concat paths
|
||||
where
|
||||
(w',paths) = mapAccumR (flip insertWall) w wls
|
||||
|
||||
insertWall :: Wall -> World -> (World,[(Int,Int,PathEdge)])
|
||||
insertWall wl = uncurry (obstructPathsCrossing BlockObstacle) (_wlLine wl)
|
||||
. (walls . at (_wlID wl) ?~ wl)
|
||||
. (cWorld . walls . at (_wlID wl) ?~ wl)
|
||||
|
||||
Reference in New Issue
Block a user