tracer/src/Types/Interior.hs

171 lines
4.9 KiB
Haskell
Raw Normal View History

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