2018-03-03 16:03:17 +00:00
|
|
|
{-# LANGUAGE FlexibleInstances #-}
|
2018-02-17 01:36:06 +00:00
|
|
|
module Types.Map where
|
|
|
|
|
2018-09-08 12:05:07 +00:00
|
|
|
import Linear (V2)
|
|
|
|
|
2018-02-17 01:36:06 +00:00
|
|
|
data TileState
|
|
|
|
= Wall
|
|
|
|
-- | Wind
|
|
|
|
| Door
|
|
|
|
| Hall
|
|
|
|
| Offi
|
|
|
|
| Toil
|
|
|
|
| Kitc
|
|
|
|
| Elev
|
|
|
|
| Unde
|
2018-03-03 16:03:17 +00:00
|
|
|
deriving (Ord, Eq)
|
2018-02-17 01:36:06 +00:00
|
|
|
|
|
|
|
instance Show TileState where
|
|
|
|
show Wall = "#"
|
|
|
|
-- show Wind = "~"
|
|
|
|
show Door = "+"
|
|
|
|
show Hall = "_"
|
|
|
|
show Offi = "."
|
|
|
|
show Toil = "o"
|
|
|
|
show Kitc = "k"
|
|
|
|
show Elev = "x"
|
|
|
|
show Unde = " "
|
|
|
|
|
|
|
|
data FloorConfig = FloorConfig
|
2018-09-08 12:05:07 +00:00
|
|
|
{ fcElevator :: V2 Int
|
|
|
|
, fcFacilities :: [V2 Int]
|
2018-03-03 16:03:17 +00:00
|
|
|
, fcSize :: (Int, Int)
|
2018-02-17 01:36:06 +00:00
|
|
|
} deriving (Show)
|
|
|
|
|
2018-03-03 16:03:17 +00:00
|
|
|
data Boundaries a = Boundaries
|
|
|
|
{ matmin :: (a, a)
|
|
|
|
, matmax :: (a, a)
|
2018-07-21 04:43:26 +00:00
|
|
|
} deriving (Show, Eq, Ord)
|
2018-02-17 01:36:06 +00:00
|
|
|
|
2018-03-03 16:03:17 +00:00
|
|
|
instance Size (Boundaries Int) where
|
|
|
|
size (Boundaries (minr, minc) (maxr, maxc)) =
|
|
|
|
fromIntegral ((maxr - minr) * (maxc - minc))
|
|
|
|
|
|
|
|
instance Size (Boundaries Double) where
|
|
|
|
size (Boundaries (minr, minc) (maxr, maxc)) =
|
|
|
|
(maxr - minr) * (maxc - minc)
|
|
|
|
|
2018-02-17 01:36:06 +00:00
|
|
|
data GraphDirection = North | South | East | West
|
|
|
|
deriving (Show, Eq)
|
|
|
|
|
|
|
|
data Graph
|
|
|
|
= GHall
|
|
|
|
{ connects :: [Graph]
|
|
|
|
}
|
|
|
|
| GRoom
|
2019-02-07 04:23:44 +00:00
|
|
|
{ neighbs :: [(GraphDirection, TileState)]
|
|
|
|
, bounds :: Boundaries Int
|
|
|
|
, clearance :: Word
|
|
|
|
, roomType :: TileState
|
2018-02-17 01:36:06 +00:00
|
|
|
}
|
2019-02-08 05:36:52 +00:00
|
|
|
deriving (Show)
|
|
|
|
|
|
|
|
instance Eq Graph where
|
|
|
|
(GHall la) == (GHall lb) = la == lb
|
|
|
|
(GRoom na ba _ _) == (GRoom nb bb _ _) = na == nb && ba == bb
|
|
|
|
_ == _ = False
|
2018-03-03 16:03:17 +00:00
|
|
|
|
2018-04-14 11:34:28 +00:00
|
|
|
graphIsRoom :: Graph -> Bool
|
2019-02-07 04:23:44 +00:00
|
|
|
graphIsRoom (GRoom _ _ _ _) = True
|
2018-04-14 11:34:28 +00:00
|
|
|
graphIsRoom _ = False
|
|
|
|
|
2018-03-03 16:03:17 +00:00
|
|
|
class Size a where
|
|
|
|
size :: a -> Double
|