clearance levels now implemented

This commit is contained in:
nek0 2019-02-08 23:10:18 +01:00
parent 763d945384
commit 44d0da34ac
2 changed files with 28 additions and 14 deletions

View file

@ -437,6 +437,19 @@ assignClearance graph imat =
then do then do
if actualRoomType b imat == Offi if actualRoomType b imat == Offi
then do then do
let neigh = filter (all ((/= Hall) . snd) . neighbs) $
catMaybes
(map
(\n -> findNeighbor n b imat onlyrooms)
nonhalls
)
onlyrooms = tail graph
nonhalls = ns -- filter ((/= Hall) . snd) ns
A.logIO A.Debug ("neighs: " ++ show neigh)
if not (null neigh) && any ((Offi /=) . flip actualRoomType imat . bounds) neigh
then
return room
else do
ret <- doRandomAssign room ret <- doRandomAssign room
return ret return ret
else return room else return room
@ -449,13 +462,14 @@ assignClearance graph imat =
(\n -> findNeighbor n b imat onlyrooms) (\n -> findNeighbor n b imat onlyrooms)
nonhalls nonhalls
) )
onlyrooms = connects (head acc) ++ tail acc onlyrooms = connects (head acc)
nonhalls = ns -- filter ((/= Hall) . snd) ns nonhalls = ns -- filter ((/= Hall) . snd) ns
ret <- if null neigh ret <- if null neigh
then doRandomAssign room then doRandomAssign room
else doBoundedAssign room (clearance $ head neigh) else doBoundedAssign room (clearance $ head neigh)
return ret return ret
else return room else
return room
actualRoomType :: Boundaries Int -> M.Matrix TileState -> TileState actualRoomType :: Boundaries Int -> M.Matrix TileState -> TileState
actualRoomType (Boundaries (minrow, mincol) (maxrow, maxcol)) imat = actualRoomType (Boundaries (minrow, mincol) (maxrow, maxcol)) imat =
@ -502,7 +516,7 @@ findNeighbor (dir, _) bnds imat ingraph
(inBounds (V2 row col) . bounds) (inBounds (V2 row col) . bounds)
ingraph ingraph
in in
case A.log A.Debug ("filtered: " ++ show filtered) filtered of case filtered of
[a@(GRoom _ _ _ ts)] -> Just a [a@(GRoom _ _ _ ts)] -> Just a
-- if ts == neighTile row col -- if ts == neighTile row col
-- then Just a -- then Just a