diff --git a/src/Floorplan.hs b/src/Floorplan.hs index 4a8e7f7..8675a4c 100644 --- a/src/Floorplan.hs +++ b/src/Floorplan.hs @@ -437,8 +437,21 @@ assignClearance graph imat = then do if actualRoomType b imat == Offi then do - ret <- doRandomAssign room - return ret + 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 + return ret else return room else do if actualRoomType b imat == Offi @@ -449,13 +462,14 @@ assignClearance graph imat = (\n -> findNeighbor n b imat onlyrooms) nonhalls ) - onlyrooms = connects (head acc) ++ tail acc + onlyrooms = connects (head acc) nonhalls = ns -- filter ((/= Hall) . snd) ns ret <- if null neigh then doRandomAssign room else doBoundedAssign room (clearance $ head neigh) return ret - else return room + else + return room actualRoomType :: Boundaries Int -> M.Matrix TileState -> TileState actualRoomType (Boundaries (minrow, mincol) (maxrow, maxcol)) imat = @@ -502,7 +516,7 @@ findNeighbor (dir, _) bnds imat ingraph (inBounds (V2 row col) . bounds) ingraph in - case A.log A.Debug ("filtered: " ++ show filtered) filtered of + case filtered of [a@(GRoom _ _ _ ts)] -> Just a -- if ts == neighTile row col -- then Just a diff --git a/src/MainGame/WorldMap.hs b/src/MainGame/WorldMap.hs index df72362..54e4ae2 100644 --- a/src/MainGame/WorldMap.hs +++ b/src/MainGame/WorldMap.hs @@ -237,16 +237,16 @@ loadMapFork ud ad future progress = do (Types.connects (head gr) ++ tail gr) ) void $ createEntity $ newEntity - { pos = Just (fmap ((+ 0.5) . fromIntegral) (pointCoord cpr)) - , vel = Just (V2 0 0) - , velFact = Just fact - , rot = Just SE - , npcMoveState = Just (NPCWalking [pointCoord cpr]) - , npcWorkplace = Just cpr - , npcActionState = Just ASWork - , npcStats = Just stats + { pos = Just (fmap ((+ 0.5) . fromIntegral) (pointCoord cpr)) + , vel = Just (V2 0 0) + , velFact = Just fact + , rot = Just SE + , npcMoveState = Just (NPCWalking [pointCoord cpr]) + , npcWorkplace = Just cpr + , npcActionState = Just ASWork + , npcStats = Just stats , npcClearanceLvl = Just (clearance room) - , anim = Just $ AnimState (AnimId "jdoem" "standing" SE) 0 0 + , anim = Just $ AnimState (AnimId "jdoem" "standing" SE) 0 0 } ) computers liftIO $ modifyMVar_ progress (return . (\(p, _) ->