{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE StrictData #-}
module Dodge.Data.Room where
import Geometry

import qualified Data.Set as S
import Control.Lens

data RoomPos = RoomPos
    { _rpPos :: Point2 
    , _rpDir :: Float
    , _rpType :: S.Set RoomPosType
    , _rpLinkStatus :: RPLinkStatus
    , _rpPlacementUse :: Int
    }
  deriving (Eq,Ord,Show)

data RoomLink = RoomLink
    { _rlType   :: S.Set RoomLinkType
    , _rlPos    :: Point2
    , _rlDir    :: Float
    } deriving (Eq,Ord)
data RoomType = DefaultRoomType
    | RectRoomType
        { _numLinkEW :: Int
        , _numLinkNS :: Int
        , _linkGapEW :: Float
        , _linkGapNS :: Float
        , _rmWidth :: Float
        , _rmHeight :: Float
        }
  deriving (Eq,Ord)
data RoomLinkType
    = OutLink
    | InLink
    | LabLink Int
    | OnEdge CardinalPoint
    | FromEdge CardinalPoint Int
    | BlockedLink
    deriving (Eq,Ord,Show)
data CardinalPoint
    = North
    | East
    | South
    | West
    deriving (Eq,Ord,Show)
data RoomWire
    = --RoomWire Point2 Float
     WallWire Point2 Float Float

data RPLinkStatus
    = UsedOutLink 
        { _rplsType :: S.Set RoomLinkType 
        , _rplsChildNum :: Int
        , _rplsOutRoomID :: Int
        }
    | UsedInLink  
        { _rplsType :: S.Set RoomLinkType 
        , _rplsInRoomID :: Int
        }
    | UnusedLink  { _rplsType :: S.Set RoomLinkType }
    | NotLink
  deriving (Eq,Ord,Show)
data PathFromEdge = PathFromEdge CardinalPoint Int
  deriving (Eq,Ord,Show)

data RoomPosType 
    = RoomPosOnPath {_onPathFromEdges :: S.Set PathFromEdge}
    | RoomPosOffPath {_offPathFromEdges :: S.Set PathFromEdge}
    | RoomPosExLink
    | RoomPosLab Int
  deriving (Eq,Ord,Show)

makeLenses ''RoomLink
makeLenses ''RoomPos
makeLenses ''RoomPosType
makeLenses ''RPLinkStatus
