module Dodge.Room.AddTile
    where
import Dodge.Room.Data
import Tile
import Geometry

import Control.Lens

addTile :: Float -> Room -> Room
addTile z r
    | not (null (_rmFloor r)) || null rp = r
    | otherwise = r & rmFloor .~ [makeTileFromPoly poly z]
  where
    rp = _rmPolys r
    poly = orderPolygon . convexHull $ concat rp
