tracer/src/Types/Interior.hs

195 lines
5.4 KiB
Haskell
Raw Normal View History

{-# LANGUAGE FlexibleInstances #-}
2018-03-03 16:03:17 +00:00
module Types.Interior where
import Data.Matrix as M
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
import Types.ImgId
import Types.Direction
2018-03-03 16:03:17 +00:00
data Cluster
= ClusterBox1
| 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
| 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
2019-01-10 17:31:36 +00:00
| ClusterVending
2019-01-14 03:00:34 +00:00
| ClusterCabCoffee
2018-10-14 21:18:41 +00:00
deriving (Enum, Bounded, Show)
2018-03-03 16:03:17 +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
]
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
]
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
]
clusterMat ClusterCornerTable _ =
2018-04-01 02:51:15 +00:00
M.fromLists
[ [Just ImgTableSE, Just ImgTableCorner]
, [Just ImgEmpty, Just ImgTableSW]
2018-03-31 21:22:10 +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
]
clusterMat ClusterFlipchart _ =
2018-07-30 13:34:45 +00:00
M.fromLists
[ [ Just ImgMiscFlipchart]
, [ Just ImgEmpty]
]
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) ++
[ Just ImgTableC3, Just ImgEmpty ]
] ++
2018-11-13 10:41:36 +00:00
replicate (mh-4) ([ Just ImgEmpty, Just ImgTableSW] ++ replicate (mw-4) (Just ImgEmpty) ++
[ Just ImgTableNE, Just ImgEmpty ]) ++
2018-11-13 10:41:36 +00:00
[ [ Just ImgEmpty, Just ImgTableC1] ++ replicate (mw-4) (Just ImgTableSE) ++
[ Just ImgTableC2, Just ImgEmpty ]
2018-11-13 10:41:36 +00:00
, replicate mw (Just ImgEmpty)
2018-07-30 19:10:42 +00:00
]
clusterMat ClusterPlant1 _ =
2018-07-31 11:30:17 +00:00
M.fromLists
[ [ Just ImgMiscPlant1 ] ]
clusterMat ClusterPlant2 _ =
2018-07-31 20:59:25 +00:00
M.fromLists
[ [ Just ImgMiscPlant2 ] ]
clusterMat ClusterToilet _ =
2018-07-31 20:59:25 +00:00
M.fromLists
[ [ Just ImgEmpty, Just ImgEmptyNoWalk] ]
clusterMat ClusterWatercooler _ =
2018-08-07 12:04:49 +00:00
M.fromLists
[ [ Just ImgMiscWatercooler ]
, [ Just ImgEmpty ]
]
2019-01-10 17:31:36 +00:00
clusterMat ClusterVending _ =
M.fromLists
[ [ Just ImgMiscVending ]
, [ Just ImgEmpty ]
]
2019-01-14 03:00:34 +00:00
clusterMat ClusterCabCoffee _ =
M.fromLists
[ [ Just ImgEmpty, Just ImgCabinetCoffee ]
]
2018-03-03 16:03:17 +00:00
2018-07-31 11:30:17 +00:00
clusterRoom :: Cluster -> [TileState]
clusterRoom ClusterBox1 = [Offi]
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]
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]
2019-01-10 17:31:36 +00:00
clusterRoom ClusterVending = [Kitc]
2019-01-14 03:00:34 +00:00
clusterRoom ClusterCabCoffee = [Kitc]
2018-03-03 16:03:17 +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
]
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
]
clusterPoints ClusterCopier _ =
2018-07-21 04:43:26 +00:00
[ ReachPoint Copier (V2 2 1) NW
]
clusterPoints ClusterFlipchart _ =
2018-07-30 13:34:45 +00:00
[ ReachPoint Table (V2 2 1) NW
]
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] ]
clusterPoints ClusterToilet _ =
2018-07-31 20:59:25 +00:00
[ ReachPoint Toilet (V2 1 1) NE
]
clusterPoints ClusterWatercooler _ =
2018-08-07 12:04:49 +00:00
[ ReachPoint Drink (V2 2 1) NW
]
2019-01-10 17:31:36 +00:00
clusterPoints ClusterVending _ =
[ ReachPoint Eat (V2 2 1) NW
]
2019-01-14 03:00:34 +00:00
clusterPoints ClusterCabCoffee _ =
[ ReachPoint Drink (V2 1 1) NE
]
clusterPoints _ _ = []
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))