{- Rooms that connect other rooms, blocking sight.  -}
module Dodge.Room.Door
    where
import Geometry
import Dodge.RoomLink
import Dodge.Data
import Dodge.Default.Room
import Dodge.Placement.Instance
import Color

import Data.Maybe
import qualified Data.IntMap.Strict as IM
import Dodge.LevelGen.Data
import Control.Lens

door :: Room
door = defaultRoom
    { _rmPolys = [rectNSWE 40 0 0 40]
    , _rmLinks = init lnks ++ [last lnks]
    , _rmPath  = [(V2 20 35,V2 20 5)]
-- door extends into side walls (for shadows as rendered 12/03)
    , _rmPmnts = [putAutoDoor (V2 0 20) (V2 40 20)]
-- note no bounds
    }
  where 
    lnks = [uncurry outLink (V2 20 35,0)
        ,uncurry inLink (V2 20  5,pi)
        ]

switchDoorRoom :: Room
switchDoorRoom = defaultRoom
    { _rmPolys = [rectNSWE 40 0 0 40]
    , _rmLinks = init lnks++ [last lnks]
    , _rmPath  = [(V2 20 35,V2 20 5)]
    , _rmPartPmnt = Just f
-- door extends into side walls (for shadows as rendered 12/03)
-- note no bounds
    }
  where 
    lnks = [uncurry outLink (V2 20 35,0)
        ,uncurry inLink(V2 20  5,pi)
        ]
    f (pmnt:_) = putDoubleDoor False red (cond pmnt) (V2 0 20) (V2 40 20) 2
    f _ = error "tried to put a door using an empty placement list"
    cond pmnt w = w & _triggers w IM.! fromJust (_plMID pmnt)

