2018-11-13 03:16:02 +00:00
|
|
|
{-# LANGUAGE FlexibleInstances #-}
|
2018-03-03 16:03:17 +00:00
|
|
|
module Types.Interior where
|
|
|
|
|
|
|
|
import Data.Matrix as M
|
|
|
|
|
2018-04-02 14:29:35 +00:00
|
|
|
import Linear.V2
|
|
|
|
|
2018-03-03 16:03:17 +00:00
|
|
|
-- internal imports
|
|
|
|
|
|
|
|
import Types.Map
|
2018-04-14 16:43:05 +00:00
|
|
|
import Types.ReachPoint
|
2018-06-04 03:29:20 +00:00
|
|
|
import Types.ImgId
|
|
|
|
import Types.Direction
|
2018-03-03 16:03:17 +00:00
|
|
|
|
|
|
|
data Cluster
|
|
|
|
= ClusterBox1
|
2018-11-13 03:16:02 +00:00
|
|
|
| ClusterTableSW
|
|
|
|
| ClusterTableNW
|
|
|
|
| ClusterTableNE
|
|
|
|
| ClusterTableSE
|
2018-03-31 21:22:10 +00:00
|
|
|
| ClusterCornerTable
|
2018-04-01 02:51:15 +00:00
|
|
|
| ClusterTableGroup
|
2018-07-21 04:43:26 +00:00
|
|
|
| ClusterCopier
|
2018-07-30 13:34:45 +00:00
|
|
|
| ClusterFlipchart
|
2018-11-13 03:16:02 +00:00
|
|
|
| ClusterConferenceTable
|
2018-07-31 11:30:17 +00:00
|
|
|
| ClusterPlant1
|
2018-07-31 20:59:25 +00:00
|
|
|
| ClusterPlant2
|
|
|
|
| ClusterToilet
|
2018-08-07 12:04:49 +00:00
|
|
|
| ClusterWatercooler
|
2018-10-14 21:18:41 +00:00
|
|
|
deriving (Enum, Bounded, Show)
|
2018-03-03 16:03:17 +00:00
|
|
|
|
2018-11-13 03:16:02 +00:00
|
|
|
-- row -> NS; col -> WE
|
|
|
|
clusterMat :: Cluster -> (Int, Int) -> Matrix (Maybe ImgId)
|
|
|
|
clusterMat ClusterBox1 _ =
|
2018-03-03 16:03:17 +00:00
|
|
|
M.fromLists
|
2018-03-05 20:11:38 +00:00
|
|
|
[ [Just ImgMiscBox1]
|
2018-03-03 16:03:17 +00:00
|
|
|
]
|
2018-11-13 03:16:02 +00:00
|
|
|
clusterMat ClusterTableSW (h, _) =
|
|
|
|
M.fromLists $ replicate h
|
|
|
|
[Just ImgEmpty, Just ImgTableSW]
|
|
|
|
clusterMat ClusterTableSE (_, w) =
|
|
|
|
M.fromLists $
|
|
|
|
[ replicate w (Just ImgTableSE)
|
|
|
|
, replicate w (Just ImgEmpty)
|
2018-04-03 20:27:41 +00:00
|
|
|
]
|
2018-11-13 03:16:02 +00:00
|
|
|
clusterMat ClusterTableNE (h, _) =
|
|
|
|
M.fromLists $ replicate h
|
|
|
|
[Just ImgTableNE, Just ImgEmpty]
|
|
|
|
clusterMat ClusterTableNW (_, w) =
|
|
|
|
M.fromLists $
|
|
|
|
[ replicate w (Just ImgEmpty)
|
|
|
|
, replicate w (Just ImgTableNW)
|
2018-04-01 02:51:15 +00:00
|
|
|
]
|
2018-11-13 03:16:02 +00:00
|
|
|
clusterMat ClusterCornerTable _ =
|
2018-04-01 02:51:15 +00:00
|
|
|
M.fromLists
|
2018-11-13 03:16:02 +00:00
|
|
|
[ [Just ImgTableSE, Just ImgTableCorner]
|
|
|
|
, [Just ImgEmpty, Just ImgTableSW]
|
2018-03-31 21:22:10 +00:00
|
|
|
]
|
2018-11-13 03:16:02 +00:00
|
|
|
clusterMat ClusterTableGroup _ =
|
|
|
|
M.fromLists
|
|
|
|
[ [ Just ImgEmpty, Just ImgTableSE, Just ImgTableCorner
|
|
|
|
, Just ImgEmpty, Just ImgTableSE, Just ImgTableCorner
|
|
|
|
]
|
|
|
|
, [ Just ImgEmpty, Just ImgEmpty, Just ImgTableSW
|
|
|
|
, Just ImgEmpty, Just ImgEmpty, Just ImgTableSW
|
|
|
|
]
|
|
|
|
, [ Just ImgEmpty, Just ImgEmpty, Just ImgEmpty
|
|
|
|
, Just ImgEmpty, Just ImgEmpty, Just ImgEmpty
|
|
|
|
]
|
|
|
|
, [ Nothing, Nothing, Nothing
|
|
|
|
, Just ImgEmpty, Just ImgTableSE, Just ImgTableCorner
|
|
|
|
]
|
|
|
|
, [ Nothing, Nothing, Nothing
|
|
|
|
, Just ImgEmpty, Just ImgEmpty, Just ImgTableSW
|
|
|
|
]
|
|
|
|
]
|
|
|
|
clusterMat ClusterCopier _ =
|
2018-07-21 04:43:26 +00:00
|
|
|
M.fromLists
|
2018-07-21 18:37:01 +00:00
|
|
|
[ [ Just ImgEmptyNoWalk]
|
|
|
|
, [ Just ImgEmpty]
|
2018-07-21 04:43:26 +00:00
|
|
|
]
|
2018-11-13 03:16:02 +00:00
|
|
|
clusterMat ClusterFlipchart _ =
|
2018-07-30 13:34:45 +00:00
|
|
|
M.fromLists
|
|
|
|
[ [ Just ImgMiscFlipchart]
|
|
|
|
, [ Just ImgEmpty]
|
|
|
|
]
|
2018-11-13 03:16:02 +00:00
|
|
|
clusterMat ClusterConferenceTable (h, w) =
|
2018-11-13 10:41:36 +00:00
|
|
|
let mw = max 4 w
|
|
|
|
mh = max 4 h
|
|
|
|
in M.fromLists $
|
|
|
|
[ replicate mw (Just ImgEmpty)
|
|
|
|
, [ Just ImgEmpty, Just ImgTableC4] ++ replicate (mw-4) (Just ImgTableNW) ++
|
2018-11-13 03:16:02 +00:00
|
|
|
[ Just ImgTableC3, Just ImgEmpty ]
|
|
|
|
] ++
|
2018-11-13 10:41:36 +00:00
|
|
|
replicate (mh-4) ([ Just ImgEmpty, Just ImgTableSW] ++ replicate (mw-4) (Just ImgEmpty) ++
|
2018-11-13 03:16:02 +00:00
|
|
|
[ Just ImgTableNE, Just ImgEmpty ]) ++
|
2018-11-13 10:41:36 +00:00
|
|
|
[ [ Just ImgEmpty, Just ImgTableC1] ++ replicate (mw-4) (Just ImgTableSE) ++
|
2018-11-13 03:16:02 +00:00
|
|
|
[ Just ImgTableC2, Just ImgEmpty ]
|
2018-11-13 10:41:36 +00:00
|
|
|
, replicate mw (Just ImgEmpty)
|
2018-07-30 19:10:42 +00:00
|
|
|
]
|
2018-11-13 03:16:02 +00:00
|
|
|
clusterMat ClusterPlant1 _ =
|
2018-07-31 11:30:17 +00:00
|
|
|
M.fromLists
|
|
|
|
[ [ Just ImgMiscPlant1 ] ]
|
2018-11-13 03:16:02 +00:00
|
|
|
clusterMat ClusterPlant2 _ =
|
2018-07-31 20:59:25 +00:00
|
|
|
M.fromLists
|
|
|
|
[ [ Just ImgMiscPlant2 ] ]
|
2018-11-13 03:16:02 +00:00
|
|
|
clusterMat ClusterToilet _ =
|
2018-07-31 20:59:25 +00:00
|
|
|
M.fromLists
|
|
|
|
[ [ Just ImgEmpty, Just ImgEmptyNoWalk] ]
|
2018-11-13 03:16:02 +00:00
|
|
|
clusterMat ClusterWatercooler _ =
|
2018-08-07 12:04:49 +00:00
|
|
|
M.fromLists
|
|
|
|
[ [ Just ImgMiscWatercooler ]
|
|
|
|
, [ Just ImgEmpty ]
|
|
|
|
]
|
2018-03-03 16:03:17 +00:00
|
|
|
|
2018-07-31 11:30:17 +00:00
|
|
|
clusterRoom :: Cluster -> [TileState]
|
|
|
|
clusterRoom ClusterBox1 = [Offi]
|
2018-11-13 03:16:02 +00:00
|
|
|
clusterRoom ClusterTableSW = [Offi]
|
|
|
|
clusterRoom ClusterTableNW = [Offi]
|
|
|
|
clusterRoom ClusterTableNE = [Offi]
|
|
|
|
clusterRoom ClusterTableSE = [Offi]
|
2018-07-31 11:30:17 +00:00
|
|
|
clusterRoom ClusterCornerTable = [Offi]
|
|
|
|
clusterRoom ClusterTableGroup = [Offi]
|
|
|
|
clusterRoom ClusterCopier = [Offi]
|
|
|
|
clusterRoom ClusterFlipchart = [Offi]
|
2018-11-13 03:16:02 +00:00
|
|
|
clusterRoom ClusterConferenceTable = [Offi]
|
2018-08-03 00:22:30 +00:00
|
|
|
clusterRoom ClusterPlant1 = [Offi]
|
|
|
|
clusterRoom ClusterPlant2 = [Offi]
|
2018-07-31 20:59:25 +00:00
|
|
|
clusterRoom ClusterToilet = [Toil]
|
2018-08-07 12:04:49 +00:00
|
|
|
clusterRoom ClusterWatercooler = [Kitc, Offi]
|
2018-03-03 16:03:17 +00:00
|
|
|
|
2018-11-13 03:16:02 +00:00
|
|
|
clusterPoints :: Cluster -> (Int, Int) -> [ReachPoint]
|
|
|
|
clusterPoints ClusterBox1 _ = []
|
|
|
|
clusterPoints ClusterTableNE (h, _) =
|
|
|
|
[ ReachPoint Table (V2 r 2) SW | r <- [1..h] ]
|
|
|
|
clusterPoints ClusterTableNW (_, w) =
|
|
|
|
[ ReachPoint Table (V2 1 c) SE | c <- [1..w] ]
|
|
|
|
clusterPoints ClusterTableSW (h, _) =
|
|
|
|
[ ReachPoint Table (V2 r 1) NE | r <- [1..h] ]
|
|
|
|
clusterPoints ClusterTableSE (_, w) =
|
|
|
|
[ ReachPoint Table (V2 2 c) NW | c <- [1..w] ]
|
|
|
|
clusterPoints ClusterCornerTable _ =
|
2018-07-30 12:34:46 +00:00
|
|
|
[ ReachPoint Computer (V2 2 1) N
|
2018-04-02 14:29:35 +00:00
|
|
|
]
|
2018-11-13 03:16:02 +00:00
|
|
|
clusterPoints ClusterTableGroup _ =
|
2018-07-30 12:34:46 +00:00
|
|
|
[ ReachPoint Computer (V2 2 2) N
|
|
|
|
, ReachPoint Computer (V2 2 5) N
|
|
|
|
, ReachPoint Computer (V2 5 5) N
|
2018-04-02 14:29:35 +00:00
|
|
|
]
|
2018-11-13 03:16:02 +00:00
|
|
|
clusterPoints ClusterCopier _ =
|
2018-07-21 04:43:26 +00:00
|
|
|
[ ReachPoint Copier (V2 2 1) NW
|
|
|
|
]
|
2018-11-13 03:16:02 +00:00
|
|
|
clusterPoints ClusterFlipchart _ =
|
2018-07-30 13:34:45 +00:00
|
|
|
[ ReachPoint Table (V2 2 1) NW
|
|
|
|
]
|
2018-11-13 03:16:02 +00:00
|
|
|
clusterPoints ClusterConferenceTable (h, w) =
|
2018-11-13 10:41:36 +00:00
|
|
|
let mw = max 4 w
|
|
|
|
mh = max 4 h
|
|
|
|
in
|
|
|
|
[ ReachPoint Table (V2 1 c) SE | c <- [2..mw-1] ] ++
|
|
|
|
[ ReachPoint Table (V2 r 1) NE | r <- [2..mh-1] ] ++
|
|
|
|
[ ReachPoint Table (V2 r mw) SW | r <- [2..mh-1] ] ++
|
|
|
|
[ ReachPoint Table (V2 mh c) NW | c <- [2..mw-1] ]
|
2018-11-13 03:16:02 +00:00
|
|
|
clusterPoints ClusterToilet _ =
|
2018-07-31 20:59:25 +00:00
|
|
|
[ ReachPoint Toilet (V2 1 1) NE
|
|
|
|
]
|
2018-11-13 03:16:02 +00:00
|
|
|
clusterPoints ClusterWatercooler _ =
|
2018-08-07 12:04:49 +00:00
|
|
|
[ ReachPoint Drink (V2 2 1) NW
|
|
|
|
]
|
2018-11-13 03:16:02 +00:00
|
|
|
clusterPoints _ _ = []
|
2018-04-02 14:29:35 +00:00
|
|
|
|
2018-11-13 03:16:02 +00:00
|
|
|
instance Size (Cluster, (Int, Int)) where
|
|
|
|
size (c, dim) =
|
|
|
|
let mat = clusterMat c dim
|
2018-03-03 16:03:17 +00:00
|
|
|
in fromIntegral ((nrows mat) * (ncols mat))
|