diff --git a/src/MainGame/WorldMap.hs b/src/MainGame/WorldMap.hs index ebac05f..4eff70f 100644 --- a/src/MainGame/WorldMap.hs +++ b/src/MainGame/WorldMap.hs @@ -118,6 +118,13 @@ loadMapFork ud ad future progress = do , "Converting to images" ))) let !imgmat = convertTileToImg mat + !doors = Prelude.foldl + (\acc coord@(r, c) -> if mat M.! coord == Door + then V2 r c : acc + else acc + ) + [] + ((,) <$> [1 .. nrows mat] <*> [1 .. ncols mat]) !exits = Prelude.foldl (\acc coord@(r, c) -> if imgmat M.! coord == Just ImgEmpty then ReachPoint RoomExit (V2 r c) NE 0 : acc @@ -259,7 +266,7 @@ loadMapFork ud ad future progress = do ( p + increment , "Registering doors into WorldState" ))) - let doors = Prelude.filter ((\t -> t == RoomExit || t == Elevator) . pointType) rps + -- let doors = Prelude.filter ((\t -> t == RoomExit || t == Elevator) . pointType) rps mapM_ (\door -> do let rooms = Prelude.foldl (\acc coord -> @@ -271,12 +278,8 @@ loadMapFork ud ad future progress = do ) [] coords - [coord] = Prelude.filter - (\(V2 r c) -> (Door ==) $ (mat M.! (r, c))) - coords graph = Types.connects (head gr) ++ tail gr - coords = Prelude.map (pointCoord door +) deltas - dcoords = Prelude.map (coord +) deltas + coords = Prelude.map (door +) deltas deltas = [ V2 0 1 , V2 1 0 @@ -285,7 +288,7 @@ loadMapFork ud ad future progress = do ] wall = Prelude.filter (\delta -> - let V2 r c = coord + delta + let V2 r c = door + delta in fromMaybe False (isWall <$> imgmat M.! (r, c))) deltas @@ -294,7 +297,7 @@ loadMapFork ud ad future progress = do | head wall == V2 1 0 || head wall == V2 (-1) 0 = NE | otherwise = error ("strange wall: " ++ show wall) void $ createEntity $ newEntity - { pos = Just (fmap ((+ 0.5) . fromIntegral) coord) + { pos = Just (fmap ((+ 0.5) . fromIntegral) door) , clearanceLvl = Just (maximum $ 0 : Prelude.map clearance (Prelude.map snd rooms)) , anim = Just $ AnimState (AnimId AnimDoor0 "shut" orientation) 0 1 , obstacle = Just $ case orientation of