{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE StrictData #-}
module Dodge.LevelGen.Data
    ( PSType (..)
    , PlacementSpot (..)
    , Placement (..)
    , sPS
    -- lenses
    , placementSpot
    , psType
    , psPos
    , psRot
    , putID
    , pwPoly
    , pwWall
    , unPutCrit
    , groupPlacementID
    , groupUpdate
    ) where
import Dodge.Data
import Picture
import Geometry.Data
import Shape.Data

import Control.Lens
import Control.Monad.State
import System.Random
data PSType = PutCrit {_unPutCrit :: Creature}
    | PutLS LightSource Picture
    | PutButton Button
    | PutFlIt Item
    | PutPressPlate PressPlate
    | PutAutoDoor Point2 Point2
    | PutBlock [Int] Color [Point2]
    | PutLineBlock Wall Float Float Point2 Point2
    | PutWall { _pwPoly :: [Point2] , _pwWall :: Wall }
    | PutDoubleDoor Color (World -> Bool) Point2 Point2 Float
    | PutSingleDoor Color (World -> Bool) Point2 Point2 Float
    | PutDoor Color (World -> Bool) [(Point2,Point2)]
    | PutBtDoor Color Point2 Float Point2 Point2 Float
    | PutSwitchDoor Color Point2 Float Point2 Point2 Float
    | RandPS (State StdGen PSType)
    | PutForeground Shape
    | PutNothing
    | PutID { _putID :: Int}
data PlacementSpot = PS
    { _psPos :: Point2
    , _psRot :: Float
    , _psType :: PSType
    }
data Placement
    = SinglePlacement {_placementSpot :: PlacementSpot }
    | GroupedPlacement
        {_groupPlacementID :: Int
        ,_groupUpdate :: World -> [Placement] -> World
        ,_placementSpot :: PlacementSpot
        }
sPS :: Point2 -> Float -> PSType -> Placement
sPS p a = SinglePlacement . PS p a
makeLenses ''PSType
makeLenses ''PlacementSpot
makeLenses ''Placement
